Commit 44fcc9c9 authored by Lisa Seeto's avatar Lisa Seeto

Bug 1827811: Folder Task

This change adds modal functionality for folders and nested folders
add javascript to the folder_render_self template.
add new class to make space between icon and title/ metadata in modals
fix blockid warning message error
added folder_render_in_modal.tpl to fix duplicate js script issues interferring with js events
creaeted toggleDetailsBtn() to handle js issues
get rid of old style comments link from showing up.
turn off click functions so json sendrequest doesn't call a billion times.
explicitly call dock.show() in the open_modal func.

Change-Id: I938f98c33479a80afc8f940038ed81a3c84ce4ff
Signed-off-by: default avatarLisa Seeto <lisaseeto@catalyst.net.nz>
parent 79201b7d
......@@ -60,10 +60,6 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
}
$smarty = smarty_core();
if ($artefactid) {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:folder:folder.tpl');
}
......
......@@ -2191,8 +2191,15 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
}
$smarty->assign('children', $childrecords);
}
$smarty->assign('blockid', $options['blockid']);
return array('html' => $smarty->fetch('artefact:file:folder_render_self.tpl'),
if (isset($options['blockid'])) {
$smarty->assign('blockid', $options['blockid']);
}
$template = 'artefact:file:folder_render_self.tpl';
if (isset($options['modal'])) {
$smarty->assign('modal', $options['modal']);
$template = 'artefact:file:folder_render_in_modal.tpl';
}
return array('html' => $smarty->fetch($template),
'javascript' => null);
}
......
......@@ -182,6 +182,8 @@ function open_modal(e) {
$('#modal_messages').html('').removeClass();
var block = $('#configureblock');
dock.show(block, false, false);
var params = {
'viewid': viewid,
'artefactid': $(e.target).closest('a').data('artefactid'),
......@@ -210,22 +212,23 @@ function open_modal(e) {
}
function delete_comment_from_modal_submit(form, data) {
if (!data.data.artefact) {
paginator.updateResults(data);
paginator.alertProxy('pagechanged', data);
}
var params = {
'viewid': viewid,
'artefactid': data.data['artefact'],
'blockid': data.data['blockid'],
}
tinymce.EditorManager.execCommand('mceRemoveEditor',true, $('#configureblock').find('textarea.wysiwyg').attr('id'));
sendjsonrequest(config['wwwroot'] + 'view/viewblocks.json.php', params, 'POST', function(data) {
$('#configureblock').find('h4').text(data.title);
$('.blockinstance-content').html(data.html);
set_up_modal_events();
if (!data.data.artefact) {
paginator.updateResults(data);
paginator.alertProxy('pagechanged', data);
}
var params = {
'viewid': viewid,
'artefactid': data.data['artefact'],
'blockid': data.data['blockid'],
}
if (!data.data['artefact']) {
params['artefactid'] = form.artefactid.value;
}
tinymce.EditorManager.execCommand('mceRemoveEditor',true, $('#configureblock').find('textarea.wysiwyg').attr('id'));
sendjsonrequest(config['wwwroot'] + 'view/viewblocks.json.php', params, 'POST', function(data) {
$('#configureblock').find('h4').text(data.title);
$('.blockinstance-content').html(data.html);
set_up_modal_events();
$('.feedbacktable').on('click', '.js-reply', null, function(e){
var replybutton = $(this);
......@@ -315,9 +318,9 @@ function setupCommentButton(element) {
}
}
jQuery(function($) {
// Show/Hide the comments and details block headers
// Show/Hide the comments and details block headers
function toggleDetailsBtn() {
$('#details-btn').off('click');
$('#details-btn').on('click', function(e) {
var headers = $('#main-column-container').find('.block-header');
......@@ -332,6 +335,11 @@ jQuery(function($) {
$('.comments-details').addClass('d-none');
}
});
}
jQuery(function($) {
toggleDetailsBtn();
// Watchlist
if ($('#toggle_watchlist_link').length) {
......
{if $description}
<div class="content-text">
{$description}
</div>
{/if}
{if $tags}
<div class="tags">
<strong>{str tag=tags}</strong>:
{list_tags owner=$owner tags=$tags view=$viewid}
</div>
{/if}
<div id="commentfiles" class="folder-card">
{if (isset($children))}
<h4 class="sr-only">
{str tag=foldercontents section=artefact.file}:
</h4>
<div class="fullwidth">
<ul class="list-group">
{foreach from=$children item=child}
<li class="filedownload-item list-group-item">
{if $child->artefacttype != 'folder'}
<a href="{$WWWROOT}artefact/file/download.php?file={$child->id}&amp;view={$viewid}" class="outer-link icon-on-hover">
<span class="sr-only">
{str tag=Details section=artefact.file}
{$child->title}
</span>
</a>
{/if}
{if $child->iconsrc}
<img src="{$child->iconsrc}" alt="{$child->artefacttype}" class="file-icon text-inline {if $modal}file-icon-render-in-modal{/if}">
{else}
<span class="icon icon-{$child->artefacttype} icon-lg left {if $modal}file-icon-render-in-modal{/if}" role="presentation" aria-hidden="true"></span>
{/if}
<h4 class="title list-group-item-heading text-inline">
<a class="modal_link inner-link" title="{$child->hovertitle}" data-toggle="modal-docked" data-target="#configureblock" href="#" data-blockid="{$blockid}" data-artefactid="{$child->id}">
{$child->title}
</a>
{if !$simpledisplay}
<span class="filedate metadata">
{$child->date}
</span>
{/if}
</h4>
{if $child->artefacttype != 'folder'}
<span class="icon icon-download icon-lg float-right text-watermark icon-action" role="presentation" aria-hidden="true"></span>
{/if}
{if $child->description}
<p class="file-description text-small text-midtone">
{$child->description|safe|clean_html}
</p>
<script>
jQuery(".file-description a").addClass('inner-link');
</script>
{/if}
</li>
{/foreach}
</ul>
</div>
{if $downloadfolderzip}
<a href="{$WWWROOT}artefact/file/downloadfolder.php?folder={$folderid}&view={$viewid}" class="link-blocktype">
<span class="icon icon-download left" role="presentation" aria-hidden="true"></span>
{str tag=downloadfolderziplink section=artefact.file}
</a>
{/if}
{else}
<span class="lead text-small">
{str tag=emptyfolder section=artefact.file}
</span>
{/if}
</div>
<script>
jQuery('.modal_link').off('click');
jQuery('.modal_link').on('click', function(e) {
open_modal(e);
toggleDetailsBtn();
});
</script>
......@@ -60,6 +60,9 @@ $width-sm: 90%;
&.blockinstance-content {
padding: 0 15px;
}
.file-icon-render-in-modal {
margin-left: 10px;
}
}
.modal-dialog {
height: 100%;
......
......@@ -393,6 +393,7 @@ jQuery(function($) {
dock.hide();
}
$('.commentlink').off('click');
$('.commentlink').on('click', function(e) {
open_modal(e);
if ( $(this).closest('div[class*=block-header]').hasClass('bh-displayiconsonly') ) {
......@@ -401,9 +402,9 @@ jQuery(function($) {
else {
$(this).closest('div[class*=block-header]').addClass('active-block');
}
});
$('.modal_link').off('click');
$('.modal_link').on('click', function (e) {
if ($(this).hasClass('no-modal')) {
e.stopPropagation();
......@@ -437,11 +438,13 @@ jQuery(function($) {
jQuery(window).on('pageupdated', {}, function() {
dock.init(jQuery(document));
$('.commentlink').off('click');
$('.commentlink').on('click', function(e) {
open_modal(e);
$(this).closest('div[class*=block-header]').addClass('active-block');
});
$('.modal_link').off('click');
$('.modal_link').on('click', function (e) {
if ($(this).hasClass('no-modal')) {
e.stopPropagation();
......@@ -461,6 +464,7 @@ if ($modal = param_integer('modal', null)) {
$javascript .= <<<EOF
jQuery(function($) {
$('#main-column-container').append('<a id="tmp_modal_link" class="modal_link" href="#" data-toggle="modal-docked" data-target="#configureblock" data-blockid="' + $block + '" data-artefactid="' + $artefact + '" ></a>');
$('a#tmp_modal_link').off('click');
$('a#tmp_modal_link').on('click', function(e) {
open_modal(e);
$('#configureblock').addClass('active').removeClass('closed');
......@@ -473,6 +477,7 @@ EOF;
$javascript .= <<<EOF
jQuery(function($) {
$('#main-column-container').append('<a id="tmp_modal_link" class="modal_link" href="#" data-toggle="modal-docked" data-target="#configureblock" data-artefactid="' + $artefact + '" ></a>');
$('a#tmp_modal_link').off('click');
$('a#tmp_modal_link').on('click', function(e) {
open_modal(e);
$('#configureblock').addClass('active').removeClass('closed');
......
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