Commit be7af61f authored by Lisa Seeto's avatar Lisa Seeto

Bug 1827811: Move "Add comment" and "Details" into modal with "Comments"

create modal using configureblock id, update various templates to use the modal for blocks:
Image
Note
File(s) to download
Journal/blogs
add JS to open/close modal, add comments, delete comments, reply to comments, paginate comments.
add JS to handle url that redirects to view/view.php with modal open and populated.
Further changes to each block will be completed in child patches.
Add segment headings to the modal. Fix display of comments to cover width of modal.
Show comment removed msg in modal/page appropriately.
Fix behat test to close modal before continuing.
do not show existing comments if comments not allowed on artefact.
add validation to modal for comments/attachments
disable image as link when editing for image block
trigger focus on modal for accessibility
close modal on escape keydown event
fix merge conflict in view/view.php
fix merge conflict with master
make configureblock modal play nicely when comment block is on the page
update display of error messages to always show at top of modal so user doesn't have to scroll
add accesibility to close modal on escape key down
handle dock show/hide events for paginated pages in modal during validation
create block-comments-details-header template file
create details button and custom scss file with js to show and hide header
update comment links to save add comment and details when commentcount == 0
add active-block class to colour the block-header when active
toggle the details-btn active css
add _block-comments-details-header.scss to patch
change class invisble to class d-none
add block-comments-details-header.tpl to blocktypecontainerviewing.tpl
code review changes
add .no-modal class to links on group home page, dashboard and profile page.
add block header to appear above the title
change assessbtn from anchor tag to button to prevent scrolling.
make all clickable links clickable on page load (ignore assess mode)
fix js issues surrounding assessbtn move and show/hide blocks
change cursor on dashboard, my profile page, group homepage to default when over disabled modal links
update assessbtn to details btn
create tooltip for hover over file download block titles
fix containerElm console log error by not reattaching tinymce unneccessarily.
fix null named attributes issues on e.target when span (icons) instead of anchor is clicked.

