Skip to content
Snippets Groups Projects
Commit 50ac09d4 authored by Thomas Mortagne's avatar Thomas Mortagne
Browse files

XWIKI-14462: Error in creating new wiki

parent 702a7b61
No related branches found
No related tags found
No related merge requests found
......@@ -182,7 +182,17 @@ public String getSearchValidFlavorsStatusURL(String namespace)
*/
public List<Extension> getValidExtensions()
{
FlavorSearchStatus status = getSearchValidFlavorsStatus();
return getValidExtensions(currentNamespace());
}
/**
* @param namespace the namespace where to validate the flavors
* @return the valid flavors found in the currently running job status
* @since 9.5
*/
public List<Extension> getValidExtensions(String namespace)
{
FlavorSearchStatus status = getSearchValidFlavorsStatus(namespace);
return status != null ? status.getFlavors() : null;
}
......
......@@ -53,8 +53,12 @@ require(['jquery'], function($) {
}
var updateProgress = function () {
// Get URL
var url = "$escapetool.javascript($services.flavor.getSearchValidFlavorsStatusURL())";
// Get base URL
var url = "$escapetool.javascript($services.flavor.getSearchValidFlavorsStatusURL(''))";
// Add namespace to the URL if needed
var picker = $('.xwiki-flavor-picker');
url += encodeURIComponent($('.xwiki-flavor-picker').attr('data-namespace'));
$.getJSON(url).done(function(data) {
// Update progress
......@@ -90,6 +94,10 @@ require(['jquery'], function($) {
// Get base URL
var url = "$escapetool.javascript($doc.getURL('view', 'xpage=flavor/picker_flavors'))";
// Add namespace to the URL if needed
var picker = $('.xwiki-flavor-picker');
url += '&namespace=' + encodeURIComponent(picker.attr('data-namespace'));
$.getJSON(url).done(function(data) {
// Update the list of flavors
flavors = data;
......
......@@ -8,11 +8,14 @@
## @param $cssClass class to add to the div (could be 'xwiki-flavor-select-small', 'xwiki-flavor-select-medium', 'xwiki-flavor-select-tall' or any other class)
## @param $noFlavorButton display the no flavor button
#########################################################
#macro(displayFlavorPicker $fieldName $defaultValue $firstIsDefaultIfDefaultNull $cssClass $noFlavorButton)
#macro(displayFlavorPicker $fieldName $defaultValue $firstIsDefaultIfDefaultNull $cssClass $noFlavorButton $namespace)
#if (!$namespace)
#set ($namespace = $xcontext.database)
#end
## TODO: put this in a webjar instead
#set ($discard = $xwiki.ssfx.use('uicomponents/flavor/picker.css', {'forceSkinAction': true}))
#set ($discard = $xwiki.jsfx.use('uicomponents/flavor/picker.js' , {'forceSkinAction': true}))
<div class="xwiki-flavor-picker $!cssClass">
<div class="xwiki-flavor-picker $!cssClass" data-namespace="$escapetool.xml($namespace)">
## Filter
<input type="text" id="${escapetool.xml($fieldName)}_filter" class="xwiki-flavor-picker-filter" placeholder="$escapetool.xml($services.localization.render('flavor.picker.filterPlaceHolder'))" style="margin-bottom: 2px;"/>
## Results
......@@ -26,7 +29,7 @@
###end
</div>
<div class="xwiki-flavor-picker-results-container">
#displayFlavorPicker_results($fieldName, $defaultValue, $firstIsDefaultIfDefaultNull, 0)
#displayFlavorPicker_results($fieldName, $defaultValue, $firstIsDefaultIfDefaultNull, 0, $namespace)
</div>
## No flavor option
#if($noFlavorButton)
......@@ -36,7 +39,10 @@
</div>
#end
##
#macro(displayFlavorPicker_results $fieldName $defaultValue $firstIsDefaultIfDefaultNull $offset)
#macro(displayFlavorPicker_results $fieldName $defaultValue $firstIsDefaultIfDefaultNull $offset $namespace)
#if (!$namespace)
#set ($namespace = $xcontext.database)
#end
#set ($resultsPerPage = 20)
#if ("$!request.filter" != '')
#set ($flavorQuery = $services.flavor.createFlavorQuery($request.filter))
......@@ -44,9 +50,9 @@
#set ($flavorQuery = $services.flavor.createFlavorQuery())
#end
##set ($flavorQuery = $flavorQuery.setOffset($offset).setLimit($resultsPerPage))
#set ($flavorSearchJobStatus = $services.flavor.getSearchValidFlavorsStatus())
#set ($flavorSearchJobStatus = $services.flavor.getSearchValidFlavorsStatus($namespace))
#if (!$flavorSearchJobStatus)
#set ($flavorSearchJob = $services.flavor.searchValidFlavors())
#set ($flavorSearchJob = $services.flavor.searchValidFlavors($namespace))
#set ($flavorSearchJobStatus = $flavorSearchJob.status)
#end
#set ($flavors = $flavorSearchJobStatus.flavors)
......
#set($flavors = [])
#foreach($extension in $services.flavor.validExtensions)
#if ("$!request.namespace" != '')
#set ($namespace = $request.namespace)
#else
#set ($namespace = $xcontext.database)
#end
#set($validExtensions = $services.flavor.getValidExtensions($namespace))
#foreach($extension in $validExtensions)
#set($flavor = {})
#set($void = $flavor.put('id', $extension.id))
#set($void = $flavor.put('website', $extension.website))
......
#template('flavor/macros.vm')
#displayFlavorPicker_results($request.fieldName, '', false, $mathtool.toInteger($request.firstIndex))
#displayFlavorPicker_results($request.fieldName, '', true, $mathtool.toInteger($request.firstIndex), $request.namespace)
......@@ -31,8 +31,8 @@
<parent>WikiManager.WebHome</parent>
<author>xwiki:XWiki.Admin</author>
<contentAuthor>xwiki:XWiki.Admin</contentAuthor>
<date>1475675577000</date>
<contentUpdateDate>1475675577000</contentUpdateDate>
<date>1498504128000</date>
<contentUpdateDate>1498504128000</contentUpdateDate>
<version>1.1</version>
<title>$services.localization.render('platform.wiki.create.title')</title>
<comment/>
......@@ -265,7 +265,8 @@
#set ($defaultFlavor = 'noFlavor')
#end
&lt;div class="xwiki-createwiki-tab #if($currentTab=='flavors')active#{else}hidden#end" id="flavors-tab"&gt;
#displayFlavorPicker('flavor', $defaultFlavor, false, 'xwiki-createwiki-flavor-picker', true)
## TODO: reload when the target subwiki id changes
#displayFlavorPicker('flavor', $defaultFlavor, true, 'xwiki-createwiki-flavor-picker', true, 'wiki:subwiki')
&lt;/div&gt;
&lt;div class="xwiki-createwiki-tab #if($currentTab=='templates')active#{else}hidden#end" id="templates-tab"&gt;
#displayTemplateFields($templates)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment