Commit 8ddfdb51 authored by Robert Lyon's avatar Robert Lyon

Bug 1667181: Change the add/copy buttons

Change-Id: I530493857423fab31f7204acb08e6b8db44fadb2
parent a902cc4e
......@@ -23,6 +23,7 @@ $title = get_string('siteviewscollections', 'admin');
define('TITLE', $title);
$offset = param_integer('offset', 0);
$urlparams = array();
$templateviews = View::get_site_template_views();
list($searchform, $data, $pagination) = View::views_by_owner(null, 'mahara');
......@@ -56,7 +57,8 @@ EOF;
}
$js .= '});';
$createviewform = pieform(create_view_form(null, 'mahara'));
$urlparams['institution'] = 'mahara';
$urlparamsstr = '&' . http_build_query($urlparams);
$smarty = smarty(array('paginator'));
setpageicon($smarty, 'icon-file-text');
......@@ -64,6 +66,7 @@ setpageicon($smarty, 'icon-file-text');
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('views', $views);
$smarty->assign('institution', 'mahara');
$smarty->assign('urlparamsstr', $urlparamsstr);
$smarty->assign('sitetemplate', View::SITE_TEMPLATE);
$smarty->assign('querystring', get_querystring());
$smarty->assign('pagination', $pagination['html']);
......@@ -71,5 +74,4 @@ $html = $smarty->fetch('view/indexresults.tpl');
$smarty->assign('viewresults', $html);
$smarty->assign('query', param_variable('query', null));
$smarty->assign('searchform', $searchform);
$smarty->assign('createviewform', $createviewform);
$smarty->display('view/index.tpl');
......@@ -103,6 +103,7 @@ $string['youcannotviewthisusersprofile'] = 'You cannot view this user\'s profile
$string['invalidlayoutselection'] = 'You tried to select a layout that doesn\'t exist.';
$string['invalidnumrows'] = 'You have tried to create a layout with more than the allowed maximum number of rows. (This should not be possible; please notify your site\'s administrator.)';
$string['previewimagegenerationfailed'] = 'Sorry, there was a problem generating the preview image.';
$string['viewtemplatenotfound'] = 'Default page template not found.';
$string['artefactnotfoundmaybedeleted'] = "Artefact with id %s not found (maybe it has been deleted already?)";
$string['artefactnotfound'] = 'Artefact with id %s not found';
......
<!-- @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Collections</h3>
<p>A collection is a set of pages that are linked to one another and have the same access permissions. You can create as many collections as you like, but a page cannot appear in more than one collection.</p>
<p>You can create a collection from scratch or copy an existing one - either one of your own or one from another user that is copyable to you.</p>
<!-- @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Pages</h3>
<h3>Pages and collections</h3>
<h4>Pages</h4>
<p>A page contains a selection of artefacts which you arrange and present to others. These may include:</p>
<ul>
<li>selected files</li>
......@@ -12,3 +13,6 @@
<li>etc.</li>
</uL>
<p>You can re-use the artefacts that you collected under "Content" in as many pages as you wish.</p>
<h4>Collections</h4>
<p>A collection is a set of pages that are linked to one another and have the same access permissions. You can create as many collections as you like, but a page cannot appear in more than one collection.</p>
<p>You can create a collection from scratch or copy an existing one - either one of your own or one from another user that is copyable to you.</p>
......@@ -401,6 +401,8 @@ $string['copyview'] = 'Copy page';
$string['createemptyview'] = 'Create empty page';
$string['copyaview'] = 'Copy a page';
$string['copyvieworcollection'] = 'Copy a page or collection';
$string['confirmaddtitle'] = 'Create a page or collection';
$string['confirmadddesc'] = 'Please choose which you would like to create:';
$string['confirmcopytitle'] = 'Confirm copying';
$string['confirmcopydesc'] = 'Please choose which you would like to copy:';
$string['Untitled'] = 'Untitled';
......
......@@ -400,6 +400,25 @@ class BehatGeneral extends BehatBase {
$elementnode->click();
}
/**
* Click on a button in the modal dialog.
*
* @When /^I click on "(?P<link_or_button>(?:[^"]|\\")*)" in the dialog$/
* @throws ElementNotFoundException
*/
public function i_click_on_in_dialog($link_or_button) {
// Find the dialog button.
$exception = new ElementNotFoundException($this->getSession(), 'dialog');
$xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' modal-dialog ')]";
$rownode = $this->find('xpath', $xpath, $exception);
list($selector, $locator) = $this->transform_selector('link_or_button', $link_or_button);
$elementnode = $this->find($selector, $locator, false, $rownode);
$this->ensure_node_is_visible($elementnode);
$elementnode->click();
}
/**
* Click on the bottom right menu elipsis inside a list panel containing the specified text.
*
......
......@@ -28,7 +28,7 @@ This button has padding on the right of the icon due to the plus class.
```
<button class="btn-default button btn">
<span class="icon icon-plus icon-lg left" role="presentation"></span>
{str tag=createview section=view}
{str tag=add section=mahara}
</button>
```
</section>
......
{include file="header.tpl"}
<div class="btn-top-right btn-group btn-group-top {if $GROUP} pagetabs{/if}">
{$createviewform|safe}
<form method="post" class="form-as-button pull-left" action="{$WWWROOT}view/choosetemplate.php">
<button class="submit btn btn-default">
<span class="icon icon-lg left icon-files-o" role="presentation" aria-hidden="true"></span>
{str tag="copyaview" section="view"}
</button>
{if $GROUP}
<input type="hidden" name="group" value="{$GROUP->id}" />
{elseif $institution}
<input type="hidden" name="institution" value="{$institution}">
{/if}
</form>
<a id="addview-button" class="btn btn-default" href="{$WWWROOT}view/edit.php?new=1{$urlparamsstr}">
<span class="icon icon-plus icon-lg left" role="presentation" aria-hidden="true"></span>
{str section=mahara tag=add}
</a>
<a id="copyview-button" class="btn btn-default" href="{$WWWROOT}view/choosetemplate.php?searchcollection=1{$urlparamsstr}">
<span class="icon icon-files-o icon-lg left" role="presentation" aria-hidden="true"></span>
{str section=mahara tag=copy}
</a>
</div>
{$searchform|safe}
......@@ -32,5 +28,47 @@
{/if}
</div>
{* Modal form *}
<div class="modal fade" id="addview-form">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">
<span class="icon icon-lg icon-flag text-danger prs"></span>
{str tag=confirmaddtitle section=view}
</h4>
</div>
<div class="modal-body">
<p>{str tag=confirmadddesc section=view}</p>
<div class="btn-group">
<button id="add-collection-button" type="button" class="btn btn-default"><span class="icon icon-folder-open text-success"></span> {str tag=Collection section=collection}</button>
<button id="add-view-button" type="button" class="btn btn-default"><span class="icon icon-file-text text-success"></span> {str tag=view}</button>
</div>
</div>
</div>
</div>
</div>
<script type="application/javascript">
var addurl = $j("#addview-button").attr('href');
$j("#addview-button").on('click', function(event) {
event.preventDefault();
event.stopPropagation();
$j("#addview-form").modal('show');
});
$j("#add-view-button").on('click', function() {
window.location = addurl;
});
$j("#add-collection-button").on('click', function() {
// redirect to the collection section
var url = addurl.replace(/view\/edit/, 'collection/edit');
window.location = url;
});
</script>
{include file="footer.tpl"}
......@@ -20,6 +20,41 @@ require_once(get_config('docroot') . 'blocktype/lib.php');
require_once(get_config('libroot') . 'view.php');
require_once(get_config('libroot') . 'group.php');
$new = param_boolean('new', 0);
$viewid = param_integer('id', false);
if ($new && $viewid === false) {
// Use the site default portfolio page to create a new page
// cribbed from createview_submit()
$sitedefaultviewid = get_field('view', 'id', 'institution', 'mahara', 'template', View::SITE_TEMPLATE, 'type', 'portfolio');
if (!empty($sitedefaultviewid)) {
$artefactcopies = array();
$values = array();
$groupid = param_integer('group', 0);
$institutionname = param_alphanum('institution', false);
if (!empty($groupid)) {
$values['group'] = $groupid;
}
else if (!empty($institutionname)) {
$values['institution'] = $institutionname;
}
list($view, $template, $copystatus) = View::create_from_template($values, $sitedefaultviewid, null, true, false, $artefactcopies);
if (isset($copystatus['quotaexceeded'])) {
$SESSION->add_error_msg(get_string('viewcreatewouldexceedquota', 'view'));
redirect(get_config('wwwroot') . 'view/index.php');
}
}
else {
throw new ConfigSanityException(get_string('viewtemplatenotfound', 'error'));
}
$goto = get_config('wwwroot') . 'view/edit.php?new=1&id=' . $view->get('id');
if (!empty($values)) {
$goto .= '&' . http_build_query($values);
}
redirect($goto);
}
$view = new View(param_integer('id'));
if (!$USER->can_edit_view($view)) {
......
......@@ -22,6 +22,7 @@ require_once(get_config('libroot') . 'view.php');
require_once(get_config('libroot') . 'group.php');
$offset = param_integer('offset', 0);
$urlparams = array();
define('GROUP', param_integer('group'));
define('SUBSECTIONHEADING', get_string('Viewscollections', 'view'));
......@@ -49,7 +50,7 @@ if (!$can_edit) {
// Add a copy view form for all templates in the list
foreach ($data->data as &$v) {
if ($v['template']) {
$v['copyform'] = pieform(create_view_form(null, null, $v['id']));
$v['copyform'] = true;
}
}
......@@ -66,7 +67,6 @@ if (!$can_edit) {
}
else {
list($searchform, $data, $pagination) = View::views_by_owner($group->id);
$createviewform = pieform(create_view_form($group->id));
}
$js = <<< EOF
jQuery(function ($) {
......@@ -93,10 +93,17 @@ EOF;
}
$js .= '});';
$urlparamsstr = '';
if (!empty($group->id)) {
$urlparams['group'] = $group->id;
$urlparamsstr = '&' . http_build_query($urlparams);
}
$smarty = smarty(array('paginator'));
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('views', $data->data);
$smarty->assign('headingclass', 'page-header');
$smarty->assign('urlparamsstr', $urlparamsstr);
$smarty->assign('pagination', $pagination['html']);
if (!$can_edit) {
......@@ -105,6 +112,7 @@ if (!$can_edit) {
$smarty->display('view/groupviews.tpl');
}
else {
$smarty->assign('group', $group->id);
$smarty->assign('query', param_variable('query', null));
$smarty->assign('querystring', get_querystring());
$smarty->assign('sitetemplate', View::SITE_TEMPLATE);
......@@ -112,6 +120,5 @@ else {
$html = $smarty->fetch('view/indexresults.tpl');
$smarty->assign('viewresults', $html);
$smarty->assign('searchform', $searchform);
$smarty->assign('createviewform', $createviewform);
$smarty->display('view/index.tpl');
}
......@@ -46,7 +46,6 @@ EOF;
}
$js .= '});';
$createviewform = pieform(create_view_form());
$groupid = param_integer('group', 0);
$institutionname = param_alphanum('institution', false);
......@@ -62,5 +61,4 @@ $smarty->assign('viewresults', $html);
$smarty->assign('headingclass', 'page-header');
$smarty->assign('query', param_variable('query', null));
$smarty->assign('searchform', $searchform);
$smarty->assign('createviewform', $createviewform);
$smarty->display('view/index.tpl');
......@@ -26,6 +26,7 @@ $offset = param_integer('offset', 0);
if ($institution == 'mahara') {
redirect('/admin/site/views.php');
}
$urlparams = array();
$s = institution_selector_for_page($institution,
get_config('wwwroot') . 'view/institutionviews.php');
......@@ -68,7 +69,11 @@ $js .= <<< EOF
{$s['institutionselectorjs']}
EOF;
$createviewform = pieform(create_view_form(null, $institution));
$urlparamsstr = '';
if (!empty($institution)) {
$urlparams['institution'] = $institution;
$urlparamsstr = '&' . http_build_query($urlparams);
}
$smarty = smarty(array('paginator'));
setpageicon($smarty, 'icon-university');
......@@ -77,6 +82,7 @@ $smarty->assign('institutionselector', $s['institutionselector']);
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('views', $data->data);
$smarty->assign('institution', $institution);
$smarty->assign('urlparamsstr', $urlparamsstr);
$smarty->assign('sitetemplate', View::SITE_TEMPLATE);
$smarty->assign('querystring', get_querystring());
$smarty->assign('pagination', $pagination['html']);
......@@ -84,5 +90,4 @@ $html = $smarty->fetch('view/indexresults.tpl');
$smarty->assign('viewresults', $html);
$smarty->assign('query', param_variable('query', null));
$smarty->assign('searchform', $searchform);
$smarty->assign('createviewform', $createviewform);
$smarty->display('view/index.tpl');
......@@ -34,9 +34,9 @@ I can create a new page from the site default portfolio page
# Create a new portfolio page
And I log in as "userA" with password "Kupuhipa1"
And I choose "Portfolio"
And I should see "Pages"
And I should see "Create page"
And I press "Create page"
And I should see "Pages and collections"
And I follow "Add"
And I click on "Page" in the dialog
And I should see "Edit title and description"
And I click on "Edit content"
Then I should see "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
......@@ -13,7 +13,8 @@ Scenario: Making adjustments to the mathslate plugin for mahara (Bug 1472446)
And I press "Update site options"
And I should see "Site options have been updated."
And I choose "Pages and collections" in "Configure site"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I set the following fields to these values:
| Page title | test |
| Page description | testing |
......
......@@ -34,7 +34,8 @@ Feature: Mahara users can create their blogs
And I fill in select2 input "editpost_tags" with "blogentry" and select "blogentry"
And I press "Save entry"
And I choose "Pages and collections" in "Portfolio"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I press "Save"
And I expand "Journals" node in the "div#content-editor-foldable" "css_element"
And I wait "1" seconds
......
......@@ -101,7 +101,8 @@ Scenario: Newly created user can get a copy of the journal (Bug 1472467)
And I should see "Spongebob"
# Creating a site page
And I choose "Pages and collections" in "Configure site"
And I press "Create"
And I follow "Add"
And I click on "Page" in the dialog
And I set the following fields to these values:
| Page title | Square pants |
| Page description | hsdfhjkl78695t 8677y8 |
......
......@@ -89,7 +89,8 @@ Scenario: Creating a plan with 11 tasks (Bug #1503036)
Then I should see "Alien invasion"
# Add the plan to a page
And I choose "Pages and collections" in "Portfolio"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I press "Save"
And I wait "5" seconds
And I expand "General" node
......
......@@ -11,7 +11,8 @@ Scenario: Creating a page with content in it (Bug 1426983)
And I should see "Admin User"
# Navigating to Portfolio to create a page
And I follow "Portfolio"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I fill in the following:
| Page title | Test view |
And I press "Save"
......
......@@ -53,7 +53,8 @@ Scenario: Adding tags to files (Bug 1426983)
And I press "Save task"
# Creating page 1 with a tag
And I follow "Portfolio"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I set the following fields to these values:
| Page title * | Test page 1 |
And I fill in select2 input "editview_tags" with "page" and select "page"
......@@ -61,7 +62,8 @@ Scenario: Adding tags to files (Bug 1426983)
And I press "Save"
And I follow "Portfolio"
# Creating page 2 with a tag
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I set the following fields to these values:
| Page title * | Testing page 2 |
And I fill in select2 input "editview_tags" with "page" and select "page"
......
......@@ -17,9 +17,9 @@ Scenario: Creating a collection AND adding pages
# Verifying log in was successful
And I should see "Admin User"
# Create Test collection
# And I choose "Pages and collections" in "Portfolio"
And I go to "collection/index.php"
And I follow "New collection"
And I choose "Pages and collections" in "Portfolio"
And I follow "Add"
And I click on "Collection" in the dialog
And I fill in the following:
| Collection name | Test Collection |
| Collection description | Test |
......@@ -47,14 +47,15 @@ Scenario: Creating a collection AND adding pages
And I select "Registered users" from "accesslist[0][searchtype]"
And I press "Save"
And I choose "Pages and collections" in "Portfolio"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I set the following fields to these values:
| Page title | New page |
| Page description | testing |
And I press "Save"
# And I choose "Pages and collections" in "Portfolio"
And I go to "collection/index.php"
And I follow "Manage pages"
And I choose "Pages and collections" in "Portfolio"
And I click on "Test Collection" panel menu
And I click on "Manage" in "Test Collection" panel menu
And I follow "All"
And I wait "1" seconds
And I press "Add pages"
......
......@@ -8,7 +8,8 @@ Scenario: Accessing annotation block (Bug 1443730)
Given I log in as "admin" with password "Kupuhipa1"
# Creating a page
And I choose "Pages and collections" in "Portfolio"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I fill in "My page is amazing" for "Page title *"
And I press "Save"
# Checking if annotation block is there
......
......@@ -16,9 +16,9 @@ Scenario: Adding collection to group (Bug 1448807)
| title | description| ownertype | ownername |
| Site Page 01 | This is the page 01 of the site | group 01 | userA |
When I log in as "userA" with password "Kupuhipa1"
# And I choose "Pages and collections" in "Portfolio"
And I go to "collection/index.php"
And I follow "New collection"
And I choose "Pages and collections" in "Portfolio"
And I follow "Add"
And I click on "Collection" in the dialog
And I set the following fields to these values:
| Collection name * | The A team |
And I press "Next: Edit collection pages"
......
......@@ -10,7 +10,8 @@ Scenario: Create a page and secret URLs to copy (Bug 1426983)
# Verifying log in was successful
And I should see "Admin User"
When I follow "Portfolio"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I fill in the following:
| Page title | Testing page 1 |
And I press "Save"
......
......@@ -23,7 +23,8 @@ Scenario: Creating and accessing social media buttons (Bug 1448948)
| Your URL or username * | https://www.facebook.com/wellingtonphoenixfc |
And I press "Save"
And I follow "Portfolio"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I set the following fields to these values:
| Page title * | Open source is for winners |
And I press "Save"
......
......@@ -25,7 +25,8 @@ Scenario: As a user leaving a public comment on a group page (Bug 1509129)
| Comment notifications | None |
And I press "Save group"
When I click on "Pages" in the ".right-text" "css_element"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I set the following fields to these values:
| Page title | Group Page 01 |
And I press "Save"
......
......@@ -224,11 +224,9 @@ These list must take into account the sort option choosen in the block config (B
And I jump to page "2" of the list "sharedviews_pagination"
And I should not see "Page userA_01" in the "ul#sharedviewlist" "css_element"
# Update the shared collection "Collection userA_06"
# And I choose "Pages and collections" in "Portfolio"
And I go to "collection/index.php"
# And I click on "Collection userA_06" panel menu
# And I click on "Edit" in "Collection userA_06" panel menu
And I click on "Edit \"Collection userA_06\""
And I choose "Pages and collections" in "Portfolio"
And I click on "Collection userA_06" panel menu
And I click on "Edit" in "Collection userA_06" panel menu
And I set the field "Collection description" to "This is the collection 06 (updated)"
And I press "Save"
# Check if it is now in the first page of the list of shared collections
......
......@@ -57,16 +57,16 @@ Scenario: Installing framework module and activating for an institution
# Adding framework to existing collection
And I follow "Return to site"
# And I choose "Pages and collections" in "Portfolio"
And I go to "collection/index.php"
And I follow "Edit title and description"
And I choose "Pages and collections" in "Portfolio"
And I click on "CollA" panel menu
And I click on "Edit" in "CollA" panel menu
And I select "Title of your framework" from "SmartEvidence framework"
And I press "Save"
Then I should see "Collection saved successfully."
# Testing the collection navigation and matrix carousel
And I go to "collection/index.php"
And I follow "CollA"
And I choose "Pages and collections" in "Portfolio"
And I click the panel "CollA"
And I should see "You are on page 1/9"
And I should see "by Admin User (admin)"
And I press "Next" in the "table#tablematrix" "css_element"
......@@ -93,9 +93,8 @@ Scenario: Installing framework module and activating for an institution
And I press "Save"
# Re-click a matrix point to add some feedback
# And I choose "Pages and collections" in "Portfolio"
And I go to "collection/index.php"
And I follow "CollA"
And I choose "Pages and collections" in "Portfolio"
And I click the panel "CollA"
And I click on the matrix point "3,4"
And I wait "1" seconds
And I fill in "This is annotation feedback" in editor "Feedback"
......
......@@ -15,15 +15,16 @@ Scenario: Meta test testing Behat's functionality (Bug #1387836)
And I press "Save profile"
And I choose "Pages and collections" in "Portfolio"
# Creating a page
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I set the field "Page title" to "test page name 1"
And I press "Save"
# Verifying it saved
And I should see "Page saved successfully"
# Creating a collection
# And I choose "Pages and collections" in "Portfolio"
And I go to "collection/index.php"
And I follow "New collection"
And I choose "Pages and collections" in "Portfolio"
And I follow "Add"
And I click on "Collection" in the dialog
And I set the field "Collection name" to "test collection name"
And the "Page navigation bar" checkbox should be checked
And I press "Next: Edit collection pages"
......@@ -36,8 +37,8 @@ Scenario: Meta test testing Behat's functionality (Bug #1387836)
And the "test page name 1" checkbox should be checked
And I press "Add pages"
And I follow "Done"
And I go to "collection/index.php"
And I hover "Delete collection" "link"
And I click on "test collection name" panel menu
And I should see "Delete"
And I go to the homepage
And I choose "Export" in "Portfolio"
And I move backward one page
......
......@@ -17,7 +17,8 @@ Scenario: Create users and search for them (Bug 897586)
And I should see "Bob Bobby"
# Creating page one
And I follow "Portfolio"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I fill in the following:
| Page title | Testing page 1 |
And I press "Save"
......@@ -25,7 +26,8 @@ Scenario: Create users and search for them (Bug 897586)
And I should see "Page saved successfully"
# Creating page two
And I follow "Portfolio"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I fill in the following:
| Page title | Testing page 2 |
And I press "Save"
......@@ -45,7 +47,8 @@ Scenario: Create users and search for them (Bug 897586)
And I should see "Jen Jenny"
# Creating page three
And I follow "Portfolio"
And I press "Create page"
And I follow "Add"
And I click on "Page" in the dialog
And I fill in the following:
| Page title | Testing page 3 |
And I press "Save"
......@@ -53,7 +56,8 @@ Scenario: Create users and search for them (Bug 897586)
And I should see "Page saved successfully"
# Creating page 4