mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 05:05:56 +00:00
add two helper account access levels:
- read only - can't subscribe to more feeds, feed updates are skipped - disabled - can't login define used access levels as UserHelper constants and refactor code to use them instead of hardcoded numbers
This commit is contained in:
12
js/App.js
12
js/App.js
@@ -17,6 +17,9 @@ const App = {
|
||||
hotkey_actions: {},
|
||||
is_prefs: false,
|
||||
LABEL_BASE_INDEX: -1024,
|
||||
UserAccessLevels: {
|
||||
ACCESS_LEVEL_READONLY: -1
|
||||
},
|
||||
_translations: {},
|
||||
Hash: {
|
||||
get: function() {
|
||||
@@ -76,10 +79,15 @@ const App = {
|
||||
</select>
|
||||
`
|
||||
},
|
||||
select_hash: function(name, value, values = {}, attributes = {}, id = "") {
|
||||
select_hash: function(name, value, values = {}, attributes = {}, id = "", params = {}) {
|
||||
let keys = Object.keys(values);
|
||||
|
||||
if (params.numeric_sort)
|
||||
keys = keys.sort((a,b) => a - b);
|
||||
|
||||
return `
|
||||
<select name="${name}" dojoType="fox.form.Select" id="${App.escapeHtml(id)}" ${this.attributes_to_string(attributes)}>
|
||||
${Object.keys(values).map((vk) =>
|
||||
${keys.map((vk) =>
|
||||
`<option ${vk == value ? 'selected="selected"' : ''} value="${App.escapeHtml(vk)}">${App.escapeHtml(values[vk])}</option>`
|
||||
).join("")}
|
||||
</select>
|
||||
|
||||
@@ -131,6 +131,9 @@ const CommonDialogs = {
|
||||
console.log(rc);
|
||||
|
||||
switch (parseInt(rc['code'])) {
|
||||
case 0:
|
||||
dialog.show_error(__("You are already subscribed to this feed."));
|
||||
break;
|
||||
case 1:
|
||||
dialog.hide();
|
||||
Notify.info(__("Subscribed to %s").replace("%s", feed_url));
|
||||
@@ -175,8 +178,11 @@ const CommonDialogs = {
|
||||
case 6:
|
||||
dialog.show_error(__("XML validation failed: %s").replace("%s", rc['message']));
|
||||
break;
|
||||
case 0:
|
||||
dialog.show_error(__("You are already subscribed to this feed."));
|
||||
case 7:
|
||||
dialog.show_error(__("Error while creating feed database entry."));
|
||||
break;
|
||||
case 8:
|
||||
dialog.show_error(__("You are not allowed to perform this operation."));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -451,6 +457,7 @@ const CommonDialogs = {
|
||||
|
||||
xhr.json("backend.php", {op: "pref-feeds", method: "editfeed", id: feed_id}, (reply) => {
|
||||
const feed = reply.feed;
|
||||
const is_readonly = reply.user.access_level == App.UserAccessLevels.ACCESS_LEVEL_READONLY;
|
||||
|
||||
// for unsub prompt
|
||||
dialog.feed_title = feed.title;
|
||||
@@ -524,7 +531,9 @@ const CommonDialogs = {
|
||||
|
||||
<fieldset>
|
||||
<label>${__("Update interval:")}</label>
|
||||
${App.FormFields.select_hash("update_interval", feed.update_interval, reply.intervals.update)}
|
||||
${App.FormFields.select_hash("update_interval", is_readonly ? -1 : feed.update_interval,
|
||||
reply.intervals.update,
|
||||
{disabled: is_readonly})}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label>${__('Article purging:')}</label>
|
||||
|
||||
@@ -75,7 +75,7 @@ const Users = {
|
||||
<fieldset>
|
||||
<label>${__('Access level: ')}</label>
|
||||
${App.FormFields.select_hash("access_level",
|
||||
user.access_level, reply.access_level_names, {disabled: admin_disabled.toString()})}
|
||||
user.access_level, reply.access_level_names, {disabled: admin_disabled.toString()}, "", {numeric_sort: true})}
|
||||
|
||||
${admin_disabled ? App.FormFields.hidden_tag("access_level",
|
||||
user.access_level.toString()) : ''}
|
||||
|
||||
Reference in New Issue
Block a user