From 5ca06d432d2d93e7d7519f36c358b0c0c31f5c48 Mon Sep 17 00:00:00 2001 From: nathangray Date: Fri, 5 Apr 2019 10:21:41 -0600 Subject: [PATCH] Break print dialog creation out into its own function --- api/js/etemplate/et2_extension_nextmatch.js | 43 +++++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/api/js/etemplate/et2_extension_nextmatch.js b/api/js/etemplate/et2_extension_nextmatch.js index 8eb6ff1f6b..d782c8bcdc 100644 --- a/api/js/etemplate/et2_extension_nextmatch.js +++ b/api/js/etemplate/et2_extension_nextmatch.js @@ -2305,7 +2305,37 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_ window.setTimeout(function() {defer.resolve();}, 0); } },this); + var value = { + content: { + row_count: Math.min(100,total), + columns: this.egw().preference(pref,app) || columns_selected, + orientation: this.egw().preference(pref+'_orientation',app) + }, + sel_options: { + columns: columns + } + }; + this._create_print_dialog.call(this, value, callback); + return defer; + }, + + /** + * Create and show the print dialog, which calls the provided callback when + * done. Broken out for overriding if needed. + * + * @param {Object} value Current settings and preferences, passed to the dialog for + * the template + * @param {Object} value.content + * @param {Object} value.sel_options + * + * @param {function(int, Object)} callback - Process the dialog response, + * format things according to the specified orientation and fetch any needed + * rows. + * + */ + _create_print_dialog: function _create_print_dialog(value, callback) + { var base_url = this.getInstanceManager().template_base_url; if (base_url.substr(base_url.length - 1) == '/') base_url = base_url.slice (0, -1); // otherwise we generate a url //api/templates, which is wrong var tab = this.get_tab_info(); @@ -2317,19 +2347,8 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_ buttons: et2_dialog.BUTTONS_OK_CANCEL, title: this.egw().lang('Print') + ' ' + this.egw().lang(title), template:this.egw().link(base_url+'/api/templates/default/nm_print_dialog.xet'), - value: { - content: { - row_count: Math.min(100,total), - columns: this.egw().preference(pref,app) || columns_selected, - orientation: this.egw().preference(pref+'_orientation',app) - }, - sel_options: { - columns: columns - } - } + value: value }); - - return defer; }, /**