mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-04 12:29:25 +01:00
avoid second full refresh by sending delete action via ajax
This commit is contained in:
parent
56376465f2
commit
6d4aaade1b
@ -1029,7 +1029,6 @@ class infolog_ui
|
|||||||
if (!isset($this->bo->grants[$group])) unset($sel_options['info_type'][$type]);
|
if (!isset($this->bo->grants[$group])) unset($sel_options['info_type'][$type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $this->tmpl->exec('infolog.infolog_ui.index',$values,$sel_options,$readonlys,$persist,$return_html ? -1 : 0);
|
return $this->tmpl->exec('infolog.infolog_ui.index',$values,$sel_options,$readonlys,$persist,$return_html ? -1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1333,6 +1332,33 @@ class infolog_ui
|
|||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply an action to multiple events, but called via AJAX instead of submit
|
||||||
|
*
|
||||||
|
* @param string $action
|
||||||
|
* @param string[] $selected
|
||||||
|
* @param bool $all_selected All events are selected, not just what's in $selected
|
||||||
|
*/
|
||||||
|
public function ajax_action($action, $selected, $all_selected)
|
||||||
|
{
|
||||||
|
$success = 0;
|
||||||
|
$failed = 0;
|
||||||
|
$action_msg = '';
|
||||||
|
$session_name = 'calendar_list';
|
||||||
|
|
||||||
|
if($this->action($action, $selected, $all_selected, $success, $failed, $action_msg, [], $msg))
|
||||||
|
{
|
||||||
|
$msg = lang('%1 entries %2',$success,$action_msg);
|
||||||
|
}
|
||||||
|
elseif(is_null($msg))
|
||||||
|
{
|
||||||
|
$msg = lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
|
||||||
|
}
|
||||||
|
$app = Api\Json\Push::onlyFallback() || $all_selected ? 'infolog' : 'msg-only-push-refresh';
|
||||||
|
Api\Json\Response::get()->call('egw.refresh', $msg, $app, $selected[0], $all_selected || count($selected) > 1 ? null :
|
||||||
|
$action === 'delete' ? 'delete' : 'edit', $app, null, null, $failed ? 'error' : 'success');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles actions on multiple infologs
|
* Handles actions on multiple infologs
|
||||||
*
|
*
|
||||||
|
@ -30,7 +30,6 @@ require("jqueryui");
|
|||||||
require("../jsapi/egw_global");
|
require("../jsapi/egw_global");
|
||||||
require("../etemplate/et2_types");
|
require("../etemplate/et2_types");
|
||||||
var egw_app_1 = require("../../api/js/jsapi/egw_app");
|
var egw_app_1 = require("../../api/js/jsapi/egw_app");
|
||||||
var et2_widget_dialog_1 = require("../../api/js/etemplate/et2_widget_dialog");
|
|
||||||
var etemplate2_1 = require("../../api/js/etemplate/etemplate2");
|
var etemplate2_1 = require("../../api/js/etemplate/etemplate2");
|
||||||
var et2_extension_nextmatch_1 = require("../../api/js/etemplate/et2_extension_nextmatch");
|
var et2_extension_nextmatch_1 = require("../../api/js/etemplate/et2_extension_nextmatch");
|
||||||
/**
|
/**
|
||||||
@ -46,8 +45,12 @@ var InfologApp = /** @class */ (function (_super) {
|
|||||||
* @memberOf app.infolog
|
* @memberOf app.infolog
|
||||||
*/
|
*/
|
||||||
function InfologApp() {
|
function InfologApp() {
|
||||||
|
var _this =
|
||||||
// call parent
|
// call parent
|
||||||
return _super.call(this, 'infolog', 'info_datemodified') || this;
|
_super.call(this, 'infolog', 'info_datemodified') || this;
|
||||||
|
_this._action_ids = [];
|
||||||
|
_this._action_all = false;
|
||||||
|
return _this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@ -352,24 +355,6 @@ var InfologApp = /** @class */ (function (_super) {
|
|||||||
(show) ? $select.each(function (i, e) { jQuery(e).hide(); }) : $select.each(function (i, e) { jQuery(e).show(); });
|
(show) ? $select.each(function (i, e) { jQuery(e).hide(); }) : $select.each(function (i, e) { jQuery(e).show(); });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
InfologApp.prototype.confirm_delete_2 = function (_action, _senders) {
|
|
||||||
var children = false;
|
|
||||||
var child_button = jQuery('#delete_sub').get(0) || jQuery('[id*="delete_sub"]').get(0);
|
|
||||||
if (child_button) {
|
|
||||||
for (var i = 0; i < _senders.length; i++) {
|
|
||||||
if (jQuery(_senders[i].iface.node).hasClass('infolog_rowHasSubs')) {
|
|
||||||
children = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
child_button.style.display = children ? 'block' : 'none';
|
|
||||||
}
|
|
||||||
var callbackDeleteDialog = function (button_id) {
|
|
||||||
if (button_id == et2_widget_dialog_1.et2_dialog.YES_BUTTON) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
et2_widget_dialog_1.et2_dialog.show_dialog(callbackDeleteDialog, this.egw.lang("Do you really want to DELETE this Rule"), this.egw.lang("Delete"), {}, et2_widget_dialog_1.et2_dialog.BUTTONS_YES_NO_CANCEL, et2_widget_dialog_1.et2_dialog.WARNING_MESSAGE);
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Confirm delete
|
* Confirm delete
|
||||||
* If entry has children, asks if you want to delete children too
|
* If entry has children, asks if you want to delete children too
|
||||||
@ -378,10 +363,14 @@ var InfologApp = /** @class */ (function (_super) {
|
|||||||
*@param _senders
|
*@param _senders
|
||||||
*/
|
*/
|
||||||
InfologApp.prototype.confirm_delete = function (_action, _senders) {
|
InfologApp.prototype.confirm_delete = function (_action, _senders) {
|
||||||
|
var _a;
|
||||||
var children = false;
|
var children = false;
|
||||||
var child_button = jQuery('#delete_sub').get(0) || jQuery('[id*="delete_sub"]').get(0);
|
var child_button = jQuery('#delete_sub').get(0) || jQuery('[id*="delete_sub"]').get(0);
|
||||||
|
this._action_all = (_a = _action.parent.data.nextmatch) === null || _a === void 0 ? void 0 : _a.getSelection().all;
|
||||||
|
this._action_ids = [];
|
||||||
if (child_button) {
|
if (child_button) {
|
||||||
for (var i = 0; i < _senders.length; i++) {
|
for (var i = 0; i < _senders.length; i++) {
|
||||||
|
this._action_ids.push(_senders[i].id.split("::").pop());
|
||||||
if (jQuery(_senders[i].iface.getDOMNode()).hasClass('infolog_rowHasSubs')) {
|
if (jQuery(_senders[i].iface.getDOMNode()).hasClass('infolog_rowHasSubs')) {
|
||||||
children = true;
|
children = true;
|
||||||
break;
|
break;
|
||||||
@ -391,6 +380,14 @@ var InfologApp = /** @class */ (function (_super) {
|
|||||||
}
|
}
|
||||||
nm_open_popup(_action, _senders);
|
nm_open_popup(_action, _senders);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Callback for action using ids set(!) in this._action_ids and this._action_all
|
||||||
|
*
|
||||||
|
* @param _action
|
||||||
|
*/
|
||||||
|
InfologApp.prototype.actionCallback = function (_action) {
|
||||||
|
egw.json("infolog.infolog_ui.ajax_action", [_action, this._action_ids, this._action_all]).sendRequest(true);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Add email from addressbook
|
* Add email from addressbook
|
||||||
*
|
*
|
||||||
|
@ -397,32 +397,6 @@ class InfologApp extends EgwApp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
confirm_delete_2(_action, _senders)
|
|
||||||
{
|
|
||||||
var children = false;
|
|
||||||
var child_button = jQuery('#delete_sub').get(0) || jQuery('[id*="delete_sub"]').get(0);
|
|
||||||
if(child_button)
|
|
||||||
{
|
|
||||||
for(var i = 0; i < _senders.length; i++)
|
|
||||||
{
|
|
||||||
if (jQuery(_senders[i].iface.node).hasClass('infolog_rowHasSubs'))
|
|
||||||
{
|
|
||||||
children = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
child_button.style.display = children ? 'block' : 'none';
|
|
||||||
}
|
|
||||||
var callbackDeleteDialog = function (button_id)
|
|
||||||
{
|
|
||||||
if (button_id == et2_dialog.YES_BUTTON )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
et2_dialog.show_dialog(callbackDeleteDialog, this.egw.lang("Do you really want to DELETE this Rule"),this.egw.lang("Delete"), {},et2_dialog.BUTTONS_YES_NO_CANCEL, et2_dialog.WARNING_MESSAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Confirm delete
|
* Confirm delete
|
||||||
* If entry has children, asks if you want to delete children too
|
* If entry has children, asks if you want to delete children too
|
||||||
@ -432,12 +406,16 @@ class InfologApp extends EgwApp
|
|||||||
*/
|
*/
|
||||||
confirm_delete(_action, _senders)
|
confirm_delete(_action, _senders)
|
||||||
{
|
{
|
||||||
var children = false;
|
let children = false;
|
||||||
var child_button = jQuery('#delete_sub').get(0) || jQuery('[id*="delete_sub"]').get(0);
|
let child_button = jQuery('#delete_sub').get(0) || jQuery('[id*="delete_sub"]').get(0);
|
||||||
|
this._action_all = _action.parent.data.nextmatch?.getSelection().all;
|
||||||
|
this._action_ids = [];
|
||||||
if(child_button)
|
if(child_button)
|
||||||
{
|
{
|
||||||
for(var i = 0; i < _senders.length; i++)
|
for(let i = 0; i < _senders.length; i++)
|
||||||
{
|
{
|
||||||
|
this._action_ids.push(_senders[i].id.split("::").pop());
|
||||||
|
|
||||||
if (jQuery(_senders[i].iface.getDOMNode()).hasClass('infolog_rowHasSubs'))
|
if (jQuery(_senders[i].iface.getDOMNode()).hasClass('infolog_rowHasSubs'))
|
||||||
{
|
{
|
||||||
children = true;
|
children = true;
|
||||||
@ -449,6 +427,19 @@ class InfologApp extends EgwApp
|
|||||||
nm_open_popup(_action, _senders);
|
nm_open_popup(_action, _senders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _action_ids = [];
|
||||||
|
private _action_all = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback for action using ids set(!) in this._action_ids and this._action_all
|
||||||
|
*
|
||||||
|
* @param _action
|
||||||
|
*/
|
||||||
|
actionCallback(_action)
|
||||||
|
{
|
||||||
|
egw.json("infolog.infolog_ui.ajax_action",[_action, this._action_ids, this._action_all]).sendRequest(true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add email from addressbook
|
* Add email from addressbook
|
||||||
*
|
*
|
||||||
|
@ -177,8 +177,8 @@
|
|||||||
<description value="Delete" class="promptheader"/>
|
<description value="Delete" class="promptheader"/>
|
||||||
<description value="Delete selected entries?" id="delete_prompt"/>
|
<description value="Delete selected entries?" id="delete_prompt"/>
|
||||||
<hbox>
|
<hbox>
|
||||||
<button label="Yes - Delete" id="delete" onclick="nm_submit_popup(this); return false;" image="check" background_image="true"/>
|
<button label="Yes - Delete" id="delete" onclick="app.infolog.actionCallback('delete'); return false;" image="check" background_image="true"/>
|
||||||
<button label="Yes - Delete including sub-entries" id="delete_sub" onclick="nm_popup_action.id = 'delete_sub'; nm_submit_popup(this); return false;" image="check" background_image="true"/>
|
<button label="Yes - Delete including sub-entries" id="delete_sub" onclick="app.infolog.actionCallback('delete_sub'); return false;" image="check" background_image="true"/>
|
||||||
<button label="No - Cancel" id="delete_cancel" onclick="nm_hide_popup(this,'delete_popup');" image="cancelled" background_image="true"/>
|
<button label="No - Cancel" id="delete_cancel" onclick="nm_hide_popup(this,'delete_popup');" image="cancelled" background_image="true"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
@ -1058,6 +1058,7 @@ class timesheet_ui extends timesheet_bo
|
|||||||
'children' => $this->get_status_labels(),
|
'children' => $this->get_status_labels(),
|
||||||
'prefix' => 'to_status_',
|
'prefix' => 'to_status_',
|
||||||
'enabled' => (boolean)$this->get_status_labels(),
|
'enabled' => (boolean)$this->get_status_labels(),
|
||||||
|
'onExecute' => 'javaScript:app.timesheet.ajax_action',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1087,6 +1088,7 @@ class timesheet_ui extends timesheet_bo
|
|||||||
'confirm_multiple' => 'Delete these entries',
|
'confirm_multiple' => 'Delete these entries',
|
||||||
'group' => ++$group,
|
'group' => ++$group,
|
||||||
'disableClass' => 'rowNoDelete',
|
'disableClass' => 'rowNoDelete',
|
||||||
|
'onExecute' => 'javaScript:app.timesheet.ajax_action',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if ($query['col_filter']['ts_status'] == self::DELETED_STATUS)
|
if ($query['col_filter']['ts_status'] == self::DELETED_STATUS)
|
||||||
@ -1098,6 +1100,7 @@ class timesheet_ui extends timesheet_bo
|
|||||||
'icon' => 'revert',
|
'icon' => 'revert',
|
||||||
'group' => $group,
|
'group' => $group,
|
||||||
'disableClass' => 'rowNoUndelete',
|
'disableClass' => 'rowNoUndelete',
|
||||||
|
'onExecute' => 'javaScript:app.timesheet.ajax_action',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// enable additonal edit check for following actions, if they are generally available
|
// enable additonal edit check for following actions, if they are generally available
|
||||||
@ -1112,6 +1115,33 @@ class timesheet_ui extends timesheet_bo
|
|||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply an action to multiple events, but called via AJAX instead of submit
|
||||||
|
*
|
||||||
|
* @param string $action
|
||||||
|
* @param string[] $selected
|
||||||
|
* @param bool $all_selected All events are selected, not just what's in $selected
|
||||||
|
*/
|
||||||
|
public function ajax_action($action, $selected, $all_selected)
|
||||||
|
{
|
||||||
|
$success = 0;
|
||||||
|
$failed = 0;
|
||||||
|
$action_msg = '';
|
||||||
|
$session_name = 'index';
|
||||||
|
|
||||||
|
if($this->action($action, $selected, $all_selected, $success, $failed, $action_msg, $session_name, $msg))
|
||||||
|
{
|
||||||
|
$msg .= lang('%1 timesheets(s) %2',$success,$action_msg);
|
||||||
|
}
|
||||||
|
elseif(empty($msg))
|
||||||
|
{
|
||||||
|
$msg = lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
|
||||||
|
}
|
||||||
|
$app = Api\Json\Push::onlyFallback() || $all_selected ? 'timesheet' : 'msg-only-push-refresh';
|
||||||
|
Api\Json\Response::get()->call('egw.refresh', $msg, $app, $selected[0], $all_selected || count($selected) > 1 ? null :
|
||||||
|
$action === 'delete' ? 'delete' : 'edit', $app, null, null, $failed ? 'error' : 'success');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* apply an action to multiple timesheets
|
* apply an action to multiple timesheets
|
||||||
*
|
*
|
||||||
|
@ -209,6 +209,21 @@ var TimesheetApp = /** @class */ (function (_super) {
|
|||||||
}
|
}
|
||||||
etemplate2_1.etemplate2.app_refresh("", pushData.app, pushData.id, pushData.type);
|
etemplate2_1.etemplate2.app_refresh("", pushData.app, pushData.id, pushData.type);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Run action via ajax
|
||||||
|
*
|
||||||
|
* @param _action
|
||||||
|
* @param _senders
|
||||||
|
*/
|
||||||
|
TimesheetApp.prototype.ajax_action = function (_action, _senders) {
|
||||||
|
var _a;
|
||||||
|
var all = (_a = _action.parent.data.nextmatch) === null || _a === void 0 ? void 0 : _a.getSelection().all;
|
||||||
|
var ids = [];
|
||||||
|
for (var i = 0; i < _senders.length; i++) {
|
||||||
|
ids.push(_senders[i].id.split("::").pop());
|
||||||
|
}
|
||||||
|
egw.json("timesheet.timesheet_ui.ajax_action", [_action.id, ids, all]).sendRequest(true);
|
||||||
|
};
|
||||||
return TimesheetApp;
|
return TimesheetApp;
|
||||||
}(egw_app_1.EgwApp));
|
}(egw_app_1.EgwApp));
|
||||||
app.classes.timesheet = TimesheetApp;
|
app.classes.timesheet = TimesheetApp;
|
||||||
|
@ -242,6 +242,23 @@ class TimesheetApp extends EgwApp
|
|||||||
}
|
}
|
||||||
etemplate2.app_refresh("",pushData.app, pushData.id, pushData.type);
|
etemplate2.app_refresh("",pushData.app, pushData.id, pushData.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run action via ajax
|
||||||
|
*
|
||||||
|
* @param _action
|
||||||
|
* @param _senders
|
||||||
|
*/
|
||||||
|
ajax_action(_action, _senders)
|
||||||
|
{
|
||||||
|
let all = _action.parent.data.nextmatch?.getSelection().all;
|
||||||
|
let ids = [];
|
||||||
|
for(let i = 0; i < _senders.length; i++)
|
||||||
|
{
|
||||||
|
ids.push(_senders[i].id.split("::").pop());
|
||||||
|
}
|
||||||
|
egw.json("timesheet.timesheet_ui.ajax_action",[_action.id, ids, all]).sendRequest(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.classes.timesheet = TimesheetApp;
|
app.classes.timesheet = TimesheetApp;
|
||||||
|
Loading…
Reference in New Issue
Block a user