partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 5ac56e2f9d8a99a45d95f48379726a504deb0f2d
parent b58ffa2e19f843520f96e2e38aa77b8cb67c0b50
Author: Felicitus <felicitus@felicitus.org>
Date:   Sat, 10 Oct 2015 19:05:18 +0200

Refactored tree system to avoid @local-tree-root. This is achieved by hiding @local-tree-root and appending our real root node below the virtual one.

Diffstat:
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/CategoryEditor/CategoryEditorTree.js | 2+-
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/CategoryTree.js | 2+-
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintNavigation.js | 32+-------------------------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintTree.js | 53++++++++++++++++++++++++++++++-----------------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartCategoryTree.js | 3+--
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartsGrid.js | 2--
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartsManager.js | 4+---
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationEditor.js | 3+--
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationNavigation.js | 38+++-----------------------------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationTree.js | 52+++++++++++++++++++++++++++++-----------------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/CategoryComboBox.js | 2+-
Asrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/TreePicker.js | 46++++++++++++++++++++++++++++++++++++++++++++++
Asrc/PartKeepr/FrontendBundle/Resources/public/js/Data/CallActions.js | 131+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Data/HydraModel.js | 54+-----------------------------------------------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Data/HydraTreeModel.js | 20++------------------
Asrc/PartKeepr/FrontendBundle/Resources/public/js/Data/HydraTreeReader.js | 13+++++++++++++
Asrc/PartKeepr/FrontendBundle/Resources/public/js/Data/store/FootprintCategoryStore.js | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Data/store/PartCategoryStore.js | 10+++++-----
Asrc/PartKeepr/FrontendBundle/Resources/public/js/Data/store/StorageLocationCategoryStore.js | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/PartKeepr/FrontendBundle/Resources/views/index.html.twig | 5+++++
20 files changed, 394 insertions(+), 200 deletions(-)

diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/CategoryEditor/CategoryEditorTree.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/CategoryEditor/CategoryEditorTree.js @@ -76,7 +76,7 @@ Ext.define("PartKeepr.CategoryEditorTree", { this.menuCategoryDelete.enable(); - if (record.isRoot()) { + if (record.parentNode !== null && record.parentNode.isRoot()) { this.menuCategoryDelete.disable(); } diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/CategoryTree.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/CategoryTree.js @@ -6,5 +6,5 @@ Ext.define("PartKeepr.CategoryTree", { animate: false }, loaded: false, - rootVisible: true + rootVisible: false }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintNavigation.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintNavigation.js @@ -33,35 +33,6 @@ Ext.define("PartKeepr.FootprintNavigation", { { this.callParent(arguments); - this.treeStore = Ext.create("Ext.data.TreeStore", - { - remoteSort: false, - folderSort: true, - rootVisible: true, - autoLoad: true, - sorters: [ - { - property: 'name', - direction: 'ASC' - } - ], - root: { - "@id": "@local-tree-root" - }, - model: "PartKeepr.FootprintBundle.Entity.FootprintCategory", - proxy: { - ignoreLoadId: '@local-tree-root', - url: "/api/footprint_categories/getExtJSRootNode", - type: "Hydra", - appendId: false, - reader: { - type: 'json' - } - - } - }); - - this.down("partkeepr\\.FootprintTree").setStore(this.treeStore); this.down("partkeepr\\.FootprintTree").on("itemclick", this.onCategoryClick, this); this.down("partkeepr\\.FootprintGrid").setStore(this.store); this.down("partkeepr\\.FootprintGrid").on("itemAdd", this.onAddFootprint, this); @@ -148,4 +119,4 @@ Ext.define("PartKeepr.FootprintNavigation", { } -});- \ No newline at end of file +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintTree.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintTree.js @@ -1,7 +1,7 @@ Ext.define("PartKeepr.FootprintTree", { - extend: 'PartKeepr.CategoryEditorTree', - alias: 'widget.FootprintTree', - xtype: 'partkeepr.FootprintTree', + extend: 'PartKeepr.CategoryEditorTree', + alias: 'widget.FootprintTree', + xtype: 'partkeepr.FootprintTree', viewConfig: { plugins: { ptype: 'treeviewdragdrop', @@ -9,30 +9,38 @@ Ext.define("PartKeepr.FootprintTree", { ddGroup: 'FootprintCategoryTree' } }, - folderSort: true, + folderSort: true, - categoryModel: "PartKeepr.FootprintBundle.Entity.FootprintCategory", + categoryModel: "PartKeepr.FootprintBundle.Entity.FootprintCategory", - /** + /** * @cfg {String} text The path to the 'add' icon */ - addButtonIcon: 'bundles/partkeeprfrontend/images/icons/footprint_add.png', + addButtonIcon: 'bundles/partkeeprfrontend/images/icons/footprint_add.png', - /** + /** * @cfg {String} text The path to the 'delete' icon */ - deleteButtonIcon: 'bundles/partkeeprfrontend/images/icons/footprint_delete.png', + deleteButtonIcon: 'bundles/partkeeprfrontend/images/icons/footprint_delete.png', - listeners: { - "foreignModelDrop": function (record, target) { - record.setCategory(target); - record.save({ - success: function() { - if (record.store && record.store.reload) { - record.store.reload(); - } - } - }); - } - } -});- \ No newline at end of file + initComponent: function () + { + this.store = Ext.create("PartKeepr.data.store.FootprintCategoryStore"); + this.callParent(); + }, + + listeners: { + "foreignModelDrop": function (record, target) + { + record.setCategory(target); + record.save({ + success: function () + { + if (record.store && record.store.reload) { + record.store.reload(); + } + } + }); + } + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartCategoryTree.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartCategoryTree.js @@ -23,4 +23,4 @@ Ext.define("PartKeepr.PartCategoryTree", { }); this.toolbar.add(['->', this.syncButton]); } -});- \ No newline at end of file +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartsGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartsGrid.js @@ -373,8 +373,6 @@ Ext.define('PartKeepr.PartsGrid', { */ setCategory: function (category) { - this.currentCategory = category; - var proxy = this.store.getProxy(); proxy.extraParams.category = category; diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartsManager.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartsManager.js @@ -47,8 +47,6 @@ Ext.define('PartKeepr.PartManager', { var treeConfig = { region: 'west', - categoryModel: 'PartKeepr.PartCategory', - categoryService: 'PartCategory', ddGroup: 'CategoryTree' }; @@ -334,9 +332,9 @@ Ext.define('PartKeepr.PartManager', { var defaultPartUnit = PartKeepr.getApplication().getPartUnitStore().findRecord("default", true); defaults.partUnit = defaultPartUnit.getId(); - defaults.category = this.grid.currentCategory; var record = Ext.create("PartKeepr.PartBundle.Entity.Part", defaults); + record.setCategory(this.getSelectedCategory()); // Inject the defaults to the editor, so the editor can create a new item on its own j.editor.partDefaults = defaults; diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationEditor.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationEditor.js @@ -117,4 +117,4 @@ Ext.define('PartKeepr.StorageLocationEditor', { this.down('#image').setValue(this.record.getImage()); } -});- \ No newline at end of file +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationNavigation.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationNavigation.js @@ -10,8 +10,7 @@ Ext.define("PartKeepr.StorageLocationNavigation", { items: [ { xtype: 'partkeepr.StorageLocationTree', - region: 'center', - rootVisible: false + region: 'center' }, { xtype: 'partkeepr.StorageLocationGrid', resizable: true, @@ -33,35 +32,6 @@ Ext.define("PartKeepr.StorageLocationNavigation", { { this.callParent(arguments); - this.treeStore = Ext.create("Ext.data.TreeStore", - { - remoteSort: false, - folderSort: true, - rootVisible: true, - autoLoad: true, - sorters: [ - { - property: 'name', - direction: 'ASC' - } - ], - root: { - "@id": "@local-tree-root" - }, - model: "PartKeepr.StorageLocationBundle.Entity.StorageLocationCategory", - proxy: { - ignoreLoadId: '@local-tree-root', - url: "/api/storage_location_categories/getExtJSRootNode", - type: "Hydra", - appendId: false, - reader: { - type: 'json' - } - - } - }); - - this.down("partkeepr\\.StorageLocationTree").setStore(this.treeStore); this.down("partkeepr\\.StorageLocationTree").on("itemclick", this.onCategoryClick, this); this.down("partkeepr\\.StorageLocationGrid").setStore(this.store); @@ -122,12 +92,11 @@ Ext.define("PartKeepr.StorageLocationNavigation", { var category; if (selection.length === 0) { - category = this.down("partkeepr\\.StorageLocationTree").getRootNode().getId(); + category = this.down("partkeepr\\.StorageLocationTree").getRootNode().firstChild.getId(); } else { var item = selection.shift(); category = item.getId(); } - this.fireEvent("itemAdd", { category: category }); @@ -183,4 +152,4 @@ Ext.define("PartKeepr.StorageLocationNavigation", { } -});- \ No newline at end of file +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationTree.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationTree.js @@ -1,7 +1,7 @@ Ext.define("PartKeepr.StorageLocationTree", { - extend: 'PartKeepr.CategoryEditorTree', - alias: 'widget.StorageLocationTree', - xtype: 'partkeepr.StorageLocationTree', + extend: 'PartKeepr.CategoryEditorTree', + alias: 'widget.StorageLocationTree', + xtype: 'partkeepr.StorageLocationTree', viewConfig: { plugins: { ptype: 'treeviewdragdrop', @@ -9,30 +9,37 @@ Ext.define("PartKeepr.StorageLocationTree", { ddGroup: 'StorageLocationTree' } }, - folderSort: true, + folderSort: true, - categoryModel: "PartKeepr.StorageLocationBundle.Entity.StorageLocationCategory", + categoryModel: "PartKeepr.StorageLocationBundle.Entity.StorageLocationCategory", - /** + /** * @cfg {String} text The path to the 'add' icon */ - addButtonIcon: 'bundles/partkeeprfrontend/images/icons/footprint_add.png', + addButtonIcon: 'bundles/partkeeprfrontend/images/icons/footprint_add.png', - /** + /** * @cfg {String} text The path to the 'delete' icon */ - deleteButtonIcon: 'bundles/partkeeprfrontend/images/icons/footprint_delete.png', + deleteButtonIcon: 'bundles/partkeeprfrontend/images/icons/footprint_delete.png', - listeners: { - "foreignModelDrop": function (record, target) { - record.setCategory(target); - record.save({ - success: function() { - if (record.store && record.store.reload) { - record.store.reload(); - } - } - }); - } - } -});- \ No newline at end of file + initComponent: function () + { + this.store = Ext.create("PartKeepr.data.store.StorageLocationCategoryStore"); + this.callParent(); + }, + listeners: { + "foreignModelDrop": function (record, target) + { + record.setCategory(target); + record.save({ + success: function () + { + if (record.store && record.store.reload) { + record.store.reload(); + } + } + }); + } + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/CategoryComboBox.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/CategoryComboBox.js @@ -1,5 +1,5 @@ Ext.define("PartKeepr.CategoryComboBox", { - extend: "Ext.ux.TreePicker", + extend: "PartKeepr.Widgets.TreePicker", alias: 'widget.CategoryComboBox', triggers: { diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/TreePicker.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Widgets/TreePicker.js @@ -0,0 +1,46 @@ +Ext.define("PartKeepr.Widgets.TreePicker", { + extend: "Ext.ux.TreePicker", + + /** + * Creates and returns the tree panel to be used as this field's picker. + */ + createPicker: function() { + var me = this, + picker = new Ext.tree.Panel({ + shrinkWrapDock: 2, + store: me.store, + floating: true, + displayField: me.displayField, + columns: me.columns, + minHeight: me.minPickerHeight, + maxHeight: me.maxPickerHeight, + manageHeight: false, + shadow: false, + rootVisible: false, + listeners: { + scope: me, + itemclick: me.onItemClick + }, + viewConfig: { + listeners: { + scope: me, + render: me.onViewRender + } + } + }), + view = picker.getView(); + + if (Ext.isIE9 && Ext.isStrict) { + // In IE9 strict mode, the tree view grows by the height of the horizontal scroll bar when the items are highlighted or unhighlighted. + // Also when items are collapsed or expanded the height of the view is off. Forcing a repaint fixes the problem. + view.on({ + scope: me, + highlightitem: me.repaintPickerView, + unhighlightitem: me.repaintPickerView, + afteritemexpand: me.repaintPickerView, + afteritemcollapse: me.repaintPickerView + }); + } + return picker; + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Data/CallActions.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Data/CallActions.js @@ -0,0 +1,131 @@ +Ext.define("PartKeepr.data.CallActions", { + /** + * Calls an action relative to the entity. + * + * For example, if the entity has a method called "setDefault" and your ID is + * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1", callAction would call + * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1/setDefault" as a result. + * + * @param {String} action The action name + * @param {Object} parameters (optional) The parameters as JS object + * @param {Function} callback (optional) A callback function, or null if not required + * @param {boolean} reload (optional) Triggers a reload of the model after executing the action + */ + callPutAction: function (action, parameters, callback, reload) + { + var proxy = this.getProxy(); + + proxy.callAction(this, action, "PUT", parameters, callback, reload); + }, + /** + * Calls an action relative to the entity. + * + * For example, if the entity has a method called "setDefault" and your ID is + * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1", callAction would call + * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1/setDefault" as a result. + * + * @param {String} action The action name + * @param {Object} parameters (optional) The parameters as JS object + * @param {Function} callback (optional) A callback function, or null if not required + * @param {boolean} reload (optional) Triggers a reload of the model after executing the action + */ + callGetAction: function (action, parameters, callback, reload) + { + var proxy = this.getProxy(); + + proxy.callAction(this, action, "GET", parameters, callback, reload); + }, + /** + * Calls an action relative to the entity. + * + * For example, if the entity has a method called "setDefault" and your ID is + * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1", callAction would call + * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1/setDefault" as a result. + * + * @param {String} action The action name + * @param {Object} parameters (optional) The parameters as JS object + * @param {Function} callback (optional) A callback function, or null if not required + * @param {boolean} reload (optional) Triggers a reload of the model after executing the action + */ + callDeleteAction: function (action, parameters, callback, reload) + { + var proxy = this.getProxy(); + + proxy.callAction(this, action, "DELETE", parameters, callback, reload); + }, + getData: function (options) + { + var data = this.callParent(options); + + if (this.phantom) { + delete data[this.idProperty]; + } + + return data; + }, + /** + * Returns data from all associations + * + * @return {Object} An object containing the associations as properties + */ + getAssociationData: function () + { + var roleName, values = [], role, item, store; + + for (roleName in this.associations) { + role = this.associations[roleName]; + item = role.getAssociatedItem(this); + if (!item || item.$gathering) { + continue; + } + + var getterName = this.associations[roleName].getterName; + + if (item.isStore) { + store = this[getterName](); + values[roleName] = store.getData().items; + } else { + values[roleName] = this[getterName](); + } + } + + return values; + }, + /** + * Sets data to all associations + * + * @param {Object} data The associations to set. Silently ignores non-existant associations. + */ + setAssociationData: function (data) + { + var setterName, getterName, roleName, store; + + for (roleName in data) { + if (this.associations[roleName]) { + + if (this.associations[roleName].isMany === true) { + getterName = this.associations[roleName].getterName; + store = this[getterName](); + store.add(data[roleName]); + } else { + setterName = this.associations[roleName].setterName; + this[setterName](data[roleName]); + } + } + } + }, + inheritableStatics: { + callPostCollectionAction: function (action, parameters, callback, ignoreException) + { + var proxy = this.getProxy(); + + proxy.callCollectionAction(action, "POST", parameters, callback, ignoreException); + }, + callGetCollectionAction: function (action, parameters, callback, ignoreException) + { + var proxy = this.getProxy(); + + proxy.callCollectionAction(action, "GET", parameters, callback, ignoreException); + } + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Data/HydraModel.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Data/HydraModel.js @@ -1,60 +1,8 @@ Ext.define("PartKeepr.data.HydraModel", { extend: 'Ext.data.Model', - /** - * Calls an action relative to the entity. - * - * For example, if the entity has a method called "setDefault" and your ID is - * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1", callAction would call - * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1/setDefault" as a result. - * - * @param {String} action The action name - * @param {Object} parameters (optional) The parameters as JS object - * @param {Function} callback (optional) A callback function, or null if not required - * @param {boolean} reload (optional) Triggers a reload of the model after executing the action - */ - callPutAction: function (action, parameters, callback, reload) - { - var proxy = this.getProxy(); - - proxy.callAction(this, action, "PUT", parameters, callback, reload); - }, - /** - * Calls an action relative to the entity. - * - * For example, if the entity has a method called "setDefault" and your ID is - * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1", callAction would call - * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1/setDefault" as a result. - * - * @param {String} action The action name - * @param {Object} parameters (optional) The parameters as JS object - * @param {Function} callback (optional) A callback function, or null if not required - * @param {boolean} reload (optional) Triggers a reload of the model after executing the action - */ - callGetAction: function (action, parameters, callback, reload) - { - var proxy = this.getProxy(); - - proxy.callAction(this, action, "GET", parameters, callback, reload); - }, - /** - * Calls an action relative to the entity. - * - * For example, if the entity has a method called "setDefault" and your ID is - * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1", callAction would call - * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1/setDefault" as a result. - * - * @param {String} action The action name - * @param {Object} parameters (optional) The parameters as JS object - * @param {Function} callback (optional) A callback function, or null if not required - * @param {boolean} reload (optional) Triggers a reload of the model after executing the action - */ - callDeleteAction: function (action, parameters, callback, reload) - { - var proxy = this.getProxy(); + mixins: ['PartKeepr.data.CallActions'], - proxy.callAction(this, action, "DELETE", parameters, callback, reload); - }, getData: function (options) { var data = this.callParent(options); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Data/HydraTreeModel.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Data/HydraTreeModel.js @@ -1,20 +1,5 @@ Ext.define("PartKeepr.data.HydraTreeModel", { extend: 'Ext.data.TreeModel', - /** - * Calls an action relative to the entity. - * - * For example, if the entity has a method called "setDefault" and your ID is - * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1", callAction would call - * "/PartKeepr/web/app_dev.php/api/part_measurement_units/1/setDefault" as a result. - * - * @param {String} action The action name - * @param {Object} parameters (optional) The parameters as JS object - * @param {Function} callback (optional) A callback function - */ - callAction: function (action, parameters, callback) { - var proxy = this.getProxy(); - - proxy.callAction(this, action, parameters, callback); - } -});- \ No newline at end of file + mixins: ['PartKeepr.data.CallActions'] +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Data/HydraTreeReader.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Data/HydraTreeReader.js @@ -0,0 +1,13 @@ +Ext.define("PartKeepr.data.TreeReader", { + extend: 'Ext.data.reader.Json', + + alias: 'reader.tree', + + getResponseData: function(response) { + var data = this.callParent(arguments); + return { + children: data + }; + } +}); + diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Data/store/FootprintCategoryStore.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Data/store/FootprintCategoryStore.js @@ -0,0 +1,61 @@ +Ext.define('PartKeepr.data.store.FootprintCategoryStore', { + extend: 'Ext.data.TreeStore', + + /** + * The store ID to use + */ + storeId: 'FootprintCategoryStore', + + /** + * Don't sort remotely as this is a tree store + */ + remoteSort: false, + + /** + * Sort folders alphabetically + */ + folderSort: true, + + /** + * Show the root node by default + */ + rootVisible: false, + + /** + * Automatically load the store + */ + autoLoad: true, + + /** + * Sort by name ascending by default + */ + sorters: [ + { + property: 'name', + direction: 'ASC' + } + ], + + /** + * Virtual Root Node + */ + root: { + "@id": "@local-tree-root", + "name": "virtual root - should not be visible" + }, + + /** + * The model to use + */ + model: "PartKeepr.FootprintBundle.Entity.FootprintCategory", + + proxy: { + ignoreLoadId: '@local-tree-root', + url: "/api/footprint_categories/getExtJSRootNode", + type: "Hydra", + appendId: false, + reader: { + type: 'tree' + } + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Data/store/PartCategoryStore.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Data/store/PartCategoryStore.js @@ -17,7 +17,7 @@ Ext.define('PartKeepr.data.store.PartCategoryStore', { folderSort: true, /** - * Hide the root node by default + * Show the root node by default */ rootVisible: false, @@ -40,7 +40,8 @@ Ext.define('PartKeepr.data.store.PartCategoryStore', { * Virtual Root Node */ root: { - "@id": "@local-tree-root" + "@id": "@local-tree-root", + "name": "virtual root - should not be visible" }, /** @@ -54,7 +55,7 @@ Ext.define('PartKeepr.data.store.PartCategoryStore', { type: "Hydra", appendId: false, reader: { - type: 'json' + type: 'tree' } } -});- \ No newline at end of file +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Data/store/StorageLocationCategoryStore.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Data/store/StorageLocationCategoryStore.js @@ -0,0 +1,61 @@ +Ext.define('PartKeepr.data.store.StorageLocationCategoryStore', { + extend: 'Ext.data.TreeStore', + + /** + * The store ID to use + */ + storeId: 'StorageLocationCategoryStore', + + /** + * Don't sort remotely as this is a tree store + */ + remoteSort: false, + + /** + * Sort folders alphabetically + */ + folderSort: true, + + /** + * Show the root node by default + */ + rootVisible: false, + + /** + * Automatically load the store + */ + autoLoad: true, + + /** + * Sort by name ascending by default + */ + sorters: [ + { + property: 'name', + direction: 'ASC' + } + ], + + /** + * Virtual Root Node + */ + root: { + "@id": "@local-tree-root", + "name": "virtual root - should not be visible" + }, + + /** + * The model to use + */ + model: "PartKeepr.StorageLocationBundle.Entity.StorageLocationCategory", + + proxy: { + ignoreLoadId: '@local-tree-root', + url: "/api/storage_location_categories/getExtJSRootNode", + type: "Hydra", + appendId: false, + reader: { + type: 'tree' + } + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig b/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig @@ -39,6 +39,7 @@ 'js/packages/extjs6/build/ext-all-debug.js' 'js/packages/extjs6/build/packages/charts/classic/charts.js' 'js/packages/extjs6/build/packages/ux/classic/ux-debug.js' + '@PartKeeprFrontendBundle/Resources/public/js/Data/CallActions.js' '@PartKeeprFrontendBundle/Resources/public/js/Data/field/Array.js' '@PartKeeprFrontendBundle/Resources/public/js/Data/HydraModel.js' '@PartKeeprFrontendBundle/Resources/public/js/Data/HydraTreeModel.js' @@ -79,6 +80,7 @@ '@PartKeeprFrontendBundle/Resources/public/js/PartKeepr.js' '@PartKeeprFrontendBundle/Resources/public/js/compat.js' '@PartKeeprFrontendBundle/Resources/public/js/Ext.ux/NumericField.js' + '@PartKeeprFrontendBundle/Resources/public/js/Components/Widgets/TreePicker.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Widgets/CurrencyNumberField.js' '@PartKeeprFrontendBundle/Resources/public/js/form/field/SearchField.js' '@PartKeeprFrontendBundle/Resources/public/js/Ext.ux/ClearableComboBox.js' @@ -93,7 +95,10 @@ '@PartKeeprFrontendBundle/Resources/public/js/Dialogs/RememberChoiceMessageBox.js' '@PartKeeprFrontendBundle/Resources/public/js/Data/HydraProxy.js' '@PartKeeprFrontendBundle/Resources/public/js/Data/HydraReader.js' + '@PartKeeprFrontendBundle/Resources/public/js/Data/HydraTreeReader.js' '@PartKeeprFrontendBundle/Resources/public/js/Data/store/PartCategoryStore.js' + '@PartKeeprFrontendBundle/Resources/public/js/Data/store/FootprintCategoryStore.js' + '@PartKeeprFrontendBundle/Resources/public/js/Data/store/StorageLocationCategoryStore.js' '@PartKeeprFrontendBundle/Resources/public/js/Data/store/UserPreferenceStore.js' '@PartKeeprFrontendBundle/Resources/public/js/ExtJS/Enhancements/Ext.tree.View-missingMethods.js' '@PartKeeprFrontendBundle/Resources/public/js/ExtJS/Enhancements/Ext.form.Basic-AssociationSupport.js'