| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- MODx.panel.FCProfiles = function(config) {
- config = config || {};
- Ext.applyIf(config,{
- id: 'modx-panel-fc-profiles'
- ,cls: 'container'
- ,defaults: { collapsible: false ,autoHeight: true }
- ,items: [{
- html: _('form_customization')
- ,id: 'modx-fcp-header'
- ,xtype: 'modx-header'
- },MODx.getPageStructure([{
- title: _('profiles')
- ,autoHeight: true
- ,layout: "form"
- ,items: [{
- html: '<p>'+_('form_customization_msg')+'</p>'
- ,xtype: 'modx-description'
- },{
- title: ''
- ,preventRender: true
- ,xtype: 'modx-grid-fc-profile'
- ,cls:'main-wrapper'
- }]
- }],{
- id: 'modx-form-customization-tabs'
- })]
- });
- MODx.panel.FCProfiles.superclass.constructor.call(this,config);
- };
- Ext.extend(MODx.panel.FCProfiles,MODx.FormPanel);
- Ext.reg('modx-panel-fc-profiles',MODx.panel.FCProfiles);
- MODx.grid.FCProfile = function(config) {
- config = config || {};
- this.sm = new Ext.grid.CheckboxSelectionModel();
- Ext.applyIf(config,{
- id: 'modx-grid-fc-profile'
- ,url: MODx.config.connector_url
- ,baseParams: {
- action: 'security/forms/profile/getlist'
- }
- ,fields: ['id','name','description','usergroups','active','rank','sets','perm']
- ,paging: true
- ,autosave: true
- ,save_action: 'security/forms/profile/updatefromgrid'
- ,sm: this.sm
- ,remoteSort: true
- ,columns: [this.sm,{
- header: _('id')
- ,dataIndex: 'id'
- ,width: 40
- ,sortable: true
- },{
- header: _('name')
- ,dataIndex: 'name'
- ,width: 200
- ,sortable: true
- ,editor: { xtype: 'textfield' }
- },{
- header: _('description')
- ,dataIndex: 'description'
- ,width: 250
- ,sortable: true
- ,editor: { xtype: 'textfield' }
- },{
- header: _('usergroups')
- ,dataIndex: 'usergroups'
- ,width: 150
- }]
- ,viewConfig: {
- forceFit:true
- ,enableRowBody:true
- ,scrollOffset: 0
- ,autoFill: true
- ,showPreview: true
- ,getRowClass : function(rec, ri, p){
- return rec.data.active ? 'grid-row-active' : 'grid-row-inactive';
- }
- }
- ,tbar: [{
- text: _('profile_create')
- ,scope: this
- ,handler: this.createProfile
- ,cls:'primary-button'
- },{
- text: _('bulk_actions')
- ,menu: [{
- text: _('selected_activate')
- ,handler: this.activateSelected
- ,scope: this
- },{
- text: _('selected_deactivate')
- ,handler: this.deactivateSelected
- ,scope: this
- },{
- text: _('selected_remove')
- ,handler: this.removeSelected
- ,scope: this
- }]
- },'->',{
- xtype: 'textfield'
- ,name: 'search'
- ,id: 'modx-fcp-search'
- ,cls: 'x-form-filter'
- ,emptyText: _('filter_by_search')
- ,listeners: {
- 'change': {fn: this.search, scope: this}
- ,'render': {fn: function(cmp) {
- new Ext.KeyMap(cmp.getEl(), {
- key: Ext.EventObject.ENTER
- ,fn: function() {
- this.fireEvent('change',this.getValue());
- this.blur();
- return true;}
- ,scope: cmp
- });
- },scope:this}
- }
- },{
- xtype: 'button'
- ,id: 'modx-filter-clear'
- ,cls: 'x-form-filter-clear'
- ,text: _('filter_clear')
- ,listeners: {
- 'click': {fn: this.clearFilter, scope: this},
- 'mouseout': { fn: function(evt){
- this.removeClass('x-btn-focus');
- }
- }
- }
- }]
- });
- MODx.grid.FCProfile.superclass.constructor.call(this,config);
- this.on('render',function() { this.getStore().reload(); },this);
- };
- Ext.extend(MODx.grid.FCProfile,MODx.grid.Grid,{
- getMenu: function() {
- var r = this.getSelectionModel().getSelected();
- var p = r.data.perm;
- var m = [];
- if (this.getSelectionModel().getCount() > 1) {
- m.push({
- text: _('selected_activate')
- ,handler: this.activateSelected
- });
- m.push({
- text: _('selected_deactivate')
- ,handler: this.deactivateSelected
- });
- m.push('-');
- m.push({
- text: _('selected_remove')
- ,handler: this.removeSelected
- });
- } else {
- if (p.indexOf('pedit') != -1) {
- m.push({
- text: _('edit')
- ,handler: this.updateProfile
- },{
- text: _('duplicate')
- ,handler: this.duplicateProfile
- },'-');
- if (r.data.active) {
- m.push({
- text: _('deactivate')
- ,handler: this.deactivateProfile
- });
- } else {
- m.push({
- text: _('activate')
- ,handler: this.activateProfile
- });
- }
- }
- if (p.indexOf('premove') != -1) {
- m.push('-',{
- text: _('remove')
- ,handler: this.confirm.createDelegate(this,['security/forms/profile/remove','profile_remove_confirm'])
- });
- }
- }
- if (m.length > 0) {
- this.addContextMenuItem(m);
- }
- }
- ,search: function(tf,newValue,oldValue) {
- var nv = newValue || tf;
- this.getStore().baseParams.search = Ext.isEmpty(nv) || Ext.isObject(nv) ? '' : nv;
- this.getBottomToolbar().changePage(1);
- //this.refresh();
- return true;
- }
- ,clearFilter: function() {
- this.getStore().baseParams = {
- action: 'security/forms/profile/getlist'
- };
- Ext.getCmp('modx-fcp-search').reset();
- this.getBottomToolbar().changePage(1);
- }
- ,createProfile: function(btn,e) {
- if (!this.windows.cpro) {
- this.windows.cpro = MODx.load({
- xtype: 'modx-window-fc-profile-create'
- ,listeners: {
- 'success': {fn:function(r) {
- this.refresh();
- },scope:this}
- }
- });
- }
- this.windows.cpro.reset();
- this.windows.cpro.show(e.target);
- }
- ,updateProfile: function(btn,e) {
- var r = this.menu.record;
- location.href = '?a=security/forms/profile/update&id='+r.id;
- }
- ,duplicateProfile: function(btn,e) {
- MODx.Ajax.request({
- url: this.config.url
- ,params: {
- action: 'security/forms/profile/duplicate'
- ,id: this.menu.record.id
- }
- ,listeners: {
- 'success': {fn:this.refresh,scope:this}
- }
- });
- }
- ,activateProfile: function(btn,e) {
- MODx.Ajax.request({
- url: this.config.url
- ,params: {
- action: 'security/forms/profile/activate'
- ,id: this.menu.record.id
- }
- ,listeners: {
- 'success': {fn:this.refresh,scope:this}
- }
- });
- }
- ,activateSelected: function() {
- var cs = this.getSelectedAsList();
- if (cs === false) return false;
- MODx.Ajax.request({
- url: this.config.url
- ,params: {
- action: 'security/forms/profile/activateMultiple'
- ,profiles: cs
- }
- ,listeners: {
- 'success': {fn:function(r) {
- this.getSelectionModel().clearSelections(true);
- this.refresh();
- },scope:this}
- }
- });
- return true;
- }
- ,deactivateProfile: function(btn,e) {
- MODx.Ajax.request({
- url: this.config.url
- ,params: {
- action: 'security/forms/profile/deactivate'
- ,id: this.menu.record.id
- }
- ,listeners: {
- 'success': {fn:this.refresh,scope:this}
- }
- });
- }
- ,deactivateSelected: function() {
- var cs = this.getSelectedAsList();
- if (cs === false) return false;
- MODx.Ajax.request({
- url: this.config.url
- ,params: {
- action: 'security/forms/profile/deactivateMultiple'
- ,profiles: cs
- }
- ,listeners: {
- 'success': {fn:function(r) {
- this.getSelectionModel().clearSelections(true);
- this.refresh();
- },scope:this}
- }
- });
- return true;
- }
- ,removeSelected: function() {
- var cs = this.getSelectedAsList();
- if (cs === false) return false;
- MODx.msg.confirm({
- title: _('profile_remove_multiple')
- ,text: _('profile_remove_multiple_confirm')
- ,url: this.config.url
- ,params: {
- action: 'security/forms/profile/removeMultiple'
- ,profiles: cs
- }
- ,listeners: {
- 'success': {fn:function(r) {
- this.getSelectionModel().clearSelections(true);
- this.refresh();
- },scope:this}
- }
- });
- return true;
- }
- });
- Ext.reg('modx-grid-fc-profile',MODx.grid.FCProfile);
- MODx.window.CreateFCProfile = function(config) {
- config = config || {};
- Ext.applyIf(config,{
- title: _('profile_create')
- ,url: MODx.config.connector_url
- ,action: 'security/forms/profile/create'
- // ,height: 150
- // ,width: 375
- ,fields: [{
- xtype: 'textfield'
- ,name: 'name'
- ,fieldLabel: _('name')
- ,id: 'modx-fccp-name'
- ,allowBlank: false
- ,anchor: '100%'
- },{
- xtype: 'textarea'
- ,name: 'description'
- ,fieldLabel: _('description')
- ,id: 'modx-fccp-description'
- ,anchor: '100%'
- },{
- xtype: 'xcheckbox'
- ,boxLabel: _('active')
- ,hideLabel: true
- ,name: 'active'
- ,id: 'modx-fccp-active'
- ,inputValue: 1
- ,value: 1
- ,checked: true
- ,anchor: '100%'
- }]
- ,keys: []
- });
- MODx.window.CreateFCProfile.superclass.constructor.call(this,config);
- };
- Ext.extend(MODx.window.CreateFCProfile,MODx.Window);
- Ext.reg('modx-window-fc-profile-create',MODx.window.CreateFCProfile);
|