You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2018/01/31 04:24:29 UTC
[sling-whiteboard] branch master updated: Improved the path and
added a taxonomy field type
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-whiteboard.git
The following commit(s) were added to refs/heads/master by this push:
new b7449bb Improved the path and added a taxonomy field type
b7449bb is described below
commit b7449bb24b351bd170c56cfdc4727c23705cfa2d
Author: Dan Klco <da...@gmail.com>
AuthorDate: Tue Jan 30 23:24:21 2018 -0500
Improved the path and added a taxonomy field type
---
.../apps/reference/components/pages/base/edit.json | 11 ++++-
.../etc/clientlibs/sling-cms/css/styles.css | 4 ++
.../etc/clientlibs/sling-cms/js/scripts.js | 47 +++++++++++++++++---
.../components/editor/fields/path/field.jsp | 4 +-
.../components/editor/fields/taxonomy.json | 4 ++
.../components/editor/fields/taxonomy/field.jsp | 50 ++++++++++++++++++++++
.../libs/sling-cms/content/site/create.json | 3 +-
7 files changed, 113 insertions(+), 10 deletions(-)
diff --git a/cms/ui/src/main/resources/jcr_root/apps/reference/components/pages/base/edit.json b/cms/ui/src/main/resources/jcr_root/apps/reference/components/pages/base/edit.json
index a3da6fb..4e0c678 100644
--- a/cms/ui/src/main/resources/jcr_root/apps/reference/components/pages/base/edit.json
+++ b/cms/ui/src/main/resources/jcr_root/apps/reference/components/pages/base/edit.json
@@ -20,10 +20,19 @@
},
"keywords": {
"jcr:primaryType": "nt:unstructured",
- "sling:resourceType": "sling-cms/components/editor/fields/repeating",
+ "sling:resourceType": "sling-cms/components/editor/fields/taxonomy",
"label": "Keywords",
"name": "keywords"
},
+ "canonical": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/editor/fields/path",
+ "basePath": "/content",
+ "type": "sling:Page",
+ "label": "Canonical",
+ "name": "canonical",
+ "titleProperty": "jcr:content/jcr:title"
+ },
"published": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "sling-cms/components/editor/fields/select",
diff --git a/cms/ui/src/main/resources/jcr_root/etc/clientlibs/sling-cms/css/styles.css b/cms/ui/src/main/resources/jcr_root/etc/clientlibs/sling-cms/css/styles.css
index 7be7622..de61a7d 100644
--- a/cms/ui/src/main/resources/jcr_root/etc/clientlibs/sling-cms/css/styles.css
+++ b/cms/ui/src/main/resources/jcr_root/etc/clientlibs/sling-cms/css/styles.css
@@ -62,6 +62,10 @@ ul.Breadcrumb {
display:none;
}
+input, textarea, select {
+ width: 100%;
+}
+
input[type="checkbox"] {
border: 0;
box-shadow: none;
diff --git a/cms/ui/src/main/resources/jcr_root/etc/clientlibs/sling-cms/js/scripts.js b/cms/ui/src/main/resources/jcr_root/etc/clientlibs/sling-cms/js/scripts.js
index 718c63c..69fb133 100644
--- a/cms/ui/src/main/resources/jcr_root/etc/clientlibs/sling-cms/js/scripts.js
+++ b/cms/ui/src/main/resources/jcr_root/etc/clientlibs/sling-cms/js/scripts.js
@@ -216,21 +216,21 @@ Sling.CMS = {
decorate: function($ctx){
$ctx.find('.repeating').each(function(){
var $rep = $(this);
- $rep.find('.repeating__remove').click(function(){
- var $rem = $(this);
- $rem.parents('.repeating__item').remove();
- return false;
- });
$rep.find('.repeating__add').click(function(){
var $div = $('<div/>').html($rep.find('.repeating__template').html());
Sling.CMS.decorate($div);
$('.repeating__container').append($div);
return false;
});
-
+ });
+ $ctx.find('.repeating__remove').click(function(){
+ var $rem = $(this);
+ $rem.parents('.repeating__item').remove();
+ return false;
});
}
};
+
Sling.CMS.ext['richtext'] = {
decorate: function($ctx){
$ctx.find('.richtext').summernote({
@@ -245,6 +245,41 @@ Sling.CMS = {
});
}
}
+
+ Sling.CMS.ext['taxonomy'] = {
+ decorate: function($ctx){
+ $ctx.find('.taxonomy').each(function(){
+ var $rep = $(this);
+ $rep.find('.taxonomy__add').click(function(){
+ var $span = $('<span/>').html($rep.find('.taxonomy__template').html());
+ var val = $ctx.find('.taxonomy__field input').val();
+ var found = false;
+ $rep.find('.taxonomy__item input').each(function(idx, el){
+ if($(el).val() === val){
+ found = true;
+ }
+ });
+ if(found){
+ return false;
+ }
+ $span.find('input').val(val);
+ var title = $ctx.find('option[value="'+val+'"]').text();
+
+
+ if(title !== ''){
+ $span.find('.taxonomy__title').text(title);
+ Sling.CMS.decorate($span);
+ $('.taxonomy__container').append($span);
+ }
+ return false;
+ });
+ });
+ $ctx.find('.taxonomy__item').click(function(){
+ $(this).remove();
+ return false;
+ });
+ }
+ };
Sling.CMS.ext['toggle-hidden'] = {
decorate: function($ctx){
diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/path/field.jsp b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/path/field.jsp
index 71f0dde..40e8ab9 100644
--- a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/path/field.jsp
+++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/path/field.jsp
@@ -17,10 +17,10 @@
* 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}" />
+<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}] WHERE ISDESCENDANTNODE([${properties.basePath}])" />
<c:forEach var="resource" items="${sling:findResources(resourceResolver,query,'JCR-SQL2')}">
- <option>${resource.path}</option>
+ <option value="${resource.path}">${resource.valueMap[properties.titleProperty]}</option>
</c:forEach>
</datalist>
\ No newline at end of file
diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/taxonomy.json b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/taxonomy.json
new file mode 100644
index 0000000..b061241
--- /dev/null
+++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/taxonomy.json
@@ -0,0 +1,4 @@
+{
+ "jcr:primaryType": "sling:Component",
+ "sling:resourceSuperType" : "sling-cms/components/editor/fields/base"
+}
\ No newline at end of file
diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/taxonomy/field.jsp b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/taxonomy/field.jsp
new file mode 100644
index 0000000..5dff69f
--- /dev/null
+++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/fields/taxonomy/field.jsp
@@ -0,0 +1,50 @@
+<%-- /*
+ * 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 class="taxonomy">
+ <fieldset disabled="disabled" class="taxonomy__template Hide">
+ <a class="button taxonomy__item">
+ <input type="hidden" name="${properties.name}" value="" />
+ <span class="taxonomy__title"></span>
+ </a>
+ </fieldset>
+ <div class="taxonomy__field Grid">
+ <div class="Cell Mobile-80">
+ <input type="text" ${required} ${disabled} list="tags-${properties.name}" autocomplete="off" />
+ </div>
+ <div class="Cell Mobile-20">
+ <button class="taxonomy__add">+</button>
+ </div>
+ </div>
+ <div class="taxonomy__container">
+ <c:forEach var="item" items="${editProperties[properties.name]}">
+ <a class="button taxonomy__item">
+ <input type="hidden" name="${properties.name}" value="${item}" />
+ <span class="taxonomy__title">${sling:encode(sling:getResource(resourceResolver,item).valueMap['jcr:title'],'HTML')}</span>
+ </a>
+ </c:forEach>
+ </div>
+</div>
+<datalist id="tags-${resource.name}">
+ <c:set var="query" value="SELECT * FROM [sling:Taxonomy] WHERE ISDESCENDANTNODE([${not empty properties.basePath ? properties.basePath : '/etc/taxonomy'}])" />
+ ${query}
+ <c:forEach var="taxonomy" items="${sling:findResources(resourceResolver,query,'JCR-SQL2')}">
+ <option value="${taxonomy.path}">${taxonomy.valueMap['jcr:title']}</option>
+ </c:forEach>
+</datalist>
\ No newline at end of file
diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/create.json b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/create.json
index db07bd3..67f6cf1 100644
--- a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/create.json
+++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/create.json
@@ -41,7 +41,8 @@
"basePath": "/etc/config",
"type": "sling:Config",
"label": "Site Config",
- "name": "sling:config"
+ "name": "sling:config",
+ "titleProperty": "jcr:title"
},
"primaryType": {
"jcr:primaryType": "nt:unstructured",
--
To stop receiving notification emails like this one, please contact
dklco@apache.org.