Skip to content

Commit

Permalink
Use the 'schema' and 'view/relation' name from the available node
Browse files Browse the repository at this point in the history
information instead of regenerate while evaluating the option -
'disabled'.
  • Loading branch information
asheshv committed Sep 17, 2024
1 parent 84e55b3 commit 90bad57
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ import BaseUISchema from 'sources/SchemaView/base_schema.ui';

export default class RuleSchema extends BaseUISchema {
constructor(fieldOptions={}) {
const schemaNode = fieldOptions?.nodeInfo['schema'];
const schema = schemaNode?.label || '';
const view = fieldOptions?.nodeData?.label;

super({
oid: undefined,
name: undefined,
schema: undefined
schema: schema,
view: view,
});

this.fieldOptions = {
Expand All @@ -42,33 +47,30 @@ export default class RuleSchema extends BaseUISchema {
if (state.name == '_RETURN') {
return true;
}
return !(obj.isNew(state) || obj.fieldOptions.nodeInfo.server.version >= 90400);

return !(
obj.isNew(state) ||
obj.fieldOptions.nodeInfo.server.version >= 90400
);
}, noEmpty: true
},
{
id: 'oid', label: gettext('OID'),
type: 'text', mode: ['properties'],
},
{
id: 'schema', label:'',
type: 'text', visible: false, disabled: (state) => {
// It is used while generating sql
state.schema = ('schema' in obj.fieldOptions.nodeInfo) ? obj.fieldOptions.nodeInfo.schema.label : '';
},
id: 'schema', label:'', type: 'text', visible: false,
},
{
id: 'view', label:'',
type: 'text', visible: false, disabled: (state) => {
// It is used while generating sql
state.view = obj.fieldOptions.nodeData.label;
},
id: 'view', label:'', type: 'text', visible: false,
},
{
id: 'is_enable_rule', label: gettext('Rule enabled?'),
mode: ['edit', 'properties'], group: gettext('Definition'),
type: 'select',
disabled: () => {
return 'catalog' in obj.fieldOptions.nodeInfo || 'view' in obj.fieldOptions.nodeInfo;
return 'catalog' in obj.fieldOptions.nodeInfo ||
'view' in obj.fieldOptions.nodeInfo;
},
options: [
{label: gettext('Enable'), value: 'O'},
Expand All @@ -90,13 +92,12 @@ export default class RuleSchema extends BaseUISchema {
],
},
{
id: 'do_instead', label: gettext('Do instead?'), group: gettext('Definition'),
type: 'switch',
id: 'do_instead', label: gettext('Do instead?'), type: 'switch',
group: gettext('Definition'),
},
{
id: 'condition', label: gettext('Condition'),
type: 'sql', isFullTab: true, group: gettext('Condition'),

},
{
id: 'statements', label: gettext('Commands'),
Expand All @@ -107,7 +108,8 @@ export default class RuleSchema extends BaseUISchema {
type: 'switch', mode: ['properties'],
},
{
id: 'comment', label: gettext('Comment'), cell: 'text', type: 'multiline',
id: 'comment', label: gettext('Comment'), cell: 'text',
type: 'multiline',
},
];
}
Expand Down

0 comments on commit 90bad57

Please sign in to comment.