|
59 | 59 | <fmt:setLocale value="${sessionScope[sessionController].language}"/>
|
60 | 60 | <view:setBundle bundle="${requestScope.resources.multilangBundle}"/>
|
61 | 61 | <view:sp-head-part>
|
| 62 | + <view:includePlugin name="spaceandcomponentbrowser"/> |
62 | 63 | <script type="text/javascript">
|
63 | 64 | $(document).ready(function() {
|
64 | 65 | displayLocations();
|
65 | 66 | <c:choose>
|
66 | 67 | <c:when test="${toolbox}">
|
67 |
| - viewComponent("<%=componentId%>"); |
| 68 | + loadComponentLocations("<%=componentId%>"); |
68 | 69 | </c:when>
|
69 | 70 | <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'); |
73 | 85 | </c:otherwise>
|
74 | 86 | </c:choose>
|
75 | 87 | });
|
|
79 | 91 | let uri = webContext +
|
80 | 92 | "/services/private/publications/<%=componentId%>/<%=id%>/locations/" + locationId;
|
81 | 93 | if (checkbox.checked) {
|
82 |
| - addAlias(uri) |
| 94 | + addAlias(uri, locationId) |
83 | 95 | } else {
|
84 | 96 | deleteAlias(uri, locationId);
|
85 | 97 | }
|
86 | 98 | }
|
87 | 99 |
|
88 |
| - function displaySpaces() { |
89 |
| - viewSpace('0'); |
90 |
| - } |
91 |
| -
|
92 |
| - const currentPath = new Map(); |
93 |
| - currentPath.set('0', ' '); |
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) { |
171 | 103 | $("#treeviewFolders").html(data);
|
172 | 104 | });
|
173 | 105 | }
|
174 | 106 |
|
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) { |
195 | 109 | $("#localTreeview").html(data);
|
196 | 110 | });
|
197 | 111 | }
|
198 | 112 |
|
199 |
| - function emptyComponentTreeview() { |
| 113 | + function emptyComponentLocations() { |
200 | 114 | $("#treeviewFolders").empty();
|
201 | 115 | }
|
202 | 116 |
|
203 | 117 | function deleteAlias(aliasURI, locationId) {
|
204 |
| - var ajaxRequest = sp.ajaxRequest(aliasURI).byDeleteMethod(); |
205 |
| - ajaxRequest.send().then(function() { |
| 118 | + sp.ajaxRequest(aliasURI).byDeleteMethod().send().then(function() { |
206 | 119 | $("#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); |
209 | 122 | });
|
210 | 123 | }
|
211 | 124 |
|
212 |
| - function addAlias(aliasURI) { |
| 125 | + function addAlias(aliasURI, locationId) { |
213 | 126 | let ajaxRequest = sp.ajaxRequest(aliasURI).byPutMethod();
|
214 | 127 | ajaxRequest.send().then(function() {
|
215 | 128 | displayLocations();
|
| 129 | + $("#localTreeview ." + locationId).prop("checked", true); |
| 130 | + $("#treeviewFolders ." + locationId).prop("checked", true); |
216 | 131 | });
|
217 | 132 | }
|
218 | 133 |
|
|
230 | 145 | li += "<span class=\"location-user\">" + location.user.fullName + "</span>";
|
231 | 146 | li += "<span class=\"location-date\">" + sp.moment.displayAsDateTime(location.date) +
|
232 | 147 | "</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 + |
234 | 149 | "', '" + locationId + "')\">Supprimer</a>";
|
235 | 150 | }
|
236 | 151 | li += "</li>";
|
|
273 | 188 | </div>
|
274 | 189 |
|
275 | 190 | <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> |
279 | 195 | </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> |
294 | 220 | </div>
|
295 | 221 | </view:board>
|
296 | 222 | </view:frame>
|
|
0 commit comments