Commit db4bc11b authored by Robert Lyon's avatar Robert Lyon
Browse files

Getting the copy a page or collection to sort by collection


Bug #1255780

When clicking the 'Copy a collection' button on the
Portfolio -> Collections page the list of copyable pages is sorted by
collection name rather than page name to make it easier to see what pages are
in the collection that you are about to copy.

Also the subheading highlighted is 'Collections' instead of 'Pages'.

When clicking the 'Copy a page' link in Portfolio -> Pages things
should work like before.

- TODO: possibly limit each copyable collection to have one 'Copy
collection' button and have the alternating row colours toggle for
each collection rather than just each row.

Change-Id: I4b9786ba95404e03f44039cacb6e6b4bf6a4b0d6
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 652e9f1f
......@@ -3784,7 +3784,7 @@ class View {
$orderby .= "COALESCE(sg.name, si.displayname, CASE WHEN su.preferredname IS NOT NULL AND su.preferredname != '' THEN su.preferredname ELSE su.firstname || ' ' || su.lastname END)";
}
else {
$orderby .= 'v.' . $item['column'];
$orderby .= (!empty($item['tablealias']) ? $item['tablealias'] : 'v') . '.' . $item['column'];
}
if ($item['desc']) {
......@@ -4122,7 +4122,7 @@ class View {
}
}
public static function set_nav($group, $institution, $share=false) {
public static function set_nav($group, $institution, $share=false, $collection=false) {
if ($group) {
define('MENUITEM', $share ? 'groups/share' : 'groups/views');
define('GROUP', $group);
......@@ -4135,6 +4135,9 @@ class View {
define('INSTITUTIONALADMIN', 1);
define('MENUITEM', $share ? 'manageinstitutions/share' : 'manageinstitutions/institutionviews');
}
else if ($collection) {
define('MENUITEM', 'myportfolio/collection');
}
else {
define('MENUITEM', $share ? 'myportfolio/share' : 'myportfolio/views');
}
......@@ -4253,7 +4256,8 @@ class View {
public static function get_templatesearch_data(&$search) {
require_once(get_config('libroot') . 'pieforms/pieform.php');
$results = self::view_search($search->query, $search->ownerquery, null, $search->copyableby, $search->limit, $search->offset, true, null, null, true);
$search->sort = (isset($search->sort)) ? $search->sort : null; // for backwards compatibility
$results = self::view_search($search->query, $search->ownerquery, null, $search->copyableby, $search->limit, $search->offset, true, $search->sort, null, true);
foreach ($results->data as &$r) {
$r['form'] = pieform(create_view_form($search->copyableby->group, $search->copyableby->institution, $r['id'], $r['collid']));
......@@ -4272,6 +4276,9 @@ class View {
if (!empty($search->institution)) {
$params['institution'] = $search->institution;
}
if (!empty($search->collection)) {
$params['searchcollection'] = $search->collection;
}
$params['viewlimit'] = $search->limit;
$smarty = smarty_core();
......
......@@ -17,7 +17,7 @@
<input type="hidden" name="viewoffset" value="0">
{if $views->group}<input type="hidden" name="group" value="{$views->group}">{/if}
{if $views->institution}<input type="hidden" name="institution" value="{$views->institution}">{/if}
{if $views->collection}<input type="hidden" name="searchcollection" value="{$views->collection}">{/if}
<span id="searchowners"><label>{str tag="searchowners" section="view"}:</label>
<input type="text" name="ownerquery" id="ownerquery" class="query" value="{$owners->query}">
<button class="query-button" type="submit">{str tag="go"}</button></span>
......
......@@ -18,8 +18,8 @@ require_once(get_config('libroot') . 'group.php');
$owner = param_integer('owner', 0);;
$groupid = param_integer('group', null);
$institution = param_alphanum('institution', null);
View::set_nav($groupid, $institution);
$searchcollection = param_integer('searchcollection', false);
View::set_nav($groupid, $institution, false, $searchcollection);
if ($usetemplate = param_integer('usetemplate', null)) {
// If a form has been submitted, build it now and pieforms will
......@@ -65,6 +65,17 @@ else {
$views->copyableby->owner = $USER->get('id');
$helptext = get_string('choosetemplatepageandcollectiondescription', 'view');
}
$sort[] = array('column' => 'title',
'desc' => 0,
);
if ($searchcollection) {
array_unshift($sort, array('column' => 'collection',
'desc' => 0,
'tablealias' => 'cv'
));
$views->collection = $searchcollection;
}
$views->sort = (object) $sort;
View::get_templatesearch_data($views);
$strpreview = json_encode(get_string('Preview','view'));
......
......@@ -28,7 +28,18 @@ $views->copyableby = (object) array('group' => $group, 'institution' => $institu
if (!($group || $institution)) {
$views->copyableby->owner = $USER->get('id');
}
$searchcollection = param_integer('searchcollection', null);
$sort[] = array('column' => 'title',
'desc' => 0,
);
if ($searchcollection) {
array_unshift($sort, array('column' => 'collection',
'desc' => 0,
'tablealias' => 'cv'
));
$views->collection = $searchcollection;
}
$views->sort = (object) $sort;
View::get_templatesearch_data($views);
json_reply(false, array(
......
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