mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-11 14:54:48 +00:00
refactor(communities): edit categories
This commit is contained in:
parent
c338bdf6ae
commit
f67ffde12c
@ -130,6 +130,11 @@ method init*(self: Controller) =
|
|||||||
if (args.communityId == self.sectionId):
|
if (args.communityId == self.sectionId):
|
||||||
self.delegate.onCommunityCategoryDeleted(args.category)
|
self.delegate.onCommunityCategoryDeleted(args.category)
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_COMMUNITY_CATEGORY_EDITED) do(e:Args):
|
||||||
|
let args = CommunityCategoryArgs(e)
|
||||||
|
if (args.communityId == self.sectionId):
|
||||||
|
self.delegate.onCommunityCategoryEdited(args.category, args.chats)
|
||||||
|
|
||||||
self.events.on(SIGNAL_COMMUNITY_CHANNEL_REORDERED) do(e:Args):
|
self.events.on(SIGNAL_COMMUNITY_CHANNEL_REORDERED) do(e:Args):
|
||||||
let args = CommunityChatOrderArgs(e)
|
let args = CommunityChatOrderArgs(e)
|
||||||
if (args.communityId == self.sectionId):
|
if (args.communityId == self.sectionId):
|
||||||
@ -311,6 +316,9 @@ method editCommunityChannel*(
|
|||||||
method createCommunityCategory*(self: Controller, name: string, channels: seq[string]) =
|
method createCommunityCategory*(self: Controller, name: string, channels: seq[string]) =
|
||||||
self.communityService.createCommunityCategory(self.sectionId, name, channels)
|
self.communityService.createCommunityCategory(self.sectionId, name, channels)
|
||||||
|
|
||||||
|
method editCommunityCategory*(self: Controller, categoryId: string, name: string, channels: seq[string]) =
|
||||||
|
self.communityService.editCommunityCategory(self.sectionId, categoryId, name, channels)
|
||||||
|
|
||||||
method deleteCommunityCategory*(self: Controller, categoryId: string) =
|
method deleteCommunityCategory*(self: Controller, categoryId: string) =
|
||||||
self.communityService.deleteCommunityCategory(self.sectionId, categoryId)
|
self.communityService.deleteCommunityCategory(self.sectionId, categoryId)
|
||||||
|
|
||||||
|
@ -131,6 +131,9 @@ method editCommunityChannel*(self: AccessInterface, channelId: string, name: str
|
|||||||
method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} =
|
method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method editCommunityCategory*(self: AccessInterface, categoryId: string, name: string, channels: seq[string]) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method deleteCommunityCategory*(self: AccessInterface, categoryId: string) {.base.} =
|
method deleteCommunityCategory*(self: AccessInterface, categoryId: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ type
|
|||||||
Position
|
Position
|
||||||
SubItems
|
SubItems
|
||||||
IsCategory
|
IsCategory
|
||||||
|
CategoryId
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
@ -80,7 +81,8 @@ QtObject:
|
|||||||
ModelRole.Active.int:"active",
|
ModelRole.Active.int:"active",
|
||||||
ModelRole.Position.int:"position",
|
ModelRole.Position.int:"position",
|
||||||
ModelRole.SubItems.int:"subItems",
|
ModelRole.SubItems.int:"subItems",
|
||||||
ModelRole.IsCategory.int:"isCategory"
|
ModelRole.IsCategory.int:"isCategory",
|
||||||
|
ModelRole.CategoryId.int:"categoryId"
|
||||||
}.toTable
|
}.toTable
|
||||||
|
|
||||||
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
||||||
@ -126,6 +128,8 @@ QtObject:
|
|||||||
result = newQVariant(item.subItems)
|
result = newQVariant(item.subItems)
|
||||||
of ModelRole.IsCategory:
|
of ModelRole.IsCategory:
|
||||||
result = newQVariant(item.`type` == ChatType.Unknown.int)
|
result = newQVariant(item.`type` == ChatType.Unknown.int)
|
||||||
|
of ModelRole.CategoryId:
|
||||||
|
result = newQVariant(item.categoryId)
|
||||||
|
|
||||||
proc appendItem*(self: Model, item: Item) =
|
proc appendItem*(self: Model, item: Item) =
|
||||||
let parentModelIndex = newQModelIndex()
|
let parentModelIndex = newQModelIndex()
|
||||||
@ -302,3 +306,7 @@ QtObject:
|
|||||||
self.items[index] = tempItem
|
self.items[index] = tempItem
|
||||||
self.endResetModel()
|
self.endResetModel()
|
||||||
|
|
||||||
|
proc clearItems*(self: Model) =
|
||||||
|
self.beginResetModel()
|
||||||
|
self.items = @[]
|
||||||
|
self.endResetModel()
|
||||||
|
@ -450,11 +450,35 @@ method onCommunityCategoryDeleted*(self: Module, cat: Category) =
|
|||||||
let amIChatAdmin = self.controller.getMyCommunity().admin
|
let amIChatAdmin = self.controller.getMyCommunity().admin
|
||||||
let channelItem = initItem(chatDto.id, chatDto.name, chatDto.identicon, false, chatDto.color,
|
let channelItem = initItem(chatDto.id, chatDto.name, chatDto.identicon, false, chatDto.color,
|
||||||
chatDto.description, chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount,
|
chatDto.description, chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount,
|
||||||
chatDto.muted, active = false, chatDto.position, "")
|
chatDto.muted, false, active = false, chatDto.position, "")
|
||||||
self.view.chatsModel().appendItem(channelItem)
|
self.view.chatsModel().appendItem(channelItem)
|
||||||
|
|
||||||
self.view.chatsModel().removeItemById(cat.id)
|
self.view.chatsModel().removeItemById(cat.id)
|
||||||
|
|
||||||
|
method onCommunityCategoryEdited*(self: Module, cat: Category, chats: seq[ChatDto]) =
|
||||||
|
var categoryItem = self.view.chatsModel().getItemById(cat.id)
|
||||||
|
let amIChatAdmin = self.controller.getMyCommunity().admin
|
||||||
|
|
||||||
|
self.view.chatsModel.renameItem(cat.id, cat.name)
|
||||||
|
|
||||||
|
for chatDto in chats:
|
||||||
|
let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0
|
||||||
|
let notificationsCount = chatDto.unviewedMentionsCount
|
||||||
|
|
||||||
|
self.view.chatsModel().removeItemById(chatDto.id)
|
||||||
|
categoryItem.subItems().removeItemById(chatDto.id)
|
||||||
|
|
||||||
|
if chatDto.categoryId == cat.id:
|
||||||
|
let channelItem = initSubItem(chatDto.id, cat.id, chatDto.name, chatDto.identicon, false, chatDto.color,
|
||||||
|
chatDto.description, chatDto.chatType.int, true, hasNotification, notificationsCount, chatDto.muted,
|
||||||
|
false, false, chatDto.position)
|
||||||
|
categoryItem.prependSubItem(channelItem)
|
||||||
|
else:
|
||||||
|
let channelItem = initItem(chatDto.id, chatDto.name, chatDto.identicon, false, chatDto.color,
|
||||||
|
chatDto.description, chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount,
|
||||||
|
chatDto.muted, false, active = false, chatDto.position, "")
|
||||||
|
self.view.chatsModel().appendItem(channelItem)
|
||||||
|
|
||||||
method onCommunityChannelDeletedOrChatLeft*(self: Module, chatId: string) =
|
method onCommunityChannelDeletedOrChatLeft*(self: Module, chatId: string) =
|
||||||
if(not self.chatContentModules.contains(chatId)):
|
if(not self.chatContentModules.contains(chatId)):
|
||||||
return
|
return
|
||||||
@ -613,6 +637,9 @@ method editCommunityChannel*(self: Module, channelId, name, description, categor
|
|||||||
method createCommunityCategory*(self: Module, name: string, channels: seq[string]) =
|
method createCommunityCategory*(self: Module, name: string, channels: seq[string]) =
|
||||||
self.controller.createCommunityCategory(name, channels)
|
self.controller.createCommunityCategory(name, channels)
|
||||||
|
|
||||||
|
method editCommunityCategory*(self: Module, categoryId: string, name: string, channels: seq[string]) =
|
||||||
|
self.controller.editCommunityCategory(categoryId, name, channels)
|
||||||
|
|
||||||
method deleteCommunityCategory*(self: Module, categoryId: string) =
|
method deleteCommunityCategory*(self: Module, categoryId: string) =
|
||||||
self.controller.deleteCommunityCategory(categoryId)
|
self.controller.deleteCommunityCategory(categoryId)
|
||||||
|
|
||||||
@ -633,3 +660,19 @@ method setCommunityMuted*(self: Module, muted: bool) =
|
|||||||
|
|
||||||
method inviteUsersToCommunity*(self: Module, pubKeysJSON: string): string =
|
method inviteUsersToCommunity*(self: Module, pubKeysJSON: string): string =
|
||||||
result = self.controller.inviteUsersToCommunity(pubKeysJSON)
|
result = self.controller.inviteUsersToCommunity(pubKeysJSON)
|
||||||
|
|
||||||
|
method prepareEditCategoryModel*(self: Module, categoryId: string) =
|
||||||
|
self.view.editCategoryChannelsModel().clearItems()
|
||||||
|
let communityId = self.controller.getMySectionId()
|
||||||
|
let chats = self.controller.getChats(communityId, "")
|
||||||
|
for chat in chats:
|
||||||
|
let c = self.controller.getChatDetails(communityId, chat.id)
|
||||||
|
let item = initItem(c.id, c.name, "", false, c.color, c.description, c.chatType.int, false,
|
||||||
|
false, 0, c.muted, false, active = false, c.position, "")
|
||||||
|
self.view.editCategoryChannelsModel().appendItem(item)
|
||||||
|
let catChats = self.controller.getChats(communityId, categoryId)
|
||||||
|
for chat in catChats:
|
||||||
|
let c = self.controller.getChatDetails(communityId, chat.id)
|
||||||
|
let item = initItem(c.id, c.name, "", false, c.color, c.description, c.chatType.int, false,
|
||||||
|
false, 0, c.muted, false, active = false, c.position, categoryId)
|
||||||
|
self.view.editCategoryChannelsModel().appendItem(item)
|
@ -56,3 +56,6 @@ method onCommunityCategoryCreated*(self: AccessInterface, category: Category, ch
|
|||||||
|
|
||||||
method onCommunityCategoryDeleted*(self: AccessInterface, category: Category) {.base.} =
|
method onCommunityCategoryDeleted*(self: AccessInterface, category: Category) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method onCommunityCategoryEdited*(self: AccessInterface, category: Category, chats: seq[ChatDto]) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
@ -115,5 +115,11 @@ method inviteUsersToCommunity*(self: AccessInterface, pubKeysJSON: string): stri
|
|||||||
method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} =
|
method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method editCommunityCategory*(self: AccessInterface, categoryId: string, name: string, channels: seq[string]) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method deleteCommunityCategory*(self: AccessInterface, categoryId: string) {.base.} =
|
method deleteCommunityCategory*(self: AccessInterface, categoryId: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method prepareEditCategoryModel*(self: AccessInterface, categoryId: string) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
@ -212,6 +212,16 @@ QtObject:
|
|||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
proc removeItemById*(self: SubModel, id: string) =
|
||||||
|
for i in 0 ..< self.items.len:
|
||||||
|
if(self.items[i].id == id):
|
||||||
|
let parentModelIndex = newQModelIndex()
|
||||||
|
defer: parentModelIndex.delete
|
||||||
|
self.beginRemoveRows(parentModelIndex, i, i)
|
||||||
|
self.items.delete(i)
|
||||||
|
self.endRemoveRows()
|
||||||
|
self.countChanged()
|
||||||
|
|
||||||
proc updateNotificationsForItemById*(self: SubModel, id: string, hasUnreadMessages: bool,
|
proc updateNotificationsForItemById*(self: SubModel, id: string, hasUnreadMessages: bool,
|
||||||
notificationsCount: int): bool =
|
notificationsCount: int): bool =
|
||||||
for i in 0 ..< self.items.len:
|
for i in 0 ..< self.items.len:
|
||||||
|
@ -17,6 +17,8 @@ QtObject:
|
|||||||
contactRequestsModelVariant: QVariant
|
contactRequestsModelVariant: QVariant
|
||||||
listOfMyContacts: contacts_model.Model
|
listOfMyContacts: contacts_model.Model
|
||||||
listOfMyContactsVariant: QVariant
|
listOfMyContactsVariant: QVariant
|
||||||
|
editCategoryChannelsModel: chats_model.Model
|
||||||
|
editCategoryChannelsVariant: QVariant
|
||||||
|
|
||||||
proc delete*(self: View) =
|
proc delete*(self: View) =
|
||||||
self.model.delete
|
self.model.delete
|
||||||
@ -27,6 +29,8 @@ QtObject:
|
|||||||
self.contactRequestsModelVariant.delete
|
self.contactRequestsModelVariant.delete
|
||||||
self.listOfMyContacts.delete
|
self.listOfMyContacts.delete
|
||||||
self.listOfMyContactsVariant.delete
|
self.listOfMyContactsVariant.delete
|
||||||
|
self.editCategoryChannelsModel.delete
|
||||||
|
self.editCategoryChannelsVariant.delete
|
||||||
self.QObject.delete
|
self.QObject.delete
|
||||||
|
|
||||||
proc newView*(delegate: io_interface.AccessInterface): View =
|
proc newView*(delegate: io_interface.AccessInterface): View =
|
||||||
@ -35,6 +39,8 @@ QtObject:
|
|||||||
result.delegate = delegate
|
result.delegate = delegate
|
||||||
result.model = chats_model.newModel()
|
result.model = chats_model.newModel()
|
||||||
result.modelVariant = newQVariant(result.model)
|
result.modelVariant = newQVariant(result.model)
|
||||||
|
result.editCategoryChannelsModel = chats_model.newModel()
|
||||||
|
result.editCategoryChannelsVariant = newQVariant(result.editCategoryChannelsModel)
|
||||||
result.activeItem = newActiveItem()
|
result.activeItem = newActiveItem()
|
||||||
result.activeItemVariant = newQVariant(result.activeItem)
|
result.activeItemVariant = newQVariant(result.activeItem)
|
||||||
result.contactRequestsModel = contacts_model.newModel()
|
result.contactRequestsModel = contacts_model.newModel()
|
||||||
@ -53,9 +59,19 @@ QtObject:
|
|||||||
|
|
||||||
proc getModel(self: View): QVariant {.slot.} =
|
proc getModel(self: View): QVariant {.slot.} =
|
||||||
return self.modelVariant
|
return self.modelVariant
|
||||||
|
|
||||||
QtProperty[QVariant] model:
|
QtProperty[QVariant] model:
|
||||||
read = getModel
|
read = getModel
|
||||||
|
|
||||||
|
proc editCategoryChannelsModel*(self: View): chats_model.Model =
|
||||||
|
return self.editCategoryChannelsModel
|
||||||
|
|
||||||
|
proc getEditCategoryChannels(self: View): QVariant {.slot.} =
|
||||||
|
return self.editCategoryChannelsVariant
|
||||||
|
|
||||||
|
QtProperty[QVariant] editCategoryChannelsModel:
|
||||||
|
read = getEditCategoryChannels
|
||||||
|
|
||||||
proc contactRequestsModel*(self: View): contacts_model.Model =
|
proc contactRequestsModel*(self: View): contacts_model.Model =
|
||||||
return self.contactRequestsModel
|
return self.contactRequestsModel
|
||||||
|
|
||||||
@ -225,5 +241,12 @@ QtObject:
|
|||||||
let channelsSeq = map(parseJson(channels).getElems(), proc(x:JsonNode):string = x.getStr())
|
let channelsSeq = map(parseJson(channels).getElems(), proc(x:JsonNode):string = x.getStr())
|
||||||
self.delegate.createCommunityCategory(name, channelsSeq)
|
self.delegate.createCommunityCategory(name, channelsSeq)
|
||||||
|
|
||||||
|
proc editCommunityCategory*(self: View, categoryId: string, name: string, channels: string) {.slot.} =
|
||||||
|
let channelsSeq = map(parseJson(channels).getElems(), proc(x:JsonNode):string = x.getStr())
|
||||||
|
self.delegate.editCommunityCategory(categoryId, name, channelsSeq)
|
||||||
|
|
||||||
proc deleteCommunityCategory*(self: View, categoryId: string) {.slot.} =
|
proc deleteCommunityCategory*(self: View, categoryId: string) {.slot.} =
|
||||||
self.delegate.deleteCommunityCategory(categoryId)
|
self.delegate.deleteCommunityCategory(categoryId)
|
||||||
|
|
||||||
|
proc prepareEditCategoryModel*(self: View, categoryId: string) {.slot.} =
|
||||||
|
self.delegate.prepareEditCategoryModel(categoryId)
|
@ -596,18 +596,31 @@ QtObject:
|
|||||||
channels: seq[string]) =
|
channels: seq[string]) =
|
||||||
try:
|
try:
|
||||||
let response = status_go.editCommunityCategory(communityId, categoryId, name, channels)
|
let response = status_go.editCommunityCategory(communityId, categoryId, name, channels)
|
||||||
|
|
||||||
if response.error != nil:
|
if response.error != nil:
|
||||||
let error = Json.decode($response.error, RpcError)
|
let error = Json.decode($response.error, RpcError)
|
||||||
raise newException(RpcException, "Error creating community category: " & error.message)
|
raise newException(RpcException, "Error creating community category: " & error.message)
|
||||||
|
|
||||||
if response.result != nil and response.result.kind != JNull:
|
if response.result != nil and response.result.kind != JNull:
|
||||||
|
var chats: seq[ChatDto] = @[]
|
||||||
|
for chatId, v in response.result["communityChanges"].getElems()[0]["chatsModified"].pairs():
|
||||||
|
let idx = findIndexById(chatId, self.joinedCommunities[communityId].chats)
|
||||||
|
if idx > -1:
|
||||||
|
self.joinedCommunities[communityId].chats[idx].categoryId = v["CategoryModified"].getStr()
|
||||||
|
self.joinedCommunities[communityId].chats[idx].position = v["PositionModified"].getInt()
|
||||||
|
|
||||||
|
let fullChatId = communityId & chatId
|
||||||
|
var chatDetails = self.chatService.getChatById(fullChatId) # we are free to do this cause channel must be created before we add it to a category
|
||||||
|
chatDetails.updateMissingFields(self.joinedCommunities[communityId].chats[idx])
|
||||||
|
self.chatService.updateOrAddChat(chatDetails) # we have to update chats stored in the chat service.
|
||||||
|
chats.add(chatDetails)
|
||||||
|
|
||||||
for k, v in response.result["communityChanges"].getElems()[0]["categoriesModified"].pairs():
|
for k, v in response.result["communityChanges"].getElems()[0]["categoriesModified"].pairs():
|
||||||
let category = v.toCategory()
|
let category = v.toCategory()
|
||||||
self.events.emit(SIGNAL_COMMUNITY_CATEGORY_EDITED,
|
self.events.emit(SIGNAL_COMMUNITY_CATEGORY_EDITED,
|
||||||
CommunityCategoryArgs(communityId: communityId, category: category #[, channels: channels]#)) # TODO: add channels
|
CommunityCategoryArgs(communityId: communityId, category: category, chats: chats))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "Error creating community category", msg = e.msg, communityId, name
|
error "Error editing community category", msg = e.msg, communityId, name
|
||||||
|
|
||||||
proc deleteCommunityCategory*(self: Service, communityId: string, categoryId: string) =
|
proc deleteCommunityCategory*(self: Service, communityId: string, categoryId: string) =
|
||||||
try:
|
try:
|
||||||
|
@ -30,8 +30,8 @@ StatusModal {
|
|||||||
onOpened: {
|
onOpened: {
|
||||||
if(isEdit){
|
if(isEdit){
|
||||||
root.contentItem.categoryName.input.text = categoryName
|
root.contentItem.categoryName.input.text = categoryName
|
||||||
// Not Refactored Yet
|
root.channels = []
|
||||||
// channels = //JSON.parse(root.store.chatsModelInst.communities.activeCommunity.getChatIdsByCategory(categoryId))
|
root.store.prepareEditCategoryModel(categoryId);
|
||||||
}
|
}
|
||||||
root.contentItem.categoryName.input.forceActiveFocus(Qt.MouseFocusReason)
|
root.contentItem.categoryName.input.forceActiveFocus(Qt.MouseFocusReason)
|
||||||
}
|
}
|
||||||
@ -110,16 +110,13 @@ StatusModal {
|
|||||||
anchors.top: channelsLabel.bottom
|
anchors.top: channelsLabel.bottom
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
width: parent.width
|
width: parent.width
|
||||||
model: root.store.chatCommunitySectionModule.model
|
model: isEdit ? root.store.chatCommunitySectionModule.editCategoryChannelsModel : root.store.chatCommunitySectionModule.model
|
||||||
interactive: false
|
interactive: false
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
delegate: StatusListItem {
|
delegate: StatusListItem {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
visible: {
|
visible: model.type != Constants.chatType.unknown
|
||||||
// TODO: if edit, show only the subitems of the current category
|
|
||||||
return root.isEdit ? null : model.type != Constants.chatType.unknown
|
|
||||||
}
|
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
title: "#" + model.name
|
title: "#" + model.name
|
||||||
icon.isLetterIdenticon: true
|
icon.isLetterIdenticon: true
|
||||||
@ -129,17 +126,15 @@ StatusModal {
|
|||||||
components: [
|
components: [
|
||||||
StatusCheckBox {
|
StatusCheckBox {
|
||||||
id: channelItemCheckbox
|
id: channelItemCheckbox
|
||||||
checked: root.isEdit ? root.channels.indexOf(model.itemId) > - 1 : false
|
checked: root.isEdit ? model.categoryId == root.categoryId : false
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
var idx = root.channels.indexOf(model.itemId)
|
|
||||||
if(checked){
|
if(checked){
|
||||||
|
var idx = root.channels.indexOf(model.itemId)
|
||||||
if(idx === -1){
|
if(idx === -1){
|
||||||
root.channels.push(model.itemId)
|
root.channels.push(model.itemId)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(idx > -1){
|
root.channels = root.channels.filter(el => el !== model.itemId);
|
||||||
root.channels.splice(idx, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,11 +214,10 @@ StatusModal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let error = ""
|
let error = ""
|
||||||
|
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
// error = root.store.editCommunityCategory(communityId, categoryId, Utils.filterXSS(root.contentItem.categoryName.input.text), JSON.stringify(channels));
|
error = root.store.editCommunityCategory(root.categoryId, Utils.filterXSS(root.contentItem.categoryName.input.text), JSON.stringify(channels));
|
||||||
} else {
|
} else {
|
||||||
error = root.store.createCommunityCategory(root.contentItem.categoryName.input.text, JSON.stringify(channels));
|
error = root.store.createCommunityCategory(Utils.filterXSS(root.contentItem.categoryName.input.text), JSON.stringify(channels));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -154,14 +154,18 @@ QtObject {
|
|||||||
chatCommunitySectionModule.createCommunityCategory(categoryName, channels)
|
chatCommunitySectionModule.createCommunityCategory(categoryName, channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
function editCommunityCategory(communityId, categoryId, categoryName, channels) {
|
function editCommunityCategory(categoryId, categoryName, channels) {
|
||||||
communitiesModuleInst.editCommunityCategory(communityId, categoryId, categoryName, channels);
|
chatCommunitySectionModule.editCommunityCategory(categoryId, categoryName, channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteCommunityCategory(categoryId) {
|
function deleteCommunityCategory(categoryId) {
|
||||||
chatCommunitySectionModule.deleteCommunityCategory(categoryId);
|
chatCommunitySectionModule.deleteCommunityCategory(categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prepareEditCategoryModel(categoryId) {
|
||||||
|
chatCommunitySectionModule.prepareEditCategoryModel(categoryId);
|
||||||
|
}
|
||||||
|
|
||||||
function leaveCommunity() {
|
function leaveCommunity() {
|
||||||
chatCommunitySectionModule.leaveCommunity();
|
chatCommunitySectionModule.leaveCommunity();
|
||||||
}
|
}
|
||||||
|
@ -227,6 +227,7 @@ Item {
|
|||||||
onTriggered: {
|
onTriggered: {
|
||||||
Global.openPopup(createCategoryPopup, {
|
Global.openPopup(createCategoryPopup, {
|
||||||
isEdit: true,
|
isEdit: true,
|
||||||
|
channels: [],
|
||||||
categoryId: categoryItem.categoryId,
|
categoryId: categoryItem.categoryId,
|
||||||
categoryName: categoryItem.name
|
categoryName: categoryItem.name
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user