한 가지 가능한 솔루션 3 구성 요소를 기반으로 -
- 표 컨테이너 구성 요소 (만 행의 구성 요소를 추가 할 수 있습니다 또는 당신이 간단한 것을 유지하기 위해 드래그 앤 드롭을 허용 할 수)
- 행 구성 요소 (또 다른 간단한 컨테이너 (열 구성 요소를 추가 할 수 있습니다. 사용자 정의 '+'기호를 사용하여 열 구성 요소를 추가 할 수있는 사용자 정의 '+'부호 사용)
- 텍스트 구성 요소를 포함하는 열 구성 요소 블로그에 here 참조)
'+'기호의 기능과 지속성을 달성하기 다음을 수행 -
이 클라이언트 라이브러리하려면 cq:ClientLibraryFolder
를 생성하고 해당 속성 categories="cq.authoring.dialog"
을 지정할로 JS를 추가 -
/* global Granite, $ */
$(document).on('cq-page-info-loaded', function() {
'use strict';
// initialisation for Mysite
window.mysite = window.mysite || {};
window.mysite.app = window.mysite.app || {};
window.mysite.app.auth = window.mysite.app.auth || {};
(function(window, ns, undefined) {
/**
* Adds a child component of a specified type to a parent editable component.
* (event handler for clicking the 'add' button in the edit interface on the sections or questions component)
*
* @param {Granite.author.Editable} parentEditable The editable parent component
* @param {string} componentName Name of the child component to add e.g. 'mysite-app/ui/components/content/link'
* @param {boolean} componentTemplate If true, call the low level interface directly. If false, call higher level Granite.author.edit methods.
*/
var createChildComponent = function(parentEditable, componentName, componentTemplate) {
return (
new ns.persistence.PostRequest()
.prepareCreateParagraph({
resourceType: componentName,
parentPath: parentEditable.path,
relativePosition: 'last',
templatePath: componentTemplate
})
.send()
).done(function() {
parentEditable.refresh();
});
};
window.mysite.app.auth.component = (function() {
return {
tablerow: {
add: function(editable) {
createChildComponent(editable, '/apps/mysite-app/ui/components/<path to row component>', false);
}
},
rowcell: {
add: function(editable) {
createChildComponent(editable, '/apps/mysite-app/ui/components/<path to column cell>', false);
}
}
};
})();
})(window, Granite.author);
});
다음이다 actionConfigs
을 editConfig
에 개별 구성 요소로 설정하고 위 스크립트의 처리기를 가리 키십시오. 당신이 구성 요소를 추가하고 노드를 지속 할 수있는 '+'기호를보고 시작합니다 editbar 구성 요소에
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
cq:actions="[edit,delete]"
jcr:primaryType="cq:EditConfig">
<cq:actionConfigs jcr:primaryType="nt:unstructured">
<addCell
jcr:primaryType="nt:unstructured"
handler="mysite.app.auth.component.rowcell.add"
icon="coral-Icon--add"
text="Add column to table row"/>
</cq:actionConfigs>
</jcr:root>
.
는 here하면 자세한 내용이 필요하면 줄을 편집 할 사용자 지정 작업 추가를 참조하십시오. 이 방법을 따라 싶지 않는 경우
가 첫 번째 스크립트는 구성 요소 노드를 지속 할 수있는 논리를 가지고, 당신은 그것을 다시 사용할 수 있으며 자신의 구현에 포함.