mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:20 +01:00
Change addressbook group / template on client side, not server side
Fixes the issue where the nextmatch_controller is part of the context for the request, but the first thing set_template() does when the server tells the nextmatch to change the template is destroy the controller. This means that when the data is parsed, the context is missing or damaged.
This commit is contained in:
parent
20cd1cf802
commit
ee472bb5a9
@ -933,7 +933,7 @@ class addressbook_ui extends addressbook_bo
|
||||
$query['actions'] = $this->get_actions($query['col_filter']['tid']);
|
||||
}
|
||||
|
||||
$query['template'] = $query['grouped_view'] == 'duplicates' ? 'addressbook.index.duplicate_rows' : 'addressbook.index.org_rows';
|
||||
$template = $query['grouped_view'] == 'duplicates' ? 'addressbook.index.duplicate_rows' : 'addressbook.index.org_rows';
|
||||
|
||||
if ($query['advanced_search'])
|
||||
{
|
||||
@ -945,7 +945,7 @@ class addressbook_ui extends addressbook_bo
|
||||
$query['search'] = $query['advanced_search'];
|
||||
}
|
||||
|
||||
switch ($query['template'])
|
||||
switch ($template)
|
||||
{
|
||||
case 'addressbook.index.org_rows':
|
||||
if ($query['order'] != 'org_name')
|
||||
@ -1684,19 +1684,9 @@ class addressbook_ui extends addressbook_bo
|
||||
}
|
||||
else // contacts view
|
||||
{
|
||||
if ($query['sitemgr_display'])
|
||||
{
|
||||
$query['template'] = $query['sitemgr_display'].'.rows';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query['template'] = 'addressbook.index.rows';
|
||||
}
|
||||
if($query['col_filter']['parent_id'])
|
||||
{
|
||||
$query['grouped_view'] = $query['col_filter']['parent_id'];
|
||||
$query['template'] = strpos($query['grouped_view'], 'duplicate') === 0 ?
|
||||
'addressbook.index.duplicate_rows' : 'addressbook.index.org_rows';
|
||||
}
|
||||
// Query doesn't like parent_id
|
||||
unset($query['col_filter']['parent_id']);
|
||||
|
@ -30,6 +30,7 @@ require("jqueryui");
|
||||
require("../jsapi/egw_global");
|
||||
require("../etemplate/et2_types");
|
||||
var egw_app_1 = require("../../api/js/jsapi/egw_app");
|
||||
var etemplate2_1 = require("../../api/js/etemplate/etemplate2");
|
||||
/**
|
||||
* UI for Addressbook
|
||||
*
|
||||
@ -123,7 +124,7 @@ var AddressbookApp = /** @class */ (function (_super) {
|
||||
if (_app === 'addressbook' && state && state.type && state.type === 'view' && state.id === _id) {
|
||||
var content = egw.dataGetUIDdata('addressbook::' + _id);
|
||||
if (content.data) {
|
||||
var view = etemplate2.getById('addressbook-view');
|
||||
var view = etemplate2_1.etemplate2.getById('addressbook-view');
|
||||
if (view) {
|
||||
view.widgetContainer._children[0].set_value({ content: content.data });
|
||||
}
|
||||
@ -144,7 +145,7 @@ var AddressbookApp = /** @class */ (function (_super) {
|
||||
else if (!content) {
|
||||
// No data on the event, we'll have to reload if calendar column is visible
|
||||
// to get the updated information
|
||||
var nm = etemplate2.getById('addressbook-index').widgetContainer.getWidgetById('nm');
|
||||
var nm = etemplate2_1.etemplate2.getById('addressbook-index').widgetContainer.getWidgetById('nm');
|
||||
var pref = nm ? nm._getPreferences() : false;
|
||||
if (pref && pref.visible.indexOf('calendar_calendar') > -1) {
|
||||
nm.refresh(null, 'update');
|
||||
@ -153,6 +154,38 @@ var AddressbookApp = /** @class */ (function (_super) {
|
||||
}
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
* Change handler for contact / org selectbox
|
||||
*
|
||||
* @param node
|
||||
* @param widget
|
||||
*/
|
||||
AddressbookApp.prototype.change_grouped_view = function (node, widget) {
|
||||
var nm = etemplate2_1.etemplate2.getById('addressbook-index').widgetContainer.getDOMWidgetById('nm');
|
||||
var template = "addressbook.index.rows";
|
||||
var value = {};
|
||||
if (nm.activeFilters.sitemgr_display) {
|
||||
template = nm.activeFilters.sitemgr_display + '.rows';
|
||||
}
|
||||
else if (widget.getValue().indexOf("org_name") == 0) {
|
||||
template = "addressbook.index.org_rows";
|
||||
}
|
||||
else if (widget.getValue().indexOf('duplicate') === 0) {
|
||||
template = 'addressbook.index.duplicate_rows';
|
||||
}
|
||||
if (nm.activeFilters.col_filter.parent_id) {
|
||||
template = widget.getValue().indexOf('duplicate') === 0 ?
|
||||
'addressbook.index.duplicate_rows' : 'addressbook.index.org_rows';
|
||||
}
|
||||
var promise = nm.set_template(template);
|
||||
value[widget.id] = widget.getValue();
|
||||
if (promise) {
|
||||
jQuery.when.apply(null, promise).done(function () {
|
||||
nm.applyFilters(value);
|
||||
});
|
||||
}
|
||||
return !promise;
|
||||
};
|
||||
/**
|
||||
* Open CRM view
|
||||
*
|
||||
@ -178,7 +211,7 @@ var AddressbookApp = /** @class */ (function (_super) {
|
||||
*/
|
||||
AddressbookApp.prototype.view_set_list = function (filter) {
|
||||
// Find the infolog list
|
||||
var list = etemplate2.getById(jQuery(this.et2.getInstanceManager().DOMContainer).nextAll('.et2_container').attr('id'));
|
||||
var list = etemplate2_1.etemplate2.getById(jQuery(this.et2.getInstanceManager().DOMContainer).nextAll('.et2_container').attr('id'));
|
||||
var nm = list ? list.widgetContainer.getWidgetById('nm') : null;
|
||||
if (nm) {
|
||||
nm.applyFilters(filter);
|
||||
@ -810,7 +843,7 @@ var AddressbookApp = /** @class */ (function (_super) {
|
||||
var state = _super.prototype.getState.call(this);
|
||||
if (jQuery.isEmptyObject(state)) {
|
||||
// Not in a list view. Try to find contact ID
|
||||
var etemplates = etemplate2.getByApplication('addressbook');
|
||||
var etemplates = etemplate2_1.etemplate2.getByApplication('addressbook');
|
||||
for (var i = 0; i < etemplates.length; i++) {
|
||||
var content = etemplates[i].widgetContainer.getArrayMgr("content");
|
||||
if (content && content.getEntry('id')) {
|
||||
@ -854,7 +887,7 @@ var AddressbookApp = /** @class */ (function (_super) {
|
||||
// Clear advanced search, which is in session and etemplate
|
||||
egw.json('addressbook.addressbook_ui.ajax_clear_advanced_search', [], function () {
|
||||
framework.setWebsiteTitle('addressbook', '');
|
||||
var index = etemplate2.getById('addressbook-index');
|
||||
var index = etemplate2_1.etemplate2.getById('addressbook-index');
|
||||
if (index && index.widgetContainer) {
|
||||
var nm = index.widgetContainer.getWidgetById('nm');
|
||||
if (nm) {
|
||||
@ -869,7 +902,7 @@ var AddressbookApp = /** @class */ (function (_super) {
|
||||
else if (state.state.grouped_view) {
|
||||
// Deal with grouped views that are not valid (not in list of options)
|
||||
// by faking viewing that organisation
|
||||
var index = etemplate2.getById('addressbook-index');
|
||||
var index = etemplate2_1.etemplate2.getById('addressbook-index');
|
||||
if (index && index.widgetContainer) {
|
||||
var grouped = index.widgetContainer.getWidgetById('grouped_view');
|
||||
var options;
|
||||
|
@ -18,6 +18,7 @@ import '../jsapi/egw_global';
|
||||
import '../etemplate/et2_types';
|
||||
|
||||
import {EgwApp} from '../../api/js/jsapi/egw_app';
|
||||
import {etemplate2} from "../../api/js/etemplate/etemplate2";
|
||||
|
||||
/**
|
||||
* UI for Addressbook
|
||||
@ -167,6 +168,46 @@ class AddressbookApp extends EgwApp
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change handler for contact / org selectbox
|
||||
*
|
||||
* @param node
|
||||
* @param widget
|
||||
*/
|
||||
change_grouped_view(node, widget)
|
||||
{
|
||||
let nm = etemplate2.getById('addressbook-index').widgetContainer.getDOMWidgetById('nm');
|
||||
let template = "addressbook.index.rows";
|
||||
let value = {};
|
||||
|
||||
if(nm.activeFilters.sitemgr_display)
|
||||
{
|
||||
template = nm.activeFilters.sitemgr_display + '.rows';
|
||||
}
|
||||
else if(widget.getValue().indexOf("org_name") == 0)
|
||||
{
|
||||
template = "addressbook.index.org_rows";
|
||||
}
|
||||
else if(widget.getValue().indexOf('duplicate') === 0)
|
||||
{
|
||||
template = 'addressbook.index.duplicate_rows';
|
||||
}
|
||||
if(nm.activeFilters.col_filter.parent_id)
|
||||
{
|
||||
template = widget.getValue().indexOf('duplicate') === 0 ?
|
||||
'addressbook.index.duplicate_rows' : 'addressbook.index.org_rows';
|
||||
}
|
||||
let promise = nm.set_template(template)
|
||||
value[widget.id] = widget.getValue();
|
||||
if(promise)
|
||||
{
|
||||
jQuery.when.apply(null, promise).done(function ()
|
||||
{
|
||||
nm.applyFilters(value);
|
||||
});
|
||||
}
|
||||
return !promise;
|
||||
}
|
||||
/**
|
||||
* Open CRM view
|
||||
*
|
||||
|
@ -175,7 +175,7 @@
|
||||
</template>
|
||||
<template id="addressbook.index.row" template="" lang="" group="0" version="1.3.001">
|
||||
<buttononly align="right" statustext="Advanced search" image="advanced-search" background_image="1" id="advanced-search" onclick="egw(window).openPopup(egw::link('/index.php','menuaction=addressbook.addressbook_ui.search'),'870','610','_blank','addressbook',null,true); return false;"/>
|
||||
<select statustext="Select a view" id="grouped_view" no_lang="1" rows="1" empty_label="All contacts"/>
|
||||
<select statustext="Select a view" id="grouped_view" no_lang="1" rows="1" empty_label="All contacts" onchange="app.addressbook.change_grouped_view"/>
|
||||
</template>
|
||||
<template id="addressbook.index.right" template="" lang="" group="0" version="1.7.001">
|
||||
<select align="right" id="col_filter[tid]" empty_label="All types"/>
|
||||
|
@ -1564,6 +1564,7 @@ var et2_nextmatch = /** @class */ (function (_super) {
|
||||
this.dataview.destroy();
|
||||
this.rowProvider.destroy();
|
||||
this.controller.destroy();
|
||||
this.controller = null;
|
||||
// Free any children from previous template
|
||||
// They may get left behind because of how detached nodes are processed
|
||||
// We don't use iterateOver because it checks sub-children
|
||||
@ -1639,6 +1640,7 @@ var et2_nextmatch = /** @class */ (function (_super) {
|
||||
this.dynheight.initialized = false;
|
||||
this.resize();
|
||||
}, this));
|
||||
return promise;
|
||||
};
|
||||
// Some accessors to match conventions
|
||||
et2_nextmatch.prototype.set_hide_header = function (hide) {
|
||||
|
@ -2134,6 +2134,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
this.dataview.destroy();
|
||||
this.rowProvider.destroy();
|
||||
this.controller.destroy();
|
||||
this.controller = null;
|
||||
|
||||
// Free any children from previous template
|
||||
// They may get left behind because of how detached nodes are processed
|
||||
@ -2228,6 +2229,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
this.resize();
|
||||
}, this)
|
||||
);
|
||||
return promise;
|
||||
}
|
||||
|
||||
// Some accessors to match conventions
|
||||
|
Loading…
Reference in New Issue
Block a user