Ensure that the save button should be disabled by default on the Sort/Filter dialog in the query tool. #5058

This commit is contained in:
Nikhil Mohite 2022-10-20 16:22:40 +05:30 committed by GitHub
parent dd25bb0fff
commit b4fcb61d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -447,7 +447,7 @@ function prepareData(val, createMode=false) {
/* If its the dialog */ /* If its the dialog */
function SchemaDialogView({ function SchemaDialogView({
getInitData, viewHelperProps, loadingText, schema={}, showFooter=true, isTabView=true, ...props}) { getInitData, viewHelperProps, loadingText, schema={}, showFooter=true, isTabView=true, checkDirtyOnEnableSave=false, ...props}) {
const classes = useDialogStyles(); const classes = useDialogStyles();
/* Some useful states */ /* Some useful states */
const [dirty, setDirty] = useState(false); const [dirty, setDirty] = useState(false);
@ -773,7 +773,7 @@ function SchemaDialogView({
<DefaultButton data-test="Reset" onClick={onResetClick} startIcon={<SettingsBackupRestoreIcon />} disabled={!dirty || saving} className={classes.buttonMargin}> <DefaultButton data-test="Reset" onClick={onResetClick} startIcon={<SettingsBackupRestoreIcon />} disabled={!dirty || saving} className={classes.buttonMargin}>
{gettext('Reset')} {gettext('Reset')}
</DefaultButton> </DefaultButton>
<PrimaryButton data-test="Save" onClick={onSaveClick} startIcon={ButtonIcon} disabled={ !(viewHelperProps.mode === 'edit' ? dirty : true) || saving || Boolean(formErr.name) || !formReady}> <PrimaryButton data-test="Save" onClick={onSaveClick} startIcon={ButtonIcon} disabled={ !(viewHelperProps.mode === 'edit' || checkDirtyOnEnableSave ? dirty : true) || saving || Boolean(formErr.name) || !formReady}>
{props.customSaveBtnName ? gettext(props.customSaveBtnName) : gettext('Save')} {props.customSaveBtnName ? gettext(props.customSaveBtnName) : gettext('Save')}
</PrimaryButton> </PrimaryButton>
</Box> </Box>
@ -812,6 +812,7 @@ SchemaDialogView.propTypes = {
customSaveBtnIconType: PropTypes.string, customSaveBtnIconType: PropTypes.string,
formClassName: CustomPropTypes.className, formClassName: CustomPropTypes.className,
Notifier: PropTypes.object, Notifier: PropTypes.object,
checkDirtyOnEnableSave: PropTypes.bool,
}; };
const usePropsStyles = makeStyles((theme)=>({ const usePropsStyles = makeStyles((theme)=>({

View File

@ -145,6 +145,7 @@ export default function FilterDialog({onClose, onSave}) {
disableDialogHelp={true} disableDialogHelp={true}
isTabView={false} isTabView={false}
formClassName={classes.root} formClassName={classes.root}
checkDirtyOnEnableSave={true}
/> />
</>); </>);
} }