From: Jaroslav Kysela Date: Thu, 4 Jan 2018 19:44:33 +0000 (+0100) Subject: lovcombo: add Ext.ux.form.ComboAny X-Git-Tag: v4.2.6~47 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bb3dacde398d7373212e7c383b2a990b854f1b9c;p=thirdparty%2Ftvheadend.git lovcombo: add Ext.ux.form.ComboAny --- diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js index 47a38e5bd..f7596d01d 100644 --- a/src/webui/static/app/epg.js +++ b/src/webui/static/app/epg.js @@ -237,7 +237,7 @@ tvheadend.epgDetails = function(event) { })); } - var confcombo = new Ext.form.ComboBox({ + var confcombo = new Ext.ux.form.ComboAny({ store: store, triggerAction: 'all', mode: 'local', @@ -692,7 +692,7 @@ tvheadend.epg = function() { // Channels, uses global store - var epgFilterChannels = new Ext.form.ComboBox({ + var epgFilterChannels = new Ext.ux.form.ComboAny({ loadingText: _('Loading...'), width: 200, displayField: 'val', @@ -715,7 +715,7 @@ tvheadend.epg = function() { // Tags, uses global store - var epgFilterChannelTags = new Ext.form.ComboBox({ + var epgFilterChannelTags = new Ext.ux.form.ComboAny({ loadingText: _('Loading...'), width: 200, displayField: 'val', @@ -739,7 +739,7 @@ tvheadend.epg = function() { // Content groups - var epgFilterContentGroup = new Ext.form.ComboBox({ + var epgFilterContentGroup = new Ext.ux.form.ComboAny({ loadingText: _('Loading...'), width: 200, displayField: 'val', @@ -760,7 +760,7 @@ tvheadend.epg = function() { } }); - var epgFilterDuration = new Ext.form.ComboBox({ + var epgFilterDuration = new Ext.ux.form.ComboAny({ loadingText: _('Loading...'), width: 150, displayField: 'label', diff --git a/src/webui/static/app/idnode.js b/src/webui/static/app/idnode.js index 178c85326..7d4843d2f 100644 --- a/src/webui/static/app/idnode.js +++ b/src/webui/static/app/idnode.js @@ -411,7 +411,6 @@ tvheadend.IdNodeField = function(conf) this.editor = function(conf) { var cons = null; - var combo = false; /* Editable? */ var d = this.rdonly; @@ -446,7 +445,7 @@ tvheadend.IdNodeField = function(conf) c['fromLegend'] = _('Available'); } else { - cons = Ext.form.ComboBox; + cons = Ext.ux.form.ComboAny; if (this.list) { cons = Ext.ux.form.LovCombo; c['checkField'] = 'checked_' + this.id; @@ -459,8 +458,6 @@ tvheadend.IdNodeField = function(conf) c['forceSelection'] = false; c['triggerAction'] = 'all'; c['emptyText'] = _('Select {0} ...').replace('{0}', this.text); - - combo = true; } /* Single */ @@ -508,10 +505,7 @@ tvheadend.IdNodeField = function(conf) } } - var r = new cons(c); - if (combo) - r.doQuery = tvheadend.doQueryAnyMatch; - return r; + return new cons(c); }; }; @@ -693,7 +687,7 @@ tvheadend.idnode_editor_field = function(f, conf) /* Enumerated (combobox) type */ } else if (f['enum']) { - var cons = Ext.form.ComboBox; + var cons = Ext.ux.form.ComboAny; if (f.list) cons = Ext.ux.form.LovCombo; var st = tvheadend.idnode_enum_store(f); @@ -719,8 +713,6 @@ tvheadend.idnode_editor_field = function(f, conf) } }); - r.doQuery = tvheadend.doQueryAnyMatch; - if (st.on) { var fn = function() { st.un('load', fn); diff --git a/src/webui/static/app/tvheadend.js b/src/webui/static/app/tvheadend.js index f92fa096f..e8e747d90 100644 --- a/src/webui/static/app/tvheadend.js +++ b/src/webui/static/app/tvheadend.js @@ -377,53 +377,9 @@ tvheadend.PagingToolbarConf = function(conf, title, auto, count) return conf; } -/* - * Any Match option in ComboBox queries - * This query is identical as in extjs-all.js - * except one - */ -tvheadend.doQueryAnyMatch = function(q, forceAll) { - q = Ext.isEmpty(q) ? '' : q; - var qe = { - query: q, - forceAll: forceAll, - combo: this, - cancel:false - }; - - if (this.fireEvent('beforequery', qe) === false || qe.cancel) - return false; - - q = qe.query; - forceAll = qe.forceAll; - if (forceAll === true || (q.length >= this.minChars)) { - if (this.lastQuery !== q) { - this.lastQuery = q; - if (this.mode == 'local') { - this.selectedIndex = -1; - if (forceAll) { - this.store.clearFilter(); - } else { - /* supply the anyMatch option (last param) */ - this.store.filter(this.displayField, q, true); - } - this.onLoad(); - } else { - this.store.baseParams[this.queryParam] = q; - this.store.load({ params: this.getParams(q) }); - this.expand(); - } - } else { - this.selectedIndex = -1; - this.onLoad(); - } - } -} - /* * Replace one entry */ - tvheadend.replace_entry = function(r, d) { if (!r) return; var dst = r.data; @@ -499,7 +455,7 @@ tvheadend.VideoPlayer = function(channelId) { initialChannelName = record.data.val; } - var selectChannel = new Ext.form.ComboBox({ + var selectChannel = new Ext.ux.form.ComboAny({ loadingText: _('Loading...'), width: 200, displayField: 'val', @@ -538,7 +494,7 @@ tvheadend.VideoPlayer = function(channelId) { }); } - var selectProfile = new Ext.form.ComboBox({ + var selectProfile = new Ext.ux.form.ComboAny({ loadingText: _('Loading...'), width: 150, displayField: 'val', diff --git a/src/webui/static/lovcombo/lovcombo-all.js b/src/webui/static/lovcombo/lovcombo-all.js index 9cb155dbf..cc596df91 100644 --- a/src/webui/static/lovcombo/lovcombo-all.js +++ b/src/webui/static/lovcombo/lovcombo-all.js @@ -29,13 +29,75 @@ if('function' !== typeof RegExp.escape) { // create namespace Ext.ns('Ext.ux.form'); + +/** + * + * @class Ext.ux.form.ComboAny + * @extends Ext.form.ComboBox + */ +Ext.ns('Ext.ux.form'); +Ext.ux.form.ComboAny = Ext.extend(Ext.form.ComboBox, { + + doQuery: function(q, forceAll) { + q = Ext.isEmpty(q) ? '' : q; + var qe = { + query: q, + forceAll: forceAll, + combo: this, + cancel:false + }; + + if (this.fireEvent('beforequery', qe) === false || qe.cancel) + return false; + + q = qe.query; + forceAll = qe.forceAll; + if (forceAll === true || (q.length >= this.minChars)) { + if (this.lastQuery !== q) { + this.lastQuery = q; + if (this.mode == 'local') { + this.selectedIndex = -1; + if (forceAll) { + this.store.clearFilter(); + } else { + /* supply the anyMatch option (last param) */ + this.store.filter(this.displayField, q, true); + } + this.onLoad(); + } else { + this.store.baseParams[this.queryParam] = q; + this.store.load({ params: this.getParams(q) }); + this.expand(); + } + } else { + this.selectedIndex = -1; + this.onLoad(); + } + } + }, + + onTypeAhead: function() { + if (this.store.getCount() > 0) { + var r = this.store.getAt(0); + var newValue = r.data[this.displayField]; + var len = newValue.length; + var olen = this.getRawValue().length; + if (olen != len) { + this.setRawValue(newValue); + this.selectText(0, len); + } + } + } + +}); + /** * * @class Ext.ux.form.LovCombo * @extends Ext.form.ComboBox */ -Ext.ux.form.LovCombo = Ext.extend(Ext.form.ComboBox, { +Ext.ux.form.LovCombo = Ext.extend(Ext.ux.form.ComboAny, { // {{{ // configuration options