Commit 00ca5fe7 authored by Ruslan Kabalin's avatar Ruslan Kabalin
Browse files

Improve portfolio search (bug #931481)



Add the list of views the artefact is associated with.

Change-Id: I62fd21c2d53819de2a57d2aee88aff9dc34191ed
Signed-off-by: default avatarRuslan Kabalin <ruslan.kabalin@luns.net.uk>
parent b3630b96
......@@ -92,6 +92,7 @@ $string['viewssubmittedtogroup'] = 'Pages submitted to this group';
$string['submitaviewtogroup'] = 'Submit a page to this group';
$string['youhavesubmitted'] = 'You have submitted <a href="%s">%s</a> to this group';
$string['youhavesubmittedon'] = 'You submitted <a href="%s">%s</a> to this group on %s';
$string['listedinpages'] = 'Listed in pages';
// access levels
$string['public'] = 'Public';
......
......@@ -134,7 +134,16 @@ abstract class PluginSearch extends Plugin {
switch ($result['type']) {
case 'artefact':
safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $result['artefacttype']));
$result['links'] = call_static_method(generate_artefact_class_name($result['artefacttype']), 'get_links', $result['id']);
$artefact = artefact_instance_from_id($result['id']);
if ($artefact->in_view_list() && $views = $artefact->get_views_instances()) {
foreach ($views as $view) {
$result['views'][$view->get('title')] = get_config('wwwroot') . 'view/artefact.php?artefact='
. $result['id'] . '&view=' . $view->get('id');
}
}
if ($links = $artefact->get_links($result['id'])) {
$result['links'] = $links;
}
break;
case 'view':
$result['links'] = array(
......
......@@ -34,6 +34,7 @@ $artefacttype = param_variable('artefacttype','all');
$enc_jsonscript = json_encode(get_config('wwwroot') . 'json/selfsearch.php');
$enc_noresults = json_encode(get_string('noresultsfound'));
$enc_pages = json_encode(get_string('listedinpages', 'view'));
$javascript = <<<EOF
var results = new TableRenderer(
......@@ -44,7 +45,7 @@ var results = new TableRenderer(
results.statevars.push('query');
results.statevars.push('type');
results.emptycontent = {$enc_noresults};
results.rowfunction = function (r, n, d) {
results.rowfunction = function (r, rownumber, d) {
var titleElement;
if (r.links && r.links._default) {
......@@ -56,20 +57,26 @@ results.rowfunction = function (r, n, d) {
}
for ( var k in r.links ) {
var button = BUTTON(null, k);
connect(button, 'onclick', partial(
function (link) { document.location.href = link },
r.links[k]
));
titleElement.push(button);
var link = A({'href': r.links[k]}, k);
titleElement.push(link);
}
if (r.views) {
var viewsList = UL(null);
var viewsElement = P(null, STRONG(null, $enc_pages), viewsList);
for ( var k in r.views ) {
var link = A({'href': r.views[k]}, k);
viewsList.appendChild(LI(null, link));
}
}
var descriptionElement = P(null);
descriptionElement.innerHTML = r.summary;
return TR(null, TD(null,
return TR({'class': 'r' + (rownumber % 2)}, TD(null,
titleElement,
descriptionElement
descriptionElement,
viewsElement
));
};
......
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