From 828d89b16a328bbc36ca125b90f752687997b6b5 Mon Sep 17 00:00:00 2001 From: develite98 Date: Fri, 3 Nov 2023 14:07:24 +0700 Subject: [PATCH] feat(): move task to share module --- .../src/app/pages/portal/portal.routes.ts | 4 +- .../task-card/task-card.component.ts | 57 --------- .../task-create/task-create.component.ts | 88 -------------- .../task-detail-modal.component.ts | 105 ---------------- .../portal/task-manage/store/task.store.ts | 45 ------- .../create-user-dialog.component.ts | 2 +- .../portal/user/services/user.service.ts | 2 +- apps/mix-cms/tsconfig.editor.json | 2 +- .../user-select/user-select.component.html | 35 ------ .../user-select/user-select.component.scss | 0 .../user-select/user-select.component.ts | 91 -------------- .../src/app/pages/portal/portal.routes.ts | 4 +- .../task-card/task-card.component.html | 27 ----- .../task-card/task-card.component.scss | 24 ---- .../task-create/task-create.component.html | 33 ----- .../task-create/task-create.component.scss | 0 .../task-detail-modal.component.html | 63 ---------- .../task-detail-modal.component.scss | 5 - .../task-dnd-list.component.html | 17 --- .../task-dnd-list.component.scss | 47 -------- .../task-dnd-list/task-dnd-list.component.ts | 114 ------------------ .../task-filter/task-filter.component.html | 37 ------ .../task-filter/task-filter.component.scss | 40 ------ .../task-filter/task-filter.component.ts | 60 --------- .../task-priority.component.html | 4 - .../task-priority.component.scss | 3 - .../task-priority/task-priority.component.ts | 22 ---- .../portal/task-manage/store/filter.store.ts | 36 ------ .../portal/task-manage/store/task.service.ts | 16 --- .../task-manage/task-manage.component.html | 24 ---- .../task-manage/task-manage.component.scss | 35 ------ .../task-manage/task-manage.component.ts | 76 ------------ .../src/app/stores/user-info.store.ts | 68 ----------- libs/mix-share/src/components/index.ts | 1 + .../user-select/user-select.component.html | 0 .../user-select/user-select.component.scss | 0 .../user-select/user-select.component.ts | 2 +- .../task-card/task-card.component.html | 0 .../task-card/task-card.component.scss | 0 .../task-card/task-card.component.ts | 2 +- .../task-create/task-create.component.html | 0 .../task-create/task-create.component.scss | 0 .../task-create/task-create.component.ts | 2 +- .../task-detail-modal.component.html | 0 .../task-detail-modal.component.scss | 0 .../task-detail-modal.component.ts | 2 +- .../task-dnd-list.component.html | 0 .../task-dnd-list.component.scss | 0 .../task-dnd-list/task-dnd-list.component.ts | 0 .../task-filter/task-filter.component.html | 0 .../task-filter/task-filter.component.scss | 0 .../task-filter/task-filter.component.ts | 2 +- .../task-priority.component.html | 0 .../task-priority.component.scss | 0 .../task-priority/task-priority.component.ts | 0 .../src/modules/task-manage/index.ts | 1 + .../src/modules/task-manage/ng-package.json | 5 + .../src/modules/task-manage/project.json | 18 +++ .../task-manage/store/filter.store.ts | 0 .../task-manage/store/task.service.ts | 0 .../modules}/task-manage/store/task.store.ts | 3 +- .../task-manage/task-manage.component.html | 0 .../task-manage/task-manage.component.scss | 0 .../task-manage/task-manage.component.ts | 0 libs/mix-share/src/stores/index.ts | 1 + .../mix-share/src}/stores/user-info.store.ts | 0 tsconfig.base.json | 3 + 67 files changed, 40 insertions(+), 1188 deletions(-) delete mode 100644 apps/mix-cms/src/app/pages/portal/task-manage/components/task-card/task-card.component.ts delete mode 100644 apps/mix-cms/src/app/pages/portal/task-manage/components/task-create/task-create.component.ts delete mode 100644 apps/mix-cms/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.ts delete mode 100644 apps/mix-cms/src/app/pages/portal/task-manage/store/task.store.ts delete mode 100644 apps/mix-kanban/src/app/components/user-select/user-select.component.html delete mode 100644 apps/mix-kanban/src/app/components/user-select/user-select.component.scss delete mode 100644 apps/mix-kanban/src/app/components/user-select/user-select.component.ts delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-card/task-card.component.html delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-card/task-card.component.scss delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-create/task-create.component.html delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-create/task-create.component.scss delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.html delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.scss delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.html delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.scss delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.ts delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.html delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.scss delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.ts delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.html delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.scss delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.ts delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/store/filter.store.ts delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/store/task.service.ts delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/task-manage.component.html delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/task-manage.component.scss delete mode 100644 apps/mix-kanban/src/app/pages/portal/task-manage/task-manage.component.ts delete mode 100644 apps/mix-kanban/src/app/stores/user-info.store.ts rename {apps/mix-cms/src/app => libs/mix-share/src}/components/user-select/user-select.component.html (100%) rename {apps/mix-cms/src/app => libs/mix-share/src}/components/user-select/user-select.component.scss (100%) rename {apps/mix-cms/src/app => libs/mix-share/src}/components/user-select/user-select.component.ts (97%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-card/task-card.component.html (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-card/task-card.component.scss (100%) rename {apps/mix-kanban/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-card/task-card.component.ts (95%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-create/task-create.component.html (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-create/task-create.component.scss (100%) rename {apps/mix-kanban/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-create/task-create.component.ts (96%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-detail-modal/task-detail-modal.component.html (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-detail-modal/task-detail-modal.component.scss (100%) rename {apps/mix-kanban/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-detail-modal/task-detail-modal.component.ts (96%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-dnd-list/task-dnd-list.component.html (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-dnd-list/task-dnd-list.component.scss (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-dnd-list/task-dnd-list.component.ts (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-filter/task-filter.component.html (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-filter/task-filter.component.scss (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-filter/task-filter.component.ts (96%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-priority/task-priority.component.html (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-priority/task-priority.component.scss (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/components/task-priority/task-priority.component.ts (100%) create mode 100644 libs/mix-share/src/modules/task-manage/index.ts create mode 100644 libs/mix-share/src/modules/task-manage/ng-package.json create mode 100644 libs/mix-share/src/modules/task-manage/project.json rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/store/filter.store.ts (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/store/task.service.ts (100%) rename {apps/mix-kanban/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/store/task.store.ts (88%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/task-manage.component.html (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/task-manage.component.scss (100%) rename {apps/mix-cms/src/app/pages/portal => libs/mix-share/src/modules}/task-manage/task-manage.component.ts (100%) rename {apps/mix-cms/src/app => libs/mix-share/src}/stores/user-info.store.ts (100%) diff --git a/apps/mix-cms/src/app/pages/portal/portal.routes.ts b/apps/mix-cms/src/app/pages/portal/portal.routes.ts index 2b58cef8..ee87cff8 100644 --- a/apps/mix-cms/src/app/pages/portal/portal.routes.ts +++ b/apps/mix-cms/src/app/pages/portal/portal.routes.ts @@ -108,9 +108,7 @@ export const PortalRoutes: Routes = [ path: CMS_ROUTES.portal.task.path, data: breadcrumbName('Task Management'), loadComponent: () => - import('./task-manage/task-manage.component').then( - (m) => m.TaskManageComponent - ), + import('@mixcore/module/task').then((m) => m.TaskManageComponent), }, { path: CMS_ROUTES.portal.settings.path, diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-card/task-card.component.ts b/apps/mix-cms/src/app/pages/portal/task-manage/components/task-card/task-card.component.ts deleted file mode 100644 index 94f8626e..00000000 --- a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-card/task-card.component.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { - ChangeDetectorRef, - Component, - Input, - OnChanges, - inject, -} from '@angular/core'; -import { - MixTaskNew, - TaskPriorityColors, - TaskTypeIcons, - UserListVm, -} from '@mixcore/lib/model'; -import { UserAvatarComponent } from '@mixcore/share/components'; -import { DialogService } from '@ngneat/dialog'; -import { take } from 'rxjs'; -import { UserInfoStore } from '../../../../../stores/user-info.store'; -import { TaskDetailModalComponent } from '../task-detail-modal/task-detail-modal.component'; -import { TaskPriorityComponent } from '../task-priority/task-priority.component'; - -@Component({ - selector: 'mix-task-card', - standalone: true, - imports: [CommonModule, TaskPriorityComponent, UserAvatarComponent], - templateUrl: './task-card.component.html', - styleUrls: ['./task-card.component.scss'], -}) -export class TaskCardComponent implements OnChanges { - @Input() public task!: MixTaskNew; - public dialog = inject(DialogService); - public userInfoStore = inject(UserInfoStore); - public cdr = inject(ChangeDetectorRef); - - public TaskPriorityColor = TaskPriorityColors; - public TaskTypeIcon = TaskTypeIcons; - public userInfo: UserListVm | undefined; - - public onClick() { - this.dialog.open(TaskDetailModalComponent, { - width: 1024, - data: { task: this.task }, - }); - } - - public ngOnChanges() { - if (this.task.reporter) { - this.userInfoStore - .getUserById(this.task.reporter) - .pipe(take(1)) - .subscribe((info) => { - this.userInfo = info; - this.cdr.detectChanges(); - }); - } - } -} diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-create/task-create.component.ts b/apps/mix-cms/src/app/pages/portal/task-manage/components/task-create/task-create.component.ts deleted file mode 100644 index a3fd2709..00000000 --- a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-create/task-create.component.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; -import { - FormControl, - FormGroup, - ReactiveFormsModule, - Validators, -} from '@angular/forms'; -import { - MixTaskNew, - TaskPriority, - TaskStatus, - TaskType, -} from '@mixcore/lib/model'; -import { BaseComponent } from '@mixcore/share/base'; -import { FormHelper } from '@mixcore/share/form'; -import { MixButtonComponent } from '@mixcore/ui/button'; -import { MixEditorComponent } from '@mixcore/ui/editor'; -import { MixInputComponent } from '@mixcore/ui/input'; -import { MixSelectComponent } from '@mixcore/ui/select'; -import { DialogRef } from '@ngneat/dialog'; -import { HotToastService } from '@ngneat/hot-toast'; -import { TaskService } from '../../store/task.service'; -import { TaskStore } from '../../store/task.store'; -import { UserSelectComponent } from '../../../../../components/user-select/user-select.component'; - -@Component({ - selector: 'mix-task-create', - standalone: true, - imports: [ - CommonModule, - MixInputComponent, - MixSelectComponent, - ReactiveFormsModule, - MixEditorComponent, - MixButtonComponent, - UserSelectComponent, - ], - templateUrl: './task-create.component.html', - styleUrls: ['./task-create.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class TaskCreateComponent extends BaseComponent { - public taskService = inject(TaskService); - public taskStore = inject(TaskStore); - public dialogRef = inject(DialogRef); - public toast = inject(HotToastService); - - public typeLabel = (type: TaskType) => type; - public typeItems = [TaskType.BUG, TaskType.STORY, TaskType.TASK]; - - public priorityLabel = (priority: TaskPriority) => priority; - public prorityItems = [ - TaskPriority.LOWEST, - TaskPriority.LOW, - TaskPriority.MEDIUM, - TaskPriority.HIGH, - TaskPriority.HIGHEST, - ]; - - public taskForm = new FormGroup({ - title: new FormControl('', Validators.required), - description: new FormControl('', Validators.required), - type: new FormControl(TaskType.STORY, Validators.required), - taskPriority: new FormControl(TaskPriority.LOW, Validators.required), - taskStatus: new FormControl(TaskStatus.BACKLOG), - reporter: new FormControl(), - priority: new FormControl(999), - }); - - public createTask() { - if (FormHelper.validateForm(this.taskForm)) { - this.taskService - .saveTask(this.taskForm.value as MixTaskNew) - .pipe(this.observerLoadingState()) - .subscribe({ - next: (result) => { - this.toast.success('Success add your new task'); - this.taskStore.addTask(result as unknown as MixTaskNew); - this.dialogRef.close(); - }, - error: () => { - this.toast.error('Something error, please try again'); - }, - }); - } - } -} diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.ts b/apps/mix-cms/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.ts deleted file mode 100644 index eb9e74e8..00000000 --- a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.ts +++ /dev/null @@ -1,105 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { Component, OnInit, inject } from '@angular/core'; -import { - FormControl, - FormGroup, - ReactiveFormsModule, - Validators, -} from '@angular/forms'; -import { - MixTaskNew, - TaskPriority, - TaskStatus, - TaskStatusDisplay, - TaskTypeIcons, -} from '@mixcore/lib/model'; -import { BaseComponent } from '@mixcore/share/base'; -import { FormHelper } from '@mixcore/share/form'; -import { MixUtcDatePipe } from '@mixcore/share/pipe'; -import { MixButtonComponent } from '@mixcore/ui/button'; -import { MixEditorComponent } from '@mixcore/ui/editor'; -import { MixInlineInputComponent } from '@mixcore/ui/inline-input'; -import { MixSelectComponent } from '@mixcore/ui/select'; -import { DialogRef } from '@ngneat/dialog'; -import { HotToastService } from '@ngneat/hot-toast'; -import { UserSelectComponent } from '../../../../../components/user-select/user-select.component'; -import { TaskService } from '../../store/task.service'; -import { TaskStore } from '../../store/task.store'; - -@Component({ - selector: 'mix-task-detail-modal', - standalone: true, - imports: [ - CommonModule, - ReactiveFormsModule, - MixInlineInputComponent, - MixEditorComponent, - MixButtonComponent, - MixSelectComponent, - MixUtcDatePipe, - UserSelectComponent - ], - templateUrl: './task-detail-modal.component.html', - styleUrls: ['./task-detail-modal.component.scss'], -}) -export class TaskDetailModalComponent extends BaseComponent implements OnInit { - public taskService = inject(TaskService); - public taskStore = inject(TaskStore); - public toast = inject(HotToastService); - public dialogRef = inject(DialogRef<{ task: MixTaskNew }>) - - public task!: MixTaskNew; - public TaskTypeIconDisplay = TaskTypeIcons; - public taskForm = new FormGroup({ - title: new FormControl('', Validators.required), - description: new FormControl('', Validators.required), - taskStatus: new FormControl(TaskStatus.BACKLOG, Validators.required), - taskPriority: new FormControl(TaskPriority.LOW, Validators.required), - reporter: new FormControl() - }); - - public statussLabel = (status: TaskStatus) => TaskStatusDisplay[status]; - public statusItems = [ - TaskStatus.BACKLOG, - TaskStatus.SELECTED, - TaskStatus.IN_PROGRESS, - TaskStatus.DONE, - ]; - - public priorityLabel = (priority: TaskPriority) => priority; - public prorityItems = [ - TaskPriority.LOWEST, - TaskPriority.LOW, - TaskPriority.MEDIUM, - TaskPriority.HIGH, - TaskPriority.HIGHEST, - ]; - - ngOnInit() { - this.task = this.dialogRef.data.task; - this.taskForm.patchValue(this.task); - } - - public saveTask(close = true) { - if (FormHelper.validateForm(this.taskForm)) { - const value = { - ...this.task, - ...this.taskForm.value - } - - this.taskService - .saveTask(value as MixTaskNew) - .pipe(this.observerLoadingState()) - .subscribe({ - next: (result) => { - this.toast.success('Success update your task'); - this.taskStore.addTask(result as unknown as MixTaskNew, 'Update'); - if (close )this.dialogRef.close(); - }, - error: () => { - this.toast.error('Something error, please try again'); - }, - }); - } - } -} diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/store/task.store.ts b/apps/mix-cms/src/app/pages/portal/task-manage/store/task.store.ts deleted file mode 100644 index 9e040723..00000000 --- a/apps/mix-cms/src/app/pages/portal/task-manage/store/task.store.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Injectable } from '@angular/core'; -import { - MixTaskNew, - PaginationRequestModel, - TaskStatus, -} from '@mixcore/lib/model'; -import { BaseCRUDStore } from '@mixcore/share/base'; -import { map } from 'rxjs'; -import { MixSystemDbName } from '../../../../shares/consts/system-database-name'; - -@Injectable({ providedIn: 'root' }) -export class TaskStore extends BaseCRUDStore { - public override requestFn = (request: PaginationRequestModel) => - this.mixApi.databaseApi.getDataByName(MixSystemDbName.Task, { - ...request, - }); - - public override requestName = 'mixTask'; - public override searchColumns = ['Title', 'Description']; - public override searchColumnsDict: { [key: string]: string } = { - Title: 'title', - Description: 'description', - }; - - public getTaskByStatus = (status: TaskStatus) => { - return this.select((s) => s).pipe( - map((s) => { - return s.data - .filter((x) => x.taskStatus === status) - .sort((a, b) => a.priority - b.priority); - }) - ); - }; - - public addTask = (task: MixTaskNew, mode: 'Update' | 'Create' = 'Create') => { - this.patchState((s) => { - if (mode === 'Create') return { ...s, data: [task, ...s.data] }; - - const taskIndex = s.data.findIndex((x) => x.id === task.id); - if (taskIndex >= 0) s.data[taskIndex] = task; - - return { ...s }; - }); - }; -} diff --git a/apps/mix-cms/src/app/pages/portal/user/components/create-user-dialog/create-user-dialog.component.ts b/apps/mix-cms/src/app/pages/portal/user/components/create-user-dialog/create-user-dialog.component.ts index 55f2fe64..e1f0aa2b 100644 --- a/apps/mix-cms/src/app/pages/portal/user/components/create-user-dialog/create-user-dialog.component.ts +++ b/apps/mix-cms/src/app/pages/portal/user/components/create-user-dialog/create-user-dialog.component.ts @@ -21,7 +21,7 @@ import { MixInputComponent } from '@mixcore/ui/input'; import { MixSelectComponent } from '@mixcore/ui/select'; import { DialogRef, DialogService } from '@ngneat/dialog'; import { HotToastService } from '@ngneat/hot-toast'; -import { UserInfoStore } from '../../../../../stores/user-info.store'; +import { UserInfoStore } from '../../../../../../../../../libs/mix-share/src/stores/user-info.store'; import { UserStore } from '../../../../../stores/user.store'; @Component({ diff --git a/apps/mix-cms/src/app/pages/portal/user/services/user.service.ts b/apps/mix-cms/src/app/pages/portal/user/services/user.service.ts index 90a93bf8..57e1387f 100644 --- a/apps/mix-cms/src/app/pages/portal/user/services/user.service.ts +++ b/apps/mix-cms/src/app/pages/portal/user/services/user.service.ts @@ -3,8 +3,8 @@ import { MixApiFacadeService } from '@mixcore/share/api'; import { toastObserverProcessing } from '@mixcore/share/helper'; import { ModalService } from '@mixcore/ui/modal'; import { HotToastService } from '@ngneat/hot-toast'; +import { UserInfoStore } from '../../../../../../../../libs/mix-share/src/stores/user-info.store'; import { UserStore } from '../../../../stores/user.store'; -import { UserInfoStore } from '../../../../stores/user-info.store'; @Injectable() export class UserService { diff --git a/apps/mix-cms/tsconfig.editor.json b/apps/mix-cms/tsconfig.editor.json index 20c4afdb..425f2826 100644 --- a/apps/mix-cms/tsconfig.editor.json +++ b/apps/mix-cms/tsconfig.editor.json @@ -1,6 +1,6 @@ { "extends": "./tsconfig.json", - "include": ["**/*.ts"], + "include": ["**/*.ts", "../../libs/mix-share/src/stores/user-info.store.ts"], "compilerOptions": { "types": ["jest", "node"] } diff --git a/apps/mix-kanban/src/app/components/user-select/user-select.component.html b/apps/mix-kanban/src/app/components/user-select/user-select.component.html deleted file mode 100644 index f5928b31..00000000 --- a/apps/mix-kanban/src/app/components/user-select/user-select.component.html +++ /dev/null @@ -1,35 +0,0 @@ -
- - Choose a users - - - - -
- - -
- - - - {{ item.userName }} - -
-
diff --git a/apps/mix-kanban/src/app/components/user-select/user-select.component.scss b/apps/mix-kanban/src/app/components/user-select/user-select.component.scss deleted file mode 100644 index e69de29b..00000000 diff --git a/apps/mix-kanban/src/app/components/user-select/user-select.component.ts b/apps/mix-kanban/src/app/components/user-select/user-select.component.ts deleted file mode 100644 index e45d6a69..00000000 --- a/apps/mix-kanban/src/app/components/user-select/user-select.component.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { Component, forwardRef, inject } from '@angular/core'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { - ControlValueAccessor, - FormControl, - NG_VALUE_ACCESSOR, - ReactiveFormsModule, -} from '@angular/forms'; -import { UserListVm } from '@mixcore/lib/model'; -import { MixApiFacadeService } from '@mixcore/share/api'; -import { tuiPure } from '@taiga-ui/cdk'; -import { - TuiDataListModule, - TuiTextfieldControllerModule, -} from '@taiga-ui/core'; -import { TuiAvatarModule, TuiSelectModule } from '@taiga-ui/kit'; -import { distinctUntilChanged, filter } from 'rxjs'; -import { UserInfoStore } from '../../stores/user-info.store'; - -@Component({ - selector: 'mix-user-select', - standalone: true, - imports: [ - CommonModule, - ReactiveFormsModule, - TuiSelectModule, - TuiDataListModule, - TuiTextfieldControllerModule, - TuiAvatarModule, - ], - templateUrl: './user-select.component.html', - styleUrls: ['./user-select.component.scss'], - providers: [ - { - provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => UserSelectComponent), - multi: true, - }, - ], -}) -export class UserSelectComponent implements ControlValueAccessor { - public mixApi = inject(MixApiFacadeService); - public store = inject(UserInfoStore); - public control = new FormControl(); - public userData: UserListVm[] = []; - public userDataMap: Record = {}; - public disabled = false; - public onChange!: (provinceData: string) => void; - public onTouched!: () => void; - - @tuiPure - public identityMatcher( - userId: string, - userDataMap: Record - ) { - return userDataMap[userId]; - } - - constructor() { - this.store.vm$ - .pipe( - filter((s) => s.status === 'Success'), - takeUntilDestroyed() - ) - .subscribe((s) => { - this.userData = s.data; - this.userData.forEach((user) => (this.userDataMap[user.id] = user)); - }); - } - - public writeValue(userId: string): void { - this.control.patchValue(userId); - } - - public registerOnChange(fn: any): void { - this.onChange = fn; - - this.control.valueChanges - .pipe(distinctUntilChanged()) - .subscribe((v) => this.onChange(v)); - } - - public registerOnTouched(fn: any): void { - this.onTouched = fn; - } - - public setDisabledState?(isDisabled: boolean): void { - this.disabled = isDisabled; - } -} diff --git a/apps/mix-kanban/src/app/pages/portal/portal.routes.ts b/apps/mix-kanban/src/app/pages/portal/portal.routes.ts index 848aca24..0441064d 100644 --- a/apps/mix-kanban/src/app/pages/portal/portal.routes.ts +++ b/apps/mix-kanban/src/app/pages/portal/portal.routes.ts @@ -14,9 +14,7 @@ export const PortalRoutes: Routes = [ path: CMS_ROUTES.portal.task.path, data: breadcrumbName('Task Management'), loadComponent: () => - import('./task-manage/task-manage.component').then( - (m) => m.TaskManageComponent - ), + import('@mixcore/module/task').then((m) => m.TaskManageComponent), }, { path: '', diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-card/task-card.component.html b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-card/task-card.component.html deleted file mode 100644 index c22130db..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-card/task-card.component.html +++ /dev/null @@ -1,27 +0,0 @@ -
-
-
- {{ task.title }} -
- -
- - - - - - {{ task.type }}-{{ task.id }} - - - - type - - - -
-
-
diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-card/task-card.component.scss b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-card/task-card.component.scss deleted file mode 100644 index 26940f2e..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-card/task-card.component.scss +++ /dev/null @@ -1,24 +0,0 @@ -:host { - display: flex; - flex-direction: column; - flex-grow: 1; - margin-bottom: 5px; -} - -.task-card { - padding: 10px; - border-radius: 0.125rem; - transition-property: all; - transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); - transition-duration: 0.1s; - box-shadow: #091e4240 0 1px 2px; - background-color: rgb(255, 255, 255); - - &:hover { - background-color: rgb(235 236 240); - } -} - -.task-card-wrap { - cursor: grab; -} diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-create/task-create.component.html b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-create/task-create.component.html deleted file mode 100644 index 991cfda7..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-create/task-create.component.html +++ /dev/null @@ -1,33 +0,0 @@ -
-
Create Task
- -
Task Type
- - -
Task Priority
- - -
Short Summary
- - -
Description
- - -
Reporter
- - -
- Create - Cancel -
-
diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-create/task-create.component.scss b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-create/task-create.component.scss deleted file mode 100644 index e69de29b..00000000 diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.html b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.html deleted file mode 100644 index 3f6b96aa..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.html +++ /dev/null @@ -1,63 +0,0 @@ -
-
- - {{ task.type }}-{{ task.id }} -
- -
-
- - -
Description
- - - -
Comment(s)
-
- -
-
STATUS
- - - -
REPORTER
- - - -
PRORITY
- - - -
-
- Created at - {{ task.createdDateTime | mixDate | date: 'dd/MM/yyyy hh:mm' }} -
-
- Updated at - {{ task.lastModified | mixDate | date: 'dd/MM/yyyy hh:mm' || '--' }} -
-
-
-
- -
- Close - - Save - - Save & Close -
-
diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.scss b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.scss deleted file mode 100644 index d6ca9d5b..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.scss +++ /dev/null @@ -1,5 +0,0 @@ -.task-detail { - .description { - height: 400px; - } -} diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.html b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.html deleted file mode 100644 index 318b04e8..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.html +++ /dev/null @@ -1,17 +0,0 @@ -
-
- {{ TaskStatusDisplay[status] }} {{ tasks.length }} -
- -
- - -
-
diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.scss b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.scss deleted file mode 100644 index 1a305d54..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.scss +++ /dev/null @@ -1,47 +0,0 @@ -.task-list { - padding: 6px; - height: 100%; - display: flex; - flex-direction: column; - - .cdk-drop-list-dragging { - transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); - - .cdk-drag:not(.cdk-drag-placeholder) { - transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); - } - } - - .items { - flex-grow: 1; - } - - .title { - margin-top: 8px; - margin-bottom: 14px; - padding-left: 8px; - } -} - -.cdk-drag-preview { - box-sizing: border-box; - border-radius: 4px; - box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), - 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12); -} - -.cdk-drag-placeholder { - .task-card-wrap { - background-color: rgba(150, 150, 200, 0.1); - border: 1px dashed #abc; - margin: 5px; - - .task-card { - opacity: 0; - } - } -} - -.cdk-drag-animating { - transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); -} diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.ts b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.ts deleted file mode 100644 index 59711af8..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.ts +++ /dev/null @@ -1,114 +0,0 @@ -import { - CdkDragDrop, - DragDropModule, - moveItemInArray, - transferArrayItem, -} from '@angular/cdk/drag-drop'; -import { CommonModule } from '@angular/common'; -import { - ChangeDetectorRef, - Component, - DestroyRef, - Input, - OnInit, - ViewEncapsulation, - inject, -} from '@angular/core'; -import { - MixTask, - MixTaskNew, - TaskStatus, - TaskStatusDisplay, -} from '@mixcore/lib/model'; -import { Observable, combineLatest, forkJoin } from 'rxjs'; -import { TaskCardComponent } from '../task-card/task-card.component'; -import { TaskFilterStore } from '../../store/filter.store'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { TaskStore } from '../../store/task.store'; -import { TaskService } from '../../store/task.service'; -import { HotToastService } from '@ngneat/hot-toast'; - -@Component({ - selector: 'mix-task-dnd-list', - standalone: true, - imports: [CommonModule, TaskCardComponent, DragDropModule], - templateUrl: './task-dnd-list.component.html', - styleUrls: ['./task-dnd-list.component.scss'], - encapsulation: ViewEncapsulation.None, -}) -export class TaskDndListComponent implements OnInit { - public destroyRef = inject(DestroyRef); - public cdr = inject(ChangeDetectorRef); - public taskStore = inject(TaskStore); - public taskService = inject(TaskService); - public toast = inject(HotToastService); - - public TaskStatusDisplay = TaskStatusDisplay; - - @Input() public status!: TaskStatus; - @Input() public listTasks!: Observable; - public tasks: MixTaskNew[] = []; - - constructor(public filterStore: TaskFilterStore) {} - - ngOnInit() { - combineLatest([this.listTasks, this.filterStore.userIds$]) - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(([tasks, filter]) => { - this.combineFilter(tasks, filter.userIds); - }); - } - - public combineFilter(tasks: MixTaskNew[], userIds: string[]) { - if (!userIds?.length) { - this.tasks = tasks; - } else { - this.tasks = tasks.filter( - (task) => task.reporter && userIds.includes(task.reporter) - ); - } - - this.cdr.detectChanges(); - } - - public drop(event: CdkDragDrop) { - const newIssue: MixTaskNew = { ...event.item.data }; - const newIssues = [...event.container.data]; - - if (event.previousContainer === event.container) { - if (event.previousIndex === event.currentIndex) return; - - moveItemInArray(newIssues, event.previousIndex, event.currentIndex); - this.updateListPosition(newIssues); - } else { - transferArrayItem( - event.previousContainer.data, - newIssues, - event.previousIndex, - event.currentIndex - ); - - const newIssueIndex = newIssues.findIndex((x) => x.id === newIssue.id); - newIssues[newIssueIndex].taskStatus = event.container.id as TaskStatus; - this.updateListPosition(newIssues); - } - } - - private updateListPosition(newList: MixTaskNew[]) { - const requests = newList.map((issue, idx) => { - const newIssueWithNewPosition = { ...issue, priority: idx + 1 }; - this.taskStore.addTask(newIssueWithNewPosition, 'Update'); - return this.taskService.saveTask(newIssueWithNewPosition); - }); - - forkJoin(requests) - .pipe( - this.toast.observe({ - loading: 'Saving...', - success: 'Succesfully update your task', - error: 'Something error, please try again', - }) - ) - .subscribe(); - } -} diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.html b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.html deleted file mode 100644 index 03270ba8..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.html +++ /dev/null @@ -1,37 +0,0 @@ -
- - -
- - - - - - - -
- -
-
- -
-
- - -
diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.scss b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.scss deleted file mode 100644 index 3d1e602e..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.scss +++ /dev/null @@ -1,40 +0,0 @@ -.task-filter { - display: flex; - padding: 16px 16px 0px 16px; - align-items: center; - - mix-input { - width: 300px; - } - - .stacking-user { - display: flex; - flex-direction: row-reverse; - align-items: center; - - .avatar { - cursor: pointer; - - &:not(:first-child) { - margin-right: -4px; - } - - &:hover { - transform: translate(3px, -3px); - transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); - } - - &.--active { - border: 2px solid var(--primary-color); - } - } - } - - .separator { - content: ''; - display: block; - height: 20px; - width: 1px; - background-color: var(--border-color-default); - } -} diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.ts b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.ts deleted file mode 100644 index 77d88d7a..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { - ChangeDetectionStrategy, - Component, - DestroyRef, - OnInit, - inject, -} from '@angular/core'; -import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms'; -import { UserAvatarComponent } from '@mixcore/share/components'; -import { MixButtonComponent } from '@mixcore/ui/button'; -import { MixInputComponent } from '@mixcore/ui/input'; -import { SkeletonLoadingComponent } from '@mixcore/ui/skeleton'; -import { tuiPure } from '@taiga-ui/cdk'; -import { TuiLinkModule } from '@taiga-ui/core'; -import { TuiFilterModule } from '@taiga-ui/kit'; -import { UserInfoStore } from '../../../../../stores/user-info.store'; -import { TaskFilterStore } from '../../store/filter.store'; -import { TaskStore } from '../../store/task.store'; - -@Component({ - selector: 'mix-task-filter', - standalone: true, - imports: [ - CommonModule, - ReactiveFormsModule, - MixInputComponent, - MixButtonComponent, - UserAvatarComponent, - TuiFilterModule, - TuiLinkModule, - SkeletonLoadingComponent, - ], - templateUrl: './task-filter.component.html', - styleUrls: ['./task-filter.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class TaskFilterComponent implements OnInit { - public userStore = inject(UserInfoStore); - public taskStore = inject(TaskStore); - public filterStore = inject(TaskFilterStore); - public destroyRef = inject(DestroyRef); - public userIds: string[] = []; - - public readonly filterItems = ['Only My Issues', 'Ignore Resolved']; - public readonly filterForm = new FormGroup({ - filters: new FormControl([]), - }); - - ngOnInit() { - this.filterStore.userIds$.subscribe( - (filter) => (this.userIds = filter.userIds) - ); - } - - @tuiPure - public isUserActive(userIds: string[], id: string) { - return userIds.includes(id); - } -} diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.html b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.html deleted file mode 100644 index f5af6268..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.html +++ /dev/null @@ -1,4 +0,0 @@ - - {{ PriorityIcon[priority] }} - diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.scss b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.scss deleted file mode 100644 index 92d692cd..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -:host { - display: contents; -} diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.ts b/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.ts deleted file mode 100644 index 6a732020..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; -import { - TaskPriority, - TaskPriorityColors, - TaskPriorityIcon, -} from '@mixcore/lib/model'; - -@Component({ - selector: 'mix-task-priority', - standalone: true, - imports: [CommonModule], - templateUrl: './task-priority.component.html', - styleUrls: ['./task-priority.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class TaskPriorityComponent { - @Input() public priority!: TaskPriority; - - public PriorityColor = TaskPriorityColors; - public PriorityIcon = TaskPriorityIcon; -} diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/store/filter.store.ts b/apps/mix-kanban/src/app/pages/portal/task-manage/store/filter.store.ts deleted file mode 100644 index 79fa7b6e..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/store/filter.store.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Injectable } from '@angular/core'; -import { ComponentStore } from '@ngrx/component-store'; - -export interface TaskFilterState { - userIds: string[]; - isOnlyMyIssue: boolean; -} - -@Injectable({ providedIn: 'root' }) -export class TaskFilterStore extends ComponentStore { - public userIds$ = this.select((s) => s); - - public toggleUserIds(userId: string) { - this.patchState((s) => { - let current = s.userIds; - if (current.includes(userId)) { - current = current.filter((id) => id !== userId); - } else { - current.push(userId); - } - - return { ...s, userIds: current }; - }); - } - - public clearFilter() { - this.patchState({ userIds: [] }); - } - - constructor() { - super({ - userIds: [], - isOnlyMyIssue: false, - }); - } -} diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/store/task.service.ts b/apps/mix-kanban/src/app/pages/portal/task-manage/store/task.service.ts deleted file mode 100644 index 05737836..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/store/task.service.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Injectable, inject } from '@angular/core'; -import { MixDynamicData, MixTaskNew } from '@mixcore/lib/model'; -import { MixApiFacadeService } from '@mixcore/share/api'; - -@Injectable({ providedIn: 'root' }) -export class TaskService { - public mixApi = inject(MixApiFacadeService); - - public saveTask(task: MixTaskNew) { - return this.mixApi.databaseApi.saveData( - 'mixDb_mixTask', - task.id ?? -1, - task as unknown as MixDynamicData - ); - } -} diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/task-manage.component.html b/apps/mix-kanban/src/app/pages/portal/task-manage/task-manage.component.html deleted file mode 100644 index 8924706b..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/task-manage.component.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
- -
- add   - {{ 'Create item' | transloco }} -
- - - -
- - -
-
-
diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/task-manage.component.scss b/apps/mix-kanban/src/app/pages/portal/task-manage/task-manage.component.scss deleted file mode 100644 index e0d06187..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/task-manage.component.scss +++ /dev/null @@ -1,35 +0,0 @@ -.task-manage { - &__main-view { - width: 100%; - height: 100%; - padding: 16px; - display: flex; - gap: 12px; - } - - &__filter { - padding: 16px 16px 0px 16px; - display: flex; - - mix-input { - width: 300px; - } - } -} - -.ad-task-container { - width: 800px; - padding: 12px 12px 18px 12px; - height: 900px; - display: flex; - flex-direction: column; -} - -.task-dnd-list { - display: block; - min-height: 400px; - min-width: 200px; - width: 320px; - background-color: rgb(244 245 247); - border-radius: 0.125rem; -} diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/task-manage.component.ts b/apps/mix-kanban/src/app/pages/portal/task-manage/task-manage.component.ts deleted file mode 100644 index 11bb3e53..00000000 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/task-manage.component.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { DragDropModule } from '@angular/cdk/drag-drop'; -import { CommonModule } from '@angular/common'; -import { - ChangeDetectionStrategy, - ChangeDetectorRef, - Component, - ViewEncapsulation, - inject, -} from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { TaskStatus } from '@mixcore/lib/model'; -import { MixApiFacadeService } from '@mixcore/share/api'; -import { BaseComponent } from '@mixcore/share/base'; -import { MixSubToolbarComponent } from '@mixcore/share/components'; -import { MixFormErrorComponent } from '@mixcore/share/form'; -import { MixButtonComponent } from '@mixcore/ui/button'; -import { MixEditorComponent } from '@mixcore/ui/editor'; -import { MixInputComponent } from '@mixcore/ui/input'; -import { SkeletonLoadingComponent } from '@mixcore/ui/skeleton'; -import { MixTextAreaComponent } from '@mixcore/ui/textarea'; -import { DialogService } from '@ngneat/dialog'; -import { HotToastService } from '@ngneat/hot-toast'; -import { TranslocoModule } from '@ngneat/transloco'; -import { TuiPaginationModule } from '@taiga-ui/kit'; -import { TaskCreateComponent } from './components/task-create/task-create.component'; -import { TaskDndListComponent } from './components/task-dnd-list/task-dnd-list.component'; -import { TaskFilterComponent } from './components/task-filter/task-filter.component'; -import { TaskStore } from './store/task.store'; - -@Component({ - selector: 'mix-task-manage', - standalone: true, - imports: [ - CommonModule, - TranslocoModule, - MixSubToolbarComponent, - MixButtonComponent, - ReactiveFormsModule, - MixInputComponent, - MixTextAreaComponent, - ReactiveFormsModule, - MixFormErrorComponent, - MixEditorComponent, - SkeletonLoadingComponent, - TuiPaginationModule, - TaskDndListComponent, - TaskFilterComponent, - DragDropModule, - ], - templateUrl: './task-manage.component.html', - styleUrls: ['./task-manage.component.scss'], - encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class TaskManageComponent extends BaseComponent { - public mixApi = inject(MixApiFacadeService); - public cdr = inject(ChangeDetectorRef); - public toast = inject(HotToastService); - public dialog = inject(DialogService); - public store = inject(TaskStore); - - public taskStatuses: TaskStatus[] = [ - TaskStatus.BACKLOG, - TaskStatus.SELECTED, - TaskStatus.IN_PROGRESS, - TaskStatus.DONE, - ]; - - constructor() { - super(); - } - - public addTask() { - this.dialog.open(TaskCreateComponent, { width: 800 }); - } -} diff --git a/apps/mix-kanban/src/app/stores/user-info.store.ts b/apps/mix-kanban/src/app/stores/user-info.store.ts deleted file mode 100644 index 39bb91b2..00000000 --- a/apps/mix-kanban/src/app/stores/user-info.store.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { Injectable, inject } from '@angular/core'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { PaginationRequestModel, UserListVm } from '@mixcore/lib/model'; -import { MixApiFacadeService } from '@mixcore/share/api'; -import { BaseState, DEFAULT_DATA } from '@mixcore/share/base'; -import { ComponentStore } from '@ngrx/component-store'; -import { filter, map, switchMap, tap } from 'rxjs'; - -@Injectable({ providedIn: 'root' }) -export class UserInfoStore extends ComponentStore> { - public mixApi = inject(MixApiFacadeService); - public vm$ = this.select((s) => s); - public request$ = this.select((s) => s.request); - - public requestFn = (request: PaginationRequestModel) => - this.mixApi.accountApi.getUserList({ ...request, loadNestedData: true }); - - public getUserById = (userId: string) => { - return this.vm$.pipe( - filter((s) => s.status === 'Success'), - map((s) => { - return s.data.find((user) => user.id === userId); - }) - ); - }; - - public loadData(request: PaginationRequestModel) { - return this.requestFn(request).pipe( - tap((result) => { - this.patchState((s) => ({ - ...s, - data: result.items, - pageInfo: result.pagingData, - status: 'Success', - })); - }) - ); - } - - public reload() { - this.requestFn(this.get().request).subscribe(); - } - - constructor() { - super({ - status: 'Loading', - request: { - pageIndex: 0, - pageSize: 50, - direction: 'Desc', - searchMethod: 'Like', - columns: '', - orderBy: 'createdDateTime', - metadataQueries: [], - }, - data: DEFAULT_DATA.items, - pageInfo: DEFAULT_DATA.pagingData, - }); - - this.request$ - .pipe( - tap(() => this.patchState((s) => ({ ...s, status: 'Loading' }))), - switchMap((request) => this.loadData(request)), - takeUntilDestroyed() - ) - .subscribe(); - } -} diff --git a/libs/mix-share/src/components/index.ts b/libs/mix-share/src/components/index.ts index 2f647cce..fa938133 100644 --- a/libs/mix-share/src/components/index.ts +++ b/libs/mix-share/src/components/index.ts @@ -15,3 +15,4 @@ export * from './setting-dialog/setting-dialog.component'; export * from './status-indicator/mix-status-indicator.component'; export * from './sub-toolbar/sub-toolbar.component'; export * from './user-avatar/user-avatar.component'; +export * from './user-select/user-select.component'; diff --git a/apps/mix-cms/src/app/components/user-select/user-select.component.html b/libs/mix-share/src/components/user-select/user-select.component.html similarity index 100% rename from apps/mix-cms/src/app/components/user-select/user-select.component.html rename to libs/mix-share/src/components/user-select/user-select.component.html diff --git a/apps/mix-cms/src/app/components/user-select/user-select.component.scss b/libs/mix-share/src/components/user-select/user-select.component.scss similarity index 100% rename from apps/mix-cms/src/app/components/user-select/user-select.component.scss rename to libs/mix-share/src/components/user-select/user-select.component.scss diff --git a/apps/mix-cms/src/app/components/user-select/user-select.component.ts b/libs/mix-share/src/components/user-select/user-select.component.ts similarity index 97% rename from apps/mix-cms/src/app/components/user-select/user-select.component.ts rename to libs/mix-share/src/components/user-select/user-select.component.ts index e45d6a69..c7eac3e4 100644 --- a/apps/mix-cms/src/app/components/user-select/user-select.component.ts +++ b/libs/mix-share/src/components/user-select/user-select.component.ts @@ -9,6 +9,7 @@ import { } from '@angular/forms'; import { UserListVm } from '@mixcore/lib/model'; import { MixApiFacadeService } from '@mixcore/share/api'; +import { UserInfoStore } from '@mixcore/share/stores'; import { tuiPure } from '@taiga-ui/cdk'; import { TuiDataListModule, @@ -16,7 +17,6 @@ import { } from '@taiga-ui/core'; import { TuiAvatarModule, TuiSelectModule } from '@taiga-ui/kit'; import { distinctUntilChanged, filter } from 'rxjs'; -import { UserInfoStore } from '../../stores/user-info.store'; @Component({ selector: 'mix-user-select', diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-card/task-card.component.html b/libs/mix-share/src/modules/task-manage/components/task-card/task-card.component.html similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-card/task-card.component.html rename to libs/mix-share/src/modules/task-manage/components/task-card/task-card.component.html diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-card/task-card.component.scss b/libs/mix-share/src/modules/task-manage/components/task-card/task-card.component.scss similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-card/task-card.component.scss rename to libs/mix-share/src/modules/task-manage/components/task-card/task-card.component.scss diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-card/task-card.component.ts b/libs/mix-share/src/modules/task-manage/components/task-card/task-card.component.ts similarity index 95% rename from apps/mix-kanban/src/app/pages/portal/task-manage/components/task-card/task-card.component.ts rename to libs/mix-share/src/modules/task-manage/components/task-card/task-card.component.ts index 94f8626e..3410a625 100644 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-card/task-card.component.ts +++ b/libs/mix-share/src/modules/task-manage/components/task-card/task-card.component.ts @@ -13,9 +13,9 @@ import { UserListVm, } from '@mixcore/lib/model'; import { UserAvatarComponent } from '@mixcore/share/components'; +import { UserInfoStore } from '@mixcore/share/stores'; import { DialogService } from '@ngneat/dialog'; import { take } from 'rxjs'; -import { UserInfoStore } from '../../../../../stores/user-info.store'; import { TaskDetailModalComponent } from '../task-detail-modal/task-detail-modal.component'; import { TaskPriorityComponent } from '../task-priority/task-priority.component'; diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-create/task-create.component.html b/libs/mix-share/src/modules/task-manage/components/task-create/task-create.component.html similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-create/task-create.component.html rename to libs/mix-share/src/modules/task-manage/components/task-create/task-create.component.html diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-create/task-create.component.scss b/libs/mix-share/src/modules/task-manage/components/task-create/task-create.component.scss similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-create/task-create.component.scss rename to libs/mix-share/src/modules/task-manage/components/task-create/task-create.component.scss diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-create/task-create.component.ts b/libs/mix-share/src/modules/task-manage/components/task-create/task-create.component.ts similarity index 96% rename from apps/mix-kanban/src/app/pages/portal/task-manage/components/task-create/task-create.component.ts rename to libs/mix-share/src/modules/task-manage/components/task-create/task-create.component.ts index a3fd2709..4fa2e692 100644 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-create/task-create.component.ts +++ b/libs/mix-share/src/modules/task-manage/components/task-create/task-create.component.ts @@ -13,6 +13,7 @@ import { TaskType, } from '@mixcore/lib/model'; import { BaseComponent } from '@mixcore/share/base'; +import { UserSelectComponent } from '@mixcore/share/components'; import { FormHelper } from '@mixcore/share/form'; import { MixButtonComponent } from '@mixcore/ui/button'; import { MixEditorComponent } from '@mixcore/ui/editor'; @@ -22,7 +23,6 @@ import { DialogRef } from '@ngneat/dialog'; import { HotToastService } from '@ngneat/hot-toast'; import { TaskService } from '../../store/task.service'; import { TaskStore } from '../../store/task.store'; -import { UserSelectComponent } from '../../../../../components/user-select/user-select.component'; @Component({ selector: 'mix-task-create', diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.html b/libs/mix-share/src/modules/task-manage/components/task-detail-modal/task-detail-modal.component.html similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.html rename to libs/mix-share/src/modules/task-manage/components/task-detail-modal/task-detail-modal.component.html diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.scss b/libs/mix-share/src/modules/task-manage/components/task-detail-modal/task-detail-modal.component.scss similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.scss rename to libs/mix-share/src/modules/task-manage/components/task-detail-modal/task-detail-modal.component.scss diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.ts b/libs/mix-share/src/modules/task-manage/components/task-detail-modal/task-detail-modal.component.ts similarity index 96% rename from apps/mix-kanban/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.ts rename to libs/mix-share/src/modules/task-manage/components/task-detail-modal/task-detail-modal.component.ts index eb9e74e8..c93ca8d8 100644 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/components/task-detail-modal/task-detail-modal.component.ts +++ b/libs/mix-share/src/modules/task-manage/components/task-detail-modal/task-detail-modal.component.ts @@ -14,6 +14,7 @@ import { TaskTypeIcons, } from '@mixcore/lib/model'; import { BaseComponent } from '@mixcore/share/base'; +import { UserSelectComponent } from '@mixcore/share/components'; import { FormHelper } from '@mixcore/share/form'; import { MixUtcDatePipe } from '@mixcore/share/pipe'; import { MixButtonComponent } from '@mixcore/ui/button'; @@ -22,7 +23,6 @@ import { MixInlineInputComponent } from '@mixcore/ui/inline-input'; import { MixSelectComponent } from '@mixcore/ui/select'; import { DialogRef } from '@ngneat/dialog'; import { HotToastService } from '@ngneat/hot-toast'; -import { UserSelectComponent } from '../../../../../components/user-select/user-select.component'; import { TaskService } from '../../store/task.service'; import { TaskStore } from '../../store/task.store'; diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.html b/libs/mix-share/src/modules/task-manage/components/task-dnd-list/task-dnd-list.component.html similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.html rename to libs/mix-share/src/modules/task-manage/components/task-dnd-list/task-dnd-list.component.html diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.scss b/libs/mix-share/src/modules/task-manage/components/task-dnd-list/task-dnd-list.component.scss similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.scss rename to libs/mix-share/src/modules/task-manage/components/task-dnd-list/task-dnd-list.component.scss diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.ts b/libs/mix-share/src/modules/task-manage/components/task-dnd-list/task-dnd-list.component.ts similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-dnd-list/task-dnd-list.component.ts rename to libs/mix-share/src/modules/task-manage/components/task-dnd-list/task-dnd-list.component.ts diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.html b/libs/mix-share/src/modules/task-manage/components/task-filter/task-filter.component.html similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.html rename to libs/mix-share/src/modules/task-manage/components/task-filter/task-filter.component.html diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.scss b/libs/mix-share/src/modules/task-manage/components/task-filter/task-filter.component.scss similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.scss rename to libs/mix-share/src/modules/task-manage/components/task-filter/task-filter.component.scss diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.ts b/libs/mix-share/src/modules/task-manage/components/task-filter/task-filter.component.ts similarity index 96% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.ts rename to libs/mix-share/src/modules/task-manage/components/task-filter/task-filter.component.ts index 77d88d7a..2a3f502a 100644 --- a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-filter/task-filter.component.ts +++ b/libs/mix-share/src/modules/task-manage/components/task-filter/task-filter.component.ts @@ -8,13 +8,13 @@ import { } from '@angular/core'; import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms'; import { UserAvatarComponent } from '@mixcore/share/components'; +import { UserInfoStore } from '@mixcore/share/stores'; import { MixButtonComponent } from '@mixcore/ui/button'; import { MixInputComponent } from '@mixcore/ui/input'; import { SkeletonLoadingComponent } from '@mixcore/ui/skeleton'; import { tuiPure } from '@taiga-ui/cdk'; import { TuiLinkModule } from '@taiga-ui/core'; import { TuiFilterModule } from '@taiga-ui/kit'; -import { UserInfoStore } from '../../../../../stores/user-info.store'; import { TaskFilterStore } from '../../store/filter.store'; import { TaskStore } from '../../store/task.store'; diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.html b/libs/mix-share/src/modules/task-manage/components/task-priority/task-priority.component.html similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.html rename to libs/mix-share/src/modules/task-manage/components/task-priority/task-priority.component.html diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.scss b/libs/mix-share/src/modules/task-manage/components/task-priority/task-priority.component.scss similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.scss rename to libs/mix-share/src/modules/task-manage/components/task-priority/task-priority.component.scss diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.ts b/libs/mix-share/src/modules/task-manage/components/task-priority/task-priority.component.ts similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/components/task-priority/task-priority.component.ts rename to libs/mix-share/src/modules/task-manage/components/task-priority/task-priority.component.ts diff --git a/libs/mix-share/src/modules/task-manage/index.ts b/libs/mix-share/src/modules/task-manage/index.ts new file mode 100644 index 00000000..65b70f8c --- /dev/null +++ b/libs/mix-share/src/modules/task-manage/index.ts @@ -0,0 +1 @@ +export * from './task-manage.component'; diff --git a/libs/mix-share/src/modules/task-manage/ng-package.json b/libs/mix-share/src/modules/task-manage/ng-package.json new file mode 100644 index 00000000..1dc0b0bd --- /dev/null +++ b/libs/mix-share/src/modules/task-manage/ng-package.json @@ -0,0 +1,5 @@ +{ + "lib": { + "entryFile": "index.ts" + } +} diff --git a/libs/mix-share/src/modules/task-manage/project.json b/libs/mix-share/src/modules/task-manage/project.json new file mode 100644 index 00000000..6eab71ba --- /dev/null +++ b/libs/mix-share/src/modules/task-manage/project.json @@ -0,0 +1,18 @@ +{ + "name": "@mixcore/share/stores", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "projectType": "library", + "sourceRoot": "libs/mix-share/src/stores", + "targets": { + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/mix-share/src/stores/**/*.ts", + "libs/mix-share/src/stores/**/*.html" + ] + } + } + } +} diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/store/filter.store.ts b/libs/mix-share/src/modules/task-manage/store/filter.store.ts similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/store/filter.store.ts rename to libs/mix-share/src/modules/task-manage/store/filter.store.ts diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/store/task.service.ts b/libs/mix-share/src/modules/task-manage/store/task.service.ts similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/store/task.service.ts rename to libs/mix-share/src/modules/task-manage/store/task.service.ts diff --git a/apps/mix-kanban/src/app/pages/portal/task-manage/store/task.store.ts b/libs/mix-share/src/modules/task-manage/store/task.store.ts similarity index 88% rename from apps/mix-kanban/src/app/pages/portal/task-manage/store/task.store.ts rename to libs/mix-share/src/modules/task-manage/store/task.store.ts index 9e040723..f9be8311 100644 --- a/apps/mix-kanban/src/app/pages/portal/task-manage/store/task.store.ts +++ b/libs/mix-share/src/modules/task-manage/store/task.store.ts @@ -6,12 +6,11 @@ import { } from '@mixcore/lib/model'; import { BaseCRUDStore } from '@mixcore/share/base'; import { map } from 'rxjs'; -import { MixSystemDbName } from '../../../../shares/consts/system-database-name'; @Injectable({ providedIn: 'root' }) export class TaskStore extends BaseCRUDStore { public override requestFn = (request: PaginationRequestModel) => - this.mixApi.databaseApi.getDataByName(MixSystemDbName.Task, { + this.mixApi.databaseApi.getDataByName('mixDb_mixTask', { ...request, }); diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/task-manage.component.html b/libs/mix-share/src/modules/task-manage/task-manage.component.html similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/task-manage.component.html rename to libs/mix-share/src/modules/task-manage/task-manage.component.html diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/task-manage.component.scss b/libs/mix-share/src/modules/task-manage/task-manage.component.scss similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/task-manage.component.scss rename to libs/mix-share/src/modules/task-manage/task-manage.component.scss diff --git a/apps/mix-cms/src/app/pages/portal/task-manage/task-manage.component.ts b/libs/mix-share/src/modules/task-manage/task-manage.component.ts similarity index 100% rename from apps/mix-cms/src/app/pages/portal/task-manage/task-manage.component.ts rename to libs/mix-share/src/modules/task-manage/task-manage.component.ts diff --git a/libs/mix-share/src/stores/index.ts b/libs/mix-share/src/stores/index.ts index 4fdc7f6f..85ecacee 100644 --- a/libs/mix-share/src/stores/index.ts +++ b/libs/mix-share/src/stores/index.ts @@ -1,2 +1,3 @@ export * from './application.store'; export * from './database.store'; +export * from './user-info.store'; diff --git a/apps/mix-cms/src/app/stores/user-info.store.ts b/libs/mix-share/src/stores/user-info.store.ts similarity index 100% rename from apps/mix-cms/src/app/stores/user-info.store.ts rename to libs/mix-share/src/stores/user-info.store.ts diff --git a/tsconfig.base.json b/tsconfig.base.json index 63e87a16..ae86c14c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -32,6 +32,9 @@ "@mixcore/share/signalR": ["libs/mix-share/src/signalR/index.ts"], "@mixcore/share/stores": ["libs/mix-share/src/stores/index.ts"], "@mixcore/share/utils": ["libs/mix-share/src/utils/index.ts"], + "@mixcore/module/task": [ + "libs/mix-share/src/modules/task-manage/index.ts" + ], "@mixcore/ui/array-media": ["libs/mix-ui/src/array-media/index.ts"], "@mixcore/ui/array-radio": ["libs/mix-ui/src/array-radio/index.ts"], "@mixcore/ui/base-control": ["libs/mix-ui/src/base/index.ts"],