Commit 00fa6014 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1827272: move theme dropdown menu to page settings"

parents a07cd80a 33d1f349
......@@ -208,8 +208,6 @@
showColumnBackgroundsOnSort();
rewriteViewThemeSelector();
makeNewBlocksDraggable();
makeExistingBlocksSortable();
......@@ -1141,21 +1139,6 @@
}
}
/**
* Wire up the view theme selector
*/
function rewriteViewThemeSelector() {
if (!viewThemeSelect) {
return;
}
var currentTheme = $('option:selected', viewThemeSelect).val();
viewThemeSelect.on('change', function() {
if ($('option:selected', viewThemeSelect).val() != currentTheme) {
$(viewThemeSelect).closest('form').trigger('submit');
}
});
}
function addConfigureBlock(oldblock, configblock, removeoncancel) {
hideMediaPlayers();
......
......@@ -521,9 +521,10 @@ $string['textbox1'] = 'Note';
$string['image'] = 'Image';
$string['addcontent'] = 'Add Content';
$string['theme'] = 'Theme';
$string['choosethemedesc'] = 'Choose a theme for the page.';
$string['lockblocks'] = "Lock blocks";
$string['lockblocksdescription'] = "You can lock the blocks on the page and prevent that they are removed when people copy the page.";
$string['lockblocksdescription'] = "You can lock the blocks on the page and prevent them from being removed when people copy the page.";
$string['instructions'] = 'Instructions';
$string['advanced'] = 'Advanced';
......
......@@ -36,18 +36,6 @@
<div id="editcontent-sidebar-wrapper" class="col-collapse">
<div id="editcontent-sidebar" data-spy="affix" data-offset-top="420" data-offset-top="100" class="toolbar-affix">
{include file="view/contenteditor.tpl" selected='content'}
{if $viewthemes}
<div id="select-theme" class="select dropdown theme-dropdown">
<label id="select-theme-header">{str tag=theme section=view}</label>
<span class="picker">
<select id="viewtheme-select" class="form-control select" name="viewtheme">
{foreach from=$viewthemes key=themeid item=themename}
<option value="{$themeid}"{if $themeid == $viewtheme} selected="selected"{/if}>{$themename}</option>
{/foreach}
</select>
</span>
</div>
{/if}
</div>
</div>
<div class="col-with-collapse">
......@@ -102,18 +90,6 @@
<div id="editcontent-sidebar-wrapper" class="col-collapse">
<div id="editcontent-sidebar">
{include file="view/contenteditor.tpl" selected='content'}
{if $viewthemes}
<div id="select-theme" class="select dropdown theme-dropdown">
<label id="select-theme-header">{str tag=theme section=view}</label>
<span class="picker">
<select id="viewtheme-select" class="form-control select" name="viewtheme">
{foreach from=$viewthemes key=themeid item=themename}
<option value="{$themeid}"{if $themeid == $viewtheme} selected="selected"{/if}>{$themename}</option>
{/foreach}
</select>
</span>
</div>
{/if}
</div>
</div>
<div class="blockconfig-background">
......
......@@ -5,7 +5,7 @@
<form action="{$formurl}" method="post" class="pieform form-inline">
<input type="hidden" id="viewid" name="id" value="{$view}">
<input type="hidden" name="sesskey" value="{$SESSKEY}">
<div class="select form-group">
<div class="select">
<label for="viewtheme-select">{str tag=theme}: </label>
<span class="picker">
<select id="viewtheme-select" name="viewtheme" class="form-control select autofocus">
......
......@@ -265,11 +265,6 @@ if (isset($groupurl)) {
}
$smarty->assign('institution', $institution);
if (get_config('userscanchooseviewthemes') && $view->is_themeable()) {
$smarty->assign('viewtheme', $viewtheme);
$smarty->assign('viewthemes', $allowedthemes);
}
$smarty->assign('viewid', $view->get('id'));
$collectionid = false;
if ($collection = $view->get('collection')) {
......
......@@ -382,6 +382,25 @@ function get_advanced_elements() {
'defaultvalue' => $view->get('anonymise'),
);
}
// Theme dropdown
$theme = $view->set_user_theme();
$allowedthemes = get_user_accessible_themes();
if ($theme && !isset($allowedthemes[$theme])) {
// We have page set with an unknown theme
// So redirect it to the choose theme page first
redirect('/view/blocks.php?id=' . $view->get('id'));
}
if (get_config('userscanchooseviewthemes') && $view->is_themeable()) {
$elements['theme'] = array(
'type' => 'select',
'title' => get_string('theme', 'view'),
'description' => get_string('choosethemedesc', 'view'),
'options' => $allowedthemes,
'defaultvalue' => $theme,
);
};
return $elements;
}
......@@ -1000,6 +1019,9 @@ function set_view_title_and_description(Pieform $form, $values) {
if (isset($values['lockblocks'])) {
$view->set('lockblocks', (int)$values['lockblocks']);
}
if (isset($values['theme'])) {
$view->set('theme', $values['theme']);
}
if (isset($values['ownerformat']) && $view->get('owner')) {
$view->set('ownerformat', $values['ownerformat']);
}
......
......@@ -24,6 +24,9 @@ Scenario: Activate page themes setting and edit a page (Bug 1591304)
Given I log in as "UserA" with password "Kupuh1pa!"
And I follow "Page UserA_01"
And I follow "Edit"
And I scroll to the id "select-theme"
And I select "Modern" from "viewtheme"
And I follow "Settings" in the "Toolbar buttons" property
And I follow "Advanced"
And I scroll to the id "settings_theme"
And I select "Modern" from "theme"
And I press "Save"
Then the "div#logo-area" element should contain "/theme/modern/images/site-logo"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment