Skip to content

Commit 364c563

Browse files
SilverYoChammoqui
authored andcommitted
Feature #13992: using space and component browser component.
The new VueJS component has been wired into mangaement page of publication locations into kmelia component.
1 parent 5d76d5a commit 364c563

File tree

7 files changed

+72
-223
lines changed

7 files changed

+72
-223
lines changed

kmelia/kmelia-configuration/src/main/config/properties/org/silverpeas/kmelia/multilang/kmeliaBundle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ kmelia.drag.publication.success2 = </b> a \u00e9t\u00e9 d\u00e9plac\u00e9e avec
383383
kmelia.drag.publication.error1 = La publication <b>
384384
kmelia.drag.publication.error2 = </b> n'a pas pu \u00eatre d\u00e9plac\u00e9e !
385385

386+
kmelia.publication.locations=Emplacements des publications
386387
kmelia.publication.draftout.impossible = Cette publication ne peut pas sortir du mode brouillon.
387388
kmelia.publication.validators.mandatory = Elle est soumise \u00e0 validation. Vous devez s\u00e9lectionner le(s) valideur(s) dans l'onglet <b>Ent\u00eate</b>.
388389
kmelia.publication.validators.select = En tant que r\u00e9dacteur, vos modifications sont soumises \u00e0 validation.<br/>Actuellement, il n'y a pas de valideur associ\u00e9 \u00e0 cette publication. <br/><br/>Afin de pouvoir la modifier, vous devez d'abord s\u00e9lectionner un valideur :

kmelia/kmelia-configuration/src/main/config/properties/org/silverpeas/kmelia/multilang/kmeliaBundle_de.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ kmelia.drag.publication.success2 = </b> was moved successfully...
438438
kmelia.drag.publication.error1 = Publication <b>
439439
kmelia.drag.publication.error2 = </b> could not be moved !
440440

441+
kmelia.publication.locations=Orte der Ver\u00f6ffentlichungen
441442
kmelia.publication.draftout.impossible = This publication may not exit the draft mode.
442443
kmelia.publication.validators.mandatory = It is subject to validation. You must select validator(s) in the tab 'Header'.
443444
kmelia.publication.validators.select = As writer, your changes are subject to validation.<br/>Actually, no validator are defined for this publication. <br/><br/>In order to modify it, you have to select validator(s) first :

kmelia/kmelia-configuration/src/main/config/properties/org/silverpeas/kmelia/multilang/kmeliaBundle_en.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ kmelia.drag.publication.success2 = </b> was moved successfully...
435435
kmelia.drag.publication.error1 = Publication <b>
436436
kmelia.drag.publication.error2 = </b> could not be moved !
437437

438+
kmelia.publication.locations=Locations of the publication
438439
kmelia.publication.draftout.impossible = This publication may not exit the draft mode.
439440
kmelia.publication.validators.mandatory = It is subject to validation. You must select validator(s) in the tab 'Header'.
440441
kmelia.publication.validators.select = As writer, your changes are subject to validation.<br/>Actually, no validator are defined for this publication. <br/><br/>In order to modify it, you have to select validator(s) first :

kmelia/kmelia-configuration/src/main/config/properties/org/silverpeas/kmelia/multilang/kmeliaBundle_fr.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ kmelia.drag.publication.success2 = </b> a \u00e9t\u00e9 d\u00e9plac\u00e9e avec
387387
kmelia.drag.publication.error1 = La publication <b>
388388
kmelia.drag.publication.error2 = </b> n'a pas pu \u00eatre d\u00e9plac\u00e9e !
389389

390+
kmelia.publication.locations=Emplacements des publications
390391
kmelia.publication.draftout.impossible = Cette publication ne peut pas sortir du mode brouillon.
391392
kmelia.publication.validators.mandatory = Elle est soumise \u00e0 validation. Vous devez s\u00e9lectionner le(s) valideur(s) dans l'onglet <b>Ent\u00eate</b>.
392393
kmelia.publication.validators.select = En tant que r\u00e9dacteur, vos modifications sont soumises \u00e0 validation.<br/>Actuellement, il n'y a pas de valideur associ\u00e9 \u00e0 cette publication. <br/><br/>Afin de pouvoir la modifier, vous devez d'abord s\u00e9lectionner un valideur :

kmelia/kmelia-war/src/main/webapp/kmelia/jsp/publicationPaths.jsp

