This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resource-editor.git

commit fe6f0e0deee0359edb95df3a28b14ad40ed1e5b2
Author: Sandro Boehme <[email protected]>
AuthorDate: Wed Apr 1 12:28:37 2015 +0000

    fixed SLING-4559 Resource Editor :: add node dialog :: use the entered but 
not yet selected values of the node name and the resource type
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1670624 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../js/tree/AddNodeController.js                   | 28 ++++++++++++++++++----
 src/test/javascript/e2e/spec/e2e_spec.js           |  5 +++-
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git 
a/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/AddNodeController.js
 
b/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/AddNodeController.js
index 4aabe8e..e3f510e 100644
--- 
a/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/AddNodeController.js
+++ 
b/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/AddNodeController.js
@@ -38,6 +38,8 @@ org.apache.sling.reseditor.AddNodeController = (function() {
                this.showAllNodeTypes = false;
                this.nodeTypeObjects = [];
                this.nodeType="";
+               this.latestEnteredNodeName="";
+               this.latestEnteredResType="";
                
                var thatAddNodeController = this;
                $(document).ready(function() {
@@ -63,7 +65,7 @@ org.apache.sling.reseditor.AddNodeController = (function() {
                        $("body").on('keydown', function (e) {
                        // see http://www.javascripter.net/faq/keycodes.htm
                                var aKey = 65;
-                       if (e.ctrlKey && aKey==e.which) {
+                       if (e.ctrlKey && aKey==e.which) { /*ctrl-a*/
                                if (thatAddNodeController.dialogShown){
                                        thatAddNodeController.addNode();
                                }
@@ -74,10 +76,9 @@ org.apache.sling.reseditor.AddNodeController = (function() {
 
        AddNodeController.prototype.addNode = function() {
                var thatAddNodeController = this;
-               var nodeName = $("#nodeName").val().trim();
+               var nodeName = this.latestEnteredNodeName.trim();
                var nodeType = $("#nodeType").val();
-               var resourceTypeData = $("#resourceType").select2('data');
-               var resourceType = resourceTypeData != null ? 
resourceTypeData.text.trim() : "";
+               var resourceType = (this.latestEnteredResType != null && 
this.latestEnteredResType != "") ? this.latestEnteredResType.trim() : "";
                
                var data = {"_charset_": "utf-8"};
                if ("" != nodeType){
@@ -204,12 +205,20 @@ org.apache.sling.reseditor.AddNodeController = 
(function() {
                $("#nodeName").select2({
                        placeholder: "Enter or select a node name",
                        allowClear: true, 
+                       selectOnBlur: true,
                        data: nodeNameObjects,
                        createSearchChoice: function(searchTerm){
                                return {id:searchTerm, text:searchTerm};
                        }
                });
-
+               $("#nodeName").on("select2-highlight", function(e) { 
+                       /* In Select2 there is currently no way of getting
+                        * the highlighted (newly entered but not yet selected) 
text.
+                        * But there is this event. Thats why I use this one. 
+                        */ 
+                       thatAddNodeController.latestEnteredNodeName=e.val;
+               })
+               
                var nodeNameList = Object.keys(appliCnTypesByNodeName);
                nodeNameList.sort();
                thatAddNodeController.nodeTypeObjects = 
getNodeTypesByDependenyState.call(thatAddNodeController, nodeNameList, 
appliCnTypesByNodeName, thatAddNodeController.nodeTypeObjects);
@@ -234,6 +243,7 @@ org.apache.sling.reseditor.AddNodeController = (function() {
                $("#nodeType").select2({
                        placeholder: "Select a node type",
                        allowClear: true,  
+                       selectOnBlur: true,
                        data: function() { 
                              return { results: 
thatAddNodeController.nodeTypeObjects } ; // Use the global variable to 
populate the list
                    }
@@ -257,11 +267,19 @@ org.apache.sling.reseditor.AddNodeController = 
(function() {
                        var select2 = $("#resourceType").select2({
                                placeholder: "Enter or select a resource type",
                                allowClear: true, 
+                               selectOnBlur: true,
                                data: data,
                                createSearchChoice: function(searchTerm){
                                        return {id:searchTerm, text:searchTerm};
                                }
                        }).data("select2");
+                       $("#resourceType").on("select2-highlight", function(e) {
+                               /* In Select2 there is currently no way of 
getting
+                                * the highlighted (newly entered but not yet 
selected) text.
+                                * But there is this event. Thats why I use 
this one. 
+                                */ 
+                               
thatAddNodeController.latestEnteredResType=e.val;
+                       })
                });
        }
        
diff --git a/src/test/javascript/e2e/spec/e2e_spec.js 
b/src/test/javascript/e2e/spec/e2e_spec.js
index 87eafda..12b1408 100644
--- a/src/test/javascript/e2e/spec/e2e_spec.js
+++ b/src/test/javascript/e2e/spec/e2e_spec.js
@@ -3,9 +3,12 @@
 var assert = require('assert');
 
 describe('The Apache Sling Resource Editor', function() {
+       browser = browser.url('http://localhost:8080/reseditor/.html');
+       // Find a way to specify the host and the port via grunt. See 
+       // 
http://stackoverflow.com/questions/29370075/how-to-pass-parameters-from-the-gruntfile-js-to-the-webdriverio-spec
+       
          it('should have a title', function(done) {
                  browser
-             .url('http://localhost:8080/reseditor/.html')
              .getTitle(function(err,title) {
                  assert(title.indexOf('Apache Sling Resource Editor') !== -1);
              })

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to