Skip to content

Commit

Permalink
#767 Добавил вывод информации об ошибки в случае проблем с сохранение…
Browse files Browse the repository at this point in the history
…м настроек
  • Loading branch information
boffart committed Jul 10, 2024
1 parent 5bd2680 commit 332526e
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,49 @@ const generalSettingsModify = {
* @param {Object} response - The response from the server after the form is sent
*/
cbAfterSendForm(response) {
$("#error-messages").remove();
if (!response.success) {
Form.$submitButton.removeClass('disabled');
generalSettingsModify.generateErrorMessageHtml(response);
} else {
$('.password-validate').remove();
}
generalSettingsModify.checkDeleteAllConditions();
},

/**
* The function collects an information message about a data saving error
* @param response
* @returns {string}
*/
generateErrorMessageHtml(response) {
if (response.messages && response.messages.error) {
const $div = $('<div>', { class: 'ui negative message', id: 'error-messages' });
const $header = $('<div>', { class: 'header' }).text(globalTranslate.gs_ErrorSaveSettings);
$div.append($header);
const $ul = $('<ul>', { class: 'list' });
const messagesSet = new Set();
response.messages.error.forEach(errorArray => {
errorArray.forEach(error => {
let textContent ='';
if(globalTranslate[error.message] === undefined){
textContent = error.message;
}else{
textContent = globalTranslate[error.message];
}
if (messagesSet.has(textContent)) {
return;
}
messagesSet.add(error.message);
$ul.append($('<li>').text(textContent));
});
});
$div.append($ul);
$('#submitbutton').before($div);
return $div;
}
},

/**
* Initialize the validation rules of the form
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Common/Messages/ru.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@
'gs_PBXRecordSavePeriodLabel' => 'Период хранения записей разговоров',
'gs_StoreAllPossibleRecords' => '',
'gs_DisableAllModules' => 'Отключить маркетплейс',
'gs_ErrorSaveSettings' => 'Ошибка сохранения настроек',
'mo_ThisNumberNotUniqueForExtensionsModels' => 'Указанный внутренний номер уже используется',
'pr_AddSIPProvider' => 'Подключить SIP',
'pr_AddIAXProvider' => 'Подключить IAX',
'pr_QualifyInstructionsIAX' => 'При включение этой опции Asterisk будет отправлять SIP Options пакеты. Это необходимо для поддержки NAT туннелирования на вашем маршрутизаторе.',
Expand Down

0 comments on commit 332526e

Please sign in to comment.