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

dklco pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git


The following commit(s) were added to refs/heads/master by this push:
     new c8969e0  Adding support from the path field for path suggestions and 
working on a content search screen
c8969e0 is described below

commit c8969e0c04842f55e2e61a5b863ccb3b02d1cd26
Author: Dan Klco <[email protected]>
AuthorDate: Wed Aug 22 13:18:08 2018 -0400

    Adding support from the path field for path suggestions and working on a
    content search screen
---
 .../internal/servlets/PathSuggestionServlet.java   | 114 +++++++++++++++++++++
 .../core/internal/servlets/VersionInfoServlet.java |   1 -
 .../sling/cms/core/models/SearchResults.java       |  69 +++++++++++++
 .../reference/components/general/cta/edit.json     |   2 +-
 .../reference/components/general/iframe/edit.json  |   2 +-
 .../reference/components/general/image/edit.json   |   2 +-
 .../reference/components/general/tags/config.json  |   3 +-
 .../apps/reference/components/pages/base/edit.json |   5 +-
 .../apps/reference/components/pages/post/edit.json |   5 +-
 ui/src/main/frontend/gulpfile.js                   |  10 +-
 ui/src/main/frontend/package.json                  |   3 +-
 ui/src/main/frontend/src/js/scripts.js             |  39 +++++++
 ui/src/main/frontend/src/scss/styles.scss          |  26 +++++
 .../sling-cms/components/cms/getform/getform.jsp   |  39 +++++++
 .../components/cms/searchresults/searchresults.jsp |  64 ++++++++++++
 .../components/editor/fields/path/field.jsp        |   8 +-
 .../libs/sling-cms/content/shared/movecopy.json    |   2 +-
 .../{site/editgroup.json => shared/search.json}    |  48 +++++----
 .../libs/sling-cms/content/site/create.json        |   4 +-
 .../libs/sling-cms/content/site/creategroup.json   |   4 +-
 .../jcr_root/libs/sling-cms/content/site/edit.json |   4 +-
 .../libs/sling-cms/content/site/editgroup.json     |   4 +-
 22 files changed, 405 insertions(+), 53 deletions(-)

diff --git 
a/core/src/main/java/org/apache/sling/cms/core/internal/servlets/PathSuggestionServlet.java
 
b/core/src/main/java/org/apache/sling/cms/core/internal/servlets/PathSuggestionServlet.java
new file mode 100644
index 0000000..3f0c15b
--- /dev/null
+++ 
b/core/src/main/java/org/apache/sling/cms/core/internal/servlets/PathSuggestionServlet.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.cms.core.internal.servlets;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.servlets.HttpConstants;
+import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
+import org.osgi.service.component.annotations.Component;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Servlet which includes the content of the page when the page is accessed.
+ */
+@Component(service = { Servlet.class }, property = { 
"sling.servlet.paths=/bin/cms/paths",
+               "sling.servlet.methods=" + HttpConstants.METHOD_GET })
+public class PathSuggestionServlet extends SlingSafeMethodsServlet {
+
+       private static final long serialVersionUID = -410942682163323725L;
+       private static final Logger log = 
LoggerFactory.getLogger(PathSuggestionServlet.class);
+
+       private static final Map<String, String[]> typeMaps = new 
HashMap<String, String[]>();
+
+       static {
+               typeMaps.put("page", new String[] { "sling:Page", "nt:folder", 
"sling:Site" });
+               typeMaps.put("file", new String[] { "nt:file", "nt:folder", 
"sling:Site" });
+               typeMaps.put("folder", new String[] { "nt:folder", "sling:Site" 
});
+               typeMaps.put("all", new String[] { "nt:base" });
+       }
+
+       protected void doGet(SlingHttpServletRequest request, 
SlingHttpServletResponse response)
+                       throws ServletException, IOException {
+               String path = request.getParameter("path");
+
+               if (StringUtils.isEmpty(path)) {
+                       path = "/";
+               }
+               log.debug("Finding valid paths under {}", path);
+
+               String type = request.getParameter("type");
+               if (!typeMaps.containsKey(type)) {
+                       type = "all";
+               }
+               log.debug("Filtering by type: {}", type);
+
+               JsonArrayBuilder arrBuilder = Json.createArrayBuilder();
+               Resource parent = 
request.getResourceResolver().getResource(path);
+
+               if (parent == null) {
+                       path = StringUtils.left(path, path.lastIndexOf("/"));
+                       if (StringUtils.isEmpty(path)) {
+                               path = "/";
+                       }
+
+                       log.debug("Using stemmed path {}", path);
+                       parent = 
request.getResourceResolver().getResource(path);
+               }
+               for (Resource child : parent.getChildren()) {
+                       if (isIncluded(child, type)) {
+                               arrBuilder.add(child.getPath());
+                       }
+
+               }
+
+               response.setContentType("application/json");
+               response.getWriter().write(arrBuilder.build().toString());
+       }
+
+       private boolean isIncluded(Resource child, String type) {
+               try {
+                       Node node = child.adaptTo(Node.class);
+                       if (node != null) {
+                               for (String t : typeMaps.get(type)) {
+                                       if (node.isNodeType(t)) {
+                                               return true;
+                                       }
+                               }
+                       } else {
+                               log.debug("Unable to adapt child resource {} to 
node", child.getPath());
+                       }
+               } catch (RepositoryException e) {
+                       log.warn("Unexpected exception accessing JCR Node", e);
+               }
+               return false;
+       }
+}
diff --git 
a/core/src/main/java/org/apache/sling/cms/core/internal/servlets/VersionInfoServlet.java
 
b/core/src/main/java/org/apache/sling/cms/core/internal/servlets/VersionInfoServlet.java
index 05828eb..767518e 100644
--- 
a/core/src/main/java/org/apache/sling/cms/core/internal/servlets/VersionInfoServlet.java
+++ 
b/core/src/main/java/org/apache/sling/cms/core/internal/servlets/VersionInfoServlet.java
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.sling.cms.core.internal.servlets;
 
 import java.io.IOException;
diff --git 
a/core/src/main/java/org/apache/sling/cms/core/models/SearchResults.java 
b/core/src/main/java/org/apache/sling/cms/core/models/SearchResults.java
new file mode 100644
index 0000000..98884e0
--- /dev/null
+++ b/core/src/main/java/org/apache/sling/cms/core/models/SearchResults.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.cms.core.models;
+
+import java.util.Iterator;
+
+import javax.jcr.query.Query;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.jackrabbit.util.Text;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.cms.core.CMSConstants;
+import org.apache.sling.models.annotations.Model;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Model for retrieving the search results
+ */
+@Model(adaptables = SlingHttpServletRequest.class)
+public class SearchResults {
+
+       private static final Logger log = 
LoggerFactory.getLogger(SearchResults.class);
+
+       private String type = CMSConstants.NT_PAGE;
+       private String path = null;
+       private String term = null;
+       private SlingHttpServletRequest request;
+
+       public SearchResults(SlingHttpServletRequest request) {
+               if (StringUtils.isNotEmpty(request.getParameter("type"))) {
+                       type = request.getParameter("type");
+               }
+
+               if (StringUtils.isNotEmpty(request.getParameter("path"))) {
+                       path = request.getParameter("path");
+               }
+
+               term = 
Text.escapeIllegalXpathSearchChars(request.getParameter("term")).replaceAll("'",
 "''");
+               this.request = request;
+       }
+
+       public Iterator<Resource> getResults() {
+               String query = "SELECT * FROM [" + type + "] AS s WHERE 
CONTAINS(s.*, '" + term + "')";
+               if (StringUtils.isNotEmpty(path)) {
+                       query += " AND ISDESCENDANTNODE([" + path + "])";
+               }
+
+               log.debug("Searching for content with {}", query);
+               return request.getResourceResolver().findResources(query, 
Query.JCR_SQL2);
+       }
+}
diff --git 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/cta/edit.json
 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/cta/edit.json
index e3b4890..a06a441 100644
--- 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/cta/edit.json
+++ 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/cta/edit.json
@@ -24,7 +24,7 @@
                        "jcr:primaryType": "nt:unstructured",
                        "sling:resourceType": 
"sling-cms/components/editor/fields/path",
                        "basePath": "/content",
-                       "type": "sling:Page",
+                       "type": "page",
                        "label": "CTA Link",
                        "name": "href",
                        "titleProperty": "jcr:content/jcr:title"
diff --git 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/iframe/edit.json
 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/iframe/edit.json
index ab1062c..4cc817a 100644
--- 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/iframe/edit.json
+++ 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/iframe/edit.json
@@ -9,7 +9,7 @@
                        "jcr:primaryType": "nt:unstructured",
                        "sling:resourceType": 
"sling-cms/components/editor/fields/path",
                        "basePath": "/content",
-                       "type": "sling:File",
+                       "type": "page",
                        "label": "Frame Source",
                        "name": "src",
                        "titleProperty": "jcr:content/jcr:title",
diff --git 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/edit.json
 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/edit.json
index 442856f..6e4b0d7 100644
--- 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/edit.json
+++ 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/edit.json
@@ -9,7 +9,7 @@
                        "jcr:primaryType": "nt:unstructured",
                        "sling:resourceType": 
"sling-cms/components/editor/fields/path",
                        "basePath": "/content",
-                       "type": "sling:File",
+                       "type": "file",
                        "label": "Image Source",
                        "name": "src",
                        "titleProperty": "jcr:content/jcr:title",
diff --git 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/config.json
 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/config.json
index 7111792..b11b927 100644
--- 
a/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/config.json
+++ 
b/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/config.json
@@ -5,7 +5,8 @@
                "jcr:primaryType": "nt:unstructured",
                "sling:resourceType": "sling-cms/components/editor/fields/path",
                "label": "Tag Page",
-               "name": "tagPage"
+               "name": "tagPage",
+               "type": "page"
        },
        "listTag": {
                "jcr:primaryType": "nt:unstructured",
diff --git 
a/reference/src/main/resources/jcr_root/apps/reference/components/pages/base/edit.json
 
b/reference/src/main/resources/jcr_root/apps/reference/components/pages/base/edit.json
index 91e6f65..19d4ae2 100644
--- 
a/reference/src/main/resources/jcr_root/apps/reference/components/pages/base/edit.json
+++ 
b/reference/src/main/resources/jcr_root/apps/reference/components/pages/base/edit.json
@@ -34,10 +34,9 @@
                        "jcr:primaryType": "nt:unstructured",
                        "sling:resourceType": 
"sling-cms/components/editor/fields/path",
                        "basePath": "/content",
-                       "type": "sling:Page",
+                       "type": "page",
                        "label": "Canonical",
-                       "name": "canonical",
-                       "titleProperty": "jcr:content/jcr:title"
+                       "name": "canonical"
                },
                "published": {
                        "jcr:primaryType": "nt:unstructured",
diff --git 
a/reference/src/main/resources/jcr_root/apps/reference/components/pages/post/edit.json
 
b/reference/src/main/resources/jcr_root/apps/reference/components/pages/post/edit.json
index 4673f6e..c568024 100644
--- 
a/reference/src/main/resources/jcr_root/apps/reference/components/pages/post/edit.json
+++ 
b/reference/src/main/resources/jcr_root/apps/reference/components/pages/post/edit.json
@@ -34,10 +34,9 @@
                        "jcr:primaryType": "nt:unstructured",
                        "sling:resourceType": 
"sling-cms/components/editor/fields/path",
                        "basePath": "/content",
-                       "type": "sling:Page",
+                       "type": "page",
                        "label": "Canonical",
-                       "name": "canonical",
-                       "titleProperty": "jcr:content/jcr:title"
+                       "name": "canonical"
                },
                "published": {
                        "jcr:primaryType": "nt:unstructured",
diff --git a/ui/src/main/frontend/gulpfile.js b/ui/src/main/frontend/gulpfile.js
index 89871e7..a530800 100755
--- a/ui/src/main/frontend/gulpfile.js
+++ b/ui/src/main/frontend/gulpfile.js
@@ -48,15 +48,18 @@ const apache2License = [
 
 gulp.task('styles', function() {
         return streamqueue ({objectMode: true},
-                        gulp.src('./src/scss/*.scss')
+                       gulp.src('./src/scss/*.scss')
                                .pipe(sass().on('error', sass.logError))
                                .pipe(concat('scss-files.scss'))
                            .pipe(sourcemaps.init())
                            .pipe(cleanCSS())
                            .pipe(header(apache2License)),
-                        
gulp.src('./node_modules/summernote/dist/summernote-lite.css')
+                       
gulp.src('./node_modules/summernote/dist/summernote-lite.css')
                            .pipe(cleanCSS()),
-                        gulp.src('node_modules/jam-icons/css/jam.min.css')
+                       gulp.src([
+                               './node_modules/jam-icons/css/jam.min.css',
+                               
'./node_modules/js-autocomplete/auto-complete.css'
+                       ])
                )
        .pipe(concat('styles.min.css'))
         .pipe(gulp.dest('./dist/jcr_root/static/clientlibs/sling-cms/css'))
@@ -69,6 +72,7 @@ gulp.task('js', function() {
                        './node_modules/jquery/dist/jquery.js',
                        './node_modules/handlebars/dist/handlebars.js',
                        './node_modules/summernote/dist/summernote-lite.js',
+                       './node_modules/js-autocomplete/auto-complete.js',
                        './src/js/scripts.js'
                        
                ])
diff --git a/ui/src/main/frontend/package.json 
b/ui/src/main/frontend/package.json
index ddcf92e..60dcb45 100644
--- a/ui/src/main/frontend/package.json
+++ b/ui/src/main/frontend/package.json
@@ -10,7 +10,8 @@
        "jquery": "^3.3.1",
        "handlebars": "^4.0.11",
        "summernote": "^0.8.9",
-       "jam-icons": "^2.0.0" 
+       "jam-icons": "^2.0.0",
+       "js-autocomplete": "^1.0.4" 
   },
   "devDependencies": {
     "gulp": "^3.9.1",
diff --git a/ui/src/main/frontend/src/js/scripts.js 
b/ui/src/main/frontend/src/js/scripts.js
index 600d466..d9db291 100644
--- a/ui/src/main/frontend/src/js/scripts.js
+++ b/ui/src/main/frontend/src/js/scripts.js
@@ -233,6 +233,9 @@ Sling.CMS = {
                                  // mouse button down over the element
                                element.addEventListener('mousedown', 
function(evt){
                                        console.log('mousedown');
+                                       
if(document.querySelector('.Modal-Body').contains(evt.target)){
+                                               return;
+                                       }
                                        mouseX = evt.clientX;
                                        mouseY = evt.clientY;
                                        mouseDown = true;
@@ -282,6 +285,22 @@ Sling.CMS = {
                        });
                }
        };
+       
+       Sling.CMS.ext['getform'] = {
+               decorate: function($ctx){
+                       $ctx.find('.Get-Form').submit(function(){
+                               var $form = $(this);
+                               var params = $form.serialize();
+                               
$form.find('.Form-Ajax__wrapper').attr('disabled', 'disabled');
+                               
+                               
$($form.data('target')).load($form.attr('action') + '?' + params +'  ' + 
$form.data('load'), function(){
+                                       
$form.find('.Form-Ajax__wrapper').removeAttr('disabled');
+                                       
Sling.CMS.decorate($($form.data('target')));
+                               });
+                               return false;
+                       });
+               }
+       };
 
        Sling.CMS.ext['includeconfig'] = {
                decorate: function($ctx){
@@ -336,6 +355,26 @@ Sling.CMS = {
                }
        };
 
+       Sling.CMS.ext['pathfield'] = {
+               decorate: function($ctx){
+                       $ctx.find('input.Field-Path').each(function(){
+                               var type = $(this).data('type');
+                               var xhr;
+                               new autoComplete({
+                                   selector: this,
+                                   source: function(term, response){
+                                       try {
+                                               xhr.abort();
+                                       } catch(e){}
+                                       xhr = $.getJSON('/bin/cms/paths', { 
path: term, type: type }, function(data){
+                                               response(data);
+                                       });
+                                   }
+                               });
+                       });
+               }
+       };
+
        Sling.CMS.ext['repeating'] = {
                decorate: function($ctx){
                        $ctx.find('.repeating').each(function(){
diff --git a/ui/src/main/frontend/src/scss/styles.scss 
b/ui/src/main/frontend/src/scss/styles.scss
index bcfa37f..e23a05e 100644
--- a/ui/src/main/frontend/src/scss/styles.scss
+++ b/ui/src/main/frontend/src/scss/styles.scss
@@ -31,6 +31,10 @@
        text-align: center;
 }
 
+.autocomplete-suggestion b {
+       color: #00678c;
+}
+
 ul.Breadcrumb  {
        margin-top: 2em;
        margin-bottom: .2em;
@@ -108,6 +112,10 @@ ul.Breadcrumb  {
     position: relative;
 }
 
+.Modal-Footer {
+       padding: 1em;
+}
+
 .Modal-Header {
        font-weight: bold;
        font-size: large;
@@ -159,6 +167,24 @@ ul.Breadcrumb  {
        float:right;
 }
 
+.Search-Result {
+    padding: .1em;
+}
+
+.Search-Result h4 {
+       margin-bottom: 0;
+}
+
+.Search-Result small {
+       font-size: x-small;
+}
+
+.Search-Result__Container {
+    border: 1px solid #ccc;
+    background-color: #f9f9f9;
+    padding: .5em;
+}
+
 table {
        table-layout: fixed;
        width: 100%;
diff --git 
a/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/getform/getform.jsp
 
b/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/getform/getform.jsp
new file mode 100644
index 0000000..1984464
--- /dev/null
+++ 
b/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/getform/getform.jsp
@@ -0,0 +1,39 @@
+<%-- /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */ --%>
+ <%@include file="/libs/sling-cms/global.jsp"%>
+<c:set var="page" 
value="${sling:adaptTo(resource,'org.apache.sling.cms.core.models.PageManager').page}"
 />
+<c:choose>
+       <c:when test="${not empty properties.action}">
+               <c:set var="action" value="${properties.action}" />
+       </c:when>
+       <c:otherwise>
+               <c:set var="action" value="${page.path}.html" />
+       </c:otherwise>
+</c:choose>
+<form method="get" action="${action}" class="Get-Form" 
data-target="${properties.target}" data-load="${properties.load}">
+       <fieldset class="Form-Ajax__wrapper">
+               <input type="hidden" name="_charset_" value="utf-8" />
+               <sling:include path="fields" 
resourceType="sling-cms/components/general/container" />
+               <div class="Field-Group">
+                       <button type="submit" class="btn btn-success" 
title="<sling:encode value="${properties.button}" mode="HTML_ATTR" />">
+                               <sling:encode value="${properties.button}" 
mode="HTML" />
+                       </button>
+               </div>
+       </fieldset>
+</form>
\ No newline at end of file
diff --git 
a/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/searchresults/searchresults.jsp
 
b/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/searchresults/searchresults.jsp
new file mode 100644
index 0000000..a99c4db
--- /dev/null
+++ 
b/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/searchresults/searchresults.jsp
@@ -0,0 +1,64 @@
+<%-- /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */ --%>
+ <%@include file="/libs/sling-cms/global.jsp"%>
+<div id="search-results">
+       <div class="Grid">
+       <sling:adaptTo adaptable="${slingRequest}" 
adaptTo="org.apache.sling.cms.core.models.SearchResults" var="results" />
+               <c:forEach var="result" items="${results.results}" begin="0" 
end="100" varStatus="status">
+                       <div class="Cell Search-Result Small-50">
+                               <div class="Search-Result__Container">
+                                       <c:choose>
+                                               <c:when test="${not empty 
result.valueMap['jcr:content/jcr:title']}">
+                                                       <c:set var="title" 
value="${result.valueMap['jcr:content/jcr:title']}" />
+                                               </c:when>
+                                               <c:when test="${not empty 
result.valueMap['jcr:title']}">
+                                                       <c:set var="title" 
value="${result.valueMap['jcr:title']}" />
+                                               </c:when>
+                                               <c:otherwise>
+                                                       <c:set var="title" 
value="${result.name}" />
+                                               </c:otherwise>
+                                       </c:choose>
+                                       <c:choose>
+                                               <c:when 
test="${result.valueMap['jcr:primaryType'] == 'sling:Page'}">
+                                                       <c:set var="icon" 
value="document" />
+                                               </c:when>
+                                               <c:when 
test="${result.valueMap['jcr:primaryType'] == 'nt:file' || 
result.valueMap['jcr:primaryType'] == 'sling:File'}">
+                                                       <c:set var="icon" 
value="file" />
+                                               </c:when>
+                                               <c:when 
test="${result.valueMap['jcr:primaryType'] == 'nt:folder' || 
result.valueMap['jcr:primaryType'] == 'sling:Folder' || 
result.valueMap['jcr:primaryType'] == 'sling:OrderedFolder'}">
+                                                       <c:set var="icon" 
value="folder" />
+                                               </c:when>
+                                               <c:otherwise>
+                                                       <c:set var="icon" 
value="sitemap" />
+                                               </c:otherwise>
+                                       </c:choose>
+                                       <h4>
+                                               <span class="jam 
jam-${icon}"></span>
+                                               ${sling:encode(title,'HTML')}
+                                       </h4>
+                                       <small>
+                                               <em>${result.path}</em>
+                                       </small><br/>
+                                       <br />
+                                       <a href="#" class="Button 
Select-Button" data-path="${result.path}">Select</a>
+                               </div>
+                       </div>
+               </c:forEach>
+       </div>
+</div>
\ No newline at end of file
diff --git 
a/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/path/field.jsp
 
b/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/path/field.jsp
index 086b8f7..e6e8b70 100644
--- 
a/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/path/field.jsp
+++ 
b/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/path/field.jsp
@@ -17,10 +17,4 @@
  * under the License.
  */ --%>
  <%@include file="/libs/sling-cms/global.jsp"%>
-<input type="text" name="${properties.name}" 
value="${editProperties[properties.name]}" ${required} ${disabled} 
list="paths-${resource.name}" autocomplete="off" />
-<datalist id="paths-${resource.name}">
-       <c:set var="query" value="SELECT * FROM [${properties.type != null ? 
properties.type : 'nt:hierarchyNode'}] WHERE 
ISDESCENDANTNODE([${properties.basePath != null ? properties.basePath : 
'/content'}]) ${properties.additionalParams}" />
-       <c:forEach var="resource" 
items="${sling:findResources(resourceResolver,query,'JCR-SQL2')}">
-               <option 
value="${resource.path}">${resource.valueMap[properties.titleProperty]}</option>
-       </c:forEach>
-</datalist>
\ No newline at end of file
+<input class="Field-Path" type="text" name="${properties.name}" 
value="${editProperties[properties.name]}" ${required} ${disabled} 
data-type="${type}" autocomplete="off" />
\ No newline at end of file
diff --git 
a/ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/movecopy.json 
b/ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/movecopy.json
index e685e1b..ce2bd3d 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/movecopy.json
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/movecopy.json
@@ -26,7 +26,7 @@
                                        },
                                        "destination": {
                                                "jcr:primaryType": 
"nt:unstructured",
-                                               "sling:resourceType" : 
"sling-cms/components/editor/fields/text",
+                                               "sling:resourceType" : 
"sling-cms/components/editor/fields/path",
                                                "label": "Destination:",
                                                "name": ":dest"
                                        },
diff --git 
a/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/editgroup.json 
b/ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/search.json
similarity index 50%
copy from 
ui/src/main/resources/jcr_root/libs/sling-cms/content/site/editgroup.json
copy to ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/search.json
index b808723..e5dce60 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/editgroup.json
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/search.json
@@ -2,7 +2,7 @@
        "jcr:primaryType": "sling:Page",
        "jcr:content": {
                "sling:resourceType": "sling-cms/components/pages/base",
-               "jcr:title": "Edit Site Group",
+               "jcr:title": "Search",
                "jcr:primaryType": "nt:unstructured",
                "container": {
                        "jcr:primaryType": "nt:unstructured",
@@ -10,35 +10,47 @@
                        "richtext": {
                                "jcr:primaryType": "nt:unstructured",
                                "sling:resourceType": 
"sling-cms/components/general/richtext",
-                               "text": "<h3>Edit Site Group</h3>"
+                               "text": "<h3>Search</h3>"
                        },
-                       "slingform": {
+                       "searchform": {
                                "jcr:primaryType": "nt:unstructured",
-                               "sling:resourceType": 
"sling-cms/components/editor/slingform",
-                               "actionSuffix": "/*",
-                               "button": "Create Folder",
-                               
"successPrepend":"/libs/sling-cms/content/site/content.html",
+                               "sling:resourceType": 
"sling-cms/components/cms/getform",
+                               "button": "Search",
+                               "load": "#search-results",
+                               "target": "#search-results",
                                "fields": {
                                        "jcr:primaryType": "nt:unstructured",
                                        "sling:resourceType": 
"sling-cms/components/general/container",
-                                       "title": {
+                                       "term": {
                                                "jcr:primaryType": 
"nt:unstructured",
                                                "sling:resourceType": 
"sling-cms/components/editor/fields/text",
-                                               "label": "Title",
-                                               "name": "jcr:content/jcr:title",
-                                               "required": true
+                                               "label": "Term",
+                                               "name": "term",
+                                               "required": "required"
                                        },
-                                       "config": {
+                                       "type": {
+                                               "jcr:primaryType": 
"nt:unstructured",
+                                               "sling:resourceType": 
"sling-cms/components/editor/fields/select",
+                                               "name": "type",
+                                               "label": "Content Type",
+                                               "options": [
+                                                       "Page=sling:Page",
+                                                       "File=sling:File",
+                                                       "Folder=sling:Folder",
+                                                       "Everything=nt:base"
+                                               ]
+                                       },
+                                       "path": {
                                                "jcr:primaryType": 
"nt:unstructured",
                                                "sling:resourceType": 
"sling-cms/components/editor/fields/path",
-                                               "basePath": "/conf",
-                                               "label": "Config",
-                                               "name": "sling:configRef",
-                                               "required": false,
-                                               "titleProperty": 
"jcr:content/jcr:title",
-                                               "type": "sling:OrderedFolder"
+                                               "label": "Path",
+                                               "name": "path"
                                        }
                                }
+                       },
+                       "searchresults": {
+                               "jcr:primaryType": "nt:unstructured",
+                               "sling:resourceType": 
"sling-cms/components/cms/searchresults"
                        }
                }
        }
diff --git 
a/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/create.json 
b/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/create.json
index fcaeb9c..70d7647 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/create.json
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/create.json
@@ -61,9 +61,7 @@
                                                "basePath": "/conf",
                                                "label": "Config",
                                                "name": "sling:configRef",
-                                               "required": false,
-                                               "titleProperty": 
"jcr:content/jcr:title",
-                                               "type": "sling:OrderedFolder"
+                                               "required": false
                                        },
                                        "primaryType": {
                                                "jcr:primaryType": 
"nt:unstructured",
diff --git 
a/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/creategroup.json 
b/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/creategroup.json
index 0e86e66..05351c4 100644
--- 
a/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/creategroup.json
+++ 
b/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/creategroup.json
@@ -46,9 +46,7 @@
                                                "basePath": "/conf",
                                                "label": "Config",
                                                "name": "sling:configRef",
-                                               "required": false,
-                                               "titleProperty": 
"jcr:content/jcr:title",
-                                               "type": "sling:OrderedFolder"
+                                               "required": false
                                        },
                                        "primaryType": {
                                                "jcr:primaryType": 
"nt:unstructured",
diff --git 
a/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/edit.json 
b/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/edit.json
index 7b6eeef..3b95969 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/edit.json
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/edit.json
@@ -54,9 +54,7 @@
                                                "basePath": "/conf",
                                                "label": "Config",
                                                "name": "sling:configRef",
-                                               "required": false,
-                                               "titleProperty": 
"jcr:content/jcr:title",
-                                               "type": "sling:OrderedFolder"
+                                               "required": false
                                        }
                                }
                        }
diff --git 
a/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/editgroup.json 
b/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/editgroup.json
index b808723..405bcb0 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/editgroup.json
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/editgroup.json
@@ -34,9 +34,7 @@
                                                "basePath": "/conf",
                                                "label": "Config",
                                                "name": "sling:configRef",
-                                               "required": false,
-                                               "titleProperty": 
"jcr:content/jcr:title",
-                                               "type": "sling:OrderedFolder"
+                                               "required": false
                                        }
                                }
                        }

Reply via email to