mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-11 17:44:56 +00:00
folders and docs can be marked for batch operation
This commit is contained in:
parent
9f34304a41
commit
d271dfbf1f
|
@ -61,16 +61,39 @@ class SeedDMS_View_Search extends SeedDMS_Theme_Style {
|
|||
$(document).ready( function() {
|
||||
$('#export').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
window.location.href = $(this).attr('href')+'&includecontent='+($('#includecontent').prop('checked') ? '1' : '0');
|
||||
var url = "";
|
||||
url = $(this).attr('href')+'&includecontent='+($('#includecontent').prop('checked') ? '1' : '0');
|
||||
|
||||
var inputs = $('input[name^=\"marks\"]');
|
||||
var values = {};
|
||||
inputs.each(function() {
|
||||
console.log(this.name+'='+this.checked);
|
||||
if(this.checked)
|
||||
values[this.name] = 1;
|
||||
});
|
||||
url += '&'+$.param(values);
|
||||
window.location.href = url;
|
||||
});
|
||||
|
||||
$('#changeowner').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
window.location.href = $(this).attr('href')+'&newowner='+($('#newowner').val());
|
||||
var url = "";
|
||||
url = $(this).attr('href')+'&newowner='+($('#newowner').val());
|
||||
var inputs = $('input[name^=\"marks\"]');
|
||||
var values = {};
|
||||
inputs.each(function() {
|
||||
console.log(this.name+'='+this.checked);
|
||||
if(this.checked)
|
||||
values[this.name] = 1;
|
||||
});
|
||||
url += '&'+$.param(values);
|
||||
window.location.href = url;
|
||||
});
|
||||
});
|
||||
<?php
|
||||
// $this->printFolderChooserJs("form1");
|
||||
$this->printDeleteFolderButtonJs();
|
||||
$this->printMarkDocumentButtonJs();
|
||||
$this->printDeleteDocumentButtonJs();
|
||||
/* Add js for catching click on document in one page mode */
|
||||
$this->printClickDocumentJs();
|
||||
|
@ -83,11 +106,64 @@ $(document).ready(function() {
|
|||
<?php
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Print button with icon for marking a document
|
||||
*
|
||||
* @param object $document document to be marked
|
||||
* @param boolean $return return html instead of printing it
|
||||
* @return string html content if $return is true, otherwise an empty string
|
||||
*/
|
||||
function printMarkDocumentButton($document, $return=false){ /* {{{ */
|
||||
$docid = $document->getID();
|
||||
$content = '';
|
||||
$content .= '<br /><span class="mark-btn document-unmarked" title="'.getMLText('mark_document').'" rel="D'.$docid.'"><i class="fa fa-square-o"></i></span><input type="checkbox" id="marks_D'.$docid.'" name="marks[D'.$docid.']" value="1" style="display: none;">';
|
||||
if($return)
|
||||
return $content;
|
||||
else
|
||||
echo $content;
|
||||
return '';
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Print button with icon for marking a folder
|
||||
*
|
||||
* @param object $folder folder to be marked
|
||||
* @param boolean $return return html instead of printing it
|
||||
* @return string html content if $return is true, otherwise an empty string
|
||||
*/
|
||||
function printMarkFolderButton($folder, $return=false){ /* {{{ */
|
||||
$folderid = $folder->getID();
|
||||
$content = '';
|
||||
$content .= '<br /><span class="mark-btn folder-unmarked" title="'.getMLText('mark_folder').'" rel="F'.$folderid.'"><i class="fa fa-square-o"></i></span><input type="checkbox" id="marks_F'.$folderid.'" name="marks[F'.$folderid.']" value="1" style="display: none;">';
|
||||
if($return)
|
||||
return $content;
|
||||
else
|
||||
echo $content;
|
||||
return '';
|
||||
} /* }}} */
|
||||
|
||||
function printMarkDocumentButtonJs(){ /* {{{ */
|
||||
$url = $this->html_url('Search', array_merge($_GET, array('action'=>null)));
|
||||
echo "
|
||||
// ".$url."
|
||||
$(document).ready(function () {
|
||||
$('body').on('click', 'span.mark-btn', function(ev){
|
||||
ev.stopPropagation();
|
||||
id = $(ev.currentTarget).attr('rel');
|
||||
$('#marks_'+id).each(function () { this.checked = !this.checked; });
|
||||
$(this).parents('tr').toggleClass('table-info');
|
||||
$(this).find('i').toggleClass('fa-square-o fa-check-square-o')
|
||||
});
|
||||
});
|
||||
";
|
||||
} /* }}} */
|
||||
|
||||
function export() { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
$entries = $this->params['searchhits'];
|
||||
$includecontent = $this->params['includecontent'];
|
||||
$marks = $this->params['marks'];
|
||||
|
||||
include("../inc/inc.ClassDownloadMgr.php");
|
||||
$downmgr = new SeedDMS_Download_Mgr();
|
||||
|
@ -95,12 +171,14 @@ $(document).ready(function() {
|
|||
$downmgr->addHeader($extraheader);
|
||||
foreach($entries as $entry) {
|
||||
if($entry->isType('document')) {
|
||||
$extracols = $this->callHook('extraDownloadColumns', $entry);
|
||||
$filename = $this->callHook('filenameDownloadItem', $entry->getLatestContent());
|
||||
if($includecontent && $rawcontent = $this->callHook('rawcontent', $entry->getLatestContent())) {
|
||||
$downmgr->addItem($entry->getLatestContent(), $extracols, $rawcontent, $filename);
|
||||
} else
|
||||
$downmgr->addItem($entry->getLatestContent(), $extracols, null, $filename);
|
||||
if(empty($marks) || !empty($marks['D'.$entry->getId()])) {
|
||||
$extracols = $this->callHook('extraDownloadColumns', $entry);
|
||||
$filename = $this->callHook('filenameDownloadItem', $entry->getLatestContent());
|
||||
if($includecontent && $rawcontent = $this->callHook('rawcontent', $entry->getLatestContent())) {
|
||||
$downmgr->addItem($entry->getLatestContent(), $extracols, $rawcontent, $filename);
|
||||
} else
|
||||
$downmgr->addItem($entry->getLatestContent(), $extracols, null, $filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
$filename = tempnam(sys_get_temp_dir(), '');
|
||||
|
@ -129,16 +207,18 @@ $(document).ready(function() {
|
|||
$user = $this->params['user'];
|
||||
$entries = $this->params['searchhits'];
|
||||
$newowner = $this->params['newowner'];
|
||||
$marks = $this->params['marks'];
|
||||
|
||||
if($newowner && $user->isAdmin()) {
|
||||
$j = $i = 0;
|
||||
foreach($entries as $entry) {
|
||||
// if($entry->isType('document')) {
|
||||
$prefix = $entry->isType('document') ? 'D' : 'F';
|
||||
if(empty($marks) || !empty($marks[$prefix.$entry->getId()])) {
|
||||
if($entry->getOwner()->getId() != $newowner->getId()) {
|
||||
$entry->setOwner($newowner);
|
||||
$j++;
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
$this->setParam('batchmsg', getMLText('batch_new_owner_msg', ['count'=>$j]));
|
||||
} else {
|
||||
|
@ -210,7 +290,7 @@ function typeahead() { /* {{{ */
|
|||
$tmp['orderby'] = ($orderby=="d"||$orderby=="da") ? "dd" : "d";
|
||||
$headcol .= " <a href=\"../out/out.Search.php?".http_build_query($tmp)."\" title=\"".getMLText("sort_by_date")."\">".($orderby=="d"||$orderby=="da"?' <i class="fa fa-sort-amount-asc selected"></i>':($orderby=="dd"?' <i class="fa fa-sort-amount-desc selected"></i>':' <i class="fa fa-sort-amount-asc"></i>'))."</a>";
|
||||
}
|
||||
return $headcol;
|
||||
return $headcol;
|
||||
} /* }}} */
|
||||
|
||||
function show() { /* {{{ */
|
||||
|
@ -271,7 +351,7 @@ function typeahead() { /* {{{ */
|
|||
//$this->contentHeading("<button class=\"btn btn-primary\" id=\"searchform-toggle\" data-toggle=\"collapse\" href=\"#searchform\"><i class=\"fa fa-exchange\"></i></button> ".getMLText('search'), true);
|
||||
$this->contentHeading(getMLText('search'), true);
|
||||
if($this->query) {
|
||||
echo "<div id=\"searchform\" class=\"_collapse mb-sm-4\">";
|
||||
echo "<div id=\"searchform\" class=\"_collapse mb-sm-4\">";
|
||||
}
|
||||
?>
|
||||
<ul class="nav nav-pills" id="searchtab">
|
||||
|
@ -858,6 +938,7 @@ function typeahead() { /* {{{ */
|
|||
$extracontent['below_title'] = $this->getListRowPath($document);
|
||||
if($attrstr)
|
||||
$extracontent['bottom_title'] = '<br />'.$this->printPopupBox('<span class="btn btn-mini btn-sm btn-secondary">'.getMLText('attributes').'</span>', $attrstr, true);
|
||||
$extracontent['end_action_list'] = $this->printMarkDocumentButton($document, true);
|
||||
|
||||
$txt = $this->callHook('documentListItem', $entry, $previewer, false, 'search', $extracontent);
|
||||
if(is_string($txt))
|
||||
|
@ -887,6 +968,7 @@ function typeahead() { /* {{{ */
|
|||
$extracontent['below_title'] = $this->getListRowPath($folder);
|
||||
if($attrstr)
|
||||
$extracontent['bottom_title'] = '<br />'.$this->printPopupBox('<span class="btn btn-mini btn-sm btn-secondary">'.getMLText('attributes').'</span>', $attrstr, true);
|
||||
$extracontent['end_action_list'] = $this->printMarkFolderButton($folder, true);
|
||||
print $this->folderListRow($folder, false, $extracontent);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user