From c04915ae0926667d688c0a4a0e45b0e6eb53d3c1 Mon Sep 17 00:00:00 2001 From: nathangray Date: Wed, 18 Mar 2020 10:36:14 -0600 Subject: [PATCH] Etemplate: Fix nextmatch printing failed after TypeScript conversion --- api/js/etemplate/et2_extension_nextmatch.js | 89 +++++++++++---------- api/js/etemplate/et2_extension_nextmatch.ts | 25 ++++-- 2 files changed, 66 insertions(+), 48 deletions(-) diff --git a/api/js/etemplate/et2_extension_nextmatch.js b/api/js/etemplate/et2_extension_nextmatch.js index 91177cea4c..1b6c3c10da 100644 --- a/api/js/etemplate/et2_extension_nextmatch.js +++ b/api/js/etemplate/et2_extension_nextmatch.js @@ -76,6 +76,7 @@ var et2_INextmatchSortable = "et2_INextmatchSortable"; function implements_et2_INextmatchSortable(obj) { return implements_methods(obj, ["setSortmode"]); } +; /** * Class which implements the "nextmatch" XET-Tag * @@ -103,17 +104,23 @@ var et2_nextmatch = /** @class */ (function (_super) { * @memberOf et2_nextmatch */ function et2_nextmatch(_parent, _attrs, _child) { - var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_nextmatch._attributes, _child || {})) || this; - _this.activeFilters = { col_filter: {} }; - _this.columns = []; - // keeps sorted columns - _this.sortedColumnsList = []; - // Directly set current col_filters from settings - jQuery.extend(_this.activeFilters.col_filter, _this.options.settings.col_filter); - /* - Process selected custom fields here, so that the settings are correctly - set before the row template is parsed - */ + var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_nextmatch._attributes, _child || {})) || this; + // When printing, we change the layout around. Keep some values so it can be restored after + _this.print = { + old_height: 0, + row_selector: '', + orientation_style: null + }; + _this.activeFilters = {col_filter: {}}; + _this.columns = []; + // keeps sorted columns + _this.sortedColumnsList = []; + // Directly set current col_filters from settings + jQuery.extend(_this.activeFilters.col_filter, _this.options.settings.col_filter); + /* + Process selected custom fields here, so that the settings are correctly + set before the row template is parsed + */ var prefs = _this._getPreferences(); var cfs = {}; for (var i = 0; i < prefs.visible.length; i++) { @@ -986,16 +993,16 @@ var et2_nextmatch = /** @class */ (function (_super) { this.controller.setPrefix(this.options.settings.dataStorePrefix); // Set the view this.controller._view = this.view; - // Load the initial order - /*this.controller.loadInitialOrder(this._getInitialOrder( - this.options.settings.rows, this.options.settings.row_id - ));*/ - // Set the initial row count - var total = typeof this.options.settings.total != "undefined" ? - this.options.settings.total : 0; - // This triggers an invalidate, which updates the grid - this.dataview.grid.setTotalCount(total); - // Insert any data sent from server, so invalidate finds data already + // Load the initial order + /*this.controller.loadInitialOrder(this._getInitialOrder( + this.options.settings.rows, this.options.settings.row_id + ));*/ + // Set the initial row count + var total = typeof this.options.settings.total != "undefined" ? + this.options.settings.total : 0; + // This triggers an invalidate, which updates the grid + this.dataview.grid.setTotalCount(total); + // Insert any data sent from server, so invalidate finds data already if (this.options.settings.rows && this.options.settings.num_rows) { this.controller.loadInitialData(this.options.settings.dataStorePrefix, this.options.settings.row_id, this.options.settings.rows); // Remove, to prevent duplication @@ -1094,16 +1101,16 @@ var et2_nextmatch = /** @class */ (function (_super) { if (!this.selectPopup) { var select_1 = et2_createWidget("select", { multiple: true, - rows: 8, - empty_label: this.egw().lang("select columns"), - selected_first: false, - value_class: "selcolumn_sortable_" - }, this); - select_1.set_select_options(columns); - select_1.set_value(columns_selected); - var autoRefresh_1 = et2_createWidget("select", { - "empty_label": "Refresh" - }, this); + rows: 8, + empty_label: this.egw().lang("select columns"), + selected_first: false, + value_class: "selcolumn_sortable_" + }, this); + select_1.set_select_options(columns); + select_1.set_value(columns_selected); + var autoRefresh_1 = et2_createWidget("select", { + "empty_label": "Refresh" + }, this); autoRefresh_1.set_id("nm_autorefresh"); autoRefresh_1.set_select_options({ // Cause [unknown] problems with mail @@ -1115,16 +1122,16 @@ var et2_nextmatch = /** @class */ (function (_super) { 1800: "30 Minutes" }); autoRefresh_1.set_value(this._get_autorefresh()); - autoRefresh_1.set_statustext(egw.lang("Automatically refresh list")); - var defaultCheck = et2_createWidget("select", { "empty_label": "Preference" }, this); - defaultCheck.set_id('nm_col_preference'); - defaultCheck.set_select_options({ - 'default': { label: 'Default', title: 'Set these columns as the default' }, - 'reset': { label: 'Reset', title: "Reset all user's column preferences" }, - 'force': { label: 'Force', title: 'Force column preference so users cannot change it' } - }); - defaultCheck.set_value(this.options.settings.columns_forced ? 'force' : ''); - var okButton = et2_createWidget("buttononly", { "background_image": true, image: "check" }, this); + autoRefresh_1.set_statustext(egw.lang("Automatically refresh list")); + var defaultCheck = et2_createWidget("select", {"empty_label": "Preference"}, this); + defaultCheck.set_id('nm_col_preference'); + defaultCheck.set_select_options({ + 'default': {label: 'Default', title: 'Set these columns as the default'}, + 'reset': {label: 'Reset', title: "Reset all user's column preferences"}, + 'force': {label: 'Force', title: 'Force column preference so users cannot change it'} + }); + defaultCheck.set_value(this.options.settings.columns_forced ? 'force' : ''); + var okButton = et2_createWidget("buttononly", {"background_image": true, image: "check"}, this); okButton.set_label(this.egw().lang("ok")); okButton.onclick = function () { // Update visibility diff --git a/api/js/etemplate/et2_extension_nextmatch.ts b/api/js/etemplate/et2_extension_nextmatch.ts index 649bdf8d17..4785e21048 100644 --- a/api/js/etemplate/et2_extension_nextmatch.ts +++ b/api/js/etemplate/et2_extension_nextmatch.ts @@ -79,14 +79,24 @@ function implements_et2_INextmatchHeader(obj : et2_widget) export interface et2_INextmatchSortable { - setSortmode(_sort_mode) : void + setSortmode(_sort_mode): void } + var et2_INextmatchSortable = "et2_INextmatchSortable"; -function implements_et2_INextmatchSortable(obj : et2_widget) + +function implements_et2_INextmatchSortable(obj: et2_widget) { return implements_methods(obj, ["setSortmode"]); } +// For holding settings while whe print +interface PrintSettings +{ + old_height: number, + row_selector: string, + orientation_style: HTMLStyleElement +}; + /** * Class which implements the "nextmatch" XET-Tag * @@ -227,10 +237,10 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 private _autorefresh_timer: number; // When printing, we change the layout around. Keep some values so it can be restored after - private print: { - old_height: number, - row_selector: string, - orientation_style: HTMLStyleElement + private print: PrintSettings = { + old_height: 0, + row_selector: '', + orientation_style: null }; /** @@ -238,7 +248,8 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 * * @memberOf et2_nextmatch */ - constructor(_parent?, _attrs? : WidgetConfig, _child? : object) { + constructor(_parent?, _attrs?: WidgetConfig, _child?: object) + { super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_nextmatch._attributes, _child || {})); this.activeFilters = {col_filter:{}};