|
|
@ -1,17 +1,19 @@ |
|
|
|
import { attachClickEvent } from "../../../helpers/dom"; |
|
|
|
import { attachClickEvent, toggleDisability } from "../../../helpers/dom"; |
|
|
|
import { deepEqual } from "../../../helpers/object"; |
|
|
|
import { deepEqual } from "../../../helpers/object"; |
|
|
|
import { ChannelParticipant } from "../../../layer"; |
|
|
|
import { ChannelParticipant } from "../../../layer"; |
|
|
|
import appChatsManager from "../../../lib/appManagers/appChatsManager"; |
|
|
|
import appChatsManager from "../../../lib/appManagers/appChatsManager"; |
|
|
|
import appDialogsManager from "../../../lib/appManagers/appDialogsManager"; |
|
|
|
import appDialogsManager from "../../../lib/appManagers/appDialogsManager"; |
|
|
|
import appProfileManager from "../../../lib/appManagers/appProfileManager"; |
|
|
|
import appPeersManager from "../../../lib/appManagers/appPeersManager"; |
|
|
|
import appUsersManager from "../../../lib/appManagers/appUsersManager"; |
|
|
|
import appUsersManager from "../../../lib/appManagers/appUsersManager"; |
|
|
|
import Button from "../../button"; |
|
|
|
import Button from "../../button"; |
|
|
|
|
|
|
|
import { addCancelButton } from "../../popups"; |
|
|
|
|
|
|
|
import PopupPeer from "../../popups/peer"; |
|
|
|
import { SettingSection } from "../../sidebarLeft"; |
|
|
|
import { SettingSection } from "../../sidebarLeft"; |
|
|
|
import { SliderSuperTabEventable } from "../../sliderTab"; |
|
|
|
import { SliderSuperTabEventable } from "../../sliderTab"; |
|
|
|
import { ChatPermissions } from "./groupPermissions"; |
|
|
|
import { ChatPermissions } from "./groupPermissions"; |
|
|
|
|
|
|
|
|
|
|
|
export default class AppUserPermissionsTab extends SliderSuperTabEventable { |
|
|
|
export default class AppUserPermissionsTab extends SliderSuperTabEventable { |
|
|
|
public participant: ChannelParticipant.channelParticipantBanned; |
|
|
|
public participant: ChannelParticipant; |
|
|
|
public chatId: number; |
|
|
|
public chatId: number; |
|
|
|
public userId: number; |
|
|
|
public userId: number; |
|
|
|
|
|
|
|
|
|
|
@ -19,6 +21,8 @@ export default class AppUserPermissionsTab extends SliderSuperTabEventable { |
|
|
|
this.container.classList.add('edit-peer-container', 'user-permissions-container'); |
|
|
|
this.container.classList.add('edit-peer-container', 'user-permissions-container'); |
|
|
|
this.title.innerHTML = 'User Permissions'; |
|
|
|
this.title.innerHTML = 'User Permissions'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let destroyListener: () => void; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
const section = new SettingSection({ |
|
|
|
const section = new SettingSection({ |
|
|
|
name: 'What can this user do?', |
|
|
|
name: 'What can this user do?', |
|
|
@ -45,18 +49,20 @@ export default class AppUserPermissionsTab extends SliderSuperTabEventable { |
|
|
|
chatId: this.chatId, |
|
|
|
chatId: this.chatId, |
|
|
|
listenerSetter: this.listenerSetter, |
|
|
|
listenerSetter: this.listenerSetter, |
|
|
|
appendTo: section.content, |
|
|
|
appendTo: section.content, |
|
|
|
participant: this.participant |
|
|
|
participant: this.participant._ === 'channelParticipantBanned' ? this.participant : undefined |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.eventListener.addEventListener('destroy', () => { |
|
|
|
destroyListener = () => { |
|
|
|
//appChatsManager.editChatDefaultBannedRights(this.chatId, p.takeOut());
|
|
|
|
//appChatsManager.editChatDefaultBannedRights(this.chatId, p.takeOut());
|
|
|
|
const rights = p.takeOut(); |
|
|
|
const rights = p.takeOut(); |
|
|
|
if(deepEqual(this.participant.banned_rights.pFlags, rights.pFlags)) { |
|
|
|
if(this.participant._ === 'channelParticipantBanned' && deepEqual(this.participant.banned_rights.pFlags, rights.pFlags)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
appChatsManager.editBanned(this.chatId, this.participant, rights); |
|
|
|
appChatsManager.editBanned(this.chatId, this.participant, rights); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.eventListener.addEventListener('destroy', destroyListener); |
|
|
|
|
|
|
|
|
|
|
|
this.scrollable.append(section.container); |
|
|
|
this.scrollable.append(section.container); |
|
|
|
} |
|
|
|
} |
|
|
@ -64,27 +70,44 @@ export default class AppUserPermissionsTab extends SliderSuperTabEventable { |
|
|
|
{ |
|
|
|
{ |
|
|
|
const section = new SettingSection({}); |
|
|
|
const section = new SettingSection({}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.participant._ === 'channelParticipantBanned') { |
|
|
|
|
|
|
|
const btnDeleteException = Button('btn-primary btn-transparent danger', {icon: 'delete', text: 'Delete Exception'}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
attachClickEvent(btnDeleteException, () => { |
|
|
|
|
|
|
|
const toggle = toggleDisability([btnDeleteException], true); |
|
|
|
|
|
|
|
appChatsManager.clearChannelParticipantBannedRights(this.chatId, this.participant).then(() => { |
|
|
|
|
|
|
|
this.eventListener.removeEventListener('destroy', destroyListener); |
|
|
|
|
|
|
|
this.close(); |
|
|
|
|
|
|
|
}, () => { |
|
|
|
|
|
|
|
toggle(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, {listenerSetter: this.listenerSetter}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
section.content.append(btnDeleteException); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const btnDelete = Button('btn-primary btn-transparent danger', {icon: 'deleteuser', text: 'Ban and Remove From Group'}); |
|
|
|
const btnDelete = Button('btn-primary btn-transparent danger', {icon: 'deleteuser', text: 'Ban and Remove From Group'}); |
|
|
|
|
|
|
|
|
|
|
|
attachClickEvent(btnDelete, () => { |
|
|
|
attachClickEvent(btnDelete, () => { |
|
|
|
/* new PopupPeer('popup-delete-group', { |
|
|
|
new PopupPeer('popup-group-kick-user', { |
|
|
|
peerId: -this.chatId, |
|
|
|
peerId: -this.chatId, |
|
|
|
title: 'Delete Group?', |
|
|
|
title: 'Ban User?', |
|
|
|
description: `Are you sure you want to delete this group? All members will be removed, and all messages will be lost.`, |
|
|
|
description: `Are you sure you want to ban <b>${appPeersManager.getPeerTitle(this.userId)}</b>`, |
|
|
|
buttons: addCancelButton([{ |
|
|
|
buttons: addCancelButton([{ |
|
|
|
text: 'DELETE', |
|
|
|
text: 'BAN', |
|
|
|
callback: () => { |
|
|
|
callback: () => { |
|
|
|
toggleDisability([btnDelete], true); |
|
|
|
const toggle = toggleDisability([btnDelete], true); |
|
|
|
|
|
|
|
|
|
|
|
appChatsManager.deleteChannel(this.chatId).then(() => { |
|
|
|
appChatsManager.kickFromChannel(this.chatId, this.participant).then(() => { |
|
|
|
|
|
|
|
this.eventListener.removeEventListener('destroy', destroyListener); |
|
|
|
this.close(); |
|
|
|
this.close(); |
|
|
|
}, () => { |
|
|
|
}, () => { |
|
|
|
toggleDisability([btnDelete], false); |
|
|
|
toggle(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
isDanger: true |
|
|
|
isDanger: true |
|
|
|
}]) |
|
|
|
}]) |
|
|
|
}).show(); */ |
|
|
|
}).show(); |
|
|
|
}, {listenerSetter: this.listenerSetter}); |
|
|
|
}, {listenerSetter: this.listenerSetter}); |
|
|
|
|
|
|
|
|
|
|
|
section.content.append(btnDelete); |
|
|
|
section.content.append(btnDelete); |
|
|
|