Introduced a 'exclude' option in the 'Field' to exclude it from the change.

* Introduced a 'exclude' option in the 'Field' to exclude it from the
change completely. Use the option 'exclude' to add field
'notNullColumns', which will be excluded from the data, but - can be
used to force rerender the 'Not Null Columns' select control on
change of it.

* Fixed the linter issue
This commit is contained in:
Ashesh Vashi 2024-09-16 15:28:33 +05:30 committed by GitHub
parent 0d39e791c9
commit 92dd13e72a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 12 deletions

View File

@ -149,6 +149,9 @@ export function getSchemaDataDiff(
}; };
schema.fields.forEach((field) => { schema.fields.forEach((field) => {
// Never include data from the field in the changes, marked as
// 'excluded'.
if (field.exclude) return;
/* /*
* If skipChange is true, then field will not be considered for changed * If skipChange is true, then field will not be considered for changed
* data. This is helpful when 'Save' or 'Reset' should not be enabled on * data. This is helpful when 'Save' or 'Reset' should not be enabled on

View File

@ -200,16 +200,29 @@ export default class ImportExportSchema extends BaseUISchema {
id: 'columns', id: 'columns',
label: gettext(this.colums_selection_label[this._type]), label: gettext(this.colums_selection_label[this._type]),
group: gettext('Columns'), group: gettext('Columns'),
type: 'select', type: () => ({
options: obj.fieldOptions.columns, type: 'select',
optionsLoaded: (options) => { options: obj.fieldOptions.columns,
obj.notNullColOptions = options.map((o) => { optionsLoaded: (options) => {
return { ...o, selected: false }; obj.notNullColOptions = options.map((o) => {
}); return { ...o, selected: false };
}, });
controlProps:{multiple: true, allowClear: false,
placeholder: this._type === 'i' ? gettext('Columns for importing...') : gettext('Columns for exporting...'), if (!obj.state) return;
},
const data = obj.state.data;
obj.state.data = {
...data,
notNullColOptions: obj.notNullColOptions,
};
},
controlProps:{
multiple: true, allowClear: false,
placeholder:
this._type === 'i' ? gettext('Columns for importing...') :
gettext('Columns for exporting...'),
},
}),
deps:['is_import'], deps:['is_import'],
depChange:(state)=>{ depChange:(state)=>{
this._type = state.is_import? 'i' : 'e'; this._type = state.is_import? 'i' : 'e';
@ -220,19 +233,23 @@ export default class ImportExportSchema extends BaseUISchema {
id: 'icolumns', id: 'icolumns',
label: gettext('NOT NULL columns'), label: gettext('NOT NULL columns'),
group: gettext('Columns'), group: gettext('Columns'),
deps: ['format', 'is_import'], deps: ['format', 'is_import', 'notNullColOptions'],
type: () => ({ type: () => ({
type: 'select', type: 'select',
options: obj.notNullColOptions, options: obj.notNullColOptions,
optionsReloadBasis: obj.notNullColOptions.length, optionsReloadBasis: obj.notNullColOptions.length,
controlProps: { controlProps: {
multiple: true, allowClear: true, placeholder: gettext('Not null columns...'), multiple: true, allowClear: true,
placeholder: gettext('Not null columns...'),
}, },
}), }),
disabled:function(state){ disabled:function(state){
return (state?.format != 'csv' || !state?.is_import); return (state?.format != 'csv' || !state?.is_import);
}, },
helpMessage: gettext('Do not match the specified column values against the null string. In the default case where the null string is empty, this means that empty values will be read as zero-length strings rather than nulls, even when they are not quoted. This option is allowed only in import, and only when using CSV format.'), helpMessage: gettext('Do not match the specified column values against the null string. In the default case where the null string is empty, this means that empty values will be read as zero-length strings rather than nulls, even when they are not quoted. This option is allowed only in import, and only when using CSV format.'),
},
{
id: 'notNullColOptions', exclude: true, visible: false, type: 'text',
} }
]; ];
} }