From 4b964f3f97829543cbab5f81128a5e16a39cccc5 Mon Sep 17 00:00:00 2001 From: johannnes <> Date: Sun, 12 Jan 2014 15:49:08 +0000 Subject: [PATCH] chartingfrontend: fixing sorting bug git-svn-id: https://svn.fhem.de/fhem/trunk@4633 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/www/frontend/controls_frontend.txt | 2 +- .../www/frontend/app/controller/MainController.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fhem/www/frontend/controls_frontend.txt b/fhem/www/frontend/controls_frontend.txt index b4b0b6264..798bbaf5d 100644 --- a/fhem/www/frontend/controls_frontend.txt +++ b/fhem/www/frontend/controls_frontend.txt @@ -280,7 +280,7 @@ UPD 2013-12-26_08:39:37 10257 www/frontend/app/view/TableDataGridPanel.js UPD 2014-01-03_01:24:06 65039 www/frontend/app/view/LineChartPanel.js UPD 2014-01-12_12:09:17 5144 www/frontend/app/view/StatusPanel.js UPD 2014-01-12_12:55:22 10486 www/frontend/app/view/Viewport.js -UPD 2014-01-12_02:42:27 21844 www/frontend/app/controller/MainController.js +UPD 2014-01-12_04:44:35 22438 www/frontend/app/controller/MainController.js UPD 2014-01-12_02:49:58 16562 www/frontend/app/controller/StatusController.js UPD 2014-01-12_03:28:35 109269 www/frontend/app/controller/ChartController.js UPD 2013-06-30_11:46:54 5415 www/frontend/app/controller/TableDataController.js diff --git a/fhem/www/frontend/www/frontend/app/controller/MainController.js b/fhem/www/frontend/www/frontend/app/controller/MainController.js index f6b8d1628..8352ed4f8 100644 --- a/fhem/www/frontend/www/frontend/app/controller/MainController.js +++ b/fhem/www/frontend/www/frontend/app/controller/MainController.js @@ -232,6 +232,18 @@ Ext.define('FHEM.controller.MainController', { } }); + // sort root by treeindex as inserting with index whil some objects not added may be faulty + rootNode.sort(function(rec, rec2) { + if (rec && rec.raw && rec.raw.data && rec.raw.data.VALUE && + rec2 && rec2.raw && rec2.raw.data && rec2.raw.data.VALUE) { + if (rec.raw.data.VALUE.treeIndex > rec2.raw.data.VALUE.treeIndex) { + return 1; + } else { + return -1; + } + } + }, true); + // at last we add a chart template to the folder which wont be saved to db and cannot be deleted chartchild = {text: 'Create new Chart', leaf: true, data: {template: true}, iconCls:'x-tree-icon-leaf-chart'}; chartfoldernode.appendChild(chartchild);