From 68bd032855f044ae73d124d2be2c0a4070cdcbb9 Mon Sep 17 00:00:00 2001
From: legac <renaud.legac@free.fr>
Date: Sat, 9 Nov 2013 15:46:58 +0100
Subject: [PATCH] ExtJS 4.2: Migrate the ComboBox.

---
 models/widgets_viewport.py                | 10 ++++++++
 static/plugin_dbui/locale/dbui-lang-fr.js |  7 ++++++
 static/plugin_dbui/src/combobox.js        | 30 ++++++++++++++---------
 3 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/models/widgets_viewport.py b/models/widgets_viewport.py
index 8a3967b2..1ae80e5a 100644
--- a/models/widgets_viewport.py
+++ b/models/widgets_viewport.py
@@ -19,8 +19,18 @@ categoriesLeaf = dbui.Window(closable=True,
                              autoHeight=True,
                              widht=500)
 
+harvestersLeaf = dbui.Window(closable=True,
+                             anchor='100%',
+                             items=[dbui.to_formPanel(db['harvesters'])],
+                             title="Add harvester ...",
+                             defaults={'anchor': '90%'},
+                             modal=True,
+                             autoHeight=True,
+                             widht=500)
+
 formNode = dbui.Node(T('Forms'))
 formNode.add_child(T("categories"), categoriesLeaf)
+formNode.add_child(T("harvesters"), harvestersLeaf)
 
 #
 # the grid node
diff --git a/static/plugin_dbui/locale/dbui-lang-fr.js b/static/plugin_dbui/locale/dbui-lang-fr.js
index 8d8ffa3e..a3c8a341 100644
--- a/static/plugin_dbui/locale/dbui-lang-fr.js
+++ b/static/plugin_dbui/locale/dbui-lang-fr.js
@@ -10,6 +10,13 @@ if (App.BasePanelWithSelector) {
     });
 }
 
+if (App.form.field.ComboBox) {
+    Ext.apply(App.form.field.ComboBox.prototype, {
+        textSelect: 'Sélectioner un(e) ',
+
+    });
+}
+
 if (App.form.DictField) {
     Ext.apply(App.form.DictField.prototype, {
         textAdd: 'Ajouter',
diff --git a/static/plugin_dbui/src/combobox.js b/static/plugin_dbui/src/combobox.js
index f1484d6d..23bafb54 100644
--- a/static/plugin_dbui/src/combobox.js
+++ b/static/plugin_dbui/src/combobox.js
@@ -1,18 +1,26 @@
 /**
- * The ComboBox is an Ext.form.ComboBox linked to an App.data.DirectStore.
+ * This is Ext.form.field.ComboBox linked to a database table.
+ *
+ * The store attribute is equal the table name when the widget
+ * is configured. It is replaced by an Ext.data.store.Direct
+ * in the initialization phase of the component.
  *
  */
-Ext.define('App.form.ComboBox', {
+Ext.define('App.form.field.ComboBox', {
 
-    extend: 'Ext.form.ComboBox',
+    extend: 'Ext.form.field.ComboBox',
     alias: 'widget.xcombobox',
 
     // Predefined setting
-    mode: 'remote',
-    editable: false,
-    selectOnFocus: true,
+    // Works in auto completion mode when the user type value.
+    // In any case the value should belongs to the list.
+    editable: true,
+    forceSelection: true,
+    queryMode: 'local',
     triggerAction: 'all',
-    typeAhead: true,
+
+    // private properties for internationalization
+    textSelect: 'Select a ',
 
     // private method require by the ExtJs component model
     initComponent: function () {
@@ -21,14 +29,14 @@ Ext.define('App.form.ComboBox', {
 
         // defined the empty text from the field label
         if (this.fieldLabel && !this.emptyText) {
-            this.emptyText = "Select a " + this.fieldLabel + " ...";
+            this.emptyText = this.textSelect + this.fieldLabel + " ...";
         }
 
-        // link the combobox to the data store
+        // link the ComboBox to the data store
         this.store = App.getStore(this.store);
 
-        // construct the underlying class. DON'T MOVE
-        App.form.ComboBox.superclass.initComponent.call(this);
+        // construct the underlying class.
+        App.form.field.ComboBox.superclass.initComponent.call(this);
 
         // load the store if not yet done
         if (this.store.getCount() === 0) {
-- 
GitLab