Skip to content

Commit

Permalink
feat(workflows): navigate to workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaviju committed Sep 14, 2023
1 parent 4b72353 commit 97a586a
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
* Copyright (c) 2023-present Kaleidos INC
*/

import { CommonModule } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
ElementRef,
EventEmitter,
Output,
Input,
OnInit,
Output,
} from '@angular/core';
import { TranslocoDirective } from '@ngneat/transloco';
import { Store } from '@ngrx/store';
import { TuiButtonModule } from '@taiga-ui/core';
import { KanbanActions } from '~/app/modules/project/feature-kanban/data-access/+state/actions/kanban.actions';
import { selectCurrentWorkflow } from '~/app/modules/project/feature-kanban/data-access/+state/selectors/kanban.selectors';
import { selectWorkflow } from '~/app/modules/project/feature-kanban/data-access/+state/selectors/kanban.selectors';
import { EditStatus } from '~/app/modules/project/feature-kanban/models/edit-status.model';
import { TuiButtonModule } from '@taiga-ui/core';
import { EditStatusComponent } from '../edit-status/edit-status.component';
import { CommonModule } from '@angular/common';
import { TranslocoDirective } from '@ngneat/transloco';
import { RestoreFocusTargetDirective } from '~/app/shared/directives/restore-focus/restore-focus-target.directive';
import { EditStatusComponent } from '../edit-status/edit-status.component';

@Component({
selector: 'tg-kanban-create-status',
Expand All @@ -49,7 +49,7 @@ export class KanbanCreateStatusComponent implements OnInit {
@Output()
public closeForm = new EventEmitter<void>();

public workflow = this.store.selectSignal(selectCurrentWorkflow);
public workflow = this.store.selectSignal(selectWorkflow);

public showAddForm = false;
public columnSize = 292;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (c) 2023-present Kaleidos INC
*/

import { CommonModule } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Expand All @@ -20,21 +21,20 @@ import {
import {
FormBuilder,
FormGroup,
Validators,
ReactiveFormsModule,
Validators,
} from '@angular/forms';
import { TranslocoDirective } from '@ngneat/transloco';
import { Store } from '@ngrx/store';
import { Status } from '@taiga/data';
import { selectCurrentWorkflow } from '~/app/modules/project/feature-kanban/data-access/+state/selectors/kanban.selectors';
import { EditStatus } from '~/app/modules/project/feature-kanban/models/edit-status.model';
import { UtilsService } from '~/app/shared/utils/utils-service.service';
import { TuiButtonModule } from '@taiga-ui/core';
import { CommonModule } from '@angular/common';
import { TranslocoDirective } from '@ngneat/transloco';
import { Status } from '@taiga/data';
import { InputsModule } from '@taiga/ui/inputs';
import { RestoreFocusDirective } from '~/app/shared/directives/restore-focus/restore-focus.directive';
import { OutsideClickDirective } from '~/app/shared/directives/outside-click/outside-click.directive';
import { selectWorkflow } from '~/app/modules/project/feature-kanban/data-access/+state/selectors/kanban.selectors';
import { EditStatus } from '~/app/modules/project/feature-kanban/models/edit-status.model';
import { AutoFocusDirective } from '~/app/shared/directives/auto-focus/auto-focus.directive';
import { OutsideClickDirective } from '~/app/shared/directives/outside-click/outside-click.directive';
import { RestoreFocusDirective } from '~/app/shared/directives/restore-focus/restore-focus.directive';
import { UtilsService } from '~/app/shared/utils/utils-service.service';

@Component({
selector: 'tg-edit-status',
Expand Down Expand Up @@ -76,7 +76,7 @@ export class EditStatusComponent implements OnInit {
this.cancelEdit();
}

public workflow = this.store.selectSignal(selectCurrentWorkflow);
public workflow = this.store.selectSignal(selectWorkflow);

public statusForm!: FormGroup;
public statusMaxLength = 30;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { filterNil } from '~/app/shared/utils/operators';
import { KanbanStatusComponent } from '../components/status/kanban-status.component';
import { KanbanWorkflowComponent } from '../components/workflow/kanban-workflow.component';
import {
selectCurrentWorkflow,
selectStory,
selectWorkflow,
} from '../data-access/+state/selectors/kanban.selectors';
import { KanbanStory } from '../kanban.model';

Expand Down Expand Up @@ -131,7 +131,7 @@ export class KanbanScrollManagerService {
private moveToStatus(status: Status) {
return new Observable((subscriber) => {
this.store
.select(selectCurrentWorkflow)
.select(selectWorkflow)
.pipe(
filterNil(),
take(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@

import { createActionGroup, emptyProps, props } from '@ngrx/store';
import { Membership, Status, Story, Workflow } from '@taiga/data';
import { DropCandidate } from '@taiga/ui/drag/drag.model';
import {
KanbanReorderEvent,
KanbanStory,
KanbanStoryA11y,
PartialStory,
} from '~/app/modules/project/feature-kanban/kanban.model';
import { DropCandidate } from '@taiga/ui/drag/drag.model';

export const KanbanActions = createActionGroup({
source: 'Kanban',
events: {
'Init Kanban': emptyProps(),
'Init Kanban': props<{ workflow: Workflow['slug'] }>(),
'Open Create Story form': props<{ status: Status['id'] }>(),
'Close Create Story form': emptyProps(),
'Create Story': props<{
Expand Down Expand Up @@ -120,7 +120,7 @@ export const KanbanActions = createActionGroup({
export const KanbanApiActions = createActionGroup({
source: 'Kanban Api',
events: {
'Fetch Workflows Success': props<{ workflows: Workflow[] }>(),
'Fetch Workflow Success': props<{ workflow: Workflow }>(),
'Fetch Stories Success': props<{
stories: Story[];
offset: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ import {
KanbanEventsActions,
} from '../actions/kanban.actions';
import {
selectCurrentWorkflow,
selectCurrentWorkflowSlug,
selectWorkflows,
selectWorkflow,
} from '../selectors/kanban.selectors';

@Injectable()
Expand All @@ -51,11 +50,14 @@ export class KanbanEffects {
]),
fetch({
run: (action, project) => {
return this.projectApiService.getWorkflows(project.id).pipe(
map((workflows) => {
return KanbanApiActions.fetchWorkflowsSuccess({ workflows });
})
);
console.log(action);
return this.projectApiService
.getWorkflow(project.id, action.workflow)
.pipe(
map((workflow) => {
return KanbanApiActions.fetchWorkflowSuccess({ workflow });
})
);
},
onError: (action, error: HttpErrorResponse) => {
return this.appService.errorManagement(error);
Expand All @@ -69,7 +71,7 @@ export class KanbanEffects {
ofType(KanbanActions.initKanban),
concatLatestFrom(() => [
this.store.select(selectCurrentProject).pipe(filterNil()),
this.store.select(selectWorkflows),
this.store.select(selectWorkflow),
]),
fetch({
run: (action, project) => {
Expand Down Expand Up @@ -437,7 +439,7 @@ export class KanbanEffects {
filter(({ candidate }) => !!candidate),
concatLatestFrom(() => [
this.store.select(selectCurrentProjectId).pipe(filterNil()),
this.store.select(selectCurrentWorkflow).pipe(filterNil()),
this.store.select(selectWorkflow).pipe(filterNil()),
]),
pessimisticUpdate({
run: (action, project, workflow) => {
Expand Down
Loading

0 comments on commit 97a586a

Please sign in to comment.