Lines changed: 58 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,29 @@
5959
<fmt:setLocale value="${sessionScope[sessionController].language}"/>
6060
<view:setBundle bundle="${requestScope.resources.multilangBundle}"/>
6161
<view:sp-head-part>
62+
<view:includePlugin name="spaceandcomponentbrowser"/>
6263
<script type="text/javascript">
6364
$(document).ready(function() {
6465
displayLocations();
6566
<c:choose>
6667
<c:when test="${toolbox}">
67-
viewComponent("<%=componentId%>");
68+
loadComponentLocations("<%=componentId%>");
6869
</c:when>
6970
<c:otherwise>
70-
viewLocalComponent();
71-
$("#browsingArea").show();
72-
displaySpaces();
71+
loadLocalComponentLocations();
72+
SpVue.createApp({
73+
methods : {
74+
componentFilter : function(component) {
75+
return component.name === 'kmelia';
76+
},
77+
reset : function() {
78+
emptyComponentLocations();
79+
},
80+
loadLocations : function(component) {
81+
loadComponentLocations(component.instanceId);
82+
}
83+
}
84+
}).mount('#browserLocation');
7385
</c:otherwise>
7486
</c:choose>
7587
});
@@ -79,140 +91,43 @@
7991
let uri = webContext +
8092
"/services/private/publications/<%=componentId%>/<%=id%>/locations/" + locationId;
8193
if (checkbox.checked) {
82-
addAlias(uri)
94+
addAlias(uri, locationId)
8395
} else {
8496
deleteAlias(uri, locationId);
8597
}
8698
}
8799
88-
function displaySpaces() {
89-
viewSpace('0');
90-
}
91-
92-
const currentPath = new Map();
93-
currentPath.set('0', '&nbsp;');
94-
const KMELIA = 'kmelia';
95-
96-
function processPath(spaceId) {
97-
if (spaceId) {
98-
// check if component is already in path
99-
if (currentPath.has(KMELIA)) {
100-
currentPath.delete(KMELIA);
101-
}
102-
// check if spaceId is already in path
103-
if (currentPath.has(spaceId)) {
104-
let deleteNext = false;
105-
for (const key of currentPath.keys()) {
106-
if (deleteNext) {
107-
currentPath.delete(key);
108-
} else {
109-
if (key === spaceId) {
110-
deleteNext = true;
111-
}
112-
}
113-
}
114-
} else {
115-
let spaceLabel = $("#space-" + spaceId).text();
116-
currentPath.set(spaceId, spaceLabel);
117-
}
118-
displayCurrentPath();
119-
}
120-
}
121-
122-
function viewSpace(spaceId) {
123-
let uri = webContext + "/services/spaces";
124-
if (spaceId !== '0') {
125-
uri += "/" + spaceId + "/spaces";
126-
}
127-
128-
processPath(spaceId);
129-
emptyComponentTreeview();
130-
$("#components ul").empty();
131-
132-
$("#spaces ul").empty();
133-
let ajaxRequest = sp.ajaxRequest(uri);
134-
ajaxRequest.send().then(function(response) {
135-
response.responseAsJson().forEach(function(space) {
136-
let li = "<li id=\"space-" + space.id + "\"><a href=\"#\" onclick=\"viewSpace('" +
137-
space.id + "'); return false;\">" + space.label + "</a></li>";
138-
$("#spaces ul").append(li);
139-
});
140-
});
141-
if (spaceId !== '0') {
142-
displayComponents(spaceId);
143-
}
144-
}
145-
146-
function displayComponents(spaceId) {
147-
let uri = webContext + "/services/spaces/" + spaceId + "/components";
148-
$("#components ul").empty();
149-
let ajaxRequest = sp.ajaxRequest(uri);
150-
ajaxRequest.send().then(function(response) {
151-
response.responseAsJson().forEach(function(component) {
152-
if (component.name === KMELIA) {
153-
let componentId = component.name + component.id;
154-
let li = "<li id=\"" + componentId + "\"><a href=\"#\" onclick=\"viewComponent('" +
155-
componentId + "');\" return false;\">" + component.label + "</a></li>";
156-
$("#components ul").append(li);
157-
}
158-
});
159-
});
160-
}
161-
162-
function viewComponent(componentId) {
163-
let componentLabel = $("#" + componentId).text();
164-
if (currentPath.has(KMELIA)) {
165-
currentPath.delete(KMELIA);
166-
}
167-
currentPath.set(KMELIA, componentLabel);
168-
displayCurrentPath();
169-
emptyComponentTreeview();
170-
$.post("<%=routerUrl%>ShowAliasTree?ComponentId=" + componentId, function(data) {
100+
function loadComponentLocations(componentId) {
101+
emptyComponentLocations();
102+
$.get("<%=routerUrl%>ShowAliasTree?ComponentId=" + componentId, function(data) {
171103
$("#treeviewFolders").html(data);
172104
});
173105
}
174106
175-
function displayCurrentPath() {
176-
let path = "";
177-
for (const key of currentPath.keys()) {
178-
if (key !== '0') {
179-
path += " > ";
180-
}
181-
let a = "";
182-
if (key === KMELIA) {
183-
a = currentPath.get(KMELIA);
184-
} else {
185-
a = "<a href=\"#\" onclick=\"viewSpace('" + key + "'); return false;\">" +
186-
currentPath.get(key) + "</a>";
187-
}
188-
path += a;
189-
}
190-
$("#currentPath").html(path);
191-
}
192-
193-
function viewLocalComponent() {
194-
$.post("<%=routerUrl%>ShowAliasTree?ComponentId=<%=componentId%>", function(data) {
107+
function loadLocalComponentLocations() {
108+
$.get("<%=routerUrl%>ShowAliasTree?ComponentId=<%=componentId%>", function(data) {
195109
$("#localTreeview").html(data);
196110
});
197111
}
198112
199-
function emptyComponentTreeview() {
113+
function emptyComponentLocations() {
200114
$("#treeviewFolders").empty();
201115
}
202116
203117
function deleteAlias(aliasURI, locationId) {
204-
var ajaxRequest = sp.ajaxRequest(aliasURI).byDeleteMethod();
205-
ajaxRequest.send().then(function() {
118+
sp.ajaxRequest(aliasURI).byDeleteMethod().send().then(function() {
206119
$("#currentLocations #" + locationId).remove();
207-
$("#localTreeview #" + locationId).prop("checked", false);
208-
$("#treeviewFolders #" + locationId).prop("checked", false);
120+
$("#localTreeview ." + locationId).prop("checked", false);
121+
$("#treeviewFolders ." + locationId).prop("checked", false);
209122
});
210123
}
211124
212-
function addAlias(aliasURI) {
125+
function addAlias(aliasURI, locationId) {
213126
let ajaxRequest = sp.ajaxRequest(aliasURI).byPutMethod();
214127
ajaxRequest.send().then(function() {
215128
displayLocations();
129+
$("#localTreeview ." + locationId).prop("checked", true);
130+
$("#treeviewFolders ." + locationId).prop("checked", true);
216131
});
217132
}
218133
@@ -230,7 +145,7 @@
230145
li += "<span class=\"location-user\">" + location.user.fullName + "</span>";
231146
li += "<span class=\"location-date\">" + sp.moment.displayAsDateTime(location.date) +
232147
"</span>";
233-
li += "<a class=\"delete-button\" href=\"#\" onclick=\"deleteAlias('" + location.uri +
148+
li += "<a class=\"delete-button\" href=\"javascript:void(0)\" onclick=\"deleteAlias('" + location.uri +
234149
"', '" + locationId + "')\">Supprimer</a>";
235150
}
236151
li += "</li>";
@@ -273,24 +188,35 @@
273188
</div>
274189

275190
<div id="browserLocation">
276-
<div id="browsingArea" style="display:none;">
277-
<div class="header">
278-
<h3><fmt:message key="kmelia.paths.external.add"/></h3>
191+
<c:set var="htmlTreeviewDock">
192+
<div id="treeview" class="accordion">
193+
<h4><fmt:message key="GML.folders"/></h4>
194+
<div id="treeviewFolders"></div>
279195
</div>
280-
<div id="currentPath"></div>
281-
<div id="spaces">
282-
<h4><fmt:message key="GML.spaces"/></h4>
283-
<ul></ul>
284-
</div>
285-
<div id="components">
286-
<h4><fmt:message key="GML.components"/></h4>
287-
<ul></ul>
288-
</div>
289-
</div>
290-
<div id="treeview" class="accordion">
291-
<h4><fmt:message key="GML.folders"/></h4>
292-
<div id="treeviewFolders"></div>
293-
</div>
196+
</c:set>
197+
<c:choose>
198+
<c:when test="${toolbox}">
199+
<div class="space-and-component-browser">
200+
<div class="browser">
201+
${htmlTreeviewDock}
202+
</div>
203+
</div>
204+
</c:when>
205+
<c:otherwise>
206+
<div class="header">
207+
<h3><fmt:message key="kmelia.paths.external.add"/></h3>
208+
</div>
209+
<silverpeas-space-and-component-browser v-bind:component-content-enabled="true"
210+
v-bind:component-filter="componentFilter"
211+
v-on:enter-root="reset"
212+
v-on:enter-space="reset"
213+
v-on:enter-component="loadLocations">
214+
<template v-slot:extend-browser>
215+
${htmlTreeviewDock}
216+
</template>
217+
</silverpeas-space-and-component-browser>
218+
</c:otherwise>
219+
</c:choose>
294220
</div>
295221
</view:board>
296222
</view:frame>

0 commit comments

Comments
 (0)