]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
lovcombo: add Ext.ux.form.ComboAny
authorJaroslav Kysela <perex@perex.cz>
Thu, 4 Jan 2018 19:44:33 +0000 (20:44 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 4 Jan 2018 19:54:46 +0000 (20:54 +0100)
src/webui/static/app/epg.js
src/webui/static/app/idnode.js
src/webui/static/app/tvheadend.js
src/webui/static/lovcombo/lovcombo-all.js

index 47a38e5bd1ea8cb79085e9e57e6ac4f47dad4c11..f7596d01ddfed1ae03d366c4373c9f7973f8287d 100644 (file)
@@ -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',
index 178c85326572a317717b9af3c031220adf72994d..7d4843d2f4c1573980a0562d296386ac93de4b40 100644 (file)
@@ -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);
index f92fa096f26bcfe59f7574f09439abf0508eeb27..e8e747d90c7f021f0e852839c9ef1920a442929a 100644 (file)
@@ -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',
index 9cb155dbf235db0a54ee1dd2cf3a968dacf9a00c..cc596df91c33898a316248859df1e4220be887ff 100644 (file)
@@ -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