Skip to content

Commit

Permalink
fixed checkboxes && record
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshnik committed Sep 2, 2024
1 parent 121cbf6 commit 3387d2a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 50 deletions.
2 changes: 1 addition & 1 deletion assets/components/extrafields/js/mgr/misc/default.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Ext.extend(ExtraFields.grid.Default, MODx.grid.Grid, {
var w = MODx.load({
xtype: 'ef-'+this.config.objectName+'-window-update',
id: Ext.id(),
record: r,
record: r.object,
listeners: {
success: {
fn: function () {
Expand Down
4 changes: 2 additions & 2 deletions assets/components/extrafields/js/mgr/misc/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ ExtraFields.utils.getAbs = function (config, class_name = ExtraFields.config.cla
listeners: {
afterrender: function (el) {
setTimeout(() => {
let values = config.record.object ? config.record.object.ab_templates : '';
let values = config.record?.ab_templates ?? '';
if (!Ext.isEmpty(values)) {
el.setValue(values);
}
Expand Down Expand Up @@ -243,7 +243,7 @@ ExtraFields.utils.getAbs = function (config, class_name = ExtraFields.config.cla
listeners: {
afterrender: function (el) {
setTimeout(() => {
let values = config.record.object ? config.record.object.ab_user_group : '';
let values = config.record?.ab_user_group ?? '';
if (!Ext.isEmpty(values)) {
el.setValue(values.split('||'));
}
Expand Down
2 changes: 1 addition & 1 deletion assets/components/extrafields/js/mgr/widgets/abs/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Ext.extend(ExtraFields.grid.FieldAbs, ExtraFields.grid.Default, {
id: Ext.id(),
class_name: class_name.value,
field_type: field_type.value,
record: r,
record: r.object,
listeners: {
success: {
fn: function () {
Expand Down
10 changes: 4 additions & 6 deletions assets/components/extrafields/js/mgr/widgets/abs/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ Ext.extend(ExtraFields.window.CreateFieldAbs, ExtraFields.window.Default, {
allowBlank: true,
baseParams: {
action: 'mgr/category/getlist',
tab_id: config.record ? config.record.object.tab_id : 0,
tab_id: config.record?.tab_id ?? 0,
sort: 'menuindex',
dir: 'asc',
combo: 1,
Expand Down Expand Up @@ -462,21 +462,19 @@ Ext.extend(ExtraFields.window.CreateFieldAbs, ExtraFields.window.Default, {
items: ExtraFields.utils.getAbs(config, config.class_name)
},{
xtype: 'checkboxgroup',
hideLabel: true,
name: 'checkboxgroup',
columns: 3,
items: [{
xtype: 'xcheckbox',
boxLabel: _('ef_row_active'),
name: 'active',
id: config.id + '-active',
checked: config.record ? config.record.object['active'] : true,
checked: config.record?.active ?? true,
}, {
xtype: 'xcheckbox',
boxLabel: _('ef_field_required'),
name: 'required',
id: config.id + '-required',
checked: config.record ? config.record.object['required'] : false,
checked: config.record?.required ?? false,
hidden: true,
}]
}];
Expand Down Expand Up @@ -622,7 +620,7 @@ ExtraFields.window.UpdateFieldAbs = function (config) {
config.id = Ext.id();
}
Ext.applyIf(config, {
title: _('ef_row_update') + ': ' + config.record.object.caption,
title: _('ef_row_update') + ': ' + config.record.caption,
action: 'mgr/abs/update',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ExtraFields.window.UpdateCategory = function (config) {
config.id = 'ef-category-window-update';
}
Ext.applyIf(config, {
title: _('ef_row_update') + ': ' + config.record.object.name,
title: _('ef_row_update') + ': ' + config.record.name,
action: 'mgr/category/update',
});
ExtraFields.window.UpdateCategory.superclass.constructor.call(this, config);
Expand Down
51 changes: 14 additions & 37 deletions assets/components/extrafields/js/mgr/widgets/field/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ ExtraFields.window.CreateField = function (config) {
Ext.extend(ExtraFields.window.CreateField, ExtraFields.window.Default, {

getFields: function (config) {

let field_null = true;
let field_null_disabled = false;
if (config.record && config.record.object) {
field_null = config.record.object['field_null'];
if (config.record.object.field_type === 'combo-boolean') {
field_null = false;
field_null_disabled = true;
}
}

return [{
xtype: 'hidden',
name: 'id',
Expand Down Expand Up @@ -70,10 +59,6 @@ Ext.extend(ExtraFields.window.CreateField, ExtraFields.window.Default, {
width: 100,
allowBlank: false,
listeners: {
afterrender: {
fn: this.changeFields,
scope: this,
},
select: {
fn: this.changeFields,
scope: this,
Expand All @@ -83,25 +68,19 @@ Ext.extend(ExtraFields.window.CreateField, ExtraFields.window.Default, {
xtype: 'textfield',
fieldLabel: _('ef_field_default'),
name: 'field_default',
id: config.id + '-field_default',
id: config.id + '-field-default',
anchor: '100%',
width: 100,
allowBlank: true,
}]
}]
}, {
xtype: 'checkboxgroup',
hideLabel: true,
name: 'checkboxgroup',
columns: 3,
items: [{
xtype: 'xcheckbox',
boxLabel: _('ef_field_null'),
name: 'field_null',
id: config.id + '-field_null',
checked: field_null,
disabled: field_null_disabled
}]
xtype: 'xcheckbox',
boxLabel: _('ef_field_null'),
name: 'field_null',
id: config.id + '-field-null',
checked: config.record?.field_null ?? true,
disabled: (config.record?.field_type === 'combo-boolean') || false
}, {
xtype: 'fieldset',
title: _('ef_settings'),
Expand All @@ -111,28 +90,26 @@ Ext.extend(ExtraFields.window.CreateField, ExtraFields.window.Default, {
hidden: false,
items: [{
xtype: 'ef-grid-field-abs',
field_id: config.record ? config.record.object.id : 0,
field_id: config.record?.id || 0,
config_id: config.id,
cls: '',
}]
}, {
xtype: 'checkboxgroup',
hideLabel: true,
name: 'checkboxgroup',
columns: 3,
items: [{
xtype: 'xcheckbox',
boxLabel: _('ef_row_active'),
name: 'active',
id: config.id + '-active',
checked: config.record ? config.record.object['active'] : true,
id: Ext.id(),
checked: config.record?.active ?? true
}]
}];
},

changeFields: function (combo, row) {
let field_null = Ext.getCmp(this.id + '-field_null');
let field_default = Ext.getCmp(this.id + '-field_default');
changeFields: function (combo) {
let field_null = Ext.getCmp(this.id + '-field-null');
let field_default = Ext.getCmp(this.id + '-field-default');

field_default.setDisabled(false);
if (field_null) {
Expand Down Expand Up @@ -163,7 +140,7 @@ ExtraFields.window.UpdateField = function (config) {
config.id = 'ef-field-window-update';
}
Ext.applyIf(config, {
title: _('ef_row_update') + ': ' + config.record.object.field_name,
title: _('ef_row_update') + ': ' + config.record.field_name,
action: 'mgr/field/update',
});

Expand Down
4 changes: 2 additions & 2 deletions assets/components/extrafields/js/mgr/widgets/tab/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Ext.extend(ExtraFields.window.CreateTab, ExtraFields.window.Default, {
hidden: true,
items: [{
xtype: 'ef-grid-categories',
tab_id: config.record ? config.record.object.id : 0,
tab_id: config.record?.id ?? 0,
}]
}, {
xtype: 'xcheckbox',
Expand Down Expand Up @@ -174,7 +174,7 @@ ExtraFields.window.UpdateTab = function (config) {
config.id = 'ef-tab-window-update';
}
Ext.applyIf(config, {
title: _('ef_row_update') + ': ' + config.record.object.name,
title: _('ef_row_update') + ': ' + config.record.name,
action: 'mgr/tab/update',
});
ExtraFields.window.UpdateTab.superclass.constructor.call(this, config);
Expand Down

0 comments on commit 3387d2a

Please sign in to comment.