Commit c479f2c3 authored by Robert Lyon's avatar Robert Lyon

Bug 1409546: Adjusting collection navigation to include framework option

This adds the framework matrix page as the first page of the collection

Change-Id: I229fe2f08c636f5f0a63a9284304c15de454bbfd
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent c97e40ac
......@@ -132,7 +132,6 @@ if (!empty($institutionname) && ($institutionname != 'mahara')) {
}
setpageicon($smarty, $pageIcon);
$smarty->assign('canedit', $canedit);
$smarty->assign('urlparamsstr', $urlparamsstr);
$smarty->assign('collections', $data->data);
......
......@@ -84,6 +84,7 @@ $string['overrideaccess'] = 'Override access';
$string['potentialviews'] = 'Potential pages';
$string['saveapply'] = 'Apply and save';
$string['savecollection'] = 'Save collection';
$string['smartevidence'] = 'SmartEvidence';
$string['update'] = 'Update';
$string['usecollectionname'] = 'Use collection name?';
$string['usecollectionnamedesc'] = 'If you wish to use the collection name instead of the block title, leave this checked.';
......
......@@ -372,6 +372,7 @@ class Collection {
c.submittedgroup,
c.submittedhost,
c.submittedtime,
c.framework,
(SELECT COUNT(*) FROM {collection_view} cv WHERE cv.collection = c.id) AS numviews
FROM {collection} c
WHERE " . $wherestm .
......@@ -380,6 +381,7 @@ class Collection {
}
self::add_submission_info($data);
self::framework_url($data);
$result = (object) array(
'count' => $count,
......@@ -625,9 +627,49 @@ class Collection {
if (!$this->views()) {
return false;
}
if (!PluginModuleFramework::is_active()) {
return false;
}
return true;
}
/**
* Get collection framework option for collection navigation
*
* @return object $option;
*/
public function collection_nav_framework_option() {
$option = new StdClass;
$option->framework = $this->framework;
$option->id = $this->id;
$option->title = get_string('smartevidence', 'collection');
$option->framework = true;
self::framework_url($option);
return $option;
}
/**
* Making the framework url
*
* @param mixed $data Object / array of objects
*
* @return $data or $url
*/
public static function framework_url(&$data) {
if (is_array($data)) {
foreach ($data as $k => $r) {
$r->frameworkurl = 'module/framework/matrix.php?id=' . $r->id;
$r->fullurl = get_config('wwwroot') . $r->frameworkurl;
}
}
else if (is_object($data)) {
$data->frameworkurl = 'module/framework/matrix.php?id=' . $data->id;
$data->fullurl = get_config('wwwroot') . $data->frameworkurl;
}
}
/**
* Get the available views the current user can choose to add to their collections.
* Restrictions on this list include:
......@@ -851,6 +893,11 @@ class Collection {
$views = $this->views();
if (!empty($views)) {
if ($this->framework) {
$this->framework_url($this);
return $this->frameworkurl;
}
$v = new View(0, $views['views'][0]);
$v->set('dirty', false);
$firstview = $v;
......
......@@ -4323,7 +4323,7 @@ class View {
}
$select .= '
v.owner, v.ownerformat, v.group, v.institution, v.template, v.mtime, v.ctime,
c.id as collid, c.name, v.type, v.urlid, v.submittedtime, v.submittedgroup, v.submittedhost
c.id as collid, c.name, c.framework, v.type, v.urlid, v.submittedtime, v.submittedgroup, v.submittedhost
';
$viewdata = get_records_sql_assoc(
......@@ -5897,7 +5897,7 @@ class View {
SELECT v.id, v.type, v.title, v.ownerformat, v.startdate, v.stopdate, v.template,
v.owner, v.group, v.institution, v.urlid, v.submittedgroup, v.submittedhost, " .
db_format_tsfield('v.submittedtime', 'submittedtime') . ", v.submittedstatus,
c.id AS cid, c.name AS cname,
c.id AS cid, c.name AS cname, c.framework,
c.submittedgroup AS csubmitgroup, c.submittedhost AS csubmithost, " .
db_format_tsfield('c.submittedtime', 'csubmittime') . ", c.submittedstatus AS csubmitstatus
FROM {view} v
......@@ -5983,6 +5983,9 @@ class View {
$collections[$cid]['ownername'] = $v['ownername'];
$collections[$cid]['ownerurl'] = $v['ownerurl'];
}
if (!empty($r['framework'])) {
$collections[$cid]['url'] = get_config('wwwroot') . 'module/framework/matrix.php?id=' . $cid;
}
}
$collections[$cid]['views'][$vid] = $v;
}
......
......@@ -89,6 +89,16 @@ $smarty = smarty(
)
);
// collection top navigation
if ($collection) {
$shownav = $collection->get('navigation');
if ($shownav) {
$viewnav = $views['views'];
array_unshift($viewnav, $collection->collection_nav_framework_option());
$smarty->assign('collection', $viewnav);
}
}
$evidence = $framework->get_evidence();
if (!$evidence) {
$evidence = array();
......
......@@ -13,14 +13,14 @@
<tr>
<td colspan="2">&nbsp;</td>
<td colspan="{$viewcount}" class="special">
<span class="btn btn-default" id="prev">
<button class="btn btn-default" id="prev">
<span class="icon left icon-chevron-left" aria-hidden="true" role="presentation"></span>
Prev
</span>
<span class="btn btn-default next" id="next">
</button>
<button class="btn btn-default next" id="next">
<span class="icon left icon-chevron-right" aria-hidden="true" role="presentation"></span>
Next
</span>
</button>
</td>
</tr>
<tr>
......
{foreach from=$collections item=collection}
<div class="list-group-item {cycle values='r0,r1'} {if $collection->submitinfo}list-group-item-warning{/if}">
{if $collection->views[0]->view}
<a href="{$collection->views[0]->fullurl}" class="outer-link"><span class="sr-only">{$collection->name}</span></a>
<a href="{if $collection->framework}{$collection->fullurl}{else}{$collection->views[0]->fullurl}{/if}" class="outer-link"><span class="sr-only">{$collection->name}</span></a>
{/if}
<div class="row">
<div class="col-md-9">
......
......@@ -337,7 +337,11 @@ if ($collection) {
$shownav = $collection->get('navigation');
if ($shownav) {
if ($views = $collection->get('views')) {
$smarty->assign('collection', $views['views']);
$viewnav = $views['views'];
if ($collection->has_framework()) {
array_unshift($viewnav, $collection->collection_nav_framework_option());
}
$smarty->assign('collection', $viewnav);
}
}
}
......
......@@ -50,3 +50,11 @@ Scenario: Installing framework module and activating for an institution
And I select "SmartEvidence" from "SmartEvidence framework"
And I press "Save"
Then I should see "Collection saved successfully."
# Testing the collection navigation and matrix carousel
And I follow "CollA"
And I should see "You are on page 1/9"
And I press "Next" in the "table#tablematrix" "css_element"
Then I should see "PageF"
And I press "Prev" in the "table#tablematrix" "css_element"
Then I should not see "PageF"
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