diff --git a/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/create.vm b/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/create.vm index 8cd4b4045e1c..ef4cb195b144 100644 --- a/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/create.vm +++ b/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/create.vm @@ -20,6 +20,7 @@ #template("startpage.vm")
+ #template('hierarchy.vm') ## --------------------------------------------------------------------------------------------------------- ## Since this template can be used for creating a Page or a Space, compute its title based on the passed ## "tocreate" parameter which can be either "page" or "space". If no "tocreate" parameter is passed then we diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/createinline.vm b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/createinline.vm index 436e4ec4c321..613b4dcf2a83 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/createinline.vm +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/createinline.vm @@ -265,8 +265,8 @@ ## --------------------------------------------------------------------------------------------------------- ## Display the form. ## --------------------------------------------------------------------------------------------------------- -## FIXME: Using the 'container' class when displayed in an ajax call by clicking on a Wanted Link so that it looks good (proper margins) in the popup. -
+#set ($isAjaxRequest = $request.getHeader('X-Requested-With') == 'XMLHttpRequest') +
## Deprecated: Pass along any received page parent. @@ -279,16 +279,13 @@
- ## Hide the first column when displayed in an AJAX call by clicking on a Wanted Link (because we know the target - ## location from the link reference) or when the current document is new (because the create action uses the location - ## of the current document as target in this case). - #if (!$request.ajax && !$doc.isNew()) + ## Hide the first column when displayed in an AJAX call by clicking on a Wanted Link, because we know the target + ## location from the link reference. + #if (!$isAjaxRequest) ## Determine the parent reference for the new document. #set ($parentReference = $spaceReference) #if (!$parentReference) ## No parent reference specified. - ## We keep this code although we tested above that the current document is not new because in the future we may - ## want to support changing the target location even if the current document is new. #if ($doc.isNew()) ## Encourage the user to create the current document. #set ($parentReference = $doc.documentReference.parent) @@ -310,6 +307,9 @@ ## Display the location picker.
#template('locationPicker_macros.vm') + ## The create action doesn't support changing the location when the current document doesn't exist (i.e. it + ## forces you to create the current document that is missing). For this reason we make the name and parent fields + ## read-only when the current document is new. #locationPicker({ 'id': 'target', 'title': { @@ -328,14 +328,16 @@ 'hint': 'core.create.spaceReference.hint', 'name': 'spaceReference', 'reference': $parentReference, - 'placeholder': 'core.create.spaceReference.placeholder' + 'placeholder': 'core.create.spaceReference.placeholder', + 'readOnly': $doc.isNew() }, 'name': { 'label': 'core.create.name.label', 'hint': 'core.create.name.hint', 'name': 'name', 'value': $name, - 'placeholder': 'core.create.name.placeholder' + 'placeholder': 'core.create.name.placeholder', + 'readOnly': $doc.isNew() } })
@@ -348,10 +350,20 @@ #set ($spaceReferenceLocalString = $services.model.serialize($spaceReference, 'local')) #end - ## FIXME: When displayed in an ajax call by clicking on a Wanted Link, the responsive classes consider the calling document (large screen) - ## as the viewport and not the popup (small screen), so we can not use them since they create problems instead of fixing them. -
+
+ #if ($isAjaxRequest) + ## The first column that shows the location preview is hidden when creating a new page from a Wanted Link so we + ## need to show this information elsewhere. Even if the target page reference can't be modified by the user, + ## they should still see where the page is going to be created. +
+ +
+
+ #set ($targetDocumentReference = $services.model.createDocumentReference($name, $spaceReference)) + #hierarchy($targetDocumentReference) +
+ #end ## --------------------------------------------------------------------------------------------------------- ## Page type ## --------------------------------------------------------------------------------------------------------- @@ -360,7 +372,10 @@ ## Terminal page - Advanced users ## --------------------------------------------------------------------------------------------------------- #set ($hidden = '') - #if (!($isAdvancedUser || $isSuperAdmin) || $deprecatedSpaceCreate) + ## Top level documents cannot be terminal. + #set ($isTopLevelDoc = $doc.documentReference.name == 'WebHome' && + $doc.documentReference.lastSpaceReference.parent.type == 'WIKI') + #if (!($isAdvancedUser || $isSuperAdmin) || $deprecatedSpaceCreate || ($doc.isNew() && $isTopLevelDoc)) #set ($hidden = 'hidden') #end
diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/locationPicker_macros.vm b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/locationPicker_macros.vm index 1d7826142fdc..2ff4fd403bec 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/locationPicker_macros.vm +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/locationPicker_macros.vm @@ -72,10 +72,7 @@ ## ## --------------------------------------------------------------------------------------------------------- @@ -87,13 +84,17 @@
#end -#macro (locationPickerActions) +#macro (locationPickerActions $options)
## Tree picker toggle - + #if ($isDocumentTreeAvailable && $options.parent.label && !$options.parent.readOnly) + #documentPickerModal($options) + $services.icon.renderHTML('chart-organisation') + #end ## Location advanced edit button. - #if ($isAdvancedUser) + #if ($isAdvancedUser && ($options.name.label || $options.parent.label || + ($options.wiki.label && $displayWikiFields))) $services.icon.renderHTML('pencil') @@ -136,9 +137,9 @@ #elseif ($wikiField) - #end ## --------------------------------------------------------------------------------------------------------- ## Parent Reference field @@ -159,17 +160,26 @@ #set ($value = $defaultParentReferenceString) #end #set ($escapedValue = $escapetool.xml($value)) -
- - $!escapetool.xml($services.localization.render($parentField.hint)) -
-
- -
+ #if ($parentField.label) +
+ + $!escapetool.xml($services.localization.render($parentField.hint)) +
+
+ +
+ #else + + + #end ## ## --------------------------------------------------------------------------------------------------------- ## Name field @@ -191,7 +201,8 @@
+ placeholder="$!escapetool.xml($services.localization.render($nameField.placeholder))" + #if ($nameField.readOnly)readonly#end />
#elseif ($nameField) diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/uicomponents/widgets/locationPicker.js b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/uicomponents/widgets/locationPicker.js index a327c47c33a7..f596af5783c9 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/uicomponents/widgets/locationPicker.js +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/uicomponents/widgets/locationPicker.js @@ -151,13 +151,18 @@ require(['jquery', 'xwiki-meta', 'xwiki-events-bridge', 'xwiki-form-validation-a * Compute a page name from a given title. **/ var getPageName = function(title) { - var url = XWiki.currentDocument.getURL("get"); - return Promise.resolve($.get(url, { - 'xpage': 'entitynamevalidation_json', - 'outputSyntax': 'plain', - 'name': title, - 'form_token': xm.form_token - })); + if (nameInput.prop('readonly')) { + // The page name is read-only so we shouldn't update it based on the title. + return Promise.resolve({transformedName: nameInput.val()}); + } else { + var url = XWiki.currentDocument.getURL("get"); + return Promise.resolve($.get(url, { + 'xpage': 'entitynamevalidation_json', + 'outputSyntax': 'plain', + 'name': title, + 'form_token': xm.form_token + })); + } }; /**