make code theme independent, open confirm dialog for category change, check if category, user, docs are selected before opening confirm dialog

This commit is contained in:
Uwe Steinmann 2023-10-14 10:45:33 +02:00
parent a2676573a6
commit ec990ef1c5

View File

@ -54,14 +54,12 @@ class SeedDMS_View_Search extends SeedDMS_Theme_Style {
?>
$(document).ready( function() {
$('#export').on('click', function(e) {
e.preventDefault();
var url = "";
url = $(this).attr('href')+'&includecontent='+($('#includecontent').prop('checked') ? '1' : '0');
var inputs = $('input[name^=\"marks\"]');
$('#export').on('click', function(ev) {
ev.preventDefault();
ev.stopPropagation();
var url = $(this).attr('href')+'&includecontent='+($('#includecontent').prop('checked') ? '1' : '0');
var values = {};
inputs.each(function() {
$('input[name^=\"marks\"]').each(function() {
if(this.checked)
values[this.name] = 1;
});
@ -69,83 +67,46 @@ $(document).ready( function() {
window.location.href = url;
});
$('#changecategory').on('click', function(e) {
e.preventDefault();
var url = "";
url = $(this).attr('href')+'&changecategory='+$('#batchcategory').val()+'&removecategory='+($('#removecategory').prop('checked') ? '1' : '0');
var inputs = $('input[name^=\"marks\"]');
$('#changecategory').on('click', function(ev) {
ev.preventDefault();
ev.stopPropagation();
confirmmsg = $(ev.currentTarget).attr('confirmmsg');
var url = $(this).attr('href')+'&changecategory='+$('#batchcategory').val()+'&removecategory='+($('#removecategory').prop('checked') ? '1' : '0');
var values = {};
inputs.each(function() {
$('input[name^=\"marks\"]').each(function() {
if(this.checked)
values[this.name] = 1;
});
url += '&'+$.param(values);
window.location.href = url;
if($('#batchcategory').val() && Object.keys(values).length > 0) {
SeedDMSBox.redirect(url, {
'message': confirmmsg,
'cancelLabel': '<?= getMLText("cancel") ?>',
'confirmLabel': '<i class="fa fa-user"></i> <?= getMLText("batch_change_category") ?>'
});
}
});
<?php if($this->getParam('theme') !== 'bootstrap4'): ?>
$('body').on('click', 'a.change-owner-btn', function(ev){
ev.preventDefault();
ev.stopPropagation();
confirmmsg = $(ev.currentTarget).attr('confirmmsg');
href = $(ev.currentTarget).attr('href');
bootbox.dialog(confirmmsg, [{
"label" : "<i class='fa fa-user'></i> <?= getMLText("batch_change_owner") ?>",
"class" : "btn-danger",
"callback": function() {
var url = "";
url = href+'&newowner='+($('#newowner').val());
var inputs = $('input[name^=\"marks\"]');
var values = {};
inputs.each(function() {
if(this.checked)
values[this.name] = 1;
});
url += '&'+$.param(values);
window.location.href = url;
}
}, {
"label" : "<?= getMLText("cancel") ?>",
"class" : "btn-cancel",
"callback": function() {
}
}]);
});
<?php else: ?>
$('body').on('click', 'a.change-owner-btn', function(ev){
ev.preventDefault();
ev.stopPropagation();
confirmmsg = $(ev.currentTarget).attr('confirmmsg');
href = $(ev.currentTarget).attr('href');
bootbox.confirm({
"message": confirmmsg,
"buttons": {
"confirm": {
"label" : "<i class='fa fa-user'></i> <?= getMLText("batch_change_owner") ?>",
"className" : "btn-danger",
},
"cancel": {
"label" : " <?= getMLText("cancel") ?>",
"className" : "btn-secondary",
}
},
"callback": function(result) {
if(result) {
var url = "";
url = href+'&newowner='+($('#newowner').val());
var inputs = $('input[name^=\"marks\"]');
var values = {};
inputs.each(function() {
if(this.checked)
values[this.name] = 1;
});
url += '&'+$.param(values);
window.location.href = url;
}
}
var url = href+'&newowner='+($('#newowner').val());
var values = {};
$('input[name^=\"marks\"]').each(function() {
if(this.checked)
values[this.name] = 1;
});
url += '&'+$.param(values);
if($('#newowner').val() && Object.keys(values).length > 0) {
SeedDMSBox.redirect(url, {
'message': confirmmsg,
'cancelLabel': '<?= getMLText("cancel") ?>',
'confirmLabel': '<i class="fa fa-user"></i> <?= getMLText("batch_change_owner") ?>'
});
}
});
<?php endif; ?>
});
<?php
// $this->printFolderChooserJs("form1");
@ -1386,7 +1347,6 @@ $(document).ready(function() {
ob_start();
$users = $dms->getAllUsers();
$options = array();
$options[] = array("-1", getMLText("choose_user"));
foreach ($users as $currUser) {
$options[] = array($currUser->getID(), htmlspecialchars($currUser->getLogin().' - '.$currUser->getFullName()), false, array(array('data-subtitle', htmlspecialchars($currUser->getEmail()))));
}
@ -1397,6 +1357,7 @@ $(document).ready(function() {
'id'=>'newowner',
'class'=>'chzn-select',
'options'=>$options,
'allow_empty'=>true,
'placeholder'=>getMLText('select_users'),
'attributes'=>array(array('style', 'width: 100%;'))
)
@ -1412,7 +1373,6 @@ $(document).ready(function() {
$cats = $dms->getDocumentCategories();
if($cats) {
$options = array();
$options[] = array("-1", getMLText("choose_category"));
foreach ($cats as $currcat) {
$options[] = array($currcat->getID(), htmlspecialchars($currcat->getName()), false);
}
@ -1424,6 +1384,7 @@ $(document).ready(function() {
'class'=>'chzn-select',
'options'=>$options,
'multiple'=>false,
'allow_empty'=>true,
'placeholder'=>getMLText('select_category'),
'attributes'=>array(array('style', 'width: 100%;'))
)
@ -1438,7 +1399,7 @@ $(document).ready(function() {
)
);
print $this->html_link('Search', array_merge($_GET, array('action'=>'changecategory')), array('class'=>'btn btn-primary change-category-btn mt-4', 'id'=>'changecategory'), "<i class=\"fa fa-user\"></i> ".getMLText("batch_change_category"), false, true)."\n";
print $this->html_link('Search', array_merge($_GET, array('action'=>'changecategory')), array('class'=>'btn btn-primary change-category-btn mt-4', 'confirmmsg'=>htmlspecialchars(getMLText("confirm_change_category", array ()), ENT_QUOTES), 'id'=>'changecategory'), "<i class=\"fa fa-user\"></i> ".getMLText("batch_change_category"), false, true)."\n";
$content = ob_get_clean();
$this->printAccordion(getMLText('batch_change_category'), $content);