diff --git a/src/webui/extjs.c b/src/webui/extjs.c index 10829e2e..9ceef1df 100644 --- a/src/webui/extjs.c +++ b/src/webui/extjs.c @@ -111,6 +111,7 @@ extjs_root(http_connection_t *hc, const char *remain, void *opaque) extjs_load(hq, "static/lovcombo/lovcombo-all.js"); extjs_load(hq, "static/multiselect/multiselect.js"); extjs_load(hq, "static/multiselect/ddview.js"); + extjs_load(hq, "static/checkcolumn/CheckColumn.js"); /** * Create a namespace for our app diff --git a/src/webui/static/app/acleditor.js b/src/webui/static/app/acleditor.js index f1dee2a6..78c05363 100644 --- a/src/webui/static/app/acleditor.js +++ b/src/webui/static/app/acleditor.js @@ -1,77 +1,73 @@ tvheadend.acleditor = function() { var fm = Ext.form; - var enabledColumn = new Ext.grid.CheckColumn({ - header : "Enabled", - dataIndex : 'enabled', - width : 60 - }); + var cm = new Ext.grid.ColumnModel({ + defaultSortable: true, - var streamingColumn = new Ext.grid.CheckColumn({ - header : "Streaming", - dataIndex : 'streaming', - width : 100 - }); + columns : [{ + xtype: 'checkcolumn', + header : "Enabled", + dataIndex : 'enabled', + width : 60 + }, { + header : "Username", + dataIndex : 'username', + editor : new fm.TextField({ + allowBlank : false + }) + }, { + header : "Password", + dataIndex : 'password', + renderer : function(value, metadata, record, row, col, store) { + return 'Hidden'; + }, + editor : new fm.TextField({ + allowBlank : false + }) + }, { + header : "Prefix", + dataIndex : 'prefix', + editor : new fm.TextField({ + allowBlank : false + }) + }, { + xtype: 'checkcolumn', + header : "Streaming", + dataIndex : 'streaming', + width : 100 + }, { + xtype: 'checkcolumn', + header : "Video Recorder", + dataIndex : 'dvr', + width : 100 + }, { + xtype: 'checkcolumn', + header : "All Configs (VR)", + dataIndex : 'dvrallcfg', + width : 100 + }, { + xtype: 'checkcolumn', + header : "Web Interface", + dataIndex : 'webui', + width : 100 + }, { + xtype: 'checkcolumn', + header : "Admin", + dataIndex : 'admin', + width : 100 + }, { + header : "Comment", + dataIndex : 'comment', + width : 400, + editor : new fm.TextField({}) + }]}); - var dvrColumn = new Ext.grid.CheckColumn({ - header : "Video Recorder", - dataIndex : 'dvr', - width : 100 - }); + var UserRecord = Ext.data.Record.create( + [ 'enabled', 'streaming', 'dvr', 'dvrallcfg', 'admin', 'webui', 'username', + 'prefix', 'password', 'comment' + ]); - var dvrallcfgColumn = new Ext.grid.CheckColumn({ - header : "All Configs (VR)", - dataIndex : 'dvrallcfg', - width : 100 - }); - - var webuiColumn = new Ext.grid.CheckColumn({ - header : "Web Interface", - dataIndex : 'webui', - width : 100 - }); - - var adminColumn = new Ext.grid.CheckColumn({ - header : "Admin", - dataIndex : 'admin', - width : 100 - }); - - var cm = new Ext.grid.ColumnModel({ - defaultSortable: true, - columns : [ enabledColumn, { - header : "Username", - dataIndex : 'username', - editor : new fm.TextField({ - allowBlank : false - }) - }, { - header : "Password", - dataIndex : 'password', - renderer : function(value, metadata, record, row, col, store) { - return 'Hidden'; - }, - editor : new fm.TextField({ - allowBlank : false - }) - }, { - header : "Prefix", - dataIndex : 'prefix', - editor : new fm.TextField({ - allowBlank : false - }) - }, streamingColumn, dvrColumn, dvrallcfgColumn, webuiColumn, adminColumn, { - header : "Comment", - dataIndex : 'comment', - width : 400, - editor : new fm.TextField({}) - } ]}); - - var UserRecord = Ext.data.Record.create([ 'enabled', 'streaming', 'dvr', - 'dvrallcfg', 'admin', 'webui', 'username', 'prefix', 'password', - 'comment' ]); - - return new tvheadend.tableEditor('Access control', 'accesscontrol', cm, - UserRecord, [ enabledColumn, streamingColumn, dvrColumn, dvrallcfgColumn, - webuiColumn, adminColumn ], null, 'config_access.html', 'group'); + return new tvheadend.tableEditor('Access control', 'accesscontrol', cm, + UserRecord, [], null, 'config_access.html', + 'group'); } diff --git a/src/webui/static/app/capmteditor.js b/src/webui/static/app/capmteditor.js index 6f0c73ea..a5928647 100644 --- a/src/webui/static/app/capmteditor.js +++ b/src/webui/static/app/capmteditor.js @@ -1,18 +1,6 @@ tvheadend.capmteditor = function() { var fm = Ext.form; - var enabledColumn = new Ext.grid.CheckColumn({ - header : "Enabled", - dataIndex : 'enabled', - width : 60 - }); - - var oscamColumn = new Ext.grid.CheckColumn({ - header : "OSCam mode", - dataIndex : 'oscam', - width : 60 - }); - function setMetaAttr(meta, record) { var enabled = record.get('enabled'); if (!enabled) return; @@ -28,7 +16,12 @@ tvheadend.capmteditor = function() { var cm = new Ext.grid.ColumnModel({ defaultSortable: true, - columns: [ enabledColumn, { + columns: [ { + xtype: 'checkcolumn', + header : "Enabled", + dataIndex : 'enabled', + width : 60 + }, { header : "Camd.socket Filename", dataIndex : 'camdfilename', width : 200, @@ -49,7 +42,13 @@ tvheadend.capmteditor = function() { editor : new fm.TextField({ allowBlank : false }) - }, oscamColumn, { + }, { + xtype: 'checkcolumn', + header : "OSCam mode", + dataIndex : 'oscam', + width : 60 + + } , { header : "Comment", dataIndex : 'comment', width : 400, @@ -83,5 +82,5 @@ tvheadend.capmteditor = function() { }); return new tvheadend.tableEditor('Capmt Connections', 'capmt', cm, rec, - [ enabledColumn, oscamColumn ], store, 'config_capmt.html', 'key'); + [ ], store, 'config_capmt.html', 'key'); } diff --git a/src/webui/static/app/cteditor.js b/src/webui/static/app/cteditor.js index 414730ba..7cbda3d4 100644 --- a/src/webui/static/app/cteditor.js +++ b/src/webui/static/app/cteditor.js @@ -1,51 +1,49 @@ tvheadend.cteditor = function() { - var fm = Ext.form; + var fm = Ext.form; - var enabledColumn = new Ext.grid.CheckColumn({ - header : "Enabled", - dataIndex : 'enabled', - width : 60 - }); - var internalColumn = new Ext.grid.CheckColumn({ - header : "Internal", - dataIndex : 'internal', - width : 100 - }); + var cm = new Ext.grid.ColumnModel({ + defaultSortable: true, + columns : [{ + xtype: 'checkcolumn', + header : "Enabled", + dataIndex : 'enabled', + width : 60 + } , { + header : "Name", + dataIndex : 'name', + editor : new fm.TextField({ + allowBlank : false + }) + }, { + xtype: 'checkcolumn', + header : "Internal", + dataIndex : 'internal', + width : 100 + }, { + header : "Icon (full URL)", + dataIndex : 'icon', + width : 400, + editor : new fm.TextField({}) + }, { + xtype: 'checkcolumn', + header : "Icon has title", + dataIndex : 'titledIcon', + width : 100, + tooltip : 'Set this if the supplied icon has a title embedded. ' + + 'This will tell displaying application not to superimpose title ' + + 'on top of logo.' + }, { + header : "Comment", + dataIndex : 'comment', + width : 400, + editor : new fm.TextField({}) + } ]}); - var titledIconColumn = new Ext.grid.CheckColumn({ - header : "Icon has title", - dataIndex : 'titledIcon', - width : 100, - tooltip : 'Set this if the supplied icon has a title embedded. ' - + 'This will tell displaying application not to superimpose title ' - + 'on top of logo.' - }); + var ChannelTagRecord = Ext.data.Record.create([ + 'enabled', 'name', 'internal', 'icon', 'comment', 'titledIcon' ]); - var cm = new Ext.grid.ColumnModel({ - defaultSortable: true, - columns : [ enabledColumn, { - header : "Name", - dataIndex : 'name', - editor : new fm.TextField({ - allowBlank : false - }) - }, internalColumn, { - header : "Icon (full URL)", - dataIndex : 'icon', - width : 400, - editor : new fm.TextField({}) - }, titledIconColumn, { - header : "Comment", - dataIndex : 'comment', - width : 400, - editor : new fm.TextField({}) - } ]}); - - var ChannelTagRecord = Ext.data.Record.create([ 'enabled', 'name', - 'internal', 'icon', 'comment', 'titledIcon' ]); - - return new tvheadend.tableEditor('Channel Tags', 'channeltags', cm, - ChannelTagRecord, [ enabledColumn, internalColumn, titledIconColumn ], - null, 'config_tags.html', 'tags'); + return new tvheadend.tableEditor('Channel Tags', 'channeltags', cm, + ChannelTagRecord, [], + null, 'config_tags.html', 'tags'); } diff --git a/src/webui/static/app/cwceditor.js b/src/webui/static/app/cwceditor.js index 52d82455..1a96ee2d 100644 --- a/src/webui/static/app/cwceditor.js +++ b/src/webui/static/app/cwceditor.js @@ -1,24 +1,6 @@ tvheadend.cwceditor = function() { var fm = Ext.form; - var enabledColumn = new Ext.grid.CheckColumn({ - header : "Enabled", - dataIndex : 'enabled', - width : 60 - }); - - var emmColumn = new Ext.grid.CheckColumn({ - header : "Update Card", - dataIndex : 'emm', - width : 100 - }); - - var emmexColumn = new Ext.grid.CheckColumn({ - header : "Update One", - dataIndex : 'emmex', - width : 100 - }); - function setMetaAttr(meta, record) { var enabled = record.get('enabled'); if (!enabled) return; @@ -34,7 +16,12 @@ tvheadend.cwceditor = function() { var cm = new Ext.grid.ColumnModel({ defaultSortable: true, - columns : [ enabledColumn, { + columns : [ { + xtype: 'checkcolumn', + header : "Enabled", + dataIndex : 'enabled', + width : 60 + }, { header : "Hostname", dataIndex : 'hostname', width : 200, @@ -86,7 +73,17 @@ tvheadend.cwceditor = function() { editor : new fm.TextField({ allowBlank : false }) - }, emmColumn, emmexColumn, { + }, { + xtype: 'checkcolumn', + header : "Update Card", + dataIndex : 'emm', + width : 100 + }, { + xtype: 'checkcolumn', + header : "Update One", + dataIndex : 'emmex', + width : 100 + }, { header : "Comment", dataIndex : 'comment', width : 400, @@ -112,8 +109,8 @@ tvheadend.cwceditor = function() { } }); - var grid = new tvheadend.tableEditor('Code Word Client', 'cwc', cm, rec, [ - enabledColumn, emmColumn, emmexColumn ], store, 'config_cwc.html', 'key'); + var grid = new tvheadend.tableEditor('Code Word Client', 'cwc', cm, rec, [], + store, 'config_cwc.html', 'key'); tvheadend.comet.on('cwcStatus', function(msg) { var rec = store.getById(msg.id); diff --git a/src/webui/static/app/dvb.js b/src/webui/static/app/dvb.js index 565f9eee..3f1ccb0d 100644 --- a/src/webui/static/app/dvb.js +++ b/src/webui/static/app/dvb.js @@ -7,12 +7,6 @@ tvheadend.dvb_muxes = function(adapterData, satConfStore) { var fm = Ext.form; - var enabledColumn = new Ext.grid.CheckColumn({ - header : "Enabled", - dataIndex : 'enabled', - width : 40 - }); - var qualityColumn = new Ext.ux.grid.ProgressColumn({ header : "Quality", dataIndex : 'quality', @@ -23,7 +17,13 @@ tvheadend.dvb_muxes = function(adapterData, satConfStore) { var cmlist = Array(); - cmlist.push(enabledColumn, { + cmlist.push({ + xtype: 'checkcolumn', + header : "Enabled", + dataIndex : 'enabled', + width : 40 + + }, { header : "Network", dataIndex : 'network', width : 200 @@ -352,7 +352,7 @@ tvheadend.dvb_muxes = function(adapterData, satConfStore) { var grid = new Ext.grid.EditorGridPanel({ stripeRows : true, title : 'Multiplexes', - plugins : [ enabledColumn, qualityColumn ], + plugins : [ qualityColumn ], store : store, clicksToEdit : 2, cm : cm, @@ -379,17 +379,6 @@ tvheadend.dvb_services = function(adapterId) { var fm = Ext.form; - var enabledColumn = new Ext.grid.CheckColumn({ - header : "Enabled", - dataIndex : 'enabled', - width : 45 - }); - - var eitColumn = new Ext.grid.CheckColumn({ - header : "EPG", - dataIndex : 'dvb_eit_enable', - width : 45 - }); var actions = new Ext.ux.grid.RowActions({ header : '', @@ -413,7 +402,12 @@ tvheadend.dvb_services = function(adapterId) { var cm = new Ext.grid.ColumnModel({ defaultSortable: true, columns: [ - enabledColumn, + { + xtype: 'checkcolumn', + header : "Enabled", + dataIndex : 'enabled', + width : 45 + }, { header : "Service name", dataIndex : 'svcname', @@ -485,7 +479,12 @@ tvheadend.dvb_services = function(adapterId) { displayField : 'value', valueField : 'key' }) - }, eitColumn, { + }, { + xtype: 'checkcolumn', + header : "EPG", + dataIndex : 'dvb_eit_enable', + width : 45 + } , { header : "Type", dataIndex : 'type', width : 50 @@ -608,7 +607,7 @@ tvheadend.dvb_services = function(adapterId) { var grid = new Ext.grid.EditorGridPanel({ stripeRows : true, title : 'Services', - plugins : [ enabledColumn, eitColumn, actions ], + plugins : [ actions ], store : store, clicksToEdit : 2, cm : cm, diff --git a/src/webui/static/app/dvr.js b/src/webui/static/app/dvr.js index 72a5ed9e..c7a77e44 100644 --- a/src/webui/static/app/dvr.js +++ b/src/webui/static/app/dvr.js @@ -404,17 +404,18 @@ tvheadend.dvrschedule = function() { tvheadend.autoreceditor = function() { var fm = Ext.form; - var enabledColumn = new Ext.grid.CheckColumn({ - header : "Enabled", - dataIndex : 'enabled', - width : 30 - }); var cm = new Ext.grid.ColumnModel({ defaultSortable: true, columns : - [ - enabledColumn, + [ + { + header: 'Enabled', + dataIndex: 'enabled', + width: 30, + xtype: 'checkcolumn' + }, + { header : "Title (Regexp)", dataIndex : 'title', @@ -562,7 +563,7 @@ tvheadend.autoreceditor = function() { } ]}); return new tvheadend.tableEditor('Automatic Recorder', 'autorec', cm, - tvheadend.autorecRecord, [ enabledColumn ], tvheadend.autorecStore, + tvheadend.autorecRecord, [], tvheadend.autorecStore, 'autorec.html', 'wand'); } /** diff --git a/src/webui/static/app/extensions.js b/src/webui/static/app/extensions.js index 281a98e4..8ba3b39c 100644 --- a/src/webui/static/app/extensions.js +++ b/src/webui/static/app/extensions.js @@ -6,41 +6,6 @@ * http://extjs.com/license */ -/** - * CheckedColumn - */ -Ext.grid.CheckColumn = function(config){ - Ext.apply(this, config); - if(!this.id){ - this.id = Ext.id(); - } - this.renderer = this.renderer.createDelegate(this); -}; - -Ext.grid.CheckColumn.prototype ={ - init : function(grid){ - this.grid = grid; - this.grid.on('render', function(){ - var view = this.grid.getView(); - view.mainBody.on('mousedown', this.onMouseDown, this); - }, this); - }, - - onMouseDown : function(e, t){ - if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){ - e.stopEvent(); - var index = this.grid.getView().findRowIndex(t); - var record = this.grid.store.getAt(index); - record.set(this.dataIndex, !record.data[this.dataIndex]); - } - }, - - renderer : function(v, p, record){ - p.css += ' x-grid3-check-col-td'; - return '
A Column subclass which renders a checkbox in each column cell which toggles the truthiness of the associated data field on click.
+ *Note. As of ExtJS 3.3 this no longer has to be configured as a plugin of the GridPanel.
+ *Example usage:
+ *
+var cm = new Ext.grid.ColumnModel([{
+ header: 'Foo',
+ ...
+ },{
+ xtype: 'checkcolumn',
+ header: 'Indoor?',
+ dataIndex: 'indoor',
+ width: 55
+ }
+]);
+
+// create the grid
+var grid = new Ext.grid.EditorGridPanel({
+ ...
+ colModel: cm,
+ ...
+});
+ *
+ * In addition to toggling a Boolean value within the record data, this
+ * class toggles a css class between 'x-grid3-check-col' and
+ * 'x-grid3-check-col-on' to alter the background image used for
+ * a column.
+ */
+Ext.ux.grid.CheckColumn = Ext.extend(Ext.grid.Column, {
+
+ /**
+ * @private
+ * Process and refire events routed from the GridView's processEvent method.
+ */
+ processEvent : function(name, e, grid, rowIndex, colIndex){
+ if (name == 'mousedown') {
+ var record = grid.store.getAt(rowIndex);
+ record.set(this.dataIndex, !record.data[this.dataIndex]);
+ return false; // Cancel row selection.
+ } else {
+ return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
+ }
+ },
+
+ renderer : function(v, p, record){
+ p.css += ' x-grid3-check-col-td';
+ return String.format('