Commit b1351b96 authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review

Merge "Fix editnote artefactchooser (BUG 1465107)"

parents 0aab5f2d 2ecddb95
......@@ -142,26 +142,19 @@ function updateTextContent(a) {
jQuery('#instconf_tagsreadonly_display').innerHTML = a.safetags;
jQuery('#instconf_makecopy').prop('checked', false);
if (a.editable == 1) {
jQuery('#instconf_textreadonly_header').addClass('hidden');
jQuery('#instconf_textreadonly_container').addClass('hidden');
jQuery('#instconf_readonlymsg_container').addClass('hidden');
jQuery('#instconf_licensereadonly_header').addClass('hidden');
jQuery('#instconf_licensereadonly_container').addClass('hidden');
jQuery('#instconf_tagsreadonly_header').addClass('hidden');
jQuery('#instconf_tagsreadonly_container').addClass('hidden');
jQuery('#instconf_text_header').removeClass('hidden');
jQuery('#instconf_text_container').removeClass('hidden');
if (jQuery('#instconf_license_header').length) {
if (jQuery('#instconf_license_container').length) {
// only deal with these if the license metadata is enabled
jQuery('#instconf_license_header').removeClass('hidden');
jQuery('#instconf_license_container').removeClass('hidden');
jQuery('#instconf_license_description').removeClass('hidden');
jQuery('#instconf_license_advanced_fieldset').removeClass('hidden');
}
jQuery('#instconf_tags_header').removeClass('hidden');
jQuery('#instconf_tags_container').removeClass('hidden');
jQuery('#instconf_tags_description').removeClass('hidden');
var blockcountmsg = jQuery('#instconf_otherblocksmsg_container');
if (blockcountmsg && jQuery('#textbox_blockcount')) {
var otherblockcount = 0;
......@@ -195,25 +188,19 @@ function updateTextContent(a) {
}
}
else {
jQuery('#instconf_text_header').addClass('hidden');
jQuery('#instconf_text_container').addClass('hidden');
jQuery('#instconf_otherblocksmsg_container').addClass('hidden');
if (jQuery('#instconf_license_header').length) {
if (jQuery('#instconf_license_container').length) {
// only deal with these if the license metadata is enabled
jQuery('#instconf_license_header').addClass('hidden');
jQuery('#instconf_license_container').addClass('hidden');
jQuery('#instconf_license_description').addClass('hidden');
jQuery('#instconf_license_advanced_fieldset').addClass('hidden');
}
jQuery('#instconf_tags_header').addClass('hidden');
jQuery('#instconf_tags_container').addClass('hidden');
jQuery('#instconf_tags_description').addClass('hidden');
jQuery('#instconf_textreadonly_header').removeClass('hidden');
jQuery('#instconf_textreadonly_container').removeClass('hidden');
jQuery('#instconf_readonlymsg_container').removeClass('hidden');
jQuery('#instconf_licensereadonly_header').removeClass('hidden');
jQuery('#instconf_licensereadonly_container').removeClass('hidden');
jQuery('#instconf_tagsreadonly_header').removeClass('hidden');
jQuery('#instconf_tagsreadonly_container').removeClass('hidden');
}
}
......@@ -237,24 +224,18 @@ forEach(getElementsByTagAndClassName('a', 'copytextboxnote', 'instconf'), functi
}
});
jQuery('#instconf_makecopy').prop('checked', true);
jQuery('#instconf_textreadonly_header').addClass('hidden');
jQuery('#instconf_textreadonly_container').addClass('hidden');
jQuery('#instconf_readonlymsg_container').addClass('hidden');
jQuery('#instconf_otherblocksmsg_container').addClass('hidden');
jQuery('#instconf_licensereadonly_header').addClass('hidden');
jQuery('#instconf_licensereadonly_container').addClass('hidden');
jQuery('#instconf_tagsreadonly_header').addClass('hidden');
jQuery('#instconf_tagsreadonly_container').addClass('hidden');
jQuery('#instconf_text_header').removeClass('hidden');
jQuery('#instconf_text_container').removeClass('hidden');
if (jQuery('#instconf_license_header').length) {
if (jQuery('#instconf_license_container').length) {
// only deal with these if the license metadata is enabled
jQuery('#instconf_license_header').removeClass('hidden');
jQuery('#instconf_license_container').removeClass('hidden');
jQuery('#instconf_license_description').removeClass('hidden');
jQuery('#instconf_license_advanced_fieldset').removeClass('hidden');
}
jQuery('#instconf_tags_header').removeClass('hidden');
jQuery('#instconf_tags_container').removeClass('hidden');
jQuery('#instconf_tags_description').removeClass('hidden');
});
......@@ -263,12 +244,8 @@ augment_tags_control('instconf_tags');
if (jQuery('#instconf_license').length) {
jQuery('#instconf_license').removeClass('hidden');
}
if (jQuery('#instconf_license_advanced_fieldset').length) {
removeElementClass(getFirstElementByTagAndClassName('fieldset', null, 'instconf_license_advanced_fieldset'), 'hidden');
}
if (jQuery('#instconf_artefactids_upload_browse')) {
jQuery('#instconf_artefactids_upload_browse').addClass('hidden');
jQuery('#instconf_artefactids_open_upload_browse_container').removeClass('hidden');
if (jQuery('#instconf_license_advanced_container').length) {
removeElementClass(getFirstElementByTagAndClassName('div', null, 'instconf_license_advanced_container'), 'hidden');
}
EOF;
}
......@@ -344,16 +321,16 @@ EOF;
'otherblocksmsg' => array(
'type' => 'html',
'class' => 'message info' . (($otherblockcount && !$readonly) ? '' : ' hidden'),
'value' => $otherblocksmsg
. ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a>',
'value' => '<p class="alert alert-info">' . $otherblocksmsg
. ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a></p>',
'help' => true,
),
// Add a message whenever this text cannot be edited here
'readonlymsg' => array(
'type' => 'html',
'class' => 'message info' . ($readonly ? '' : ' hidden'),
'value' => get_string('readonlymessage', 'blocktype.internal/textbox')
. ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a>',
'value' => '<p class="alert alert-info">' . get_string('readonlymessage', 'blocktype.internal/textbox')
. ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a></p>',
'help' => true,
),
'text' => array(
......@@ -369,8 +346,7 @@ EOF;
'type' => 'html',
'class' => $readonly ? '' : 'hidden',
'title' => get_string('blockcontent', 'blocktype.internal/textbox'),
'width' => '100%',
'value' => '<div id="instconf_textreadonly_display">' . $text . '</div>',
'value' => '<div id="instconf_textreadonly_display" class="well text-medium">' . $text . '</div>',
),
'makecopy' => array(
'type' => 'checkbox',
......@@ -384,9 +360,9 @@ EOF;
),
'managenotes' => array(
'type' => 'html',
'class' => 'text-right hidden',
'value' => '<a href="' . $manageurl . '" target="_blank">'
. get_string('managealltextboxcontent1', 'blocktype.internal/textbox') . ' &raquo;</a>',
'class' => 'hidden text-right',
'value' => '<a href="' . $manageurl . '" target="_blank" class="pull-right">'
. get_string('managealltextboxcontent1', 'blocktype.internal/textbox') . ' <span class="icon icon-arrow-right pls"></span></a>',
),
'artefactid' => self::artefactchooser_element(isset($artefactid) ? $artefactid : null),
'license' => license_form_el_basic(isset($artefact) ? $artefact : null),
......@@ -394,7 +370,6 @@ EOF;
'licensereadonly' => array(
'type' => 'html',
'class' => $readonly ? '' : 'hidden',
'width' => '100%',
'title' => get_string('license'),
'value' => '<div id="instconf_licensereadonly_display">' . (isset($artefact) ? render_license($artefact) : get_string('licensenone')) . '</div>',
),
......@@ -406,7 +381,6 @@ EOF;
'tags' => array(
'type' => 'tags',
'class' => $readonly ? 'hidden' : '',
'width' => '100%',
'title' => get_string('tags'),
'description' => get_string('tagsdescprofile'),
'defaultvalue' => $tags,
......@@ -414,7 +388,6 @@ EOF;
'tagsreadonly' => array(
'type' => 'html',
'class' => $readonly ? '' : 'hidden',
'width' => '100%',
'title' => get_string('tags'),
'value' => '<div id="instconf_tagsreadonly_display">' . (is_array($tags) ? hsc(join(', ', $tags)) : '') . '</div>',
),
......@@ -425,7 +398,7 @@ EOF;
'legend' => get_string('attachments', 'artefact.blog'),
'class' => 'last mtl',
'elements' => array(
'artefactid' => self::filebrowser_element($instance, (isset($configdata['artefactids'])) ? $configdata['artefactids'] : null),
'artefactids' => self::filebrowser_element($instance, (isset($configdata['artefactids'])) ? $configdata['artefactids'] : null),
)
)
);
......
......@@ -88,14 +88,6 @@ function pieform_element_artefactchooser_get_value(Pieform $form, $element) {
return null;
}
//function pieform_element_artefactchooser_rule_required(Pieform $form, $value, $element) {
// if (is_array($value) && count($value)) {
// return null;
// }
//
// return $form->i18n('rule', 'required', 'required', $element);
//}
function pieform_element_artefactchooser_set_attributes($element) {
if (!isset($element['selectone'])) {
$element['selectone'] = true;
......@@ -214,42 +206,10 @@ if (ul) {
}
sendjsonrequest(p.jsonScript, queryData, 'GET', function(data) {
var tbody = getFirstElementByTagAndClassName('tbody', null, p.datatable);
if (tbody) {
if (
(document.all && document.documentElement && typeof(document.documentElement.style.maxHeight) != "undefined" && !window.opera)
||
(/Konqueror|AppleWebKit|KHTML/.test(navigator.userAgent))) {
var temp = DIV({'id':'ie-workaround'});
temp.innerHTML = '<table><tbody>' + data.data.tablerows + '</tbody></table>';
swapDOM(tbody, temp.childNodes[0].childNodes[0]);
}
else {
// This does not work in IE and Konqueror, the tbody
// innerHTML property is readonly.
// http://www.ericvasilik.com/2006/07/code-karma.html
tbody.innerHTML = data['data']['tablerows'];
}
}
// Use pagination.js to update search results
p.updateResults(data);
{$artefactchooserdata}
{$artefactchooserselect}
// Update the pagination
if ($(p.id)) {
var tmp = DIV();
tmp.innerHTML = data['data']['pagination'];
swapDOM(p.id, tmp.firstChild);
// Run the pagination js to make it live
eval(data['data']['pagination_js']);
// Update the result count
var results = getFirstElementByTagAndClassName('div', 'results', p.id);
if (results) {
results.innerHTML = data['data']['results'];
}
}
});
});
$('artefactchooser-searchfield').focus();
......
<div>
<div class="artefactchooser-item list-group-item list-group-item-default">
{$formcontrols|safe}
<label for="{$elementname}_{$artefact->id}">
{$artefact->title|str_shorten_text:60:true}
<label class="lead text-small mbs" for="{$elementname}_{$artefact->id}">
{$artefact->title|str_shorten_text:60:true}
</label>
{if $artefact->ownerurl}({str tag=by section=view}
{if $artefact->ownerurl}({str tag=by section=view}
<a href="{$artefact->ownerurl}" class="metadata">{$artefact->ownername}</a>)
{/if}
<div class="with-label text-small">
{$artefact->description|str_shorten_html:80:true|strip_tags|safe}
<div class="with-label text-small" for="{$elementname}_{$artefact->id}">
{$artefact->description|str_shorten_html:80:true|strip_tags|safe}
</div>
</div>
......@@ -2,23 +2,33 @@
<ul class="artefactchooser-tabs nav nav-tabs">
<li{if !$.request.s} class="current active"{/if}><a href="{$browseurl}">{str tag=Browse section=view}</a></li>
<li{if $.request.s} class="current active"{/if}><a href="{$searchurl}">{str tag=Search section=view}</a></li>
</ul>{/if}
</ul>
{/if}
<div id="artefactchooser-body">
<div class="cb artefactchooser-splitter">
<div id="artefactchooser-searchform" class="form-group {if !$.request.s} hidden{/if}"> {* Use a smarty var, not smarty.request *}
<label for="artefactchooser-searchfield">{str tag=search section=mahara}</label>
<div class="artefactchooser-splitter">
<div id="artefactchooser-searchform" class="input-group clearfix {if !$.request.s} hidden{/if} ptm pbm"> {* Use a smarty var, not smarty.request *}
<label class="sr-only" for="artefactchooser-searchfield">
{str tag=search section=mahara}
</label>
<input type="text" class="text form-control" id="artefactchooser-searchfield" name="search" value="{$.request.search}" tabindex="42">
<input type="hidden" name="s" value="1">
<button class="submit btn btn-primary" type="submit" id="artefactchooser-searchsubmit" name="action_acsearch_id_{$blockinstance}" tabindex="42">
{str tag=search}
</button>
<span class="input-group-btn">
<button class="submit btn btn-primary" type="submit" id="artefactchooser-searchsubmit" name="action_acsearch_id_{$blockinstance}" tabindex="42">
{str tag=search}
</button>
</span>
</div>
{if !$artefacts}
<p class=" ptm noartefacts lead text-small">{str tag=noartefactstochoosefrom section=view}</p>
{/if}
<div id="{$datatable}" class="artefactchooser-data form-group checkbox last">
<div id="{$datatable}" class="artefactchooser-data list-group list-group-lite pbl">
{if empty($artefacts)}
<span class="ptm noartefacts lead">
{str tag=noartefactstochoosefrom section=view}
</span>
{else}
{$artefacts|safe}
{/if}
</div>
{$pagination|safe}
</div>
</div>
\ No newline at end of file
</div>
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