From 6cd0cd8e3c29f28921a870255d4ab82cfc1dbd1d Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 4 Dec 2014 12:12:41 -0800 Subject: [PATCH] [Layout] Refactor view switcher Refactor view switcher to simplify it; treat it as a representation of a domain object that modifies an ng-model. This simplifies reuse, e.g. in frames within a layout. WTD-535. --- platform/commonUI/browse/bundle.json | 5 -- .../browse/res/templates/browse-object.html | 11 +++-- platform/commonUI/general/bundle.json | 14 ++++-- .../res/templates/controls/switcher.html | 49 ++++++++++--------- .../src/ViewSwitcherController.js | 13 ++--- 5 files changed, 48 insertions(+), 44 deletions(-) rename platform/commonUI/{browse => general}/src/ViewSwitcherController.js (80%) diff --git a/platform/commonUI/browse/bundle.json b/platform/commonUI/browse/bundle.json index 249f75da47..155b802fc7 100644 --- a/platform/commonUI/browse/bundle.json +++ b/platform/commonUI/browse/bundle.json @@ -16,11 +16,6 @@ "implementation": "BrowseController.js", "depends": [ "$scope", "objectService", "navigationService" ] }, - { - "key": "ViewSwitcherController", - "implementation": "ViewSwitcherController.js", - "depends": [ "$scope" ] - }, { "key": "CreateMenuController", "implementation": "creation/CreateMenuController", diff --git a/platform/commonUI/browse/res/templates/browse-object.html b/platform/commonUI/browse/res/templates/browse-object.html index 93174f9739..ecd91b71c4 100644 --- a/platform/commonUI/browse/res/templates/browse-object.html +++ b/platform/commonUI/browse/res/templates/browse-object.html @@ -1,4 +1,4 @@ - +
@@ -13,14 +13,17 @@ parameters="{ category: 'view-control' }"> - - + +
- +
\ No newline at end of file diff --git a/platform/commonUI/general/bundle.json b/platform/commonUI/general/bundle.json index f5c0114fb0..0d68c0d9d4 100644 --- a/platform/commonUI/general/bundle.json +++ b/platform/commonUI/general/bundle.json @@ -8,10 +8,6 @@ "key": "bottombar", "templateUrl": "templates/bottombar.html" }, - { - "key": "switcher", - "templateUrl": "templates/controls/switcher.html" - }, { "key": "action-button", "templateUrl": "templates/controls/action-button.html" @@ -41,6 +37,11 @@ "key": "ClickAwayController", "implementation": "ClickAwayController.js", "depends": [ "$scope", "$document" ] + }, + { + "key": "ViewSwitcherController", + "implementation": "ViewSwitcherController.js", + "depends": [ "$scope" ] } ], "directives": [ @@ -93,6 +94,11 @@ "key": "context-menu", "templateUrl": "templates/menu/context-menu.html", "uses": [ "action" ] + }, + { + "key": "switcher", + "templateUrl": "templates/controls/switcher.html", + "uses": [ "view" ] } ] } diff --git a/platform/commonUI/general/res/templates/controls/switcher.html b/platform/commonUI/general/res/templates/controls/switcher.html index ba1df9d5b4..9bdc765645 100644 --- a/platform/commonUI/general/res/templates/controls/switcher.html +++ b/platform/commonUI/general/res/templates/controls/switcher.html @@ -1,28 +1,33 @@ - - - - {{ngModel.selected.glyph}} - {{ngModel.selected.name}} \ No newline at end of file diff --git a/platform/commonUI/browse/src/ViewSwitcherController.js b/platform/commonUI/general/src/ViewSwitcherController.js similarity index 80% rename from platform/commonUI/browse/src/ViewSwitcherController.js rename to platform/commonUI/general/src/ViewSwitcherController.js index 287afdfe90..a7942fe627 100644 --- a/platform/commonUI/browse/src/ViewSwitcherController.js +++ b/platform/commonUI/general/src/ViewSwitcherController.js @@ -32,15 +32,10 @@ define( // Get list of views, read from capability function updateOptions(views) { - var options = views || []; - - $scope.switcher = { - options: options, - selected: findMatchingOption( - options, - ($scope.switcher || {}).selected - ) - }; + $scope.ngModel.selected = findMatchingOption( + views || [], + ($scope.ngModel || {}).selected + ); } // Update view options when the in-scope results of using the