commit e79fd5bc911b27b76b4d033403466c99ac2a5326
parent dc00ffe7c203bed85aeacd0894231f983ed7d352
Author: Timo A. Hummel <timo@netraver.de>
Date: Sun, 12 Jun 2011 10:21:27 +0200
Several bugfixes:
* Bugfixes for ExtJS 4.0.1, see http://www.sencha.com/forum/showthread.php?136747-ExtJS-4.0.2-CellEditing-plugin-ComboBox-own-values and http://www.sencha.com/forum/showthread.php?136746-ExtJS-4.0.2-including-Bugfix-Select-items-on-non-rendered-views
* Fixed wrong variable when adding parameters
Diffstat:
7 files changed, 114 insertions(+), 13 deletions(-)
diff --git a/frontend/js/Components/Part/PartParameterGrid.js b/frontend/js/Components/Part/PartParameterGrid.js
@@ -142,8 +142,8 @@ Ext.define('PartDB2.PartParameterGrid', {
}
},
onAfterEdit: function (editor, e) {
- console.log(e);
var f = e.record.get("prefixedValue");
e.record.set("siprefix_id", f.siprefix_id);
+ e.record.set("value", f.value);
}
});
\ No newline at end of file
diff --git a/frontend/js/Components/Unit/UnitEditor.js b/frontend/js/Components/Unit/UnitEditor.js
@@ -48,8 +48,6 @@ Ext.define('PartDB2.UnitEditor', {
var pfxStore = PartDB2.getApplication().getSiPrefixStore();
for (var i=0;i<records.length;i++) {
- console.log(PartDB2.getApplication().getSiPrefixStore().find("id", records[i].get("id")));
-
toSelect.push(pfxStore.getAt(pfxStore.find("id", records[i].get("id"))));
}
diff --git a/frontend/js/Components/Widgets/PartParameterComboBox.js b/frontend/js/Components/Widgets/PartParameterComboBox.js
@@ -37,12 +37,6 @@ Ext.define("PartDB2.PartParameterComboBox",{
}, this);
this.callParent();
- },
- getValue: function () {
- var j = this.callParent();
-
- console.log(j);
- return j;
}
});
diff --git a/frontend/js/Components/Widgets/SiUnitField.js b/frontend/js/Components/Widgets/SiUnitField.js
@@ -153,8 +153,7 @@ Ext.define("PartDB2.SiUnitField",{
'<div class="thumb-wrap">',
'{symbol} {prefix}',
'</div>',
- '</tpl>'
- );
+ '</tpl>');
var tmp = Ext.create('PartDB2.SiUnitList', {
store: this.getStore(),
diff --git a/frontend/js/Components/Widgets/SiUnitList.js b/frontend/js/Components/Widgets/SiUnitList.js
@@ -3,5 +3,5 @@ Ext.define('PartDB2.SiUnitList', {
alias: 'widget.siunitlist',
getInnerTpl: function(displayField) {
return '<span style="display: inline-block; width: 15px;">{' + displayField + '}</span><span style="display: inline-block; width: 40px;">{prefix}</span>(10<sup>{power}</span>)';
- },
+ }
});
\ No newline at end of file
diff --git a/frontend/js/bugfixes.js b/frontend/js/bugfixes.js
@@ -41,6 +41,116 @@ Ext.override(Ext.data.Connection, {
});
+Ext.form.field.ComboBox.override({
+ beforeBlur: function() {
+ var me = this;
+ me.doQueryTask.cancel();
+
+ me.assertValue();
+ },
+
+ // private
+ assertValue: function() {
+ var me = this,
+ value = me.getRawValue(),
+ rec;
+
+ if (me.forceSelection) {
+ if (me.multiSelect) {
+ // For multiselect, check that the current displayed value matches the current
+ // selection, if it does not then revert to the most recent selection.
+ if (value !== me.getDisplayValue()) {
+ me.setValue(me.lastSelection);
+ }
+ } else {
+ // For single-select, match the displayed value to a record and select it,
+ // if it does not match a record then revert to the most recent selection.
+ rec = me.findRecordByDisplay(value);
+ if (rec) {
+ me.select(rec);
+ } else {
+ me.setValue(me.lastSelection);
+ }
+ }
+ }
+ me.collapse();
+ },
+
+
+ setValue: function(value, doSelect) {
+ var me = this,
+ valueNotFoundText = me.valueNotFoundText,
+ inputEl = me.inputEl,
+ i, len, record,
+ models = [],
+ displayTplData = [],
+ processedValue = [];
+
+ if (me.store.loading) {
+ // Called while the Store is loading. Ensure it is processed by the onLoad method.
+ me.value = value;
+ return me;
+ }
+
+ // This method processes multi-values, so ensure value is an array.
+ value = Ext.Array.from(value);
+
+ // Loop through values
+ for (i = 0, len = value.length; i < len; i++) {
+ record = value[i];
+ if (!record || !record.isModel) {
+ var tmpRecord = me.findRecordByValue(record);
+
+ record = tmpRecord;
+
+ }
+ // record found, select it.
+ if (record) {
+ models.push(record);
+ displayTplData.push(record.data);
+ processedValue.push(record.get(me.valueField));
+ }
+ // record was not found, this could happen because
+ // store is not loaded or they set a value not in the store
+ else {
+ if (!me.forceSelection) {
+ displayTplData.push(value[i]);
+ } else {
+ // if valueNotFoundText is defined, display it, otherwise display nothing for this value
+ if (Ext.isDefined(valueNotFoundText)) {
+ displayTplData.push(valueNotFoundText);
+ }
+ }
+ processedValue.push(value[i]);
+ }
+ }
+
+ // Set the value of this field. If we are multiselecting, then that is an array.
+ me.value = me.multiSelect ? processedValue : processedValue[0];
+ if (!Ext.isDefined(me.value)) {
+ me.value = null;
+ }
+ me.displayTplData = displayTplData; //store for getDisplayValue method
+ me.lastSelection = me.valueModels = models;
+
+ if (inputEl && me.emptyText && !Ext.isEmpty(value)) {
+ inputEl.removeCls(me.emptyCls);
+ }
+
+ // Calculate raw value from the collection of Model data
+ me.setRawValue(me.getDisplayValue());
+ me.checkChange();
+
+ if (doSelect !== false) {
+ me.syncSelection();
+ }
+ me.applyEmptyText();
+
+ return me;
+ }
+
+});
+
/**
* Bugfix for selection on views which aren't bound
*/
diff --git a/src/de/RaumZeitLabor/PartDB2/Part/PartManager.php b/src/de/RaumZeitLabor/PartDB2/Part/PartManager.php
@@ -243,7 +243,7 @@ class PartManager extends Singleton {
$partParameter->setSiPrefix(SiPrefix::loadById($record["siprefix_id"]));
$partParameter->setUnit(Unit::loadById($record["unit_id"]));
- $part->getParameters()->add($distributor);
+ $part->getParameters()->add($partParameter);
}
}
}