commit 33794d4f59a056eaf3b3c1b75340a60b31252eb3
parent e842609d4e3f54875189502025d57a5e7238f4c9
Author: Felicitus <felicitus@felicitus.org>
Date: Mon, 3 Aug 2015 16:35:50 +0200
Fixed "sync category path" function
Diffstat:
3 files changed, 27 insertions(+), 30 deletions(-)
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartsManager.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartsManager.js
@@ -201,19 +201,21 @@ Ext.define('PartKeepr.PartManager', {
*/
onSyncCategory: function ()
{
- var r = this.grid.getSelectionModel().getLastSelected();
-
- var rootNode = this.tree.getRootNode();
- var cat = r.get("category");
+ var r = this.grid.getSelectionModel().getSelection();
- var node = rootNode.findChild("id", cat, true);
+ if (r.length != 1) {
+ return;
+ }
- this.tree.getView().ensureVisible(node);
- this.tree.getView().scrollIntoView(node);
+ var rootNode = this.tree.getRootNode();
+ var cat = r[0].getCategory().getId();
- var htmlNode = new Ext.Element(this.tree.getView().getNode(node));
+ var node = rootNode.findChild("@id", cat, true);
- htmlNode.first().highlight("2aaad3");
+ if (node) {
+ this.tree.getView().ensureVisible(node);
+ this.tree.getView().focusNode(node);
+ }
},
/**
* Called when the delete button was clicked.
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/ExtJS/Enhancements/Ext.tree.View-missingMethods.js b/src/PartKeepr/FrontendBundle/Resources/public/js/ExtJS/Enhancements/Ext.tree.View-missingMethods.js
@@ -1,30 +1,24 @@
/**
* Enhancements for Ext.tree.View:
- *
+ *
* Ported ensureVisible and scrollIntoView from ExtJS3
*/
-Ext.override(Ext.tree.View, {
- /**
+Ext.define("PartKeepr.tree.View", {
+ override: "Ext.tree.View",
+
+ /**
* Expands all parent nodes so the child is visible.
* @param {Ext.data.Model} record The record to make visible
*/
- ensureVisible: function (record) {
- if (!record) { return; }
-
- if (record.parentNode) {
- record.parentNode.expand();
- this.ensureVisible(record.parentNode);
- }
- },
- /**
- * Scrolls the specified record node into view
- * @param {Ext.data.Model} record The record to scroll into view
- */
- scrollIntoView: function (record) {
- var node = this.getNode(record);
+ ensureVisible: function (record)
+ {
+ if (!record) {
+ return;
+ }
- if (node) {
- node.scrollIntoView(this.getEl());
- }
- }
+ if (record.parentNode) {
+ record.parentNode.expand();
+ this.ensureVisible(record.parentNode);
+ }
+ }
});
\ 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
@@ -67,6 +67,7 @@
'@PartKeeprFrontendBundle/Resources/public/js/Data/HydraModel.js'
'@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/Components/Statusbar.js'
'@PartKeeprFrontendBundle/Resources/public/js/Components/Auth/LoginDialog.js'
'@PartKeeprFrontendBundle/Resources/public/js/Components/Part/PartImageDisplay.js'