More fixes related to ERD color change. #4392

This commit is contained in:
Aditya Toshniwal 2022-10-13 18:34:34 +05:30 committed by GitHub
parent 1904a64e42
commit ff095fc7c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 5 deletions

View File

@ -29,8 +29,11 @@ export function withColorPicker(Component) {
};
const eleRef = useRef();
const pickrObj = useRef();
const onChangeRef = useRef(onChange);
const onSaveRef = useRef(onSave);
const onChangeRef = useRef();
const onSaveRef = useRef();
onChangeRef.current = onChange;
onSaveRef.current = onSave;
const setColor = (newVal, silent) => {
pickrObj.current?.setColor((_.isUndefined(newVal) || newVal == '') ? pickrOptions.defaultColor : newVal, silent);

View File

@ -55,10 +55,22 @@ const useStyles = makeStyles((theme)=>({
border: '1px solid ' + theme.palette.default.borderColor,
justifyContent: 'flex-start',
},
fillColorIcon: (props)=>({
'& path[fill-opacity]': {
fillOpacity: 1,
color: props.fillColor ?? theme.palette.background.default,
}
}),
textColorIcon: (props)=>({
'& path[fill-opacity]': {
fillOpacity: 1,
color: props.textColor ?? theme.palette.text.primary,
}
}),
}));
export function MainToolBar({preferences, eventBus, fillColor, textColor}) {
const classes = useStyles();
const classes = useStyles({fillColor,textColor});
const theme = useTheme();
const [buttonsDisabled, setButtonsDisabled] = useState({
'save': true,
@ -231,7 +243,7 @@ export function MainToolBar({preferences, eventBus, fillColor, textColor}) {
}} />
</PgButtonGroup>
<PgButtonGroup size="small">
<ColorButton title={gettext('Fill Color')} icon={<FormatColorFillRoundedIcon />}
<ColorButton title={gettext('Fill Color')} icon={<FormatColorFillRoundedIcon className={classes.fillColorIcon} />}
value={fillColor ?? theme.palette.background.default} options={{
allowSave: true,
}}
@ -242,7 +254,7 @@ export function MainToolBar({preferences, eventBus, fillColor, textColor}) {
eventBus.fireEvent(ERD_EVENTS.CHANGE_COLORS, null, textColor);
}
}}/>
<ColorButton title={gettext('Text Color')} icon={<FormatColorTextRoundedIcon />}
<ColorButton title={gettext('Text Color')} icon={<FormatColorTextRoundedIcon className={classes.textColorIcon} />}
value={textColor ?? theme.palette.text.primary} options={{
allowSave: true,
}}

View File

@ -55,6 +55,7 @@ export class TableNodeModel extends DefaultNodeModel {
};
this.fireEvent(this._metadata, 'dataAvaiable');
this.fireEvent({}, 'nodeUpdated');
this.fireEvent({}, 'selectionChanged');
}).catch(()=>{
this._metadata = {
...this._metadata,