commit 476b1901735ae56231edb800d3b9fb40cb76dd5d
parent 15e6698d6df2cdf22fb5ce698953e457792fdb68
Author: Felicitus <felicitus@felicitus.org>
Date: Wed, 5 Aug 2015 23:15:57 +0200
Added form association support. Last commit prior my holiday, see you in two weeks ;)
Diffstat:
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/ExtJS/Enhancements/Ext.form.Basic-AssociationSupport.js b/src/PartKeepr/FrontendBundle/Resources/public/js/ExtJS/Enhancements/Ext.form.Basic-AssociationSupport.js
@@ -0,0 +1,21 @@
+/**
+ * Overrides Ext.form.Basic to implement getter support for loadRecord(). This enables us to directly
+ * assign comboboxes to associations.
+ */
+Ext.define("PartKeepr.form.Basic", {
+ override: "Ext.form.Basic",
+
+ loadRecord: function (record)
+ {
+ this._record = record;
+
+ var values = record.getData();
+
+ for (var i in record.associations) {
+ var getterName = record.associations[i].getterName;
+ values[i] = record[getterName]();
+ }
+
+ return this.setValues(values);
+ }
+});+
\ No newline at end of file
diff --git a/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig b/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig
@@ -68,6 +68,7 @@
'@PartKeeprFrontendBundle/Resources/public/js/Data/HydraTreeModel.js'
'@PartKeeprFrontendBundle/Resources/public/js/Data/HydraReader.js'
'@PartKeeprFrontendBundle/Resources/public/js/ExtJS/Enhancements/Ext.tree.View-missingMethods.js'
+ '@PartKeeprFrontendBundle/Resources/public/js/ExtJS/Enhancements/Ext.form.Basic-AssociationSupport.js'
'@PartKeeprFrontendBundle/Resources/public/js/Components/Statusbar.js'
'@PartKeeprFrontendBundle/Resources/public/js/Components/Auth/LoginDialog.js'
'@PartKeeprFrontendBundle/Resources/public/js/Components/Part/PartImageDisplay.js'