|
|
@ -4,7 +4,7 @@ |
|
|
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
|
|
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
import { attachClickEvent } from "../../../helpers/dom"; |
|
|
|
import { attachClickEvent, replaceContent } from "../../../helpers/dom"; |
|
|
|
import findUpTag from "../../../helpers/dom/findUpTag"; |
|
|
|
import findUpTag from "../../../helpers/dom/findUpTag"; |
|
|
|
import ListenerSetter from "../../../helpers/listenerSetter"; |
|
|
|
import ListenerSetter from "../../../helpers/listenerSetter"; |
|
|
|
import ScrollableLoader from "../../../helpers/listLoader"; |
|
|
|
import ScrollableLoader from "../../../helpers/listLoader"; |
|
|
@ -12,7 +12,7 @@ import { ChannelParticipant, Chat, ChatBannedRights, Update } from "../../../lay |
|
|
|
import appChatsManager, { ChatRights } from "../../../lib/appManagers/appChatsManager"; |
|
|
|
import appChatsManager, { ChatRights } from "../../../lib/appManagers/appChatsManager"; |
|
|
|
import appDialogsManager from "../../../lib/appManagers/appDialogsManager"; |
|
|
|
import appDialogsManager from "../../../lib/appManagers/appDialogsManager"; |
|
|
|
import appProfileManager from "../../../lib/appManagers/appProfileManager"; |
|
|
|
import appProfileManager from "../../../lib/appManagers/appProfileManager"; |
|
|
|
import I18n, { i18n, LangPackKey } from "../../../lib/langPack"; |
|
|
|
import I18n, { i18n, join, LangPackKey } from "../../../lib/langPack"; |
|
|
|
import rootScope from "../../../lib/rootScope"; |
|
|
|
import rootScope from "../../../lib/rootScope"; |
|
|
|
import CheckboxField from "../../checkboxField"; |
|
|
|
import CheckboxField from "../../checkboxField"; |
|
|
|
import PopupPickUser from "../../popups/pickUser"; |
|
|
|
import PopupPickUser from "../../popups/pickUser"; |
|
|
@ -26,7 +26,8 @@ export class ChatPermissions { |
|
|
|
public v: Array<{ |
|
|
|
public v: Array<{ |
|
|
|
flags: ChatRights[], |
|
|
|
flags: ChatRights[], |
|
|
|
text: LangPackKey, |
|
|
|
text: LangPackKey, |
|
|
|
checkboxField?: CheckboxField |
|
|
|
exceptionText: LangPackKey, |
|
|
|
|
|
|
|
checkboxField?: CheckboxField, |
|
|
|
}>; |
|
|
|
}>; |
|
|
|
private toggleWith: Partial<{[chatRight in ChatRights]: ChatRights[]}>; |
|
|
|
private toggleWith: Partial<{[chatRight in ChatRights]: ChatRights[]}>; |
|
|
|
|
|
|
|
|
|
|
@ -37,14 +38,14 @@ export class ChatPermissions { |
|
|
|
participant?: ChannelParticipant.channelParticipantBanned |
|
|
|
participant?: ChannelParticipant.channelParticipantBanned |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
this.v = [ |
|
|
|
this.v = [ |
|
|
|
{flags: ['send_messages'], text: 'UserRestrictionsSend'}, |
|
|
|
{flags: ['send_messages'], text: 'UserRestrictionsSend', exceptionText: 'UserRestrictionsNoSend'}, |
|
|
|
{flags: ['send_media'], text: 'UserRestrictionsSendMedia'}, |
|
|
|
{flags: ['send_media'], text: 'UserRestrictionsSendMedia', exceptionText: 'UserRestrictionsNoSendMedia'}, |
|
|
|
{flags: ['send_stickers', 'send_gifs'], text: 'UserRestrictionsSendStickers'}, |
|
|
|
{flags: ['send_stickers', 'send_gifs'], text: 'UserRestrictionsSendStickers', exceptionText: 'UserRestrictionsNoSendStickers'}, |
|
|
|
{flags: ['send_polls'], text: 'UserRestrictionsSendPolls'}, |
|
|
|
{flags: ['send_polls'], text: 'UserRestrictionsSendPolls', exceptionText: 'UserRestrictionsNoSendPolls'}, |
|
|
|
{flags: ['embed_links'], text: 'UserRestrictionsEmbedLinks'}, |
|
|
|
{flags: ['embed_links'], text: 'UserRestrictionsEmbedLinks', exceptionText: 'UserRestrictionsNoEmbedLinks'}, |
|
|
|
{flags: ['invite_users'], text: 'UserRestrictionsInviteUsers'}, |
|
|
|
{flags: ['invite_users'], text: 'UserRestrictionsInviteUsers', exceptionText: 'UserRestrictionsNoInviteUsers'}, |
|
|
|
{flags: ['pin_messages'], text: 'UserRestrictionsPinMessages'}, |
|
|
|
{flags: ['pin_messages'], text: 'UserRestrictionsPinMessages', exceptionText: 'UserRestrictionsNoPinMessages'}, |
|
|
|
{flags: ['change_info'], text: 'UserRestrictionsChangeInfo'} |
|
|
|
{flags: ['change_info'], text: 'UserRestrictionsChangeInfo', exceptionText: 'UserRestrictionsNoChangeInfo'} |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
this.toggleWith = { |
|
|
|
this.toggleWith = { |
|
|
@ -210,34 +211,30 @@ export default class AppGroupPermissionsTab extends SliderSuperTabEventable { |
|
|
|
const setSubtitle = (li: Element, participant: ChannelParticipant.channelParticipantBanned) => { |
|
|
|
const setSubtitle = (li: Element, participant: ChannelParticipant.channelParticipantBanned) => { |
|
|
|
const bannedRights = participant.banned_rights;//appChatsManager.combineParticipantBannedRights(this.chatId, participant.banned_rights);
|
|
|
|
const bannedRights = participant.banned_rights;//appChatsManager.combineParticipantBannedRights(this.chatId, participant.banned_rights);
|
|
|
|
const defaultBannedRights = (appChatsManager.getChat(this.chatId) as Chat.channel).default_banned_rights; |
|
|
|
const defaultBannedRights = (appChatsManager.getChat(this.chatId) as Chat.channel).default_banned_rights; |
|
|
|
const combinedRights = appChatsManager.combineParticipantBannedRights(this.chatId, bannedRights); |
|
|
|
//const combinedRights = appChatsManager.combineParticipantBannedRights(this.chatId, bannedRights);
|
|
|
|
|
|
|
|
|
|
|
|
const cantWhat: string[] = [], canWhat: string[] = []; |
|
|
|
const cantWhat: LangPackKey[] = []/* , canWhat: LangPackKey[] = [] */; |
|
|
|
chatPermissions.v.forEach(info => { |
|
|
|
chatPermissions.v.forEach(info => { |
|
|
|
const mainFlag = info.flags[0]; |
|
|
|
const mainFlag = info.flags[0]; |
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
if(bannedRights.pFlags[mainFlag] && !defaultBannedRights.pFlags[mainFlag]) { |
|
|
|
if(bannedRights.pFlags[mainFlag] && !defaultBannedRights.pFlags[mainFlag]) { |
|
|
|
cantWhat.push(info.text); |
|
|
|
cantWhat.push(info.exceptionText); |
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
} else if(!combinedRights.pFlags[mainFlag]) { |
|
|
|
}/* else if(!combinedRights.pFlags[mainFlag]) { |
|
|
|
canWhat.push(info.text); |
|
|
|
canWhat.push(info.exceptionText); |
|
|
|
} |
|
|
|
} */ |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const el = li.querySelector('.user-last-message'); |
|
|
|
const el = li.querySelector('.user-last-message') as HTMLElement; |
|
|
|
let str: string; |
|
|
|
|
|
|
|
if(cantWhat.length) { |
|
|
|
if(cantWhat.length) { |
|
|
|
str = 'Can\'t ' + cantWhat.join(cantWhat.length === 2 ? ' and ' : ', '); |
|
|
|
el.innerHTML = ''; |
|
|
|
} else if(canWhat.length) { |
|
|
|
el.append(...join(cantWhat.map(t => i18n(t)), false)); |
|
|
|
|
|
|
|
}/* else if(canWhat.length) { |
|
|
|
str = 'Can ' + canWhat.join(canWhat.length === 2 ? ' and ' : ', '); |
|
|
|
str = 'Can ' + canWhat.join(canWhat.length === 2 ? ' and ' : ', '); |
|
|
|
} |
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
|
|
//const user = appUsersManager.getUser(participant.user_id);
|
|
|
|
el.classList.toggle('hide', !cantWhat.length); |
|
|
|
if(str) { |
|
|
|
|
|
|
|
el.innerHTML = str; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
el.classList.toggle('hide', !str); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const add = (participant: ChannelParticipant.channelParticipantBanned, append: boolean) => { |
|
|
|
const add = (participant: ChannelParticipant.channelParticipantBanned, append: boolean) => { |
|
|
@ -285,8 +282,7 @@ export default class AppGroupPermissionsTab extends SliderSuperTabEventable { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const setLength = () => { |
|
|
|
const setLength = () => { |
|
|
|
addExceptionRow.subtitle.textContent = ''; |
|
|
|
replaceContent(addExceptionRow.subtitle, i18n(exceptionsCount ? 'Permissions.ExceptionsCount' : 'Permissions.NoExceptions', [exceptionsCount])); |
|
|
|
addExceptionRow.subtitle.append(i18n(exceptionsCount ? 'Permissions.ExceptionsCount' : 'Permissions.NoExceptions', [exceptionsCount])); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let exceptionsCount = 0; |
|
|
|
let exceptionsCount = 0; |
|
|
|