* Add option to merge documents as PDF

This commit is contained in:
nathan
2021-09-28 17:00:55 -06:00
parent 2a4faf0137
commit 707c57ecf0
3 changed files with 125 additions and 73 deletions

View File

@ -725,7 +725,7 @@ export abstract class EgwApp
framework.pushState('view');
if(templateName)
{
this.et2_view.load(this.appname+'.'+templateName,templateURL, data, typeof et2_callback == 'function'?et2_callback:function(){}, app);
this.et2_view.load(this.appname + '.' + templateName, templateURL, data, typeof et2_callback == 'function' ? et2_callback : function() {}, app);
}
// define a global close function for view template
@ -733,6 +733,49 @@ export abstract class EgwApp
this.et2_view.close = destroy;
}
/**
* Merge selected entries into template document
*
* @param {egwAction} _action
* @param {egwActionObject[]} _selected
*/
merge(_action : egwAction, _selected : egwActionObject[])
{
// Find what we need
let nm = null;
let action = _action;
let as_pdf = false;
// Find Select all
while(nm == null && action != null)
{
if(action.data != null && action.data.nextmatch)
{
nm = action.data.nextmatch;
}
action = action.parent;
}
let all = nm?.getSelection().all || false;
as_pdf = action.getActionById('as_pdf')?.checked || false;
// Get list of entry IDs
let ids = [];
for(let i = 0; !all && i < _selected.length; i++)
{
let split = _selected[i].id.split("::");
ids.push(split[1]);
}
let vars = {
..._action.data.merge_data,
pdf: as_pdf,
select_all: all,
id: JSON.stringify(ids)
};
egw.open_link(egw.link('/index.php', vars), '_blank');
}
/**
* Initializes actions and handlers on sidebox (delete)
*
@ -741,12 +784,12 @@ export abstract class EgwApp
_init_sidebox(sidebox)
{
// Initialize egw tutorial sidebox, but only for non-popups, as calendar edit app.js has this.et2 set to tutorial et2 object
if (!this.egw.is_popup())
if(!this.egw.is_popup())
{
var egw_fw = egw_getFramework();
var tutorial = jQuery('#egw_tutorial_'+this.appname+'_sidebox', egw_fw ? egw_fw.sidemenuDiv : document);
var tutorial = jQuery('#egw_tutorial_' + this.appname + '_sidebox', egw_fw ? egw_fw.sidemenuDiv : document);
// _init_sidebox gets currently called multiple times, which needs to be fixed
if (tutorial.length && !this.tutorial_initialised)
if(tutorial.length && !this.tutorial_initialised)
{
this.egwTutorial_init(tutorial[0]);
this.tutorial_initialised = true;