Author: sboehme
Date: Sat Nov 5 23:32:32 2016
New Revision: 1768284
URL: http://svn.apache.org/viewvc?rev=1768284&view=rev
Log:
SLING-6248 Resource Editor :: Create a simple Resource Type Editor
Added:
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/scriptpathchooser/
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/scriptpathchooser/scriptfilechooser.js
Modified:
sling/trunk/contrib/explorers/resourceeditor/src/main/less/reseditor.less
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/MainController.js
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/JSTreeAdapter.js
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/TreeController.js
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/html.jsp
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/node-content.jsp
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/rootnodes.json.jsp
Modified:
sling/trunk/contrib/explorers/resourceeditor/src/main/less/reseditor.less
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/resourceeditor/src/main/less/reseditor.less?rev=1768284&r1=1768283&r2=1768284&view=diff
==============================================================================
--- sling/trunk/contrib/explorers/resourceeditor/src/main/less/reseditor.less
(original)
+++ sling/trunk/contrib/explorers/resourceeditor/src/main/less/reseditor.less
Sat Nov 5 23:32:32 2016
@@ -160,7 +160,7 @@ body
width: 200px;
}
-#tree
+.tree-and-props
{
overflow: auto;
height: 100%;
@@ -204,14 +204,14 @@ body
clear: both
}
-#tree a, #tree :visited, #tree :link {
+.tree-and-props a, .tree-and-props :visited, .tree-and-props :link {
border:1px solid transparent;
padding:0px 1px;
font-family: arial, helvetica, sans-serif, times;
color: @textColor
}
-#tree .jstree-hovered, #tree .jstree-hovered.jstree-clicked {
+.tree-and-props .jstree-hovered, .tree-and-props
.jstree-hovered.jstree-clicked{
.plate-selected-text-shadow;
color: #FFF;
background: transparent;
@@ -291,8 +291,9 @@ body
box-shadow: none;
}
-#tree .jstree-clicked
+.tree-and-props .jstree-clicked, #page-script-chooser-row .files>tr:hover
{
+ .rounded;
background: @selectedBackground;
border:1px solid black;
padding:0px 1px;
@@ -373,4 +374,14 @@ input.jstree-rename-input{
#properties-info-icon {
margin-top: 5px;
+}
+
+#page-script-chooser-row {
+ .rounded;
+ border: 1px solid @textColor;
+ margin: 10px;
+}
+
+#page-script-chooser-row .table > tbody > tr > td {
+ border-top: 0;
}
\ No newline at end of file
Modified:
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/MainController.js
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/MainController.js?rev=1768284&r1=1768283&r2=1768284&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/MainController.js
(original)
+++
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/MainController.js
Sat Nov 5 23:32:32 2016
@@ -157,13 +157,13 @@ org.apache.sling.reseditor.MainControlle
var alert_height = $("#alerts").outerHeight(true);
var content_tab_height = $("#content-tabs").outerHeight(true);
var footer_height = $("#footer").outerHeight(true);
- var sidebar_margin =
$("#sidebar").outerHeight(true)-$("#sidebar").outerHeight(false);
+ var tree_margin =
$("#tree").outerHeight(true)-$("#tree").outerHeight(false);
var mainrow_margin =
$("#main-row").outerHeight(true)-$("#main-row").outerHeight(false);
- var usable_height = $(window).height() - login_height -
header_height - alert_height - sidebar_margin - mainrow_margin - 15;
+ var usable_height = $(window).height() - login_height -
header_height - alert_height - tree_margin - mainrow_margin - 15;
// activate again if the footer is needed
-// var usable_height = $(window).height() - header_height -
footer_height - sidebar_margin - 1;
- $("#sidebar").height( usable_height );
+// var usable_height = $(window).height() - header_height -
footer_height - tree_margin - 1;
+ $("#tree").height( usable_height );
$("#outer_content").height( usable_height-content_tab_height );
}
Added:
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/scriptpathchooser/scriptfilechooser.js
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/scriptpathchooser/scriptfilechooser.js?rev=1768284&view=auto
==============================================================================
---
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/scriptpathchooser/scriptfilechooser.js
(added)
+++
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/scriptpathchooser/scriptfilechooser.js
Sat Nov 5 23:32:32 2016
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+/*
+ * Represents the functionality for the file chooser within the script path
chooser.
+ */
+
+// creating the namespace
+var org = org || {};
+org.apache = org.apache || {};
+org.apache.sling = org.apache.sling || {};
+org.apache.sling.sitebuilder = org.apache.sling.sitebuilder || {};
+
+//defining the module
+org.apache.sling.sitebuilder.Scriptfilechooser = (function() {
+
+ function Scriptfilechooser(){
+ this.selectedScriptResourcePath = "";
+ var thisScriptfilechooser = this;
+ $('#page-script-chooser-row .files').on("click", "td",
function(e) {
+ thisScriptfilechooser.selectedPageScriptPath =
$(this).text();
+ var selectedPageScriptFilePath =
thisScriptfilechooser.selectedScriptResourcePath+"/"+$(this).text()
+ $('#selected-script-path-row
input[name="selectedScriptFilePath"]').val(selectedPageScriptFilePath);
+ $('#selected-script-path-row
input[name="resourceSuperType"]').val(thisScriptfilechooser.selectedScriptResourcePath);
+ });
+ }
+ Scriptfilechooser.prototype.setSelectedScriptResourcePath =
function(selectedScriptResourcePath) {
+ this.selectedScriptResourcePath = selectedScriptResourcePath;
+ }
+
+ return Scriptfilechooser;
+}());
\ No newline at end of file
Modified:
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/JSTreeAdapter.js
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/JSTreeAdapter.js?rev=1768284&r1=1768283&r2=1768284&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/JSTreeAdapter.js
(original)
+++
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/JSTreeAdapter.js
Sat Nov 5 23:32:32 2016
@@ -52,30 +52,34 @@ $(document).ready(function() {
// TO CREATE AN INSTANCE
// select the tree container using jQuery
- $("#tree")
+ $(thisJSTreeAdapter.treeController.settings.treeAndPropsSelector)
.bind("loaded.jstree", function (event, data) {
- var pathElements =
treeController.getPathElements(settings.resourcePath);
-
- if (pathElements.length >= 1 && pathElements[0] != "") {
- treeController.openElement($("#tree > ul >
li[nodename=''] > ul"), pathElements);
+ if (thisJSTreeAdapter.treeController.settings.rootPath == null)
{
+ var pathElements =
treeController.getPathElements(settings.resourcePath);
+ if (pathElements.length >= 1 && pathElements[0] != "") {
+
treeController.openElement($(thisJSTreeAdapter.treeController.settings.treeAndPropsSelector+"
> ul > li[nodename=''] > ul"), pathElements);
+ }
}
// position the info-icon
- $('#tree-info-icon').show();
- $('#root i:first').before($('#tree-info-icon'));
+ if (thisJSTreeAdapter.treeController.settings.treeSelector !=
null) {
+
$(thisJSTreeAdapter.treeController.settings.treeRootElementSelector+'
i:first').before($('.tree-info-icon:last').clone().show());
+ thisJSTreeAdapter.treeController.initTreeEvents();
+ }
})
// call `.jstree` with the options object
.jstree({
"core" : {
"check_callback" : true,
- multiple: true,
+ multiple:
thisJSTreeAdapter.treeController.settings.multipleSelection == null ? true :
thisJSTreeAdapter.treeController.settings.multipleSelection,
animation: 600,
'dblclick_toggle': false,
'data' : {
'url' : function (liJson) {
// initial call for the root element
if (liJson.id === '#'){
- return
settings.contextPath+"/reseditor/.rootnodes.json";
+ var rootPath =
thisJSTreeAdapter.treeController.settings.rootPath == null ? "/" :
thisJSTreeAdapter.treeController.settings.rootPath;
+ return
settings.contextPath+"/reseditor"+rootPath+".rootnodes.json";
} else {
// the li the user clicked on.
var li = $('#'+liJson.id);
@@ -159,12 +163,17 @@ $(document).ready(function() {
}).on('keydown.jstree', 'a.jstree-anchor', function (e) {
treeController.configureKeyListeners(e);
}).on('select_node.jstree', function (e, data) {
- //noop
- ;
+ if (thisJSTreeAdapter.treeController.settings.selectCallback != null) {
+ thisJSTreeAdapter.treeController.settings.selectCallback(e,
data);
+ }
}).on('after_open.jstree', function(e, data){
treeController.afterOpen(data.node);
}).on('close_node.jstree', function(e, data){
treeController.beforeClose(data.node);
+ }).on('ready.jstree', function(e, data){
+ if (thisJSTreeAdapter.treeController.settings.readyCallback != null) {
+ thisJSTreeAdapter.treeController.settings.readyCallback(e,
data);
+ }
});
});
Modified:
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/TreeController.js
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/TreeController.js?rev=1768284&r1=1768283&r2=1768284&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/TreeController.js
(original)
+++
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/TreeController.js
Sat Nov 5 23:32:32 2016
@@ -40,32 +40,38 @@ org.apache.sling.reseditor.TreeControlle
var addNodeControllerSettings = {};
this.addNodeController = new
org.apache.sling.reseditor.AddNodeController(addNodeControllerSettings,
mainController);
- $(document).ready(function() {
- $("#tree").on("click", "#root",function(e) {
- var target = $(e.target);
- if (target.hasClass("open-icon")){
- thatTreeController.openNodeTarget(e);
- } else if (target.hasClass("add-icon")){
-
thatTreeController.openAddNodeDialog(target.parents("li"));
- }else if (target.hasClass("remove-icon")){
-
thatTreeController.deleteSingleNode(target.parents("li"));
- }
- });
- $("#tree").on("dblclick", "#root",function(e) {
- var target = $(e.target);
- if (target.hasClass("jstree-anchor") ||
target.hasClass("node-type")){
- var id =
target.parents("li:first").attr("id");
-
thatTreeController.openRenameNodeDialog(id);
- }
- });
- $("#tree-info-icon").on("click", function(e, data) {
- $('#sidebar
.info-content-container').slideToggle();
+ };
+
+ TreeController.prototype.initTreeEvents = function(root, paths) {
+ var thatTreeController = this;
+ $(thatTreeController.settings.treeAndPropsSelector).on("click",
function(e) {
+ var target = $(e.target);
+ if (target.hasClass("open-icon")){
+ thatTreeController.openNodeTarget(e);
+ } else if (target.hasClass("add-icon")){
+
thatTreeController.openAddNodeDialog(target.parents("li"));
+ }else if (target.hasClass("remove-icon")){
+
thatTreeController.deleteSingleNode(target.parents("li"));
+ }
+ });
+
$(thatTreeController.settings.treeAndPropsSelector).on("dblclick",
thatTreeController.settings.treeRootElementSelector,function(e) {
+ var target = $(e.target);
+ if (target.hasClass("jstree-anchor") ||
target.hasClass("node-type")){
+ var id = target.parents("li:first").attr("id");
+ thatTreeController.openRenameNodeDialog(id);
+ }
+ });
+ if (thatTreeController.settings.treeSelector != null) {
+ $(thatTreeController.settings.treeSelector+"
.tree-info-icon").on("click", function(e, data) {
+
console.log($(thatTreeController.settings.treeSelector+'
.info-content-container').parentsUntil("body"));
+ $(thatTreeController.settings.treeSelector+'
.info-content-container').slideToggle();
});
- $("#sidebar .info-content-container
.close").on("click", function(e, data) {
- $('#sidebar
.info-content-container').slideToggle();
+ $(thatTreeController.settings.treeSelector+"
.info-content-container .close").on("click", function(e, data) {
+
console.log($(thatTreeController.settings.treeSelector+'
.info-content-container').parentsUntil("body"));
+ $(thatTreeController.settings.treeSelector+'
.info-content-container').slideToggle();
});
- });
- };
+ }
+ }
TreeController.prototype.configureKeyListeners = function(e) {
// see http://www.javascripter.net/faq/keycodes.htm
@@ -129,7 +135,7 @@ org.apache.sling.reseditor.TreeControlle
TreeController.prototype.openRenameNodeDialog = function(id) {
var liElement = $('#'+id);
- $("#tree").jstree("edit", $('#'+id),
this.mainController.decodeFromHTML(liElement.attr("nodename")));
+ $(this.settings.treeAndPropsSelector).jstree("edit", $('#'+id),
this.mainController.decodeFromHTML(liElement.attr("nodename")));
}
TreeController.prototype.renameNode = function(e, data) {
@@ -176,7 +182,7 @@ org.apache.sling.reseditor.TreeControlle
}
TreeController.prototype.getPathFromLi = function(li){
- var path = $(li).parentsUntil(".root").andSelf().map(
+ var path =
$(li).parentsUntil(this.settings.treeAndPropsSelector).andSelf().map(
function() {
return this.tagName == "LI"
?
$(this).attr("nodename")
@@ -199,12 +205,12 @@ org.apache.sling.reseditor.TreeControlle
if (pathElementLi.length === 0){
alert("Couldn't find "+pathElementName+" under the path
"+this.getPathFromLi(root.parent()));
} else {
- $('#tree').jstree('open_node', pathElementLi,
+
$(this.settings.treeAndPropsSelector).jstree('open_node', pathElementLi,
function(){
if (paths.length>0){
thisTreeController.openElement($("#"+pathElementLi.attr('id')).children("ul"),
paths);
} else {
-
$('#tree').jstree('select_node', pathElementLi.attr('id'), 'true');
+
$(thisTreeController.settings.treeAndPropsSelector).jstree('select_node',
pathElementLi.attr('id'), 'true');
var target =
$('#'+pathElementLi.attr('id')+' a:first');
target.focus();
}
@@ -217,13 +223,14 @@ org.apache.sling.reseditor.TreeControlle
var path = this.getPathFromLi(li);
path = this.mainController.decodeFromHTML(path);
path = this.mainController.encodeURL(path);
- return this.settings.contextPath+"/reseditor"+path+extension;
+ var rootPath = this.settings.rootPath == null ? "" :
this.settings.rootPath ;
+ return
this.settings.contextPath+"/reseditor"+rootPath+path+extension;
}
TreeController.prototype.deleteNodes = function() {
var thatTreeController = this;
var lastDeletedLI;
- var selectedIds = $("#tree").jstree('get_selected');
+ var selectedIds =
$(this.settings.treeAndPropsSelector).jstree('get_selected');
var firstId = selectedIds[0];
var parentLi = $('#'+firstId).parents('li');
var parentPath = this.getURLEncodedPathFromLi(parentLi);
@@ -245,7 +252,7 @@ org.apache.sling.reseditor.TreeControlle
type: 'POST',
url: parentPath,
success: function(server_data) {
- var tree =
$('#tree').jstree(true);
+ var tree =
$(thatTreeController.settings.treeAndPropsSelector).jstree(true);
for (var i=0;
i<selectedIds.length; i++){
var id =
selectedIds[i];
tree.delete_node(id);
@@ -280,7 +287,7 @@ org.apache.sling.reseditor.TreeControlle
url: encodedResourcePathToDelete,
success: function(server_data) {
var id = li.attr("id");
- var tree =
$('#tree').jstree(true);
+ var tree =
$(thatTreeController.settings.treeAndPropsSelector).jstree(true);
tree.delete_node(id);
},
error: function(errorJson) {
Modified:
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/html.jsp
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/html.jsp?rev=1768284&r1=1768283&r2=1768284&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/html.jsp
(original)
+++
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/html.jsp
Sat Nov 5 23:32:32 2016
@@ -64,6 +64,9 @@ original
<script type="text/javascript" src="<%= request.getContextPath()
%>/libs/sling/resource-editor-static-content/js/LoginController.js"></script>
<script type="text/javascript" src="<%= request.getContextPath()
%>/libs/sling/resource-editor-static-content/js/MainController.js"></script>
+
+<script type="text/javascript" src="<%= request.getContextPath()
%>/libs/sling/resource-editor-static-content/js/scriptpathchooser/scriptfilechooser.js"></script>
+
<!--
<script type="text/javascript" src="<%= request.getContextPath()
%>/libs/sling/resource-editor-static-content/generated/3rd_party/js/jquery.scrollTo-min.js"></script>
<script type="text/javascript" src="<%= request.getContextPath()
%>/libs/sling/resource-editor-static-content/generated/3rd_party/js/urlEncode.js"></script>
@@ -99,7 +102,10 @@ var mainControllerSettings = {
var mainController = new
org.apache.sling.reseditor.MainController(mainControllerSettings, ntManager);
var treeControllerSettings = {
- contextPath: "<%= request.getContextPath() %>"
+ contextPath: "<%= request.getContextPath() %>",
+ treeAndPropsSelector: "#tree-and-props",
+ treeSelector: "#tree",
+ treeRootElementSelector: "#tree-and-props .root-element"
};
var treeController = new
org.apache.sling.reseditor.TreeController(treeControllerSettings,
mainController);
@@ -193,7 +199,7 @@ new org.apache.sling.reseditor.PropertyC
</div>
<div id="main-row" class="row">
<div id="sidebar-col" class="col-sm-4">
- <div id="sidebar" class="plate">
+ <div id="tree" class="plate">
<div class="ie9filter-plate-div">
<div style="display:none;"
class="info-content-container" >
<div class="well
well-sm info-content">
@@ -212,7 +218,7 @@ new org.apache.sling.reseditor.PropertyC
</ul>
</div>
</div>
- <div id="tree" class="root"
></div>
+ <div id="tree-and-props"
class="root tree-and-props" ></div>
</div>
</div>
</div>
@@ -226,7 +232,7 @@ new org.apache.sling.reseditor.PropertyC
</div>
</div>
</div>
- <span id="tree-info-icon" class="info-icon info-icon-lightgray
pull-right clearfix" style="display:none;"></span>
+ <span class="tree-info-icon info-icon info-icon-lightgray pull-right
clearfix" style="display:none;"></span>
<!-- Add node dialog -->
<div class="modal fade" id="addNodeDialog" tabindex="-1" role="dialog"
aria-labelledby="addNodeDialogLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
Modified:
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/node-content.jsp
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/node-content.jsp?rev=1768284&r1=1768283&r2=1768284&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/node-content.jsp
(original)
+++
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/node-content.jsp
Sat Nov 5 23:32:32 2016
@@ -8,21 +8,145 @@
<sling:defineObjects />
<div id="node-content" class="col-sm-8">
<c:set var="scriptResource" scope="request"
value="${sling:getResource(resourceResolver,sling:getResource(resourceResolver,resource.path).resourceType)}"/>
- <% Resource theResource = (Resource)
request.getAttribute("scriptResource");%>
- <c:set var="isWebPage" value="<%=theResource !=
null ? theResource.isResourceType("sling/web-page") : false %>"/>
+ <%
+ Resource scriptResourceReqAttr = (Resource)
request.getAttribute("scriptResource");
+ boolean hasScriptResource =
scriptResourceReqAttr != null;
+ %>
+ <%--
+ Has to inherit from
sling/resource-editor/node-content and has to have a "name" string property
+ When should it be displayed as active?
+ --%>
+ <c:set var="isWebPage"
value="<%=hasScriptResource ?
scriptResourceReqAttr.isResourceType("sling/web-page") : false %>"/>
<c:if test="${isWebPage}">
<ul id="content-tabs" class="nav
nav-pills" role="tablist">
<li role="presentation"
class="active"><a href="#page-editor" aria-controls="page-editor" role="tab"
data-toggle="pill">Web Page Editor</a></li>
<li role="presentation"><a
href="#page-preview" aria-controls="page-preview" role="tab"
data-toggle="pill">Page Preview</a></li>
+ <li role="presentation"><a
href="#resource-type-editor" aria-controls="resource-type-editor" role="tab"
data-toggle="pill">Resource Type Editor</a></li>
<li role="presentation"><a
href="#properties" aria-controls="properties" role="tab"
data-toggle="pill">Properties</a></li>
</ul>
</c:if>
+ <c:if test="${!isWebPage}">
+ <ul id="content-tabs" class="nav
nav-pills" role="tablist">
+ <li role="presentation"
class="active"><a href="#properties" aria-controls="properties" role="tab"
data-toggle="pill">Properties</a></li>
+ <li role="presentation"><a
href="#resource-type-editor" aria-controls="resource-type-editor" role="tab"
data-toggle="pill">Resource Type Editor</a></li>
+ </ul>
+ </c:if>
<div id="outer_content" class="plate">
<div class="ie9filter-plate-div">
<div id="inner_content_margin"
class="full-height">
<div class="row
full-height" >
<div
class="col-sm-12 full-height" >
<div
class="tab-content full-height" >
+ <%--
TODO: move the resource-type-editor to the Sitebuilder project --%>
+
<div style="color: #c0c0c0;" role="tabpanel" class="tab-pane"
id="resource-type-editor">
+
<script type="text/javascript">
+
var superTypeTreeController = null;
+
var selectedScriptResourcePath = "";
+
var scriptFileChooser = null;
+
function selectCallback(e, data) {
+
//
https://www.jstree.com/api/#/?q=.jstree%20Event&f=select_node.jstree
+
var id = data.selected[0];
+
var li = $('#'+id);
+
var selectedPath =
superTypeTreeController.get_uri_from_li(li,".json");
+
+
scriptFileChooser.setSelectedScriptResourcePath($('#'+id+"
.node-type:first").text());
+
+
$.getJSON(selectedPath).done(function(propertyJson) {
+
$('#page-script-chooser-row .files').empty();
+
for (var key in propertyJson) {
+
$('#page-script-chooser-row
.files').append("<tr><td>"+key+"</td></tr>");
+
}
+
}).fail(function(data) {
+
superTypeTreeController.mainController.displayAlertHtml(data.responseText);
+
});
+
};
+
var superTypeTreeControllerSettings = {
+
contextPath : "<%= request.getContextPath() %>",
+
treeAndPropsSelector:
"#resource-super-type-tree-and-props",
+
treeSelector: null,
+
treeRootElementSelector:
"#resource-super-type-tree-and-props .root-element",
+
rootPath:"/apps/inheritedresources",
+
multipleSelection: false,
+
selectCallback: selectCallback,
+
readyCallback: pageScriptChooserReady
+
};
+
superTypeTreeController = new
org.apache.sling.reseditor.TreeController(superTypeTreeControllerSettings,
mainController);
+
+
function pageScriptChooserReady(){
+
scriptFileChooser = new
org.apache.sling.sitebuilder.Scriptfilechooser(selectedScriptResourcePath);
+
+
// TODO: Use this page as an editor for the resource type.
+//
var pathElements =
superTypeTreeController.getPathElements("/com/lux-car-rental");
+//
if (pathElements.length >= 1 && pathElements[0] != "") {
+//
superTypeTreeController.openElement($(superTypeTreeControllerSettings.treeAndPropsSelector+"
.root-element > ul"), pathElements);
+//
}
+
};
+
+
var superTypesTreeAdapterSettings = {
+
resourcePath : "${resource.path}",
+
requestURI: "${pageContext.request.requestURI}",
+
contextPath: "<%= request.getContextPath() %>",
+
resolutionPathInfo:
"${resource.resourceMetadata['sling.resolutionPathInfo']}"
+
};
+
new
org.apache.sling.reseditor.JSTreeAdapter(superTypesTreeAdapterSettings,
superTypeTreeController, mainController);
+
+
</script>
+
<div class="row">
+
<div id="sidebar-col" class="col-sm-12">
+
<h5>Script to copy and overwrite</h5>
+
</div>
+
</div>
+
<div id="page-script-chooser-row" class="row">
+
<div id="sidebar-col" class="col-sm-8">
+
<div id="resource-super-type-tree" class="">
+
<div class="ie9filter-plate-div">
+
<div
id="resource-super-type-tree-and-props" class="root tree-and-props" ></div>
+
</div>
+
</div>
+
</div>
+
<div class="col-sm-4">
+
<div class="file-props-container">
+
<table class="table table-hover">
+
<thead>
+
<tr>
+
<th>Filename:</th>
+
</tr>
+
</thead>
+
<tbody class="files">
+
</tbody>
+
</table>
+
</div>
+
</div>
+
</div>
+
<div id="selected-script-path-row" class="row">
+
<form method="post" action="<%= request.getRequestURL() %>"
enctype="multipart/form-data">
+
<div class="col-sm-12">
+
<div class="form-group">
+
<label for="resourceSuperType">Resource
super type:</label>
+
<input type="text" class="form-control"
id="resourceSuperType" name="resourceSuperType" readonly>
+
</div>
+
<div class="form-group">
+
<label for="resourceType">Resource
Type:</label>
+
<input type="text" class="form-control"
id="resourceType" name="resourceType" >
+
</div>
+
<div class="form-group">
+
<label
for="selectedScriptFilePath">Resource super type script to overwrite:</label>
+
<input type="text" class="form-control"
id="selectedScriptFilePath" name="selectedScriptFilePath" readonly>
+
</div>
+
<div>'Create new script' does the following:
+
<ol>
+
<li>Creates the specified
resource type</li>
+
<li>Assigns the specified
resource super type to the resource type</li>
+
<li>Copies the specified script
to the resource type to overwrite it from the resource super type</li>
+
</ol>
+
</div>
+
<input type="hidden" name=":operation"
value="edit-resource-type">
+
<input type="hidden" name="_charset_"
value="utf-8">
+
<button type="submit" class="btn
btn-default">Create new script</button>
+
</div>
+
</form>
+
</div>
+
</div>
<div role="tabpanel" class="tab-pane ${isWebPage ? 'active' : ''} full-height"
id="page-editor">
<a href="/pageeditor${resource.path}.main.html" target="_blank">
<span id="open-new-window" class="glyphicon
glyphicon-share-alt" aria-hidden="true"></span>
@@ -39,7 +163,7 @@
</a>
<iframe id="iframe" src="${resource.path}.html" allowtransparency="true"
frameborder="0" height="100%" width="100%" style="height: 500px;background:none
transparent;-webkit-border-radius:7px;-moz-border-radius: 7px;border-radius:
7px; border: 3px solid black"></iframe>
</div>
-
<div role="tabpanel" class="tab-pane ${!isWebPage ? 'active' : ''}"
id="properties">
+
<div role="tabpanel" class="tab-pane ${!isWebPage && !showPageChooser ?
'active' : ''}" id="properties">
<div style="display: none;" class="info-content-container" >
<div class="well well-sm info-content">
<button type="button" class="close"><span
aria-hidden="true">×</span><span class="sr-only">Close</span></button>
Modified:
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/rootnodes.json.jsp
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/rootnodes.json.jsp?rev=1768284&r1=1768283&r2=1768284&view=diff
==============================================================================
---
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/rootnodes.json.jsp
(original)
+++
sling/trunk/contrib/explorers/resourceeditor/src/main/resources/SLING-INF/libs/sling/resource-editor/rootnodes.json.jsp
Sat Nov 5 23:32:32 2016
@@ -34,7 +34,7 @@
"id" : "root",
"state" : {"opened":true, "disabled": false, "selected": false},
"text" : "<i class=\"jstree-icon node-icon open-icon\"></i><i
class=\"jstree-icon node-icon add-icon\"></i> /",
- "li_attr" :{ "nodename" : "${currentNode.name}", "nodetype"
:"${currentNode.primaryNodeType.name}" },
+ "li_attr" :{ "nodename" : "${currentNode.name}", "nodetype"
:"${currentNode.primaryNodeType.name}", "class": "root-element"},
"a_attr" :{ "href" : "<%= request.getContextPath() %>/reseditor/.html"
},
"children" :
<%@ include file="nodes.json.incl.jsp" %>