add 'data-target-id' to folder and document rows in list

This will be used to specify the document associated to the row.
This commit is contained in:
Uwe Steinmann 2020-04-10 07:52:35 +02:00
parent 24925bf2de
commit 71a24bb826
2 changed files with 12 additions and 3 deletions

View File

@ -2281,7 +2281,9 @@ $('body').on('click', '[id^=\"table-row-document\"] td:nth-child(2)', function(e
?>
/* catch click on a document row in the list folders and documents */
$('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev) {
attr_id = $(ev.currentTarget).parent().attr('id').split('-')[3];
attr_id = $(ev.currentTarget).parent().data('target-id');
if(typeof attr_id == 'undefined')
attr_id = $(ev.currentTarget).parent().attr('id').split('-')[3];
window.location = '../out/out.ViewFolder.php?folderid=' + attr_id;
});
<?php
@ -2296,7 +2298,7 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
*/
function documentListRowStart($document, $class='') { /* {{{ */
$docID = $document->getID();
return "<tr id=\"table-row-document-".$docID."\" class=\"table-row-document droptarget ".($class ? ' '.$class : '')."\" data-droptarget=\"document_".$docID."\" rel=\"document_".$docID."\" formtoken=\"".createFormKey('')."\" draggable=\"true\" data-name=\"".htmlspecialchars($document->getName(), ENT_QUOTES)."\">";
return "<tr id=\"table-row-document-".$docID."\" data-target-id=\"".$docID."\" class=\"table-row-document droptarget ".($class ? ' '.$class : '')."\" data-droptarget=\"document_".$docID."\" rel=\"document_".$docID."\" formtoken=\"".createFormKey('')."\" draggable=\"true\" data-name=\"".htmlspecialchars($document->getName(), ENT_QUOTES)."\">";
} /* }}} */
function documentListRowEnd($document) { /* {{{ */

View File

@ -183,7 +183,14 @@ $('body').on('click', '#goto-parent', function(ev) {
});
/* catch click on a folder row in the list folders and documents */
$('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev) {
attr_id = $(ev.currentTarget).parent().attr('id').split('-')[3];
/* retrieve the id of the target folder either from data-target-id or
* from the id. Prefer data-target-id because the id is also used for identifying
* the table row when deleting the folder
* This was added for the internal_link extensіon
*/
attr_id = $(ev.currentTarget).parent().data('target-id');
if(typeof attr_id == 'undefined')
attr_id = $(ev.currentTarget).parent().attr('id').split('-')[3];
folderSelected(attr_id, '');
$([document.documentElement, document.body]).animate({
scrollTop: 200