From 585da04bb72d36a894f6ea5939ab909e53fd8c23 Mon Sep 17 00:00:00 2001
From: Mariusz Krzaczkowski
Date: Fri, 10 Dec 2021 10:29:46 +0100
Subject: [PATCH] Added minor improvements
---
app/Controller/View/Page.php | 4 +-
config/version.php | 4 +-
.../Users/Modals/PasswordModalFooter.tpl | 52 +++++++++----------
layouts/basic/modules/Vtiger/Index.tpl | 4 +-
modules/Users/actions/Logout.php | 8 ---
.../basic/modules/Vtiger/resources/List.js | 10 ++--
.../modules/Vtiger/resources/RelatedList.js | 2 +-
.../basic/modules/Vtiger/resources/Vtiger.js | 2 +-
public_html/layouts/resources/Connector.js | 29 +++++++++--
public_html/layouts/resources/app.js | 39 ++++++--------
10 files changed, 81 insertions(+), 73 deletions(-)
diff --git a/app/Controller/View/Page.php b/app/Controller/View/Page.php
index dac682a6975f..f19711229ec8 100644
--- a/app/Controller/View/Page.php
+++ b/app/Controller/View/Page.php
@@ -175,7 +175,7 @@ protected function getMenuHeaderLinks(\App\Request $request): array
'linklabel' => 'LBL_SIGN_OUT',
'linkurl' => 'index.php?module=Users&parent=Settings&action=Logout',
'icon' => 'fas fa-power-off fa-fw',
- 'linkclass' => 'btn-danger d-md-none',
+ 'linkclass' => 'btn-danger d-md-none js-post-action',
];
$headerLinkInstances = [];
foreach ($headerLinks as $headerLink) {
@@ -254,7 +254,7 @@ protected function getUserQuickMenuLinks(\App\Request $request): array
'linklabel' => 'LBL_SIGN_OUT',
'linkurl' => 'index.php?module=Users&parent=Settings&action=Logout',
'icon' => 'fas fa-power-off fa-fw',
- 'linkclass' => 'd-none d-sm-none d-md-block',
+ 'linkclass' => 'd-none d-sm-none d-md-block js-post-action',
];
$headerLinkInstances = [];
foreach ($headerLinks as $headerLink) {
diff --git a/config/version.php b/config/version.php
index c64b7f7d366d..6bb53d72b5e8 100644
--- a/config/version.php
+++ b/config/version.php
@@ -1,7 +1,7 @@
'6.2.262',
- 'patchVersion' => '2021.12.09',
+ 'appVersion' => '6.2.263',
+ 'patchVersion' => '2021.12.10',
'lib_roundcube' => '0.2.3',
];
diff --git a/layouts/basic/modules/Users/Modals/PasswordModalFooter.tpl b/layouts/basic/modules/Users/Modals/PasswordModalFooter.tpl
index bf719b0d27bd..0a2c530bd32f 100644
--- a/layouts/basic/modules/Users/Modals/PasswordModalFooter.tpl
+++ b/layouts/basic/modules/Users/Modals/PasswordModalFooter.tpl
@@ -1,29 +1,29 @@
{**}
{strip}
-
-
-
-
+
+
+
+
{/strip}
diff --git a/layouts/basic/modules/Vtiger/Index.tpl b/layouts/basic/modules/Vtiger/Index.tpl
index d38344764d20..3d437aa38fc0 100644
--- a/layouts/basic/modules/Vtiger/Index.tpl
+++ b/layouts/basic/modules/Vtiger/Index.tpl
@@ -20,10 +20,10 @@
{\App\Language::translate('LBL_GO_BACK')}
-
+
{\App\Language::translate('LBL_SIGN_OUT')}
-
+
{\App\Language::translate('LBL_MAIN_PAGE')}
diff --git a/modules/Users/actions/Logout.php b/modules/Users/actions/Logout.php
index 293dce0781c1..1d0c92af33b7 100644
--- a/modules/Users/actions/Logout.php
+++ b/modules/Users/actions/Logout.php
@@ -38,12 +38,4 @@ public function process(App\Request $request)
//End
header('location: index.php');
}
-
- /**
- * {@inheritdoc}
- */
- public function validateRequest(App\Request $request)
- {
- $request->validateReadAccess();
- }
}
diff --git a/public_html/layouts/basic/modules/Vtiger/resources/List.js b/public_html/layouts/basic/modules/Vtiger/resources/List.js
index afcc93eb5527..f8182a83873c 100644
--- a/public_html/layouts/basic/modules/Vtiger/resources/List.js
+++ b/public_html/layouts/basic/modules/Vtiger/resources/List.js
@@ -195,7 +195,7 @@ $.Class(
let formData = container.find('.js-modal-form').serializeFormData();
const listInstance = Vtiger_List_Js.getInstance();
$.extend(formData, listInstance.getSearchParams());
- app.openUrlMethodPost('index.php', formData);
+ AppConnector.requestForm('index.php', formData);
Vtiger_Helper_Js.showMessage({
text: app.vtranslate('JS_STARTED_GENERATING_FILE'),
type: 'info'
@@ -355,7 +355,7 @@ $.Class(
}
let params = Vtiger_List_Js.getInstance().getSearchParams();
delete params.view;
- app.openUrlMethodPost(exportActionUrl, params, formAttr);
+ AppConnector.requestForm(exportActionUrl, params, formAttr);
},
/**
* Function to reload list
@@ -1488,7 +1488,7 @@ $.Class(
Vtiger_Helper_Js.showConfirmationBox({
message: app.vtranslate('JS_LBL_ARE_YOU_SURE_YOU_WANT_TO_DELETE_FILTER')
}).done((e) => {
- app.openUrlMethodPost(thisInstance.getSelectOptionFromChosenOption(liElement).data('deleteurl'));
+ AppConnector.requestForm(thisInstance.getSelectOptionFromChosenOption(liElement).data('deleteurl'));
});
event.stopPropagation();
});
@@ -1505,7 +1505,7 @@ $.Class(
//to close the dropdown
thisInstance.getFilterSelectElement().data('select2').close();
const liElement = $(event.currentTarget).closest('.select2-results__option');
- app.openUrlMethodPost(thisInstance.getSelectOptionFromChosenOption(liElement).data('approveurl'));
+ AppConnector.requestForm(thisInstance.getSelectOptionFromChosenOption(liElement).data('approveurl'));
event.stopPropagation();
});
}
@@ -1521,7 +1521,7 @@ $.Class(
//to close the dropdown
thisInstance.getFilterSelectElement().data('select2').close();
const liElement = $(event.currentTarget).closest('.select2-results__option');
- app.openUrlMethodPost(thisInstance.getSelectOptionFromChosenOption(liElement).data('denyurl'));
+ AppConnector.requestForm(thisInstance.getSelectOptionFromChosenOption(liElement).data('denyurl'));
event.stopPropagation();
});
}
diff --git a/public_html/layouts/basic/modules/Vtiger/resources/RelatedList.js b/public_html/layouts/basic/modules/Vtiger/resources/RelatedList.js
index 1301ef13ceac..ba07361655a9 100644
--- a/public_html/layouts/basic/modules/Vtiger/resources/RelatedList.js
+++ b/public_html/layouts/basic/modules/Vtiger/resources/RelatedList.js
@@ -86,7 +86,7 @@ jQuery.Class(
data: postData
};
if (type === 'sendByForm') {
- app.openUrlMethodPost(massActionUrl, postData);
+ AppConnector.requestForm(massActionUrl, postData);
progressIndicatorElement.progressIndicator({ mode: 'hide' });
} else {
AppConnector.request(actionParams)
diff --git a/public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js b/public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js
index a03d697a3af6..2ff5e497f411 100644
--- a/public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js
+++ b/public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js
@@ -171,7 +171,7 @@ var Vtiger_Index_Js = {
form.append($('', { name: i, value: JSON.stringify(postData[i]) }));
}
$('body').append(form);
- form.submit();
+ form.trigger('submit');
} else {
window.location.href = url;
}
diff --git a/public_html/layouts/resources/Connector.js b/public_html/layouts/resources/Connector.js
index 63904e11a851..4c98f2e552f8 100644
--- a/public_html/layouts/resources/Connector.js
+++ b/public_html/layouts/resources/Connector.js
@@ -146,8 +146,31 @@ window.AppConnector = {
}
return aDeferred.promise();
},
-
- requestForm: function (url, params = {}) {
- app.openUrlMethodPost(url, params);
+ /**
+ * Send form data
+ * @param {string} url
+ * @param {object} postData
+ * @param {object} formAttr
+ */
+ requestForm: function (url, postData = {}, formAttr = {}) {
+ $.extend(formAttr, {
+ method: 'post',
+ action: url,
+ style: 'display:none;'
+ });
+ let form = $('', formAttr);
+ if (typeof csrfMagicName !== 'undefined') {
+ postData[csrfMagicName] = csrfMagicToken;
+ }
+ $.each(postData, (index, value) => {
+ let input = $(document.createElement('input'));
+ input.attr('type', 'hidden');
+ input.attr('name', index);
+ input.val(value);
+ form.append(input);
+ });
+ $('body').append(form);
+ form.trigger('submit');
+ form.remove();
}
};
diff --git a/public_html/layouts/resources/app.js b/public_html/layouts/resources/app.js
index 29205a5b1cd6..af4a6d77af70 100644
--- a/public_html/layouts/resources/app.js
+++ b/public_html/layouts/resources/app.js
@@ -306,7 +306,7 @@ var App = (window.App = {
$(data).removeAttr('data-validation-engine');
});
form.addClass('not_validation');
- form.submit();
+ form.trigger('submit');
},
/**
* Register tab events
@@ -484,7 +484,7 @@ var App = (window.App = {
$(data).removeAttr('data-validation-engine');
});
form.addClass('not_validation');
- form.submit();
+ form.trigger('submit');
},
/**
* Save quick create form
@@ -2627,27 +2627,6 @@ var app = (window.app = {
window.location.href = url;
}
},
- openUrlMethodPost(url, postData = {}, formAttr = {}) {
- $.extend(formAttr, {
- method: 'post',
- action: url,
- style: 'display:none;'
- });
- let form = $('', formAttr);
- if (typeof csrfMagicName !== 'undefined') {
- postData[csrfMagicName] = csrfMagicToken;
- }
- $.each(postData, (index, value) => {
- let input = $(document.createElement('input'));
- input.attr('type', 'hidden');
- input.attr('name', index);
- input.val(value);
- form.append(input);
- });
- $('body').append(form);
- form.submit();
- form.remove();
- },
/**
* Convert url string to object
*
@@ -3177,6 +3156,19 @@ var app = (window.app = {
}
});
}
+ },
+ /**
+ * Register POST action
+ * @param {jQuery} container
+ */
+ registerPostActionEvent: function (container) {
+ container.on('click', '.js-post-action', function (e) {
+ e.preventDefault();
+ let element = $(this);
+ if (element.attr('href')) {
+ AppConnector.requestForm(element.attr('href'));
+ }
+ });
}
});
CKEDITOR.disableAutoInline = true;
@@ -3203,6 +3195,7 @@ $(function () {
app.registerFormsEvents(document);
app.registerRecordActionsEvents(document);
app.registerKeyboardShortcutsEvent(document);
+ app.registerPostActionEvent(document);
App.Components.QuickCreate.register(document);
App.Components.Scrollbar.initPage();
App.Clipboard.register(document);