mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-07 20:16:53 +03:00
Merge pull request #29 from itdoginfo/feature/web-versions-view
feat: add validation and warning messages for regional lists
This commit is contained in:
@@ -112,6 +112,76 @@ return view.extend({
|
|||||||
o.rmempty = false;
|
o.rmempty = false;
|
||||||
o.ucisection = 'main';
|
o.ucisection = 'main';
|
||||||
|
|
||||||
|
let lastValues = [];
|
||||||
|
let isProcessing = false;
|
||||||
|
|
||||||
|
o.onchange = function (ev, section_id, value) {
|
||||||
|
if (isProcessing) return;
|
||||||
|
isProcessing = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const values = Array.isArray(value) ? value : [value];
|
||||||
|
let newValues = [...values];
|
||||||
|
let notifications = [];
|
||||||
|
|
||||||
|
// Проверка взаимоисключающих региональных опций
|
||||||
|
const regionalOptions = ['russia_inside', 'russia_outside', 'ukraine_inside'];
|
||||||
|
const selectedRegionalOptions = regionalOptions.filter(opt => newValues.includes(opt));
|
||||||
|
|
||||||
|
if (selectedRegionalOptions.length > 1) {
|
||||||
|
// Оставляем только последний выбранный региональный вариант
|
||||||
|
const lastSelected = selectedRegionalOptions[selectedRegionalOptions.length - 1];
|
||||||
|
const removedRegions = selectedRegionalOptions.slice(0, -1);
|
||||||
|
newValues = newValues.filter(v => v === lastSelected || !regionalOptions.includes(v));
|
||||||
|
|
||||||
|
const warningMsg = _('Warning: %s cannot be used together with %s. Previous selections have been removed.').format(
|
||||||
|
removedRegions.join(', '),
|
||||||
|
lastSelected
|
||||||
|
);
|
||||||
|
|
||||||
|
notifications.push(E('p', { class: 'alert-message warning' }, [
|
||||||
|
E('strong', {}, _('Regional options cannot be used together')), E('br'),
|
||||||
|
warningMsg
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Специальная обработка для russia_inside
|
||||||
|
if (newValues.includes('russia_inside')) {
|
||||||
|
const allowedWithRussiaInside = ['russia_inside', 'meta', 'twitter', 'discord', 'telegram'];
|
||||||
|
const removedServices = newValues.filter(v => !allowedWithRussiaInside.includes(v));
|
||||||
|
|
||||||
|
if (removedServices.length > 0) {
|
||||||
|
newValues = newValues.filter(v => allowedWithRussiaInside.includes(v));
|
||||||
|
|
||||||
|
const warningMsg = _('Warning: Russia inside can only be used with Meta, Twitter, Discord, and Telegram. %s have been removed from selection.').format(
|
||||||
|
removedServices.join(', ')
|
||||||
|
);
|
||||||
|
|
||||||
|
notifications.push(E('p', { class: 'alert-message warning' }, [
|
||||||
|
E('strong', {}, _('Russia inside restrictions')), E('br'),
|
||||||
|
warningMsg
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Если были изменения, обновляем значения
|
||||||
|
if (JSON.stringify(newValues.sort()) !== JSON.stringify(values.sort())) {
|
||||||
|
this.getUIElement(section_id).setValue(newValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Показываем все накопленные уведомления
|
||||||
|
notifications.forEach(notification => {
|
||||||
|
ui.addNotification(null, notification);
|
||||||
|
});
|
||||||
|
|
||||||
|
lastValues = newValues;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error in onchange handler:', e);
|
||||||
|
} finally {
|
||||||
|
isProcessing = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
o = s.taboption('basic', form.ListValue, 'custom_domains_list_type', _('User Domain List Type'), _('Select how to add your custom domains'));
|
o = s.taboption('basic', form.ListValue, 'custom_domains_list_type', _('User Domain List Type'), _('Select how to add your custom domains'));
|
||||||
o.value('disabled', _('Disabled'));
|
o.value('disabled', _('Disabled'));
|
||||||
o.value('dynamic', _('Dynamic List'));
|
o.value('dynamic', _('Dynamic List'));
|
||||||
@@ -844,7 +914,6 @@ return view.extend({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Add new section 'extra'
|
// Add new section 'extra'
|
||||||
var s = m.section(form.TypedSection, 'extra', _('Extra configurations'));
|
var s = m.section(form.TypedSection, 'extra', _('Extra configurations'));
|
||||||
s.anonymous = false;
|
s.anonymous = false;
|
||||||
|
|||||||
@@ -461,4 +461,20 @@ msgid "Show Sing-Box Config"
|
|||||||
msgstr "Показать конфигурацию Sing-Box"
|
msgstr "Показать конфигурацию Sing-Box"
|
||||||
|
|
||||||
msgid "Lists Update Results"
|
msgid "Lists Update Results"
|
||||||
msgstr "Результаты обновления списков"
|
msgstr "Результаты обновления списков"
|
||||||
|
|
||||||
|
#: applications/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js:XXX
|
||||||
|
msgid "Warning: %s cannot be used together with %s. Previous selections have been removed."
|
||||||
|
msgstr "Предупреждение: %s нельзя использовать вместе с %s. Предыдущие варианты были удалены."
|
||||||
|
|
||||||
|
#: applications/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js:XXX
|
||||||
|
msgid "Warning: Russia inside can only be used with Meta, Twitter, Discord, and Telegram. %s have been removed from selection."
|
||||||
|
msgstr "Внимание: Russia inside может использоваться только с Meta, Twitter, Discord и Telegram. %s были удалены из выбора."
|
||||||
|
|
||||||
|
#: applications/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js:XXX
|
||||||
|
msgid "Regional options cannot be used together"
|
||||||
|
msgstr "Нельзя использовать несколько региональных опций"
|
||||||
|
|
||||||
|
#: applications/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js:XXX
|
||||||
|
msgid "Russia inside restrictions"
|
||||||
|
msgstr "Ограничения Russia inside"
|
||||||
@@ -461,4 +461,20 @@ msgid "Show Sing-Box Config"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Lists Update Results"
|
msgid "Lists Update Results"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: applications/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js:XXX
|
||||||
|
msgid "Warning: %s cannot be used together with %s. Previous selections have been removed."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: applications/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js:XXX
|
||||||
|
msgid "Warning: Russia inside can only be used with Meta, Twitter, Discord, and Telegram. %s have been removed from selection."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: applications/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js:XXX
|
||||||
|
msgid "Regional options cannot be used together"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: applications/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js:XXX
|
||||||
|
msgid "Russia inside restrictions"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
Reference in New Issue
Block a user