| Ext.define('PortalApp.controller.PbxControl.EditDialplan', { |
| extend: 'Ext.app.Controller', |
| controllers: [ |
| 'PortalApp.controller.InetPbxAdministration.Queues' |
| ], |
| models: [], |
| stores: [], |
| init: function() { |
| this.control({ |
| 'exten-edit-dialplan': { |
| beforerender: this.afterRenderWindow, |
| close: this.closeWindow |
| }, |
| 'exten-edit-dialplan combobox[name=command]': { |
| // beforerender: this.afterRenderWindow, |
| change: this.cahngeCommand |
| }, |
| 'exten-edit-dialplan #dialGrid button[action=addContact]': { |
| click: this.addContact |
| }, |
| 'exten-edit-dialplan #dialGrid': { |
| show: this.showDialGrid, |
| beforeedit: this.beforeeditContact, |
| validateedit: this.validateeditContact, |
| canceledit: this.canceleditContact, |
| select: this.selectContact, |
| }, |
| }); |
| }, |
| /** |
| * @method selectContact [description] |
| * @param {[type]} selMod [Description of selMod] |
| * @return {void} |
| */ |
| selectContact: function(selMod) { |
| selMod.view.panel.down('button[action=deleteContact]').enable(); |
| }, |
| beforeeditContact: function(editor, context) { |
| editor.grid.down('toolbar').disable(); |
| }, |
| validateeditContact: function(editor, context) { |
| editor.editor.down('#InetPbxContactCombo').allowBlank = false; |
| }, |
| canceleditContact: function(editor, context) { |
| var grid = editor.grid; |
| if (!context.value) { |
| grid.getSelectionModel().select(grid.getStore().last()); |
| grid.getStore().removeAt(context.rowIdx); |
| } |
| grid.down('toolbar').enable(); |
| }, |
| addContact: function(button) { |
| var grid = button.up('gridpanel'), |
| store = grid.getStore(), |
| count = store.getCount(), |
| plugin = button.up('gridpanel').getPlugin('dial-contact-grid-re'); |
| plugin.cancelEdit(); |
| plugin.editor.down('#InetPbxContactCombo').allowBlank = true; |
| store.add(Ext.create('PortalApp.model.PbxControl.Extens.Dialplan')) |
| plugin.startEdit(count, 0); |
| }, |
| // /** |
| // * @method closeWindow [description] |
| // * @param {[type]} win [Description of win] |
| // * @return {void} |
| // */ |
| closeWindow: function(win) { |
| Ext.getStore('InetPbxDialplanDialContacts').removeAll(); |
| Ext.getStore('PbxControl.Extens').clearFilter(); |
| }, |
| /** |
| * @method showDialGrid [description] |
| * @param {[type]} grid [Description of grid] |
| * @return {void} |
| */ |
| showDialGrid: function(grid) { |
| grid |
| }, |
| /** |
| * @method aftertRenderWindow [description] |
| * @param {[type]} window [Description of window] |
| * @return {void} |
| */ |
| afterRenderWindow: function(win) { |
| win.setDefault = function() { |
| // win.down('combobox[name=command]').setValue('dial') |
| win.setTitle('. Добавить команду плана обработки вызова'); |
| } |
| win.down('dial-contact-grid').internalContactsStore = Ext.getStore('PbxControl.Extens'); |
| win.down('dial-contact-grid').externalContactsStore = Ext.getStore('InetPbxContactsCombo'); |
| Ext.getStore('PbxControl.Extens').clearFilter(); |
| // win.down('').getStore().load(); |
| Ext.getStore('PbxControl.Extens').filter([{ |
| filterFn: function(item) { |
| return item.get("id") != Ext.app.inetPbxCurrentExtenId; |
| } |
| }]); |
| }, |
| cahngeCommand: function(combo, newValue) { |
| console.log(newValue) |
| var displayIconPath = combo.getStore().findRecord('command', newValue).get('icon'), |
| form = combo.up('form'), |
| win = form.up('window'), |
| dialWaitTime = form.down('field[name=dialWaitTime]'), |
| contactStore = Ext.getStore('InetPbxContactsCombo'), |
| searchRegex = RegExp('.{0,}' + newValue + '.{0,}', 'i'); |
| form.items.each(function(item) { |
| if (item.name !== 'command' && item.name !== 'DialplanLabel') { |
| item.hide(); |
| item.allowBlank = true; |
| } |
| if (searchRegex.test(item.itemId)) { |
| item.show(); |
| item.allowBlank = (item.name !== 'comment') ? false : true; |
| } |
| }); |
| combo.inputEl.setStyle({ |
| 'background-image': 'url(' + displayIconPath + ')', |
| 'background-repeat': 'no-repeat', |
| 'background-position': '3px center', |
| 'padding-left': '25px' |
| }); |
| displayIconPath = combo.getStore().findRecord('command', newValue).get('icon'); |
| switch (newValue) { |
| case 'wait': |
| dialWaitTime.setMaxValue(300); |
| dialWaitTime.setValue(120); |
| break; |
| case 'queue': |
| dialWaitTime.setMaxValue(1800); |
| dialWaitTime.setValue(600); |
| break; |
| case 'faxEmail': |
| var filterRegex = RegExp('^.{6,}$', 'i'); |
| contactStore.clearFilter(); |
| contactStore.filter('contactEmail', filterRegex); |
| break; |
| case 'voiceEmail': |
| var filterRegex = RegExp('^.{6,}$', 'i'); |
| contactStore.clearFilter(); |
| contactStore.filter('contactEmail', filterRegex); |
| break; |
| case 'dial': |
| var filterRegex = RegExp('^[0-9]{7,}$', 'i'); |
| contactStore.clearFilter(); |
| contactStore.filter('contactTelNumber', filterRegex); |
| dialWaitTime.setMaxValue(300); |
| dialWaitTime.setValue(120); |
| break; |
| default: |
| break; |
| } |
| } |
| }); |
Комментарии