Some fixes for tile view after Typescript conversion

This commit is contained in:
nathangray 2020-03-23 10:05:46 -06:00
parent 7e1da8d909
commit 3350f3a024
4 changed files with 147 additions and 147 deletions

View File

@ -104,23 +104,23 @@ var et2_nextmatch = /** @class */ (function (_super) {
* @memberOf et2_nextmatch * @memberOf et2_nextmatch
*/ */
function et2_nextmatch(_parent, _attrs, _child) { function et2_nextmatch(_parent, _attrs, _child) {
var _this = _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_nextmatch._attributes, _child || {})) || this; 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 // When printing, we change the layout around. Keep some values so it can be restored after
_this.print = { _this.print = {
old_height: 0, old_height: 0,
row_selector: '', row_selector: '',
orientation_style: null orientation_style: null
}; };
_this.activeFilters = {col_filter: {}}; _this.activeFilters = { col_filter: {} };
_this.columns = []; _this.columns = [];
// keeps sorted columns // keeps sorted columns
_this.sortedColumnsList = []; _this.sortedColumnsList = [];
// Directly set current col_filters from settings // Directly set current col_filters from settings
jQuery.extend(_this.activeFilters.col_filter, _this.options.settings.col_filter); jQuery.extend(_this.activeFilters.col_filter, _this.options.settings.col_filter);
/* /*
Process selected custom fields here, so that the settings are correctly Process selected custom fields here, so that the settings are correctly
set before the row template is parsed set before the row template is parsed
*/ */
var prefs = _this._getPreferences(); var prefs = _this._getPreferences();
var cfs = {}; var cfs = {};
for (var i = 0; i < prefs.visible.length; i++) { for (var i = 0; i < prefs.visible.length; i++) {
@ -740,6 +740,17 @@ var et2_nextmatch = /** @class */ (function (_super) {
else { else {
colName = this._getColumnName(_row[i].widget); colName = this._getColumnName(_row[i].widget);
} }
_colData[i].visible = negated;
var stop_1 = false;
for (var j = 0; j < columnDisplay.length && !stop_1; j++) {
if (columnDisplay[j] == colName) {
_colData[i].visible = !negated;
stop_1 = true;
}
}
if (!negated) {
_colData[i].order = typeof order[colName] === 'undefined' ? i : order[colName];
}
if (!colName) if (!colName)
continue; continue;
if (size[colName]) { if (size[colName]) {
@ -751,16 +762,6 @@ var et2_nextmatch = /** @class */ (function (_super) {
_colData[i].width = parseInt(size[colName]) + 'px'; _colData[i].width = parseInt(size[colName]) + 'px';
} }
} }
if (!negated) {
_colData[i].order = typeof order[colName] === 'undefined' ? i : order[colName];
}
for (var j = 0; j < columnDisplay.length; j++) {
if (columnDisplay[j] == colName) {
_colData[i].visible = !negated;
continue RowLoop;
}
}
_colData[i].visible = negated;
} }
} }
_colData.sort(function (a, b) { _colData.sort(function (a, b) {
@ -956,53 +957,54 @@ var et2_nextmatch = /** @class */ (function (_super) {
} }
}; };
et2_nextmatch.prototype._parseDataRow = function (_row, _rowData, _colData) { et2_nextmatch.prototype._parseDataRow = function (_row, _rowData, _colData) {
var columnWidgets = []; var columnWidgets = [];
_row.sort(function (a, b) { _row.sort(function (a, b) {
return a.colData.order - b.colData.order; return a.colData.order - b.colData.order;
}); });
for (var x = 0; x < this.columns.length; x++) { for (var x = 0; x < this.columns.length; x++) {
if (!this.columns[x].visible) { if (!this.columns[x].visible) {
continue; continue;
} }
if (typeof _row[x] != "undefined" && _row[x].widget) { if (typeof _row[x] != "undefined" && _row[x].widget) {
columnWidgets[x] = _row[x].widget; columnWidgets[x] = _row[x].widget;
// Append the widget to this container // Append the widget to this container
this.addChild(_row[x].widget); this.addChild(_row[x].widget);
} else { }
columnWidgets[x] = _row[x].widget; else {
} columnWidgets[x] = _row[x].widget;
// Pass along column alignment }
if (_row[x].align && columnWidgets[x]) { // Pass along column alignment
columnWidgets[x].align = _row[x].align; if (_row[x].align && columnWidgets[x]) {
} columnWidgets[x].align = _row[x].align;
} }
this.rowProvider.setDataRowTemplate(columnWidgets, _rowData, this); }
// Create the grid controller this.rowProvider.setDataRowTemplate(columnWidgets, _rowData, this);
this.controller = new et2_extension_nextmatch_controller_1.et2_nextmatch_controller(null, this.egw(), this.getInstanceManager().etemplate_exec_id, this, null, this.dataview.grid, this.rowProvider, this.options.settings.action_links, null, this.options.actions); // Create the grid controller
// Need to trigger empty row the first time this.controller = new et2_extension_nextmatch_controller_1.et2_nextmatch_controller(null, this.egw(), this.getInstanceManager().etemplate_exec_id, this, null, this.dataview.grid, this.rowProvider, this.options.settings.action_links, null, this.options.actions);
if (total == 0) // Need to trigger empty row the first time
this.controller._emptyRow(); if (total == 0)
// Set data cache prefix to either provided custom or auto this.controller._emptyRow();
if (!this.options.settings.dataStorePrefix && this.options.settings.get_rows) { // Set data cache prefix to either provided custom or auto
// Use jsapi data module to update if (!this.options.settings.dataStorePrefix && this.options.settings.get_rows) {
var list = this.options.settings.get_rows.split('.', 2); // Use jsapi data module to update
if (list.length < 2) var list = this.options.settings.get_rows.split('.', 2);
list = this.options.settings.get_rows.split('_'); // support "app_something::method" if (list.length < 2)
this.options.settings.dataStorePrefix = list[0]; list = this.options.settings.get_rows.split('_'); // support "app_something::method"
} this.options.settings.dataStorePrefix = list[0];
this.controller.setPrefix(this.options.settings.dataStorePrefix); }
// Set the view this.controller.setPrefix(this.options.settings.dataStorePrefix);
this.controller._view = this.view; // Set the view
// Load the initial order this.controller._view = this.view;
/*this.controller.loadInitialOrder(this._getInitialOrder( // Load the initial order
this.options.settings.rows, this.options.settings.row_id /*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" ? // Set the initial row count
this.options.settings.total : 0; var total = typeof this.options.settings.total != "undefined" ?
// This triggers an invalidate, which updates the grid this.options.settings.total : 0;
this.dataview.grid.setTotalCount(total); // This triggers an invalidate, which updates the grid
// Insert any data sent from server, so invalidate finds data already 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) { 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); this.controller.loadInitialData(this.options.settings.dataStorePrefix, this.options.settings.row_id, this.options.settings.rows);
// Remove, to prevent duplication // Remove, to prevent duplication
@ -1101,37 +1103,37 @@ var et2_nextmatch = /** @class */ (function (_super) {
if (!this.selectPopup) { if (!this.selectPopup) {
var select_1 = et2_createWidget("select", { var select_1 = et2_createWidget("select", {
multiple: true, multiple: true,
rows: 8, rows: 8,
empty_label: this.egw().lang("select columns"), empty_label: this.egw().lang("select columns"),
selected_first: false, selected_first: false,
value_class: "selcolumn_sortable_" value_class: "selcolumn_sortable_"
}, this); }, this);
select_1.set_select_options(columns); select_1.set_select_options(columns);
select_1.set_value(columns_selected); select_1.set_value(columns_selected);
var autoRefresh_1 = et2_createWidget("select", { var autoRefresh_1 = et2_createWidget("select", {
"empty_label": "Refresh" "empty_label": "Refresh"
}, this); }, this);
autoRefresh_1.set_id("nm_autorefresh"); autoRefresh_1.set_id("nm_autorefresh");
autoRefresh_1.set_select_options({ autoRefresh_1.set_select_options({
// Cause [unknown] problems with mail // Cause [unknown] problems with mail
//30: "30 seconds", //30: "30 seconds",
//60: "1 Minute", //60: "1 Minute",
180: "3 Minutes", 180: "3 Minutes",
300: "5 Minutes", 300: "5 Minutes",
900: "15 Minutes", 900: "15 Minutes",
1800: "30 Minutes" 1800: "30 Minutes"
}); });
autoRefresh_1.set_value(this._get_autorefresh()); autoRefresh_1.set_value(this._get_autorefresh());
autoRefresh_1.set_statustext(egw.lang("Automatically refresh list")); autoRefresh_1.set_statustext(egw.lang("Automatically refresh list"));
var defaultCheck = et2_createWidget("select", {"empty_label": "Preference"}, this); var defaultCheck = et2_createWidget("select", { "empty_label": "Preference" }, this);
defaultCheck.set_id('nm_col_preference'); defaultCheck.set_id('nm_col_preference');
defaultCheck.set_select_options({ defaultCheck.set_select_options({
'default': {label: 'Default', title: 'Set these columns as the default'}, 'default': { label: 'Default', title: 'Set these columns as the default' },
'reset': {label: 'Reset', title: "Reset all user's column preferences"}, 'reset': { label: 'Reset', title: "Reset all user's column preferences" },
'force': {label: 'Force', title: 'Force column preference so users cannot change it'} 'force': { label: 'Force', title: 'Force column preference so users cannot change it' }
}); });
defaultCheck.set_value(this.options.settings.columns_forced ? 'force' : ''); defaultCheck.set_value(this.options.settings.columns_forced ? 'force' : '');
var okButton = et2_createWidget("buttononly", {"background_image": true, image: "check"}, this); var okButton = et2_createWidget("buttononly", { "background_image": true, image: "check" }, this);
okButton.set_label(this.egw().lang("ok")); okButton.set_label(this.egw().lang("ok"));
okButton.onclick = function () { okButton.onclick = function () {
// Update visibility // Update visibility
@ -1421,7 +1423,7 @@ var et2_nextmatch = /** @class */ (function (_super) {
// We don't use iterateOver because it checks sub-children // We don't use iterateOver because it checks sub-children
for (var i = this._children.length - 1; i >= 0; i--) { for (var i = this._children.length - 1; i >= 0; i--) {
var _node = this._children[i]; var _node = this._children[i];
if (_node != this.header) { if (_node != this.header && _node !== template) {
this.removeChild(_node); this.removeChild(_node);
_node.destroy(); _node.destroy();
} }
@ -1433,9 +1435,6 @@ var et2_nextmatch = /** @class */ (function (_super) {
} }
this.dataview = new et2_dataview_1.et2_dataview(this.innerDiv, this.egw()); this.dataview = new et2_dataview_1.et2_dataview(this.innerDiv, this.egw());
} }
// Create the template
if (template_name) {
}
if (!template) { if (!template) {
this.egw().debug("error", "Error while loading definition template for " + this.egw().debug("error", "Error while loading definition template for " +
"nextmatch widget.", template_name); "nextmatch widget.", template_name);

View File

@ -1054,6 +1054,20 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
{ {
colName = this._getColumnName(_row[i].widget); colName = this._getColumnName(_row[i].widget);
} }
_colData[i].visible = negated;
let stop = false;
for(var j = 0; j < columnDisplay.length && !stop; j++)
{
if(columnDisplay[j] == colName)
{
_colData[i].visible = !negated;
stop = true;
}
}
if(!negated)
{
_colData[i].order = typeof order[colName] === 'undefined' ? i : order[colName];
}
if(!colName) continue; if(!colName) continue;
if(size[colName]) if(size[colName])
@ -1068,20 +1082,6 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
_colData[i].width = parseInt(size[colName])+'px'; _colData[i].width = parseInt(size[colName])+'px';
} }
} }
if(!negated)
{
_colData[i].order = typeof order[colName] === 'undefined' ? i : order[colName];
}
for(var j = 0; j < columnDisplay.length; j++)
{
if(columnDisplay[j] == colName)
{
_colData[i].visible = !negated;
continue RowLoop;
}
}
_colData[i].visible = negated;
} }
} }
@ -1941,7 +1941,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
// We don't use iterateOver because it checks sub-children // We don't use iterateOver because it checks sub-children
for (let i = this._children.length - 1; i >= 0; i--) { for (let i = this._children.length - 1; i >= 0; i--) {
const _node = this._children[i]; const _node = this._children[i];
if (_node != this.header) { if (_node != this.header && _node !== template) {
this.removeChild(_node); this.removeChild(_node);
_node.destroy(); _node.destroy();
} }
@ -1955,11 +1955,6 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
this.dataview = new et2_dataview(this.innerDiv, this.egw()); this.dataview = new et2_dataview(this.innerDiv, this.egw());
} }
// Create the template
if (template_name)
{
}
if (!template) if (!template)
{ {
this.egw().debug("error", "Error while loading definition template for " + this.egw().debug("error", "Error while loading definition template for " +

View File

@ -38,8 +38,8 @@ var filemanagerAPP = /** @class */ (function (_super) {
*/ */
function filemanagerAPP() { function filemanagerAPP() {
var _this = var _this =
// call parent // call parent
_super.call(this, 'filemanager') || this; _super.call(this, 'filemanager') || this;
/** /**
* path widget, by template * path widget, by template
*/ */
@ -302,12 +302,18 @@ var filemanagerAPP = /** @class */ (function (_super) {
*/ */
filemanagerAPP.prototype._upload_callback = function (_data) { filemanagerAPP.prototype._upload_callback = function (_data) {
if (_data.msg || _data.uploaded) if (_data.msg || _data.uploaded)
window.egw_refresh(_data.msg, this.appname); window.egw_refresh(_data.msg, this.appname);
var that = this; var that = this;
for (var file in _data.uploaded) { for (var file in _data.uploaded) {
if (_data.uploaded[file].confirm && !_data.uploaded[file].confirmed) { if (_data.uploaded[file].confirm && !_data.uploaded[file].confirmed) {
var buttons = [ var buttons = [
{ text: this.egw.lang("Yes"), id: "overwrite", class: "ui-priority-primary", "default": true, image: 'check' }, {
text: this.egw.lang("Yes"),
id: "overwrite",
class: "ui-priority-primary",
"default": true,
image: 'check'
},
{ text: this.egw.lang("Rename"), id: "rename", image: 'edit' }, { text: this.egw.lang("Rename"), id: "rename", image: 'edit' },
{ text: this.egw.lang("Cancel"), id: "cancel" } { text: this.egw.lang("Cancel"), id: "cancel" }
]; ];
@ -513,7 +519,7 @@ var filemanagerAPP = /** @class */ (function (_super) {
* @param _data * @param _data
*/ */
filemanagerAPP.prototype._do_action_callback = function (_data) { filemanagerAPP.prototype._do_action_callback = function (_data) {
window.egw_refresh(_data.msg, this.appname); window.egw_refresh(_data.msg, this.appname);
}; };
/** /**
* Force download of a file by appending '?download' to it's download url * Force download of a file by appending '?download' to it's download url
@ -612,14 +618,14 @@ var filemanagerAPP = /** @class */ (function (_super) {
} }
// Toggle button icon to the other view // Toggle button icon to the other view
//todo: nm.controller needs to be changed to nm.getController after merging typescript branch into master //todo: nm.controller needs to be changed to nm.getController after merging typescript branch into master
button_widget.set_image("list_" + (view == nm.getController().VIEW_ROW ? nm.getController().VIEW_TILE : nm.getController().VIEW_ROW)); button_widget.set_image("list_" + (view == et2_nextmatch_controller.VIEW_ROW ? et2_nextmatch_controller.VIEW_TILE : et2_nextmatch_controller.VIEW_ROW));
button_widget.set_statustext(view == nm.getController().VIEW_ROW ? this.egw.lang("Tile view") : this.egw.lang('List view')); button_widget.set_statustext(view == et2_nextmatch_controller.VIEW_ROW ? this.egw.lang("Tile view") : this.egw.lang('List view'));
} }
nm.set_view(view); nm.set_view(view);
// Put it into active filters (but don't refresh) // Put it into active filters (but don't refresh)
nm.activeFilters["view"] = view; nm.activeFilters["view"] = view;
// Change template to match // Change template to match
var template = view == nm.getController().VIEW_ROW ? 'filemanager.index.rows' : 'filemanager.tile'; var template = view == et2_nextmatch_controller.VIEW_ROW ? 'filemanager.index.rows' : 'filemanager.tile';
nm.set_template(template); nm.set_template(template);
// Wait for template to load, then refresh // Wait for template to load, then refresh
template = nm.getWidgetById(template); template = nm.getWidgetById(template);
@ -724,8 +730,8 @@ var filemanagerAPP = /** @class */ (function (_super) {
(dir && dir.data && dir.data.class && dir.data.class.indexOf('noEdit') === -1 || !dir) (dir && dir.data && dir.data.class && dir.data.class.indexOf('noEdit') === -1 || !dir)
}); });
// Last 10 folders // Last 10 folders
var previous_dsts = jQuery.extend([], egw.preference('drop_history', this.appname)); var previous_dsts = jQuery.extend([], egw.preference('drop_history', this.appname));
var action_index = 0; var action_index = 0;
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var path = i < previous_dsts.length ? previous_dsts[i] : ''; var path = i < previous_dsts.length ? previous_dsts[i] : '';
actions.push({ actions.push({
@ -806,10 +812,10 @@ var filemanagerAPP = /** @class */ (function (_super) {
} }
} }
// Remember the target for next time // Remember the target for next time
var previous_dsts = jQuery.extend([], egw.preference('drop_history', this.appname)); var previous_dsts = jQuery.extend([], egw.preference('drop_history', this.appname));
previous_dsts.unshift(dst); previous_dsts.unshift(dst);
previous_dsts = Array.from(new Set(previous_dsts)).slice(0, 9); previous_dsts = Array.from(new Set(previous_dsts)).slice(0, 9);
egw.set_preference(this.appname, 'drop_history', previous_dsts); egw.set_preference(this.appname, 'drop_history', previous_dsts);
// Actual action id will be something like file_drop_{move|copy|link}[_other_id], // Actual action id will be something like file_drop_{move|copy|link}[_other_id],
// but we need to send move, copy or link // but we need to send move, copy or link
var action_id = _action.id.replace("file_drop_", '').split('_', 1)[0]; var action_id = _action.id.replace("file_drop_", '').split('_', 1)[0];
@ -976,7 +982,7 @@ var filemanagerAPP = /** @class */ (function (_super) {
*/ */
filemanagerAPP.prototype._share_link_callback = function (_data) { filemanagerAPP.prototype._share_link_callback = function (_data) {
if (_data.msg || _data.share_link) if (_data.msg || _data.share_link)
window.egw_refresh(_data.msg, this.appname); window.egw_refresh(_data.msg, this.appname);
console.log("_data", _data); console.log("_data", _data);
var app = this; var app = this;
var copy_link_to_clipboard = function (evt) { var copy_link_to_clipboard = function (evt) {

View File

@ -744,9 +744,9 @@ export class filemanagerAPP extends EgwApp
// Toggle button icon to the other view // Toggle button icon to the other view
//todo: nm.controller needs to be changed to nm.getController after merging typescript branch into master //todo: nm.controller needs to be changed to nm.getController after merging typescript branch into master
button_widget.set_image("list_"+(view == nm.getController().VIEW_ROW ? nm.getController().VIEW_TILE : nm.getController().VIEW_ROW)); button_widget.set_image("list_"+(view == et2_nextmatch_controller.VIEW_ROW ? et2_nextmatch_controller.VIEW_TILE : et2_nextmatch_controller.VIEW_ROW));
button_widget.set_statustext(view == nm.getController().VIEW_ROW ? this.egw.lang("Tile view") : this.egw.lang('List view')); button_widget.set_statustext(view == et2_nextmatch_controller.VIEW_ROW ? this.egw.lang("Tile view") : this.egw.lang('List view'));
} }
nm.set_view(view); nm.set_view(view);
@ -754,7 +754,7 @@ export class filemanagerAPP extends EgwApp
nm.activeFilters["view"]= view; nm.activeFilters["view"]= view;
// Change template to match // Change template to match
let template : any = view == nm.getController().VIEW_ROW ? 'filemanager.index.rows' : 'filemanager.tile'; let template : any = view == et2_nextmatch_controller.VIEW_ROW ? 'filemanager.index.rows' : 'filemanager.tile';
nm.set_template(template); nm.set_template(template);
// Wait for template to load, then refresh // Wait for template to load, then refresh