<
From version < 10.1 >
edited by Marius Dumitru Florea
on 2013/07/15
To version < 12.1 >
edited by Vincent Massol
on 2014/10/21
>
Change comment: Install extension [org.xwiki.platform:xwiki-platform-blog-ui-6.2.2]

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.mflorea
1 +XWiki.VincentMassol
Content
... ... @@ -1,4 +1,4 @@
1 -{{include document="Blog.CategoriesCode"/}}
1 +{{include reference="Blog.CategoriesCode"/}}
2 2  
3 3  {{velocity filter="none"}}
4 4  {{html clean="false" wiki="true"}}
... ... @@ -37,14 +37,14 @@
37 37   #set($newCategoryParent = $escapetool.url($request.newCategoryParent))
38 38   #if($request.ajax)
39 39   #if("$!{request.mode}" == 'select')
40 - #set($xredirect = ${doc.getURL('view', "xpage=plain&display=list&listType=selectable&root=${newCategoryParent}")})
40 + #set($xredirect = $doc.getURL('view', "xpage=plain&display=list&listType=selectable&root=${newCategoryParent}&entry=$!{request.entry}&entryObjNb=$!{request.entryObjNb}"))
41 41   #else
42 - #set($xredirect = ${doc.getURL('view', "xpage=plain&display=list&root=${newCategoryParent}")})
43 - #end
44 - $response.sendRedirect($xwiki.getURL($name, 'save', "template=${blogCategoryTemplate}&parent=${newCategoryParent}&${blogCategoryClassname}_0_name=${title}&${blogCategoryClassname}_0_description=&xredirect=${escapetool.url($xredirect)}&xhidden=1&form_token=$!{services.csrf.getToken()}"))
42 + #set($xredirect = $doc.getURL('view', "xpage=plain&display=list&root=${newCategoryParent}&entry=$!{request.entry}&entryObjNb=$!{request.entryObjNb}"))
43 + #end
45 45   #else ## request.ajax
46 - $response.sendRedirect($xwiki.getURL($name, 'save', "template=${blogCategoryTemplate}&parent=${newCategoryParent}&${blogCategoryClassname}_0_name=${title}&${blogCategoryClassname}_0_description=&xredirect=${escapetool.url(${doc.getURL()})}&xhidden=1&form_token=$!{services.csrf.getToken()}"))
45 + #set($xredirect = $doc.getURL('view', "entry=$!{request.entry}&entryObjNb=$!{request.entryObjNb}"))
47 47   #end
47 + $response.sendRedirect($xwiki.getURL($name, 'save', "template=${blogCategoryTemplate}&parent=${newCategoryParent}&${blogCategoryClassname}_0_name=${title}&${blogCategoryClassname}_0_description=&xredirect=${escapetool.url($xredirect)}&xhidden=1&form_token=$!{services.csrf.getToken()}"))
48 48   #end ## empty title
49 49  #end
50 50  #####################################################
XWiki.JavaScriptExtension[0]
Code
... ... @@ -187,11 +187,22 @@
187 187   },
188 188   createAddSubcategoryForm : function (item) {
189 189   var parent = item.up('.blog-categories-list');
190 + var ajaxParams = {};
191 + var urlParams = item.getAttribute('href').toQueryParams();
192 + var entry = urlParams.entry;
193 + if(entry && entry != '') {
194 + ajaxParams['entry'] = entry;
195 + }
196 + var entryObjNb = urlParams.entryObjNb;
197 + if(entryObjNb && entryObjNb != '') {
198 + ajaxParams['entryObjNb'] = entryObjNb;
199 + }
190 190   if (!parent._x_add_form) {
191 191   if (!parent.disabled) {
192 192   new Ajax.Request(
193 193   "$doc.getURL('view', 'xpage=plain&display=addForm&ajax=1')",
194 194   {
205 + parameters : ajaxParams,
195 195   onCreate : function () {
196 196   // ignore "cascade" clicks
197 197   parent.disabled = true;
... ... @@ -241,6 +241,11 @@
241 241   this.activateForm(form);
242 242   },
243 243   ajaxifyAddForm : function(form) {
255 + var params = 'ajax=1&xpage=plain&';
256 + var separator = '?';
257 + if(form.action.toQueryParams().entry)
258 + separator = '&';
259 + params = separator + params;
244 244   form.setAttribute('autocomplete', 'off');
245 245   form.down('input[type=text]').setAttribute('autocomplete', 'off');
246 246   form.down('input[type=text]').setAttribute('autocomplete', 'off');
... ... @@ -250,9 +250,9 @@
250 250   if (form.newCategoryName.value != '') {
251 251   new Ajax.Request(
252 252   #if("$!{request.mode}" == 'select')
253 - form.action + '?ajax=1&xpage=plain&mode=select&' + form.serialize(),
269 + form.action + params + 'mode=select&' + form.serialize(),
254 254   #else
255 - form.action + '?ajax=1&xpage=plain&' + form.serialize(),
271 + form.action + params + form.serialize(),
256 256   #end
257 257   {
258 258   onCreate : function () {
... ... @@ -267,9 +267,25 @@
267 267   reference.insert({after : response.responseText});
268 268   this.initialize();
269 269   }*/
286 + var checkedCategories = [];
287 + $$(".blog-categories-list").each(function(item){
288 + item.select('input[type=checkbox]').each(function(input){
289 + if(input.checked){
290 + checkedCategories.push(input.value);
291 + }
292 + });
293 + });
270 270   $$(".blog-categories-list").first().replace(response.responseText);
271 271   this.initialize();
272 272   form.reset();
297 + $$(".blog-categories-list").each(function(item){
298 + item.select('input[type=checkbox]').each(function(input){
299 + input.checked = false;
300 + if(!input.checked && checkedCategories.contains(input.value)){
301 + input.checked = true;
302 + }
303 + });
304 + });
273 273   }.bind(this),
274 274   onFailure : function (response) {
275 275   new XWiki.widgets.Notification(response.responseText || "$services.localization.render('core.widgets.ajaxRequest.error.noServer')", "error");
XWiki.StyleSheetExtension[0]
Code
... ... @@ -12,7 +12,6 @@
12 12  }
13 13  .blog-categories-list ul {
14 14   list-style-type: none !important;
15 - padding: 0;
16 16  }
17 17  .blog-categories-list .blog-category-level {
18 18   padding: 1px 2px 3px;

Get Connected