brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [2/4] incubator-brooklyn git commit: wip: none location in add app wizard
Date Wed, 14 Jan 2015 22:32:37 GMT
wip: none location in add app wizard


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/359bd1c1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/359bd1c1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/359bd1c1

Branch: refs/heads/master
Commit: 359bd1c146f57a6c222458ff8bb1aab36d9791ed
Parents: a893a22
Author: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Authored: Wed Jan 14 13:43:26 2015 +0000
Committer: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Committed: Wed Jan 14 13:43:26 2015 +0000

----------------------------------------------------------------------
 .../assets/js/view/application-add-wizard.js    | 46 ++++++++++----------
 1 file changed, 22 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/359bd1c1/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js b/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js
index 833a5ff..a763c86 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js
@@ -557,33 +557,31 @@ define([
         },
         renderAddedLocations:function () {
             // renders the locations added to the model
-            var that = this;
-            var container = this.$("#selector-container")
-            container.empty()
+            var rowTemplate = this.locationRowTemplate,
+                optionTemplate = this.locationOptionTemplate,
+                container = this.$("#selector-container");
+            container.empty();
             for (var li = 0; li < this.model.spec.get("locations").length; li++) {
                 var chosenLocation = this.model.spec.get("locations")[li];
-                container.append(that.locationRowTemplate({
-                        initialValue: chosenLocation,
-                        rowId: li
-                    }))
+                container.append(rowTemplate({
+                    initialValue: chosenLocation,
+                    rowId: li
+                }));
             }
-            var $locationOptions = container.find('.select-location')
-            this.locations.each(function(aLocation) {
-                    if (!aLocation.id) {
-                        log("missing id for location:");
-                        log(aLocation);
-                    } else {
-                        var $option = that.locationOptionTemplate({
-                            id:aLocation.id,
-                            name:aLocation.getPrettyName()
-                        })
-                        $locationOptions.append($option)
-                    }
-                })
+            var $locationOptions = container.find('.select-location');
+            var templated = this.locations.map(function(aLocation) {
+                return optionTemplate({
+                    id: aLocation.id || "",
+                    name: aLocation.getPrettyName()
+                });
+            });
+            // insert "none" location
+            templated.push(optionTemplate({ id: "", name: '&lt;none&gt;' }));
+            $locationOptions.append(templated.join(""));
             $locationOptions.each(function(i) {
-                var w = $($locationOptions[i]);
-                w.val( w.parent().attr('initialValue') );
-            })
+                var option = $($locationOptions[i]);
+                option.val(option.parent().attr('initialValue'));
+            });
         },
         render:function () {
             this.delegateEvents()
@@ -671,7 +669,7 @@ define([
             var loc_id = $(event.currentTarget).val();
             var loc = this.locations.find(function (candidate) {
                 return candidate.get("id")==loc_id;
-            })
+            });
             if (!loc) {
                 log("invalid location "+loc_id);
                 this.showFailure("Invalid location "+loc_id);


Mime
View raw message