Изменения документа Document Tree Macros

Редактировал(а) Давид Гавриков 2024/10/22 15:18

От версии 5.1
отредактировано Давид Гавриков
на 2024/10/22 15:18
Изменить комментарий: Install extension [org.xwiki.platform:xwiki-platform-index-tree-macro/16.8.0]
К версии 4.1
отредактировано Давид Гавриков
на 2024/05/29 15:58
Изменить комментарий: Install extension [org.xwiki.platform:xwiki-platform-index-tree-macro/16.3.1]

Сводка

Подробности

Свойства страницы
Содержимое
... ... @@ -76,11 +76,7 @@
76 76  #macro (handleDocumentTreeRequest)
77 77   #if ($request.action)
78 78   #if ($services.csrf.isTokenValid($request.form_token))
79 - #if ($request.action == 'create' && $request.type == 'addDocument')
80 - #handleNewNodeCreationRequest()
81 - #else
82 - $response.sendError(400, 'The specified action is not supported.')
83 - #end
79 + $response.sendError(400, 'The specified action is not supported.')
84 84   #elseif ($isAjaxRequest)
85 85   $response.sendError(403, 'The CSRF token is missing.')
86 86   #else
... ... @@ -106,22 +106,6 @@
106 106   #end
107 107  #end
108 108  
109 -#macro (handleNewNodeCreationRequest)
110 - #set ($cleanId = $stringtool.substring($request.id, $stringtool.length('document:')))
111 - #set ($parentReference = $services.model.resolveDocument($cleanId))
112 - #set ($requestedName = $request.name)
113 - #set ($transformedName = $services.modelvalidation.transformName($requestedName))
114 - #set ($spaceReference = $services.model.createSpaceReference($transformedName, $parentReference.lastSpaceReference))
115 - #set ($documentReference = $services.model.createDocumentReference('WebHome', $spaceReference))
116 - #set ($data = [])
117 - #addDocumentNode($documentReference, $data)
118 - ## We want to allow opening the node to add another hierarchy.
119 - #set ($data[0].children = true)
120 - ## We want to display the actual requested name as node name.
121 - #set ($data[0].text = $requestedName)
122 - #jsonResponse($data)
123 -#end
124 -
125 125  #macro (postProcessDocumentTreeData $data)
126 126   ## This is just a hook to allow post processing the document tree data.
127 127  #end
... ... @@ -372,18 +372,14 @@
372 372  #end
373 373  
374 374  #macro (addAddDocumentNode $documentReference $siblings)
375 - ## FIXME: This URL is wrong, it should use the $documentReference as the parent for creation of the node:
376 - ## the reference is already an existing doc, so it shouldn't be the one used for creation.
377 377   #set ($discard = $siblings.add({
378 378   'id': "addDocument:$services.model.serialize($documentReference, 'default')",
379 - 'text': $services.localization.render('index.documentTree.addDocument'),
357 + 'text': 'New page...',
380 380   'icon': 'fa fa-plus-circle',
381 381   'children': false,
382 382   'data': {
383 383   'type': 'addDocument',
384 - 'validChildren': [],
385 - 'hasContextMenu': true,
386 - 'canRename': true
362 + 'validChildren': []
387 387   },
388 388   'a_attr': {
389 389   'href': $xwiki.getURL($documentReference, 'create')