chat_ui/mixins/headerMixin.js
2025-03-15 13:45:02 +03:30

120 lines
3.5 KiB
JavaScript

import chatApi from "@chat/apis/chatApi";
// import repoApi from "~/apis/repoApi";
// import HttpService from "~/services/httpService";
export default {
beforeMount() {
this.httpService = useNuxtApp()["$http"];
},
methods: {
selectAllCheckbox(val) {
if (this.checked)
this.selectedCommentsId = this.localComments.map((item) => item.id);
else this.selectedCommentsId = [];
},
removeFromLabelFilter() {
// array(multiple) mode
// const index = this.labelFilter.findIndex(item=>item.id = selectedItem.id)
// this.labelFilter.splice(index,1)
// single mode
this.selectedLabel = null;
this.selectedMember = null;
this.selectedMessageLabel = [];
this.localComments = [];
this.showMobileActions = false;
this.selectedGroupMember = [];
this.selectedMessageLabel = [];
this.toLastItem();
},
removeFromUserFilter() {
// array(multiple) mode
// const index = this.userFilter.findIndex(item=>item.id = selectedItem.id)
// this.userFilter.splice(index,1)
// single mode
this.selectedMember = null;
this.selectedLabel = null;
this.selectedMessageLabel = [];
this.localComments = [];
this.showMobileActions = false;
this.selectedGroupMember = [];
this.selectedMessageLabel = [];
this.toLastItem();
},
getGroupMembers() {
if (
this.$route.name !== "privates" &&
(this.listGetter?.group_id || this.listGetter?.id)
)
this.httpService
.getRequest(
"message/" +
chatApi.groups.groupMembers +
(this.listGetter?.group_id || this.listGetter?.id)
)
.then((response) => (this.groupMember = response.data));
},
filterMessagesBySection(selectedLabel) {
// this.resetPagination();
// this.userFilter = [];
this.selectedMember = null;
this.showMobileActions = false;
this.selectedGroupMember = [];
this.selectedMessageLabel = [];
if (selectedLabel) {
this.selectedMessageLabel = [selectedLabel.entity_field_id];
selectedLabel["title"] = selectedLabel?.lable;
selectedLabel["keyName"] = "label";
}
// this.selectedMessageLabel = this.selectedLabel.map(
// (item) => item.entity_field_id
// );
let entityId = this.listGetter?.reference_id;
if (entityId) {
this.getIssue(entityId).then(() => {
this.getSections().then(() => {
if (selectedLabel) this.showIssueProperties = true;
else this.closeIssueProperties();
this.localComments = [];
this.toLastItem();
});
});
} else {
this.localComments = [];
this.closeIssueProperties();
this.toLastItem();
}
},
filterMessagesByUser(selectedUser) {
// this.resetPagination();
// labelFilter.length || userFilter.length"
// this.labelFilter = [];
this.selectedLabel = null;
this.selectedMessageLabel = [];
selectedUser["title"] = selectedUser?.full_name ?? '';
selectedUser["keyName"] = "user";
this.selectedGroupMember = selectedUser ? [selectedUser?.user_id] : [];
this.localComments = [];
this.showMobileActions = false;
this.toLastItem();
},
getSectionDetails() {
let url =
"message/" + chatApi.entity.get + "/" + this.listGetter.reference_id;
this.httpService.getRequest(url).then((res) => {
this.issue = res._source;
});
},
},
};