This commit is contained in:
Richard Park 2020-01-20 18:01:34 +09:00
commit 52e9631c65
3 changed files with 64 additions and 46 deletions

View File

@ -170,6 +170,7 @@ export class GroupComponent implements OnInit, OnDestroy {
const tempOrderArr: GroupDetailData[] = [];
let myDeptGroup: GroupDetailData;
let defaultGroup: GroupDetailData;
const normalGroup: GroupDetailData[] = [];
groupList.forEach(group => {
if (
@ -178,10 +179,10 @@ export class GroupComponent implements OnInit, OnDestroy {
group.seq
) {
myDeptGroup = group;
}
if (0 === group.seq) {
} else if (0 === group.seq) {
defaultGroup = group;
} else {
normalGroup.push(group);
}
});
@ -190,16 +191,9 @@ export class GroupComponent implements OnInit, OnDestroy {
}
tempOrderArr.push(
...groupList
.filter(
group =>
group.seq !==
environment.productConfig.CommonSetting.myDeptGroupSeq &&
group.seq !== 0
)
.sort((a, b) =>
a.name < b.name ? -1 : a.name > b.name ? 1 : 0
)
...normalGroup.sort((a, b) =>
a.name < b.name ? -1 : a.name > b.name ? 1 : 0
)
);
if (!!defaultGroup) {

View File

@ -63,6 +63,7 @@ import {
AlertDialogData
} from '@ucap-webmessenger/ui';
import { TranslateService } from '@ngx-translate/core';
import { environment } from '../../../../../environments/environment';
export interface CreateChatDialogData {
type?: string;
@ -187,6 +188,45 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
)
]).pipe(
map(([buddyList, groupList]) => {
// sort..
if (!!groupList && groupList.length > 0) {
const tempOrderArr: GroupDetailData[] = [];
let myDeptGroup: GroupDetailData;
let defaultGroup: GroupDetailData;
const normalGroup: GroupDetailData[] = [];
groupList.forEach(group => {
if (
!!environment.productConfig.CommonSetting
.useMyDeptGroup &&
environment.productConfig.CommonSetting
.myDeptGroupSeq === group.seq
) {
myDeptGroup = group;
} else if (0 === group.seq) {
defaultGroup = group;
} else {
normalGroup.push(group);
}
});
if (!!myDeptGroup) {
tempOrderArr.push(myDeptGroup);
}
tempOrderArr.push(
...normalGroup.sort((a, b) =>
a.name < b.name ? -1 : a.name > b.name ? 1 : 0
)
);
if (!!defaultGroup) {
tempOrderArr.push(defaultGroup);
}
groupList = tempOrderArr;
}
const groupBuddyList: {
group: GroupDetailData;
buddyList: UserInfo[];

View File

@ -5,11 +5,11 @@ import {
UserInfo,
GroupDetailData,
RoomUserData,
RoomUserDetailData,
RoomUserDetailData
} from '@ucap-webmessenger/protocol-sync';
import {
RoomInfo,
UserInfo as RoomUserInfo,
UserInfo as RoomUserInfo
} from '@ucap-webmessenger/protocol-room';
export interface Buddy2State extends EntityState<UserInfo> {
@ -38,26 +38,10 @@ export interface State {
}
export const adapterBuddy2 = createEntityAdapter<UserInfo>({
selectId: userInfo => userInfo.seq,
selectId: userInfo => userInfo.seq
});
export const adapterGroup2 = createEntityAdapter<GroupDetailData>({
selectId: groupDetailData => groupDetailData.seq,
sortComparer: (a, b) => {
// 기본그룹은 제일 하단
if (0 === a.seq) {
return 1;
} else if (0 === b.seq) {
return -1;
} else {
if (a.name > b.name) {
return 1;
}
if (b.name > a.name) {
return -1;
}
return 0;
}
},
selectId: groupDetailData => groupDetailData.seq
});
export const adapterRoom = createEntityAdapter<RoomInfo>({
selectId: roomInfo => roomInfo.roomSeq,
@ -70,23 +54,23 @@ export const adapterRoom = createEntityAdapter<RoomInfo>({
.toDate()
.getTime()
);
},
}
});
export const adapterRoomUser = createEntityAdapter<RoomUserDetailData>({
selectId: roomUserDetailData => roomUserDetailData.roomSeq,
selectId: roomUserDetailData => roomUserDetailData.roomSeq
});
export const adapterRoomUserShort = createEntityAdapter<RoomUserData>({
selectId: roomUserData => roomUserData.roomSeq,
selectId: roomUserData => roomUserData.roomSeq
});
const buddy2InitialState: Buddy2State = adapterBuddy2.getInitialState({
syncDate: '',
syncDate: ''
});
const group2InitialState: Group2State = adapterGroup2.getInitialState({
syncDate: '',
syncDate: ''
});
const roomInitialState: RoomState = adapterRoom.getInitialState({
syncDate: '',
syncDate: ''
});
const roomUserInitialState: RoomUserState = adapterRoomUser.getInitialState({});
const roomUserShortInitialState: RoomUserShortState = adapterRoomUserShort.getInitialState(
@ -99,42 +83,42 @@ export const initialState: State = {
room: roomInitialState,
roomUser: roomUserInitialState,
roomUserShort: roomUserShortInitialState,
chatUnreadCount: 0,
chatUnreadCount: 0
};
const {
selectAll: ngeSelectAllBuddy2,
selectEntities: ngeSelectEntitiesBuddy2,
selectIds: ngeSelectIdsBuddy2,
selectTotal: ngeSelectTotalBuddy2,
selectTotal: ngeSelectTotalBuddy2
} = adapterBuddy2.getSelectors();
const {
selectAll: ngeSelectAllGroup2,
selectEntities: ngeSelectEntitiesGroup2,
selectIds: ngeSelectIdsGroup2,
selectTotal: ngeSelectTotalGroup2,
selectTotal: ngeSelectTotalGroup2
} = adapterGroup2.getSelectors();
const {
selectAll: ngeSelectAllRoom,
selectEntities: ngeSelectEntitiesRoom,
selectIds: ngeSelectIdsRoom,
selectTotal: ngeSelectTotalRoom,
selectTotal: ngeSelectTotalRoom
} = adapterRoom.getSelectors();
const {
selectAll: ngeSelectAllRoomUser,
selectEntities: ngeSelectEntitiesRoomUser,
selectIds: ngeSelectIdsRoomUser,
selectTotal: ngeSelectTotalRoomUser,
selectTotal: ngeSelectTotalRoomUser
} = adapterRoomUser.getSelectors();
const {
selectAll: ngeSelectAllRoomUserShort,
selectEntities: ngeSelectEntitiesRoomUserShort,
selectIds: ngeSelectIdsRoomUserShort,
selectTotal: ngeSelectTotalRoomUserShort,
selectTotal: ngeSelectTotalRoomUserShort
} = adapterRoomUserShort.getSelectors();
export function selectors<S>(selector: Selector<any, State>) {
@ -178,6 +162,6 @@ export function selectors<S>(selector: Selector<any, State>) {
selectChatUnreadCount: createSelector(
selector,
(state: State) => state.chatUnreadCount
),
)
};
}