Switch nextmatch print & select all to using Et2Dialog

This commit is contained in:
nathan 2022-03-23 13:28:15 -06:00
parent db7c68bdc7
commit 9693cfe538
4 changed files with 56 additions and 39 deletions

View File

@ -17,17 +17,17 @@
import {egw} from "../jsapi/egw_global"; import {egw} from "../jsapi/egw_global";
import {et2_bounds} from "./et2_core_common"; import {et2_bounds} from "./et2_core_common";
import {et2_dialog} from "./et2_widget_dialog";
import {et2_createWidget} from "./et2_core_widget";
import {et2_dataview_rowAOI} from "./et2_dataview_view_aoi"; import {et2_dataview_rowAOI} from "./et2_dataview_view_aoi";
import {egwActionObjectInterface} from "../egw_action/egw_action.js";
import { import {
egwActionObjectInterface EGW_AO_SHIFT_STATE_BLOCK,
} from "../egw_action/egw_action.js"; EGW_AO_SHIFT_STATE_MULTI,
import { EGW_AO_STATE_FOCUSED,
EGW_AO_SHIFT_STATE_BLOCK, EGW_AO_SHIFT_STATE_MULTI, EGW_AO_STATE_NORMAL,
EGW_AO_STATE_FOCUSED, EGW_AO_STATE_NORMAL, EGW_AO_STATE_SELECTED EGW_AO_STATE_SELECTED
} from "../egw_action/egw_action_constants.js"; } from "../egw_action/egw_action_constants.js";
import {egwBitIsSet, egwSetBit} from "../egw_action/egw_action_common.js"; import {egwBitIsSet, egwSetBit} from "../egw_action/egw_action_common.js";
import {Et2Dialog} from "./Et2Dialog/Et2Dialog";
/** /**
* The selectioManager is internally used by the et2_dataview_controller class * The selectioManager is internally used by the et2_dataview_controller class
@ -673,50 +673,63 @@ export class et2_dataview_selectionManager
var range_index = 0; var range_index = 0;
var range_count = queryRanges.length; var range_count = queryRanges.length;
var cont = true; var cont = true;
var fetchPromise = new Promise(function (resolve) { var fetchPromise = new Promise(function(resolve)
{
resolve(); resolve();
}); });
// Found after dialog loads // Found after dialog loads
var progressbar; var progressbar;
var parent = et2_dialog._create_parent(); let dialog = new Et2Dialog(this._context._widget.egw());
var dialog = et2_createWidget("dialog", { dialog.transformAttributes({
callback: callback:
// Abort the long task if they canceled the data load // Abort the long task if they canceled the data load
function() {cont = false}, function() {cont = false},
template: egw.webserverUrl+'/api/templates/default/long_task.xet', template: egw.webserverUrl + '/api/templates/default/long_task.xet',
message: egw.lang('Loading'), message: egw.lang('Loading'),
title: egw.lang('please wait...'), title: egw.lang('please wait...'),
buttons: [{"button_id": et2_dialog.CANCEL_BUTTON,"text": egw.lang('cancel'),id: 'dialog[cancel]',image: 'cancel'}], buttons: [{
button_id: Et2Dialog.CANCEL_BUTTON,
label: egw.lang('cancel'),
id: 'dialog[cancel]',
image: 'cancel'
}],
width: 300 width: 300
}, parent); });
jQuery(dialog.template.DOMContainer).on('load', function() { (this._context._widget.getDOMNode() || document.body).appendChild(dialog);
dialog.addEventListener('load', function()
{
// Get access to template widgets // Get access to template widgets
progressbar = dialog.template.widgetContainer.getWidgetById('progressbar'); progressbar = dialog.template.widgetContainer.getWidgetById('progressbar');
}); });
for (var i = 0; i < queryRanges.length; i++) for(var i = 0; i < queryRanges.length; i++)
{ {
if(record_count + (queryRanges[i].bottom - queryRanges[i].top+1) > that.MAX_SELECTION) if(record_count + (queryRanges[i].bottom - queryRanges[i].top + 1) > that.MAX_SELECTION)
{ {
egw.message(egw.lang('Too many rows selected.<br />Select all, or less than %1 rows', that.MAX_SELECTION)); egw.message(egw.lang('Too many rows selected.<br />Select all, or less than %1 rows', that.MAX_SELECTION));
break; break;
} }
else else
{ {
record_count += (queryRanges[i].bottom - queryRanges[i].top+1); record_count += (queryRanges[i].bottom - queryRanges[i].top + 1);
fetchPromise = fetchPromise.then((function () fetchPromise = fetchPromise.then((function()
{ {
// Check for abort // Check for abort
if(!cont) return; if(!cont)
{
return;
}
return new Promise(function(resolve) { return new Promise(function(resolve)
that._queryRangeCallback.call(that._context, this, {
function (_order) { that._queryRangeCallback.call(that._context, this,
for (var j = 0; j < _order.length; j++) function(_order)
{ {
// Check for no_actions flag via data since entry isn't there/available for(var j = 0; j < _order.length; j++)
var data = egw.dataGetUIDdata(_order[j]); {
// Check for no_actions flag via data since entry isn't there/available
var data = egw.dataGetUIDdata(_order[j]);
if(!data || data && data.data && !data.data.no_actions) if(!data || data && data.data && !data.data.no_actions)
{ {
var entry = this._getRegisteredRowsEntry(_order[j]); var entry = this._getRegisteredRowsEntry(_order[j]);
@ -732,7 +745,7 @@ export class et2_dataview_selectionManager
} }
} }
fetchPromise.finally(function() { fetchPromise.finally(function() {
dialog.destroy(); dialog.close();
}); });
} }

View File

@ -74,6 +74,7 @@ import {egw} from "../jsapi/egw_global";
import {et2_compileLegacyJS} from "./et2_core_legacyJSFunctions"; import {et2_compileLegacyJS} from "./et2_core_legacyJSFunctions";
import {egwIsMobile} from "../egw_action/egw_action_common.js"; import {egwIsMobile} from "../egw_action/egw_action_common.js";
import Sortable from 'sortablejs/modular/sortable.complete.esm.js'; import Sortable from 'sortablejs/modular/sortable.complete.esm.js';
import {Et2Dialog} from "./Et2Dialog/Et2Dialog";
//import {et2_selectAccount} from "./et2_widget_SelectAccount"; //import {et2_selectAccount} from "./et2_widget_SelectAccount";
@ -2954,9 +2955,9 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
this.set_columns(jQuery.extend([], this.egw().preference(pref, app))); this.set_columns(jQuery.extend([], this.egw().preference(pref, app)));
} }
const callback = jQuery.proxy(function(button, value) const callback = function(button, value)
{ {
if(button === et2_dialog.CANCEL_BUTTON) if(button === Et2Dialog.CANCEL_BUTTON)
{ {
// Give dialog a chance to close, or it will be in the print // Give dialog a chance to close, or it will be in the print
window.setTimeout(function() window.setTimeout(function()
@ -3007,7 +3008,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
} }
// If they want the whole thing, style it as all // If they want the whole thing, style it as all
if(button === et2_dialog.OK_BUTTON && rows == this.controller._grid.getTotalCount()) if(button === Et2Dialog.OK_BUTTON && rows == this.controller._grid.getTotalCount())
{ {
// Add the class, gives more reliable sizing // Add the class, gives more reliable sizing
this.div.addClass('print'); this.div.addClass('print');
@ -3021,7 +3022,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
let fetchedCount = 0; let fetchedCount = 0;
let cancel = false; let cancel = false;
const nm = this; const nm = this;
const dialog = et2_dialog.show_dialog( const dialog = Et2Dialog.show_dialog(
// Abort the long task if they canceled the data load // Abort the long task if they canceled the data load
function() function()
{ {
@ -3033,7 +3034,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
}, 0); }, 0);
}, },
egw.lang('Loading'), egw.lang('please wait...'), {}, [ egw.lang('Loading'), egw.lang('please wait...'), {}, [
{"button_id": et2_dialog.CANCEL_BUTTON, "text": 'cancel', id: 'dialog[cancel]', image: 'cancel'} {"button_id": Et2Dialog.CANCEL_BUTTON, label: 'cancel', id: 'dialog[cancel]', image: 'cancel'}
] ]
); );
@ -3080,13 +3081,13 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
jQuery('.egwGridView_scrollarea', this.div).css('height', 'auto'); jQuery('.egwGridView_scrollarea', this.div).css('height', 'auto');
// Grid needs to redraw before it can be printed, so wait // Grid needs to redraw before it can be printed, so wait
window.setTimeout(jQuery.proxy(function() window.setTimeout(function()
{ {
dialog.destroy(); dialog.close();
// Should be OK to print now // Should be OK to print now
defer.resolve(); defer.resolve();
}, nm), et2_dataview_grid.ET2_GRID_INVALIDATE_TIMEOUT); }.bind(nm), et2_dataview_grid.ET2_GRID_INVALIDATE_TIMEOUT);
} }
@ -3116,7 +3117,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
defer.resolve(); defer.resolve();
}, 0); }, 0);
} }
}, this); }.bind(this);
var value = { var value = {
content: { content: {
row_count: Math.min(100, total), row_count: Math.min(100, total),
@ -3153,6 +3154,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
const tab = this.get_tab_info(); const tab = this.get_tab_info();
// Get title for print dialog from settings or tab, if available // Get title for print dialog from settings or tab, if available
const title = this.options.settings.label ? this.options.settings.label : (tab ? tab.label : ''); const title = this.options.settings.label ? this.options.settings.label : (tab ? tab.label : '');
debugger;
const dialog = et2_createWidget("dialog", { const dialog = et2_createWidget("dialog", {
// If you use a template, the second parameter will be the value of the template, as if it were submitted. // If you use a template, the second parameter will be the value of the template, as if it were submitted.
callback: callback, // return false to prevent dialog closing callback: callback, // return false to prevent dialog closing

View File

@ -1901,7 +1901,8 @@ export abstract class EgwApp
var dialog = function(_content, _callback?) var dialog = function(_content, _callback?)
{ {
return et2_createWidget("dialog", { let dialog = new Et2Dialog(this.egw);
dialog.transformAttributes({
callback: function(_button_id, _value) callback: function(_button_id, _value)
{ {
if(typeof _callback == "function") if(typeof _callback == "function")
@ -1912,7 +1913,7 @@ export abstract class EgwApp
title: egw.lang('Backup/Restore'), title: egw.lang('Backup/Restore'),
buttons: [{ buttons: [{
"button_id": 'close', "button_id": 'close',
"text": egw.lang('Close'), "label": egw.lang('Close'),
id: 'dialog[close]', id: 'dialog[close]',
image: 'cancelled', image: 'cancelled',
"default": true "default": true
@ -1926,6 +1927,7 @@ export abstract class EgwApp
class: "pgp_backup_restore", class: "pgp_backup_restore",
modal: true modal: true
}); });
return dialog;
}; };
if(typeof mailvelope != 'undefined') if(typeof mailvelope != 'undefined')
{ {

View File

@ -5,7 +5,7 @@
<template id="nm_print_dialog" template="" lang="" group="0" version="16.1"> <template id="nm_print_dialog" template="" lang="" group="0" version="16.1">
<vbox> <vbox>
<description value="Columns to print"/> <description value="Columns to print"/>
<select id="columns" rows="8" selected_first="false"/> <select id="columns" multiple="true" selected_first="false"/>
<integer id="row_count" label="How many rows to print"/> <integer id="row_count" label="How many rows to print"/>
<checkbox id="orientation" toggle_on="Portrait" toggle_off="Landscape" selected_value="portrait" unselected_value="landscape"/> <checkbox id="orientation" toggle_on="Portrait" toggle_off="Landscape" selected_value="portrait" unselected_value="landscape"/>
</vbox> </vbox>