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

View File

@ -63,6 +63,7 @@ import {
AlertDialogData AlertDialogData
} from '@ucap-webmessenger/ui'; } from '@ucap-webmessenger/ui';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { environment } from '../../../../../environments/environment';
export interface CreateChatDialogData { export interface CreateChatDialogData {
type?: string; type?: string;
@ -187,6 +188,45 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
) )
]).pipe( ]).pipe(
map(([buddyList, groupList]) => { 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: { const groupBuddyList: {
group: GroupDetailData; group: GroupDetailData;
buddyList: UserInfo[]; buddyList: UserInfo[];

View File

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