Fixed icon updates for channel groups and permission
parent
64fce4f3c6
commit
414636a1d5
|
@ -616,7 +616,7 @@ class IconManager {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
id = id >>> 0;
|
id = id >>> 0;
|
||||||
if(id == 0)
|
if(id == 0 || !id)
|
||||||
return $.spawn("div").addClass("icon_empty");
|
return $.spawn("div").addClass("icon_empty");
|
||||||
else if(id < 1000)
|
else if(id < 1000)
|
||||||
return $.spawn("div").addClass("icon client-group_" + id);
|
return $.spawn("div").addClass("icon client-group_" + id);
|
||||||
|
|
|
@ -424,13 +424,16 @@ namespace Modals {
|
||||||
return modal;
|
return modal;
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_channel_tree(connection: ConnectionHandler, channel_list: JQuery, select_callback: (channel: ChannelEntry) => any) {
|
function build_channel_tree(connection: ConnectionHandler, channel_list: JQuery, select_callback: (channel: ChannelEntry, icon_update: (id: number) => any) => any) {
|
||||||
const root = connection.channelTree.get_first_channel();
|
const root = connection.channelTree.get_first_channel();
|
||||||
if(!root) return;
|
if(!root) return;
|
||||||
|
|
||||||
const build_channel = (channel: ChannelEntry) => {
|
const build_channel = (channel: ChannelEntry) => {
|
||||||
let tag = $.spawn("div").addClass("channel").attr("channel-id", channel.channelId);
|
let tag = $.spawn("div").addClass("channel").attr("channel-id", channel.channelId);
|
||||||
connection.fileManager.icons.generateTag(channel.properties.channel_icon_id).appendTo(tag);
|
let icon_tag = connection.fileManager.icons.generateTag(channel.properties.channel_icon_id);
|
||||||
|
icon_tag.appendTo(tag);
|
||||||
|
const _update_icon = icon_id => icon_tag.replaceWith(icon_tag = connection.fileManager.icons.generateTag(icon_id));
|
||||||
|
|
||||||
{
|
{
|
||||||
let name = $.spawn("a").text(channel.channelName() + " (" + channel.channelId + ")").addClass("name");
|
let name = $.spawn("a").text(channel.channelName() + " (" + channel.channelId + ")").addClass("name");
|
||||||
//if(connection.channelTree.server.properties. == group.id)
|
//if(connection.channelTree.server.properties. == group.id)
|
||||||
|
@ -441,7 +444,7 @@ namespace Modals {
|
||||||
tag.on('click', event => {
|
tag.on('click', event => {
|
||||||
channel_list.find(".selected").removeClass("selected");
|
channel_list.find(".selected").removeClass("selected");
|
||||||
tag.addClass("selected");
|
tag.addClass("selected");
|
||||||
select_callback(channel);
|
select_callback(channel, _update_icon);
|
||||||
});
|
});
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
|
@ -763,6 +766,7 @@ namespace Modals {
|
||||||
|
|
||||||
function apply_channel_permission(connection: ConnectionHandler, editor: PermissionEditor, tab_tag: JQuery) {
|
function apply_channel_permission(connection: ConnectionHandler, editor: PermissionEditor, tab_tag: JQuery) {
|
||||||
let current_channel: ChannelEntry | undefined;
|
let current_channel: ChannelEntry | undefined;
|
||||||
|
let update_channel_icon: (id: number) => any;
|
||||||
|
|
||||||
/* the editor */
|
/* the editor */
|
||||||
{
|
{
|
||||||
|
@ -800,6 +804,10 @@ namespace Modals {
|
||||||
return connection.serverConnection.send_command("channeldelperm", {
|
return connection.serverConnection.send_command("channeldelperm", {
|
||||||
cid: current_channel.channelId,
|
cid: current_channel.channelId,
|
||||||
permid: permission.id,
|
permid: permission.id,
|
||||||
|
}).then(e => {
|
||||||
|
if(permission.name === "i_icon_id" && update_channel_icon)
|
||||||
|
update_channel_icon(undefined);
|
||||||
|
return e;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
/* TODO Remove this because its totally useless. Remove this from the UI as well */
|
/* TODO Remove this because its totally useless. Remove this from the UI as well */
|
||||||
|
@ -831,6 +839,10 @@ namespace Modals {
|
||||||
permvalue: value.value,
|
permvalue: value.value,
|
||||||
permskip: value.flag_skip,
|
permskip: value.flag_skip,
|
||||||
permnegate: value.flag_negate
|
permnegate: value.flag_negate
|
||||||
|
}).then(e => {
|
||||||
|
if(permission.name === "i_icon_id" && update_channel_icon)
|
||||||
|
update_channel_icon(value.value);
|
||||||
|
return e;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
/* TODO Remove this because its totally useless. Remove this from the UI as well */
|
/* TODO Remove this because its totally useless. Remove this from the UI as well */
|
||||||
|
@ -857,15 +869,16 @@ namespace Modals {
|
||||||
}
|
}
|
||||||
|
|
||||||
let channel_list = tab_tag.find(".list-channel .entries");
|
let channel_list = tab_tag.find(".list-channel .entries");
|
||||||
build_channel_tree(connection, channel_list, channel => {
|
build_channel_tree(connection, channel_list, (channel, update) => {
|
||||||
current_channel = channel;
|
current_channel = channel;
|
||||||
|
update_channel_icon = update;
|
||||||
editor.trigger_update();
|
editor.trigger_update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function apply_channel_groups(connection: ConnectionHandler, editor: PermissionEditor, tab_tag: JQuery) {
|
function apply_channel_groups(connection: ConnectionHandler, editor: PermissionEditor, tab_tag: JQuery) {
|
||||||
let current_group;
|
let current_group;
|
||||||
|
let update_group_icon: (id: number) => any;
|
||||||
/* the editor */
|
/* the editor */
|
||||||
{
|
{
|
||||||
const pe_server = tab_tag.find("permission-editor.group-channel");
|
const pe_server = tab_tag.find("permission-editor.group-channel");
|
||||||
|
@ -902,6 +915,10 @@ namespace Modals {
|
||||||
return connection.serverConnection.send_command("channelgroupdelperm", {
|
return connection.serverConnection.send_command("channelgroupdelperm", {
|
||||||
cgid: current_group.id,
|
cgid: current_group.id,
|
||||||
permid: permission.id,
|
permid: permission.id,
|
||||||
|
}).then(e => {
|
||||||
|
if(permission.name === "i_icon_id" && update_group_icon)
|
||||||
|
update_group_icon(undefined);
|
||||||
|
return e;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
log.info(LogCategory.PERMISSIONS, tr("Removing channel group grant permission %s. permission.id: %o"),
|
log.info(LogCategory.PERMISSIONS, tr("Removing channel group grant permission %s. permission.id: %o"),
|
||||||
|
@ -932,6 +949,10 @@ namespace Modals {
|
||||||
permvalue: value.value,
|
permvalue: value.value,
|
||||||
permskip: value.flag_skip,
|
permskip: value.flag_skip,
|
||||||
permnegate: value.flag_negate
|
permnegate: value.flag_negate
|
||||||
|
}).then(e => {
|
||||||
|
if(permission.name === "i_icon_id" && update_group_icon)
|
||||||
|
update_group_icon(value.value);
|
||||||
|
return e;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
log.info(LogCategory.PERMISSIONS, tr("Adding or updating channel group grant permission %s. permission.{id: %o, value: %o}"),
|
log.info(LogCategory.PERMISSIONS, tr("Adding or updating channel group grant permission %s. permission.{id: %o, value: %o}"),
|
||||||
|
@ -973,7 +994,10 @@ namespace Modals {
|
||||||
}
|
}
|
||||||
|
|
||||||
let tag = $.spawn("div").addClass("group").attr("group-id", group.id);
|
let tag = $.spawn("div").addClass("group").attr("group-id", group.id);
|
||||||
connection.fileManager.icons.generateTag(group.properties.iconid).appendTo(tag);
|
let icon_tag = connection.fileManager.icons.generateTag(group.properties.iconid);
|
||||||
|
icon_tag.appendTo(tag);
|
||||||
|
const _update_icon = icon_id => icon_tag.replaceWith(icon_tag = connection.fileManager.icons.generateTag(icon_id));
|
||||||
|
|
||||||
{
|
{
|
||||||
let name = $.spawn("a").text(group.name + " (" + group.id + ")").addClass("name");
|
let name = $.spawn("a").text(group.name + " (" + group.id + ")").addClass("name");
|
||||||
if(group.properties.savedb)
|
if(group.properties.savedb)
|
||||||
|
@ -986,6 +1010,7 @@ namespace Modals {
|
||||||
|
|
||||||
tag.on('click', event => {
|
tag.on('click', event => {
|
||||||
current_group = group;
|
current_group = group;
|
||||||
|
update_group_icon = _update_icon;
|
||||||
group_list.find(".selected").removeClass("selected");
|
group_list.find(".selected").removeClass("selected");
|
||||||
tag.addClass("selected");
|
tag.addClass("selected");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue