commit a6dcade6af5dcaeb418f855a1bfef5ef8c960bc9
parent a4cbe518f472e15d623069092480c342e0404d67
Author: Felicitus <felicitus@felicitus.org>
Date: Fri, 25 May 2012 05:50:00 +0200
Added reload function to the category tree, fixes #197
Diffstat:
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/frontend/js/Components/CategoryTree.js b/src/frontend/js/Components/CategoryTree.js
@@ -29,6 +29,8 @@ Ext.define("PartKeepr.CategoryTree", {
this.loadCategories();
},
loadCategories: function () {
+ this.loaded = false;
+
var call = new PartKeepr.ServiceCall(this.categoryService, "getAllCategories");
call.setLoadMessage(i18n("Loading categories..."));
call.setHandler(Ext.bind(this._onCategoriesLoaded, this));
diff --git a/src/frontend/js/Components/Widgets/CategoryComboBox.js b/src/frontend/js/Components/Widgets/CategoryComboBox.js
@@ -3,6 +3,9 @@ Ext.define("PartKeepr.CategoryComboBox",{
alias: 'widget.CategoryComboBox',
requires:["Ext.tree.Panel"],
selectedValue: null,
+
+ trigger2Cls: Ext.baseCSSPrefix + 'form-reload-trigger',
+
initComponent: function(){
var self = this;
@@ -17,6 +20,28 @@ Ext.define("PartKeepr.CategoryComboBox",{
this.createPicker();
},
+ onTrigger1Click: function () {
+ this.onTriggerClick();
+ },
+ onTrigger2Click: function () {
+ this.collapse();
+ this.picker.loadCategories();
+ this.expand();
+ },
+ /**
+ * Override the expand method so that it doesn't expand immediately when data is being loaded. Defers the expand
+ * function for 100 milliseconds until the picker data has been loaded.
+ */
+ expand: function () {
+ console.log(this.picker);
+
+ if (!this.picker.loaded) {
+ Ext.defer(this.expand, 100, this);
+ return;
+ } else {
+ this.callParent();
+ }
+ },
createPicker: function(){
var self = this;