-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from createit-ru/feature/msextrafield
Feature/msextrafield
- Loading branch information
Showing
20 changed files
with
1,702 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
204 changes: 204 additions & 0 deletions
204
assets/components/minishop3/js/mgr/utilities/extrafield/grid.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
ms3.grid.ExtraField = function (config) { | ||
config = config || {}; | ||
if (!config.id) { | ||
config.id = 'ms3-grid-extrafields'; | ||
} | ||
config.disableContextMenuAction = true; | ||
config.class_key = null; | ||
|
||
Ext.applyIf(config, { | ||
baseParams: { | ||
action: 'MiniShop3\\Processors\\Utilities\\ExtraField\\GetList' | ||
}, | ||
stateful: true, | ||
stateId: config.id, | ||
multi_select: true, | ||
}); | ||
ms3.grid.ExtraField.superclass.constructor.call(this, config); | ||
}; | ||
|
||
Ext.extend(ms3.grid.ExtraField, ms3.grid.Default, { | ||
|
||
getFields: function () { | ||
return ['id', 'class', 'key', 'label', 'dbtype', 'exists', 'active', 'actions']; | ||
}, | ||
|
||
getTopBar: function () { | ||
return [{ | ||
text: '<i class="icon icon-plus"></i> ' + _('ms3_btn_create'), | ||
handler: this.createExtraField, | ||
scope: this | ||
}, '->', this.getSearchField()]; | ||
}, | ||
|
||
getColumns: function () { | ||
return [ | ||
{ | ||
header: _('ms3_id'), | ||
dataIndex: 'id', | ||
width: 50, | ||
sortable: true | ||
}, { | ||
header: _('ms3_extrafields_class'), | ||
dataIndex: 'class', | ||
width: 150, | ||
sortable: true, | ||
hidden: true | ||
}, { | ||
header: _('ms3_extrafields_key'), | ||
dataIndex: 'key', | ||
width: 100, | ||
sortable: true | ||
}, { | ||
header: _('ms3_extrafields_label'), | ||
dataIndex: 'label', | ||
width: 100, | ||
sortable: true | ||
}, { | ||
header: _('ms3_extrafields_dbtype'), | ||
dataIndex: 'dbtype', | ||
width: 100, | ||
sortable: true | ||
}, { | ||
header: _('ms3_extrafields_exists'), | ||
dataIndex: 'exists', | ||
width: 80, | ||
sortable: true, | ||
renderer: ms3.utils.renderBoolean | ||
}, { | ||
header: _('ms3_active'), | ||
dataIndex: 'active', | ||
width: 80, | ||
sortable: true, | ||
renderer: ms3.utils.renderBoolean | ||
}, { | ||
header: _('ms3_actions'), | ||
dataIndex: 'actions', | ||
id: 'actions', | ||
width: 70, | ||
renderer: ms3.utils.renderActions | ||
} | ||
]; | ||
}, | ||
|
||
getListeners: function () { | ||
return { | ||
rowDblClick: function (grid, rowIndex, e) { | ||
const row = grid.store.getAt(rowIndex); | ||
this.updateExtraField(grid, e, row); | ||
}, | ||
}; | ||
}, | ||
|
||
extraFieldAction: function (method) { | ||
const ids = this._getSelectedIds(); | ||
if (!ids.length) { | ||
return false; | ||
} | ||
MODx.Ajax.request({ | ||
url: ms3.config.connector_url, | ||
params: { | ||
action: 'MiniShop3\\Processors\\Utilities\\ExtraField\\Multiple', | ||
method: method, | ||
ids: Ext.util.JSON.encode(ids), | ||
}, | ||
listeners: { | ||
success: { | ||
fn: function () { | ||
//noinspection JSUnresolvedFunction | ||
this.refresh(); | ||
}, scope: this | ||
}, | ||
failure: { | ||
fn: function (response) { | ||
MODx.msg.alert(_('error'), response.message); | ||
}, scope: this | ||
}, | ||
} | ||
}) | ||
}, | ||
|
||
createExtraField: function (btn, e) { | ||
let w = Ext.getCmp('ms3-window-extra-field-create'); | ||
if (w) { | ||
w.close(); | ||
} | ||
w = MODx.load({ | ||
xtype: 'ms3-window-extra-field-create', | ||
id: 'ms3-window-extra-field-create', | ||
listeners: { | ||
success: { | ||
fn: function () { | ||
this.refresh(); | ||
}, scope: this | ||
} | ||
} | ||
}); | ||
w.setValues({ | ||
attributes: '', | ||
default: '', | ||
class: this.config.class_key | ||
}); | ||
w.show(e.target); | ||
}, | ||
|
||
updateExtraField: function (btn, e, row) { | ||
if (typeof(row) != 'undefined') { | ||
this.menu.record = row.data; | ||
} | ||
const id = this.menu.record.id; | ||
|
||
MODx.Ajax.request({ | ||
url: this.config.url, | ||
params: { | ||
action: 'MiniShop3\\Processors\\Utilities\\ExtraField\\Get', | ||
id: id | ||
}, | ||
listeners: { | ||
success: { | ||
fn: function (r) { | ||
let w = Ext.getCmp('ms3-window-extra-field-update'); | ||
if (w) { | ||
w.close(); | ||
} | ||
|
||
w = MODx.load({ | ||
xtype: 'ms3-window-extra-field-update', | ||
id: 'ms3-window-extra-field-update', | ||
record: r.object, | ||
listeners: { | ||
success: { | ||
fn: function () { | ||
this.refresh(); | ||
}, scope: this | ||
} | ||
} | ||
}); | ||
w.fp.getForm().reset(); | ||
w.fp.getForm().setValues(r.object); | ||
w.show(e.target); | ||
}, scope: this | ||
} | ||
} | ||
}); | ||
}, | ||
|
||
removeExtraField: function () { | ||
const ids = this._getSelectedIds(); | ||
|
||
Ext.MessageBox.confirm( | ||
_('ms3_menu_remove_title'), | ||
ids.length > 1 | ||
? _('ms3_menu_remove_multiple_confirm') | ||
: _('ms3_menu_remove_confirm'), | ||
function (val) { | ||
if (val == 'yes') { | ||
this.extraFieldAction('Remove'); | ||
} | ||
}, | ||
this | ||
); | ||
}, | ||
|
||
}); | ||
Ext.reg('ms3-grid-extrafields', ms3.grid.ExtraField); |
84 changes: 84 additions & 0 deletions
84
assets/components/minishop3/js/mgr/utilities/extrafield/tree.classes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* Generates the Extra Fiels Classes Tree | ||
* | ||
* @class ms3.tree.ExtraFieldClass | ||
* @extends MODx.tree.Tree | ||
* @param {Object} config An object of options. | ||
* @xtype ms3-tree-extrafieldclass | ||
*/ | ||
MODx.tree.ExtraFieldClass = function (config) { | ||
config = config || {}; | ||
Ext.applyIf(config, { | ||
title: _('user_groups'), | ||
id: 'ms3-tree-extrafieldclass', | ||
url: MODx.config.connector_url, | ||
action: 'MiniShop3\\Processors\\Utilities\\ExtraField\\GetClassNodes', | ||
rootIconCls: 'icon-group', | ||
//root_id: 'n_ug_0', | ||
//root_name: _('user_groups'), | ||
enableDD: false, | ||
rootVisible: false, | ||
//ddAppendOnly: true, | ||
useDefaultToolbar: false, | ||
tbar: [], | ||
|
||
resize: { | ||
fn: function(cmp) { | ||
if (Ext.getCmp('ms3-grid-extrafields').hidden) { | ||
cmp.layout.west.getSplitBar().el.hide(); | ||
} | ||
}, | ||
scope: this | ||
}, | ||
refresh: { | ||
fn: function() { | ||
this.setActiveClassKey(); | ||
}, | ||
scope: this | ||
} | ||
}); | ||
MODx.tree.ExtraFieldClass.superclass.constructor.call(this, config); | ||
}; | ||
|
||
Ext.extend(MODx.tree.ExtraFieldClass, MODx.tree.Tree, { | ||
windows: { | ||
|
||
}, | ||
|
||
/** | ||
* Handles tree clicks | ||
* @param {Object} n The node clicked | ||
* @param {Object} e The event object | ||
*/ | ||
_handleClick: function (n, e) { | ||
e.stopEvent(); | ||
e.preventDefault(); | ||
|
||
this.setActiveClassKey(n.attributes.type); | ||
|
||
if (this.disableHref) { return true; } | ||
if (e.ctrlKey) { return true; } | ||
return true; | ||
}, | ||
getMenu: function () { | ||
return []; | ||
}, | ||
setActiveClassKey: function(class_key) { | ||
const grid = Ext.getCmp('ms3-grid-extrafields'), | ||
westPanel = Ext.getCmp('ms3-tree-panel-extrafield').layout.west | ||
; | ||
if (class_key) { | ||
grid.store.removeAll(); | ||
grid.show(); | ||
westPanel.getSplitBar().el.show(); | ||
grid.config.class_key = class_key; | ||
grid.store.baseParams.class = class_key; | ||
grid.store.load(); | ||
} else { | ||
grid.hide(); | ||
westPanel.getSplitBar().el.hide(); | ||
|
||
} | ||
} | ||
}); | ||
Ext.reg('ms3-tree-extrafieldclass', MODx.tree.ExtraFieldClass); |
Oops, something went wrong.