Change-Id: I2e5218c040f8a9e252f785165ce9c566ecc2f56e
Signed-off-by: default avatarLisa Seeto <lisaseeto@catalyst.net.nz>
parent e3a53e16
......@@ -53,7 +53,6 @@ if (!empty($extradata->artefact) && !artefact_in_view($extradata->artefact, $ext
}
if ($ispagination) {
// This is not really working yet. Need to do more work on artefact/artefact.php
$options = ArtefactTypeAnnotationfeedback::get_annotation_feedback_options();
$options->limit = $limit;
$options->offset = $offset;
......
......@@ -33,7 +33,7 @@ class PluginBlocktypeAnnotation extends MaharaCoreBlocktype {
}
public static function has_title_link() {
return false; // true; // need to do more work on aretfact/artefact.php before this can be switched on.
return false;
}
public static function allowed_in_view(View $view) {
......
......@@ -894,9 +894,8 @@ class ArtefactTypeAnnotationfeedback extends ArtefactType {
);
$data->jsonscript = 'artefact/annotation/annotations.json.php';
$data->baseurl = get_config('wwwroot') . 'artefact/artefact.php?' .
'artefact=' . $data->annotation .
'&view=' . $data->view .
$data->baseurl = get_config('wwwroot') . 'view/view.php?id=' . $data->view .
'&artefact=' . $data->annotation .
(isset($data->block) ? '&block=' . $data->block : '');
$smarty = smarty_core();
......@@ -1139,6 +1138,7 @@ class ArtefactTypeAnnotationfeedback extends ArtefactType {
$block = new BlockInstance($blockid);
$smarty->assign('blockid', $blockid);
$smarty->assign('artefactid', $annotationartefact->get('id'));
$smarty->assign('annotationtitle', $block->get('title'));
$smarty->assign('annotationfeedbackcount', $annotationfeedbackcount);
$smarty->assign('annotationfeedback', $annotationfeedback);
......@@ -1613,7 +1613,7 @@ function delete_annotation_feedback_submit(Pieform $form, $values) {
$viewid = $view->get('id');
if ($artefactid = $annotation->get('artefact')) {
$url = 'artefact/artefact.php?view=' . $viewid . '&artefact=' . $artefactid;
$url = 'view/view.php?id=' . $viewid . '&artefact=' . $artefactid;
}
else {
$url = $view->get_url(false);
......@@ -1959,7 +1959,7 @@ class ActivityTypeArtefactAnnotationAnnotationfeedback extends ActivityTypePlugi
$institutionid = $artefactinstance->get('institution');
}
if (empty($this->url)) {
$this->url = 'artefact/artefact.php?artefact=' . $onartefact . '&view=' . $this->viewid;
$this->url = 'view/view.php?id=' . $this->viewid . '&artefact=' . $onartefact;
}
}
else if ($onview = $annotation->get('view')) {
......
......@@ -54,7 +54,7 @@ if (!empty($ancestors)) {
$pathitem = artefact_instance_from_id($ancestor);
if (artefact_in_view($pathitem, $viewid)) {
$artefactpath[] = array(
'url' => get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $pathitem->get('id') . '&view=' . $viewid,
'url' => get_config('wwwroot') . 'view/view.php?id=' . $viewid,
'title' => $pathitem->display_title(),
);
$artefactok = true;
......
......@@ -41,7 +41,7 @@ class PluginBlocktypeBlog extends MaharaCoreBlocktype {
public static function get_link(BlockInstance $instance) {
$configdata = $instance->get('configdata');
if (!empty($configdata['artefactid'])) {
$data = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $configdata['artefactid'] . '&view=' . $instance->get('view');
$data = get_config('wwwroot') . 'view/view.php?id=' . $instance->get('view') . '&modal=1&block=' . $instance->get('id') . '&artefact=' . $configdata['artefactid'];
return sanitize_url($data);
}
}
......
......@@ -30,6 +30,7 @@ if ($blockid = param_integer('block', null)) {
$configdata['countcomments'] = true;
$configdata['versioning'] = false;
$configdata['viewid'] = $bi->get('view');
$configdata['blockid'] = $blockid;
$posts = ArtefactTypeBlogpost::get_posts($configdata['artefactid'], $limit, $offset, $configdata);
$template = 'artefact:blog:viewposts.tpl';
$baseurl = $bi->get_view()->get_url();
......
......@@ -44,6 +44,7 @@ class PluginBlocktypeComment extends MaharaCoreBlocktype {
if ($editing) {
$smarty = smarty_core();
$smarty->assign('editing', get_string('ineditordescription1', 'blocktype.comment/comment'));
$smarty->assign('blockid', $instance->get('id'));
$html = $smarty->fetch('blocktype:comment:comment.tpl');
return $html;
}
......
......@@ -30,16 +30,20 @@ $limit = param_integer('limit', 10);
$offset = param_integer('offset');
$artefact = null;
$blockid = null;
if (!empty($extradata->artefact)) {
$artefact = artefact_instance_from_id($extradata->artefact);
}
if (!empty($extradata->blockid)) {
$blockid = $extradata->blockid;
}
$view = new View($extradata->view);
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->limit = $limit;
$commentoptions->offset = $offset;
$commentoptions->view = $view;
$commentoptions->artefact = $artefact;
$commentoptions->blockid = $blockid;
$data = ArtefactTypeComment::get_comments($commentoptions);
json_reply(false, array('data' => $data));
......@@ -16,7 +16,10 @@ $string['Comment'] = 'Comment';
$string['Comments'] = 'Comments';
$string['comment'] = 'comment';
$string['comments'] = 'comments';
$string['Details'] = 'Details';
$string['anddetails'] = 'and details';
$string['addcomment'] = 'Add comment';
$string['commentsanddetails'] = 'Comments (%d) and details';
$string['Allow'] = 'Allow';
$string['allowcomments'] = 'Allow comments';
$string['approvalrequired'] = 'Comments are moderated. If you choose to make this comment public, it will not be visible to others until it is approved by the owner.';
......
......@@ -355,6 +355,7 @@ class ArtefactTypeComment extends ArtefactType {
$sortorder = get_user_institution_comment_sort_order();
$options->sort = (!empty($sortorder)) ? $sortorder : 'earliest';
$options->threaded = null;
$options->blockid = null;
return $options;
}
......@@ -367,6 +368,7 @@ class ArtefactTypeComment extends ArtefactType {
*/
public static function get_comments($options) {
global $USER;
$allowedoptions = self::get_comment_options();
// set the object's key/val pairs as variables
foreach ($options as $key => $option) {
......@@ -541,6 +543,7 @@ class ArtefactTypeComment extends ArtefactType {
// check to see if the comments are to be displayed in a block instance
// or the base of the page
$result->position = 'base';
$result->blockid = isset($options->blockid) ? $options->blockid : null;
$blocks = get_records_array('block_instance', 'view', $viewid);
if (!empty($blocks)) {
foreach ($blocks as $block) {
......@@ -550,6 +553,7 @@ class ArtefactTypeComment extends ArtefactType {
}
}
$result->baseplacement = $result->artefact ? false : true;
self::build_html($result, $onview);
return $result;
}
......@@ -698,6 +702,7 @@ class ArtefactTypeComment extends ArtefactType {
$commentoptions->view = $view;
$commentoptions->artefact = $artefact;
$commentoptions->onview = true;
$commentoptions->blockid = $blockid;
$comments = ArtefactTypeComment::get_comments($commentoptions);
$commentcount = isset($comments->count) ? $comments->count : 0;
......@@ -706,13 +711,9 @@ class ArtefactTypeComment extends ArtefactType {
return array(0, '');
}
$artefacttitle = $artefact->title;
$artefacturl = get_config('wwwroot') . 'artefact/artefact.php?view=' . $view->get('id') . '&artefact=' . $artefact->get('id');
if ($html) {
$smarty = smarty_core();
$smarty->assign('artefacturl', $artefacturl);
$smarty->assign('artefacttitle', $artefacttitle);
$smarty->assign('artefactid', $artefact->get('id'));
$smarty->assign('blockid', $blockid);
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
......@@ -800,7 +801,7 @@ class ArtefactTypeComment extends ArtefactType {
if ($check->submittedstatus == View::UNSUBMITTED ||
($item->canedit && $item->id == $lastcomment->id && $item->ts > $editableafter)
) {
$item->deleteform = pieform(self::delete_comment_form($item->id));
$item->deleteform = pieform(self::delete_comment_form($item->id, $data->blockid, $data->artefact, $data->threaded));
}
}
......@@ -873,14 +874,18 @@ class ArtefactTypeComment extends ArtefactType {
$extradata = array('view' => $data->view);
$data->jsonscript = 'artefact/comment/comments.json.php';
$data->baseurl = get_config('wwwroot') . 'view/view.php?id=' . $data->view;
if (!empty($data->blockid) && !empty($data->artefact)) {
$data->baseurl .= '&modal=1&block=' . $data->blockid . '&artefact=' . $data->artefact;
}
if (!empty($data->blockid)) {
$extradata['blockid'] = $data->blockid;
}
if (!empty($data->artefact)) {
$data->baseurl = get_config('wwwroot') . 'artefact/artefact.php?view=' . $data->view . '&artefact=' . $data->artefact;
$extradata['artefact'] = $data->artefact;
}
else {
$data->baseurl = get_config('wwwroot') . 'view/view.php?id=' . $data->view;
}
$smarty = smarty_core();
$smarty->assign('data', $data->data);
......@@ -893,15 +898,18 @@ class ArtefactTypeComment extends ArtefactType {
$smarty->assign('star', $icon ? $icon : 'star');
$colour = get_config_plugin('artefact', 'comment', 'ratingcolour');
$smarty->assign('colour', $colour ? $colour : '#DBB80E');
$blockid = !empty($data->blockid) ? $data->blockid : null;
$smarty->assign('blockid', $blockid);
$data->tablerows = $smarty->fetch('artefact:comment:commentlist.tpl');
$id = 'feedback_pagination' . (($data->blockid) ? '_' . $data->blockid : '');
$datatable = 'feedbacktable' . (($data->blockid) ? '_' . $data->blockid : '');
$pagination = build_pagination(array(
'id' => 'feedback_pagination',
'id' => $id,
'class' => 'center',
'url' => $data->baseurl,
'jsonscript' => $data->jsonscript,
'datatable' => 'feedbacktable',
'datatable' => $datatable,
'count' => $data->count,
'limit' => $data->limit,
'offset' => $data->offset,
......@@ -919,18 +927,22 @@ class ArtefactTypeComment extends ArtefactType {
}
public static function add_comment_form($defaultprivate=false, $moderate=false) {
global $USER;
global $USER, $artefact, $block;
$form = array(
'name' => 'add_feedback_form',
'name' => $block ? 'add_feedback_form_' . $block->get('id') : 'add_feedback_form',
'method' => 'post',
'plugintype' => 'artefact',
'pluginname' => 'comment',
'jsform' => true,
'autofocus' => false,
'elements' => array(),
'validatecallback' => 'add_feedback_form_validate',
'successcallback' => 'add_feedback_form_submit',
'jssuccesscallback' => 'addFeedbackSuccess',
'jserrorcallback' => 'addFeedbackError',
);
if (!$USER->is_logged_in()) {
$form['spam'] = array(
'secret' => get_config('formsecret'),
......@@ -953,7 +965,9 @@ class ArtefactTypeComment extends ArtefactType {
'class' => ($USER->is_logged_in() ? 'hide-label' : ''),
'rows' => 5,
'cols' => 80,
'rules' => array('maxlength' => 1000000),
'rules' => array(
'maxlength' => 1000000
),
);
if (get_config_plugin('artefact', 'comment', 'commentratings')) {
$form['elements']['rating'] = array(
......@@ -990,6 +1004,23 @@ class ArtefactTypeComment extends ArtefactType {
'class' => 'btn-secondary',
'value' => array(get_string('Comment', 'artefact.comment'), get_string('cancel')),
);
if ($artefact) {
$form['elements']['commented_on_artefactid'] = array(
'type' => 'hidden',
'value' => $artefact->id,
);
}
if ($block) {
$form['elements']['commented_on_blockid'] = array(
'type' => 'hidden',
'value' => $block->get('id'),
);
$form['elements']['position'] = array(
'type' => 'hidden',
'value' => 'blockinstance',
);
}
// This is a placeholder where we can display the parent comment's text
// And also the strings we display when we are forcing a reply to be public or private
$snippet = smarty_core();
......@@ -1024,10 +1055,13 @@ class ArtefactTypeComment extends ArtefactType {
);
}
public static function delete_comment_form($id) {
public static function delete_comment_form($id, $blockid=null, $artefactid=null, $threaded=null) {
global $THEME;
return array(
$form = array(
'name' => 'delete_comment' . $id,
'jsform' => true,
'jssuccesscallback' => 'delete_comment_from_modal_submit',
'successcallback' => 'delete_comment_submit',
'renderer' => 'div',
'class' => 'form-as-button float-left delete-comment btn-group-item',
......@@ -1043,6 +1077,27 @@ class ArtefactTypeComment extends ArtefactType {
),
),
);
if ($blockid) {
$form['elements']['blockid'] = array(
'type' => 'hidden',
'value' => $blockid,
);
}
if ($artefactid) {
$form['elements']['artefactid'] = array(
'type' => 'hidden',
'value' => $artefactid,
);
}
if ($threaded) {
$form['elements']['threaded'] = array(
'type' => 'hidden',
'value' => $threaded,
);
}
return $form;
}
public function exportable() {
......@@ -1051,7 +1106,7 @@ class ArtefactTypeComment extends ArtefactType {
public function get_view_url($viewid, $showcomment=true, $full=true) {
if ($artefact = $this->get('onartefact')) {
$url = 'artefact/artefact.php?view=' . $viewid . '&artefact=' . $artefact;
$url = 'view/view.php?id=' . $viewid . '&artefact=' . $artefact;
}
else {
$url = 'view/view.php?id=' . $viewid;
......@@ -1460,12 +1515,8 @@ function delete_comment_submit(Pieform $form, $values) {
}
$viewid = $view->get('id');
if ($artefact = $comment->get('onartefact')) {
$url = 'artefact/artefact.php?view=' . $viewid . '&artefact=' . $artefact;
}
else {
$url = $view->get_url(false);
}
$artefact = $comment->get('onartefact');
$url = $view->get_url(false);
// If this page is being marked, make comments un-deletable until released
// unless it is the last comment still with in the editable timeframe
......@@ -1540,10 +1591,33 @@ function delete_comment_submit(Pieform $form, $values) {
require_once('embeddedimage.php');
EmbeddedImage::delete_embedded_images('comment', $comment->get('id'));
db_commit();
}
if ( isset($values['blockid']) && isset($values['artefactid']) ) {
$block = new BlockInstance($values['blockid']);
$blockid = $values['blockid'];
$artefact = $block->get_artefact_instance($values['artefactid']);
}
else {
$artefact = null;
$blockid = null;
}
$SESSION->add_ok_msg(get_string('commentremoved', 'artefact.comment'));
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->view = $view;
$commentoptions->artefact = $artefact;
$commentoptions->blockid = $blockid;
if (isset($values['threaded'])) {
$commentoptions->threaded = $values['threaded'];
}
redirect(get_config('wwwroot') . $url);
$newlist = ArtefactTypeComment::get_comments($commentoptions);
$form->json_reply(PIEFORM_OK, array(
'message' => get_string('commentremoved', 'artefact.comment'),
'goto' => $url,
'data' => $newlist,
));
}
function add_feedback_form_validate(Pieform $form, $values) {
......@@ -1638,13 +1712,14 @@ function add_feedback_form_validate(Pieform $form, $values) {
}
function add_feedback_form_submit(Pieform $form, $values) {
global $view, $artefact, $USER;
require_once('embeddedimage.php');
global $view, $artefact, $block, $USER;
require_once('embeddedimage.php');
$data = (object) array(
'title' => get_string('Comment', 'artefact.comment'),
'description' => ArtefactTypeComment::remove_comments_classes($values['message']),
);
if ($artefact) {
$data->onartefact = $artefact->get('id');
$data->owner = $artefact->get('owner');
......@@ -1868,9 +1943,16 @@ function add_feedback_form_submit(Pieform $form, $values) {
$commentoptions->showcomment = $comment->get('id');
$commentoptions->view = $view;
$commentoptions->artefact = $artefact;
$commentoptions->blockid = ($block) ? $block->get('id') : null;
$newlist = ArtefactTypeComment::get_comments($commentoptions);
$newlist->updatelink = $updatelink;
$newlist->commentlink = ' ' . get_string('commentsanddetails', 'artefact.comment', $newlist->count);
if ($block) {
$newlist->blockid = $block->get('id');
}
// If you're anonymous and your message is moderated or private, then you won't
// be able to tell what happened to it. So we'll provide some more explanation in
// the comment message.
......@@ -1925,7 +2007,7 @@ class ActivityTypeArtefactCommentFeedback extends ActivityTypePlugin {
$institutionid = $artefactinstance->get('institution');
}
if (empty($this->url)) {
$this->url = 'artefact/artefact.php?artefact=' . $onartefact . '&view=' . $this->viewid;
$this->url = 'view/view.php?id=' . $this->viewid;
}
}
else { // comment on page.
......
......@@ -27,6 +27,8 @@ class PluginBlocktypeFiledownload extends MaharaCoreBlocktype {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
require_once(get_config('docroot') . 'artefact/comment/lib.php');
$configdata = $instance->get('configdata');
$viewid = $instance->get('view');
......@@ -41,6 +43,8 @@ class PluginBlocktypeFiledownload extends MaharaCoreBlocktype {
catch (ArtefactNotFoundException $e) {
continue;
}
$view = new View($viewid);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
$file = array(
'id' => $artefactid,
......@@ -55,6 +59,7 @@ class PluginBlocktypeFiledownload extends MaharaCoreBlocktype {
array('id' => $artefactid, 'viewid' => $viewid)
),
'downloadurl' => $wwwroot,
'commentcount' => $commentcount,
);
if ($artefact instanceof ArtefactTypeProfileIcon) {
......@@ -70,7 +75,9 @@ class PluginBlocktypeFiledownload extends MaharaCoreBlocktype {
$smarty = smarty_core();
$smarty->assign('viewid', $instance->get('view'));
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('files', $files);
$smarty->assign('editing', $editing);
return $smarty->fetch('blocktype:filedownload:filedownload.tpl');
}
......
......@@ -43,6 +43,7 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
$configdata = $instance->get('configdata');
$configdata['viewid'] = $instance->get('view');
$configdata['simpledisplay'] = true;
$configdata['blockid'] = $instance->get('id');
// This can be either an image or profileicon. They both implement
// render_self
......
......@@ -361,7 +361,7 @@ class PluginBlocktypeGallery extends MaharaCoreBlocktype {
$link = $src . '&maxwidth=' . get_config_plugin('blocktype', 'gallery', 'previewwidth');
}
else {
$link = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $artefactid . '&view=' . $instance->get('view');
$link = get_config('wwwroot') . 'view/view.php?id=' . $instance->get('view') . '&modal=1&block=' . $instance->get('id') .' &artefact=' . $artefactid;
}
// If the Thumbnails are Square or not...
......
......@@ -63,12 +63,14 @@ class PluginBlocktypeImage extends MaharaCoreBlocktype {
$view = new View($viewid);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($image, $view, $instance->get('id'), true, $editing, $versioning);
$smarty = smarty_core();
$smarty->assign('editing', $editing);
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
$smarty->assign('url', $wwwroot . 'artefact/artefact.php?artefact=' . $id . '&view=' . $viewid);
$smarty->assign('src', $src);
$smarty->assign('description', $description);
$smarty->assign('showdescription', !empty($configdata['showdescription']) && !empty($description));
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('artefactid', $id);
return $smarty->fetch('blocktype:image:image.tpl');
}
......
......@@ -13,6 +13,7 @@ defined('INTERNAL') || die();
$string['pluginname'] = 'Files';
$string['commentsanddetails'] = 'Comments (%d) and details';
$string['sitefilesloaded'] = 'Site files loaded';
$string['addafile'] = 'Add a file';
$string['archive'] = 'Archive';
......
......@@ -2191,6 +2191,7 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
}
$smarty->assign('children', $childrecords);
}
$smarty->assign('blockid', $options['blockid']);
return array('html' => $smarty->fetch('artefact:file:folder_render_self.tpl'),
'javascript' => null);
}
......@@ -2476,12 +2477,15 @@ class ArtefactTypeImage extends ArtefactTypeFile {
public function render_self($options) {
$downloadpath = get_config('wwwroot') . 'artefact/file/download.php?file=' . $this->id;
$url = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $this->id;
if (isset($options['viewid'])) {
$downloadpath .= '&view=' . $options['viewid'];
$url .= '&view=' . $options['viewid'];
}
$metadataurl = $url . '&details=1';
if (isset($options['viewid'])) {
$metadataurl = get_config('wwwroot') . 'view/view.php?id=' . $options['viewid'] . '&modal=1&artefact=' . $this->id;
}
else {
$metadataurl = null;
}
if (empty($options['metadata'])) {
$smarty = smarty_core();
$smarty->assign('id', $this->id);
......
......@@ -53,7 +53,6 @@ class PluginBlocktypeTextbox extends MaharaCoreBlocktype {
$f = artefact_instance_from_id($attachment->id);
$attachment->size = $f->describe_size();
$attachment->iconpath = $f->get_icon(array('id' => $attachment->id, 'viewid' => isset($options['viewid']) ? $options['viewid'] : 0));
$attachment->viewpath = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $attachment->id . '&view=' . (isset($viewid) ? $viewid : 0);
$attachment->downloadpath = get_config('wwwroot') . 'artefact/file/download.php?file=' . $attachment->id;
if (isset($viewid)) {
$attachment->downloadpath .= '&view=' . $viewid;
......
......@@ -1000,7 +1000,6 @@ class ArtefactTypeHtml extends ArtefactType {
$f = artefact_instance_from_id($attachment->id);
$attachment->size = $f->describe_size();
$attachment->iconpath = $f->get_icon(array('id' => $attachment->id, 'viewid' => isset($options['viewid']) ? $options['viewid'] : 0));
$attachment->viewpath = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $attachment->id . '&view=' . (isset($options['viewid']) ? $options['viewid'] : 0);
$attachment->downloadpath = get_config('wwwroot') . 'artefact/file/download.php?file=' . $attachment->id;
if (isset($options['viewid'])) {
$attachment->downloadpath .= '&view=' . $options['viewid'];
......@@ -1009,6 +1008,7 @@ class ArtefactTypeHtml extends ArtefactType {
$smarty->assign('attachments', $attachments);
}
$smarty->assign('view', (isset($options['viewid']) ? $options['viewid'] : null));
$smarty->assign('modal', (isset($options['modal']) ? $options['modal'] : false));
return array(
'html' => $smarty->fetch('artefact.tpl'),
'javascript'=>''
......
......@@ -1365,8 +1365,8 @@ class BlockInstance {
$configdata = $this->get('configdata');
if (!empty($configdata['artefactid']) && $displayforrole) {
if (call_static_method($classname, 'has_title_link')) {
$smarty->assign('viewartefacturl', get_config('wwwroot') . 'artefact/artefact.php?artefact='
. $configdata['artefactid'] . '&view=' . $this->get('view') . '&block=' . $this->get('id'));
$smarty->assign('blockid', $this->get('id'));
$smarty->assign('artefactid', $configdata['artefactid']);
}
}
......@@ -1389,6 +1389,36 @@ class BlockInstance {
$cardicontype = !empty($cssicontype) ? preg_replace('/^icon-/', 'card-', $cssicontype) : '';
$smarty->assign('cardicontype', $cardicontype);
$smarty->assign('versioning', $versioning);
/* Apply the comments and details header via template to these types of blocks only
* These blocks have one artefact per block, for blocks with multiple artefacts
* the header will be added elsewhere via their specific templates
*/
$includetheseblocks = array('image', 'textbox');
$blockheader = (in_array($this->get('blocktype'), $includetheseblocks)) ? true : false;
$smarty->assign('blockheader', $blockheader);
//Set up template for the blocks that have the comments and details header
if ($blockheader) {
if (!empty($configdata['artefactid'])) {
$smarty->assign('artefactid', $configdata['artefactid']);
$artefact = $this->get_artefact_instance($configdata['artefactid']);
$smarty->assign('allowcomments', $artefact->get('allowcomments'));
if (!$artefact->get('allowcomments')) {
$smarty->assign('allowdetails', (int)get_config('licensemetadata'));
}
else {
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->limit = 0;
$commentoptions->view = new View($this->get('view'));
$commentoptions->artefact = $artefact;
$commentoptions->onview = true;
$commentoptions->blockid = $this->get('id');
$comments = ArtefactTypeComment::get_comments($commentoptions);
$commentcount = isset($comments->count) ? $comments->count : 0;
$smarty->assign('commentcount', $commentcount);
}
}
}
return $smarty->fetch('view/blocktypecontainerviewing.tpl');
}
......
......@@ -93,7 +93,16 @@ if ($group->public) {
$javascript = array('paginator');
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
$inlinejs = "jQuery( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
$inlinejs = <<<JS
jQuery(function($) {
JS;
$inlinejs .= join("\n", $blocktype_js['initjs']) . "\n";
$inlinejs .= <<<JS
// Disable the modal_links for images etc... when page loads
$('a[class*=modal_link], a[class*=inner-link]').addClass('no-modal');
$('a[class*=modal_link], a[class*=inner-link]').css('cursor', 'default');
});
JS;
$headers = array_merge($headers, $view->get_all_blocktype_css());
......
......@@ -78,6 +78,10 @@ jQuery(function($) {
if ($('#hideinfo').length) {
$('#hideinfo').on('click', nevershow);
}
// Disable the modal_links for images etc... when page loads
$('a[class*=modal_link], a[class*=inner-link]').addClass('no-modal');
$('a[class*=modal_link], a[class*=inner-link]').css('cursor', 'default');
});
JAVASCRIPT;
......
......@@ -13,25 +13,51 @@
* This shows the tinymce editor and error message
*/
function addFeedbackError(form, data) {
if (isTinyMceUsed()) {
if (isTinyMceUsed() && $('#configureblock').hasClass('closed')) {
var mce = tinyMCE.get('add_feedback_form_message');
mce.show();
jQuery('.mce-toolbar.mce-first').siblings().toggleClass('d-none');
mce.focus();
}
if (jQuery('#feedback-form').hasClass('modal-docked')) {
jQuery('#feedback-form').removeClass('closed').addClass('active');
// The comment block modal will try to close but since it has errors keep it open
if (form['id'] == 'add_feedback_form') {
if (jQuery('#feedback-form').hasClass('modal-docked')) {
jQuery('#feedback-form').removeClass('closed').addClass('active');