| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- /**
- * @class MODx.panel.FCSet
- * @extends MODx.FormPanel
- * @param {Object} config An object of configuration properties
- * @xtype modx-panel-fc-set
- */
- MODx.panel.FCSet = function(config) {
- config = config || {};
- Ext.applyIf(config,{
- url: MODx.config.connector_url
- ,baseParams: {
- action: 'security/forms/set/update'
- }
- ,id: 'modx-panel-fc-set'
- ,class_key: 'modFormCustomizationSet'
- ,cls: 'container'
- ,items: [{
- html: _('set_edit')
- ,id: 'modx-fcs-header'
- ,xtype: 'modx-header'
- },MODx.getPageStructure([{
- title: _('set_and_fields')
- ,xtype: 'panel'
- ,border: false
- ,defaults: { border: false }
- ,items: [{
- html: '<p>'+_('set_msg')+'</p>'
- ,id: 'modx-fcs-msg'
- ,xtype: 'modx-description'
- },{
- layout: 'form'
- ,id: 'modx-fcs-form'
- ,msgTarget: 'side'
- ,cls: 'main-wrapper'
- ,labelWidth: 150
- ,items: [{
- xtype: 'hidden'
- ,name: 'id'
- ,id: 'modx-fcs-id'
- ,value: config.record.id || MODx.request.id
- },{
- xtype: 'modx-combo-fc-action'
- ,fieldLabel: _('action')
- ,name: 'action_id'
- ,hiddenName: 'action_id'
- ,id: 'modx-fcs-action'
- ,anchor: '100%'
- ,allowBlank: false
- ,value: config.record.action
- ,listeners: {
- 'select': {scope:this,fn:function(f,e) {
- Ext.getCmp('modx-fcs-header').getEl().update(_('set')+': '+f.getRawValue());
- }}
- }
- },{
- xtype: 'modx-combo-template'
- ,fieldLabel: _('template')
- ,description: _('set_template_desc')
- ,name: 'template'
- ,hiddenName: 'template'
- ,value: config.record.template || 0
- ,anchor: '100%'
- ,allowBlank: true
- ,lazyInit: false
- ,lazyRender: false
- ,baseParams: {
- action: 'element/template/getList'
- ,combo: true
- }
- ,listeners: {
- 'select': {fn:this.changeTemplate,scope:this}
- }
- },{
- xtype: 'textarea'
- ,fieldLabel: _('description')
- ,name: 'description'
- ,id: 'modx-fcs-description'
- ,anchor: '100%'
- ,maxLength: 255
- ,grow: false
- ,value: config.record.description
- },{
- xtype: 'hidden'
- ,fieldLabel: _('constraint_class')
- ,name: 'constraint_class'
- ,value: 'modResource'
- ,anchor: '100%'
- ,allowBlank: true
- },{
- xtype: 'textfield'
- ,fieldLabel: _('constraint_field')
- ,description: _('set_constraint_field_desc')
- ,name: 'constraint_field'
- ,value: config.record.constraint_field
- ,anchor: '100%'
- ,allowBlank: true
- },{
- xtype: 'textfield'
- ,fieldLabel: _('constraint')
- ,description: _('set_constraint_desc')
- ,name: 'constraint'
- ,value: config.record.constraint
- ,anchor: '100%'
- ,allowBlank: true
- },{
- xtype: 'xcheckbox'
- ,fieldLabel: _('active')
- ,name: 'active'
- ,inputValue: true
- ,value: config.record.active ? true : false
- ,anchor: '100%'
- ,allowBlank: true
- }]
- },{
- html: '<p>'+_('set_fields_msg')+'</p>'
- ,xtype: 'modx-description'
- },{
- id: 'modx-fcs-fields-form'
- ,msgTarget: 'side'
- ,cls: 'main-wrapper'
- ,layout: 'anchor'
- ,items: [{
- xtype: 'modx-grid-fc-set-fields'
- ,data: config.record.fields || []
- ,preventRender: true
- }]
- }]
- },{
- title: _('regions')
- ,border: false
- ,layout: 'anchor'
- ,items: [{
- html: '<p>'+_('set_tabs_msg')+'</p>'
- ,xtype: 'modx-description'
- },{
- xtype: 'modx-grid-fc-set-tabs'
- ,cls: 'main-wrapper'
- ,data: config.record.tabs || []
- ,preventRender: true
- }]
- },{
- title: _('tvs')
- ,border: false
- ,layout: 'anchor'
- ,items: [{
- html: '<p>'+_('set_tvs_msg')+'</p>'
- ,xtype: 'modx-description'
- },{
- xtype: 'modx-grid-fc-set-tvs'
- ,cls: 'main-wrapper'
- ,data: config.record.tvs || []
- ,preventRender: true
- }]
- }],{
- id: 'modx-fc-set-tabs'
- })]
- ,listeners: {
- 'setup': {fn:this.setup,scope:this}
- ,'success': {fn:this.success,scope:this}
- ,'beforeSubmit': {fn:this.beforeSubmit,scope:this}
- }
- });
- MODx.panel.FCSet.superclass.constructor.call(this,config);
- };
- Ext.extend(MODx.panel.FCSet,MODx.FormPanel,{
- initialized: false
- ,setup: function() {
- if (!this.initialized) {this.getForm().setValues(this.config.record);}
- if (!Ext.isEmpty(this.config.record.controller)) {
- Ext.getCmp('modx-fcs-header').update(_('set')+': '+this.config.record.controller);
- }
- this.fireEvent('ready',this.config.record);
- this.clearDirty();
- this.initialized = true;
- MODx.fireEvent('ready');
- return true;
- }
- ,beforeSubmit: function(o) {
- Ext.apply(o.form.baseParams,{
- fields: Ext.getCmp('modx-grid-fc-set-fields').encode()
- ,tabs: Ext.getCmp('modx-grid-fc-set-tabs').encode()
- ,tvs: Ext.getCmp('modx-grid-fc-set-tvs').encode()
- });
- return this.fireEvent('save',{
- values: this.getForm().getValues()
- });
- }
- ,success: function(r) {
- this.getForm().setValues(r.result.object);
- Ext.getCmp('modx-grid-fc-set-fields').getStore().commitChanges();
- Ext.getCmp('modx-grid-fc-set-tabs').getStore().commitChanges();
- Ext.getCmp('modx-grid-fc-set-tvs').getStore().commitChanges();
- }
- ,changeTemplate: function(cb) {
- if (cb.getValue() != this.config.record.template) {
- Ext.Msg.confirm(_('set_change_template'),_('set_change_template_confirm'),function(e) {
- if (e == 'yes') {
- this.on('success',function() {
- location.href = location.href;
- },this);
- this.submit();
- } else {
- cb.setValue(this.config.record.template);
- }
- },this);
- }
- return false;
- }
- });
- Ext.reg('modx-panel-fc-set',MODx.panel.FCSet);
- MODx.grid.FCSetFields = function(config) {
- config = config || {};
- this.vcb = new Ext.ux.grid.CheckColumn({
- header: _('visible')
- ,dataIndex: 'visible'
- ,width: 40
- ,sortable: false
- });
- Ext.applyIf(config,{
- id: 'modx-grid-fc-set-fields'
- ,fields: ['id','action','name','tab','tab_rank','other','rank','visible','label','default_value']
- ,autoHeight: true
- ,grouping: true
- ,groupBy: 'tab'
- ,plugins: [this.vcb]
- ,stateful: false
- ,remoteSort: false
- ,sortBy: 'rank'
- ,sortDir: 'ASC'
- ,hideGroupedColumn: true
- ,groupTextTpl: '{group} ({[values.rs.length]} {[values.rs.length > 1 ? "'+_('fields')+'" : "'+_('field')+'"]})'
- ,columns: [{
- header: _('name')
- ,dataIndex: 'name'
- ,width: 200
- },{
- header: _('region')
- ,dataIndex: 'tab'
- ,width: 100
- },this.vcb,{
- header: _('label')
- ,dataIndex: 'label'
- ,editor: { xtype: 'textfield' }
- ,renderer: function(v,md) {
- return Ext.util.Format.htmlEncode(v);
- }
- },{
- header: _('default_value')
- ,dataIndex: 'default_value'
- ,editor: { xtype: 'textfield' }
- ,renderer: function(v,md) {
- return Ext.util.Format.htmlEncode(v);
- }
- }]
- ,viewConfig: {
- forceFit:true
- ,enableRowBody:true
- ,scrollOffset: 0
- ,autoFill: true
- ,showPreview: true
- ,getRowClass : function(rec, ri, p){
- return rec.data.visible ? 'grid-row-active' : 'grid-row-inactive';
- }
- }
- });
- MODx.grid.FCSetFields.superclass.constructor.call(this,config);
- this.propRecord = Ext.data.Record.create(config.fields);
- };
- Ext.extend(MODx.grid.FCSetFields,MODx.grid.LocalGrid);
- Ext.reg('modx-grid-fc-set-fields',MODx.grid.FCSetFields);
- MODx.grid.FCSetTabs = function(config) {
- config = config || {};
- this.vcb = new Ext.ux.grid.CheckColumn({
- header: _('visible')
- ,dataIndex: 'visible'
- ,width: 40
- ,sortable: false
- });
- Ext.applyIf(config,{
- id: 'modx-grid-fc-set-tabs'
- ,fields: ['id','action','name','form','other','rank','visible','label','type']
- ,autoHeight: true
- ,plugins: [this.vcb]
- ,stateful: false
- ,columns: [{
- header: _('tab_id')
- ,dataIndex: 'name'
- ,width: 200
- },this.vcb,{
- header: _('tab_title')
- ,dataIndex: 'label'
- ,editor: { xtype: 'textfield' }
- }]
- ,viewConfig: {
- forceFit:true
- ,enableRowBody:true
- ,scrollOffset: 0
- ,autoFill: true
- ,showPreview: true
- ,getRowClass : function(rec, ri, p){
- return rec.data.visible ? 'grid-row-active' : 'grid-row-inactive';
- }
- }
- ,tbar: [{
- text: _('tab_create')
- ,cls: 'primary-button'
- ,handler: this.createTab
- ,scope: this
- }]
- });
- MODx.grid.FCSetTabs.superclass.constructor.call(this,config);
- this.propRecord = Ext.data.Record.create(config.fields);
- };
- Ext.extend(MODx.grid.FCSetTabs,MODx.grid.LocalGrid,{
- createTab: function(btn,e) {
- if (!this.windows.ctab) {
- this.windows.ctab = MODx.load({
- xtype: 'modx-window-fc-set-add-tab'
- ,listeners: {
- 'success': {fn:function(r) {
- var s = this.getStore();
- var rec = new this.propRecord(r);
- s.add(rec);
- },scope:this}
- }
- });
- }
- this.windows.ctab.reset();
- this.windows.ctab.show(e.target);
- }
- ,getMenu: function(g,ri) {
- var rec = this.getStore().getAt(ri);
- if (rec.data.type == 'new') {
- return [{
- text: _('tab_remove')
- ,handler: this.removeTab
- ,scope: this
- }];
- }
- return [];
- }
- ,removeTab: function(btn,e) {
- var rec = this.getSelectionModel().getSelected();
- Ext.Msg.confirm(_('tab_remove'),_('tab_remove_confirm'),function(e) {
- if (e == 'yes') {
- this.getStore().remove(rec);
- }
- },this);
- }
- });
- Ext.reg('modx-grid-fc-set-tabs',MODx.grid.FCSetTabs);
- MODx.window.AddTabToSet = function(config) {
- config = config || {};
- Ext.applyIf(config,{
- title: _('tab_create')
- // ,height: 150
- // ,width: 375
- ,fields: [{
- xtype: 'hidden'
- ,name: 'container'
- ,value: 'modx-resource-tabs'
- },{
- xtype: 'hidden'
- ,name: 'visible'
- ,value: true
- },{
- xtype: 'hidden'
- ,name: 'type'
- ,value: 'new'
- },{
- xtype: 'textfield'
- ,name: 'name'
- ,fieldLabel: _('tab_id')
- ,id: 'modx-fcatab-id'
- ,allowBlank: false
- ,anchor: '100%'
- },{
- xtype: 'textfield'
- ,fieldLabel: _('tab_title')
- ,name: 'value'
- ,id: 'modx-fcatab-name'
- ,allowBlank: false
- ,anchor: '100%'
- }]
- });
- MODx.window.AddTabToSet.superclass.constructor.call(this,config);
- };
- Ext.extend(MODx.window.AddTabToSet,MODx.Window,{
- submit: function() {
- var rec = this.fp.getForm().getValues();
- var g = Ext.getCmp('modx-grid-fc-set-tabs');
- var s = g.getStore();
- var v = s.query('name',rec.name).items;
- if (v.length > 0) {
- MODx.msg.alert(_('error'),_('set_tab_err_ae'));
- return false;
- }
- rec.label = rec.value;
- rec.visible = true;
- rec.type = 'new';
- this.fireEvent('success',rec);
- this.hide();
- return false;
- }
- });
- Ext.reg('modx-window-fc-set-add-tab',MODx.window.AddTabToSet);
- MODx.grid.FCSetTVs = function(config) {
- config = config || {};
- this.vcb = new Ext.ux.grid.CheckColumn({
- header: _('visible')
- ,dataIndex: 'visible'
- ,width: 40
- ,sortable: false
- });
- Ext.applyIf(config,{
- id: 'modx-grid-fc-set-tvs'
- ,fields: ['id','name','tab','rank','visible','label','default_value','category','default_text']
- ,autoHeight: true
- ,grouping: true
- ,groupBy: 'category'
- ,sortBy: 'rank'
- ,sortDir: 'ASC'
- ,stateful: false
- ,groupTextTpl: '{group} ({[values.rs.length]} {[values.rs.length > 1 ? "'+_('tvs')+'" : "'+_('tv')+'"]})'
- ,plugins: [this.vcb]
- ,hideGroupedColumn: true
- ,columns: [{
- header: _('category')
- ,dataIndex: 'category'
- },{
- header: _('tv_name')
- ,dataIndex: 'name'
- ,width: 200
- },this.vcb,{
- header: _('label')
- ,dataIndex: 'label'
- ,editor: { xtype: 'textfield' }
- },{
- header: _('default_value')
- ,dataIndex: 'default_value'
- ,editor: { xtype: 'textfield' }
- ,renderer: function(v) { return Ext.util.Format.htmlEncode(v); }
- },{
- header: _('original_value')
- ,dataIndex: 'default_text'
- ,editable: false
- },{
- header: _('region')
- ,dataIndex: 'tab'
- ,width: 100
- ,editor: { xtype: 'textfield' }
- },{
- header: _('tab_rank')
- ,dataIndex: 'rank'
- ,width: 70
- ,editor: { xtype: 'textfield' }
- }]
- ,viewConfig: {
- forceFit:true
- ,enableRowBody:true
- ,scrollOffset: 0
- ,autoFill: true
- ,showPreview: true
- ,getRowClass : function(rec, ri, p){
- return rec.data.visible ? 'grid-row-active' : 'grid-row-inactive';
- }
- }
- });
- MODx.grid.FCSetTVs.superclass.constructor.call(this,config);
- this.propRecord = Ext.data.Record.create(config.fields);
- };
- Ext.extend(MODx.grid.FCSetTVs,MODx.grid.LocalGrid,{
- });
- Ext.reg('modx-grid-fc-set-tvs',MODx.grid.FCSetTVs);
|