Skip to content

Commit

Permalink
Merge branch 'develop' into feature/ALCS-1858-update-condition-pills
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarreta committed Dec 11, 2024
2 parents 4d6feb8 + 2646c1b commit 34fa55a
Show file tree
Hide file tree
Showing 98 changed files with 1,493 additions and 606 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ <h4>{{ isEdit ? 'Edit' : 'Create' }} Board</h4>
<mat-label>Code</mat-label>
<input [formControl]="code" required maxlength="4" minlength="4" matInput id="code" name="code" />
</mat-form-field>
<div *ngIf="form.get('code')?.hasError('codeExists')">
<app-error-message message="Code already in use, pick a different code."></app-error-message>
</div>
</div>

<div class="full-width">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
import { Component, Inject, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { FormBuilder, FormControl, FormGroup, NgModel, Validators } from '@angular/forms';
import { MatCheckboxChange } from '@angular/material/checkbox';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { AdminBoardManagementService } from '../../../../services/admin-board-management/admin-board-management.service';
Expand All @@ -10,6 +10,7 @@ import { BoardService } from '../../../../services/board/board.service';
import { CardStatusService } from '../../../../services/card/card-status/card-status.service';
import { CardType } from '../../../../shared/card/card.component';
import { BaseCodeDto } from '../../../../shared/dto/base.dto';
import { codeExistsValidator } from '../../../../shared/validators/code-exists-validator';

const DISABLED_CREATE_CARD_TYPES = [
CardType.APP,
Expand Down Expand Up @@ -60,6 +61,7 @@ export class BoardManagementDialogComponent implements OnInit {
public data: {
board: MinimalBoardDto | undefined;
cardTypes: BaseCodeDto[];
existingCodes: string[];
},
private dialogRef: MatDialogRef<BoardManagementDialogComponent>,
private cardStatusService: CardStatusService,
Expand All @@ -76,6 +78,8 @@ export class BoardManagementDialogComponent implements OnInit {
for (const type of this.cardTypes) {
this.cardTypeMap[type.code] = type.label;
}

this.code.addValidators(codeExistsValidator(this.data?.existingCodes ? this.data.existingCodes : []));
}

async loadBoard(code: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class BoardManagementComponent implements OnInit, OnDestroy {
height: '80%',
data: {
cardTypes: this.cardTypes,
existingCodes: this.boards.map((b) => b.code.toLowerCase()),
},
});
dialog.beforeClosed().subscribe(async (result) => {
Expand All @@ -62,6 +63,7 @@ export class BoardManagementComponent implements OnInit, OnDestroy {
data: {
board: boardDto,
cardTypes: this.cardTypes,
existingCodes: this.boards.map((b) => b.code.toLowerCase()),
},
});
dialog.beforeClosed().subscribe(async (result) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ <h4>{{ isEdit ? 'Edit' : 'Create' }} Column</h4>
matInput
id="code"
[(ngModel)]="code"
#codeModel="ngModel"
name="code"
/>
</mat-form-field>
</div>

<div *ngIf="isCodeExisiting(codeModel) && !isEdit" class="full-width code-error-message">
<app-error-message message="Code already in use, pick a different code."></app-error-message>
</div>
<div>
<mat-form-field class="label" appearance="outline">
<mat-label>Label</mat-label>
Expand All @@ -37,7 +40,7 @@ <h4>{{ isEdit ? 'Edit' : 'Create' }} Column</h4>

<div class="split">
<div [matTooltip]="canDeleteReason" [matTooltipDisabled]="canDelete">
<button [disabled]="!canDelete" (click)='onDelete()' mat-stroked-button color="warn">Delete</button>
<button [disabled]="!canDelete" (click)="onDelete()" mat-stroked-button color="warn">Delete</button>
</div>
<div class="button-container">
<button mat-stroked-button color="primary" mat-dialog-close="false">Close</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
.mat-mdc-form-field {
width: 100%;
}

.code-error-message {
margin: -20px 0 -20px 0;
}

.code {
padding-top: 8px;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('CardStatusDialogComponent', () => {
imports: [ReactiveFormsModule, FormsModule],
declarations: [CardStatusDialogComponent],
providers: [
{ provide: MAT_DIALOG_DATA, useValue: undefined },
{ provide: MAT_DIALOG_DATA, useValue: { existingCodes: [] } },
{ provide: MatDialogRef, useValue: {} },
{
provide: CardStatusService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { CardStatusDto } from '../../../../services/application/application-code.dto';
import { CardStatusService } from '../../../../services/card/card-status/card-status.service';
import { NgModel } from '@angular/forms';
import { codeExistsDirectiveValidator } from '../../../../shared/validators/code-exists-validator';

@Component({
selector: 'app-decision-condition-types-dialog',
Expand All @@ -19,16 +21,20 @@ export class CardStatusDialogComponent implements OnInit {
canDeleteReason = '';

constructor(
@Inject(MAT_DIALOG_DATA) public data: CardStatusDto | undefined,
@Inject(MAT_DIALOG_DATA)
public data: {
cardStatus: CardStatusDto | undefined;
existingCodes: string[];
},
private dialogRef: MatDialogRef<CardStatusDialogComponent>,
private cardStatusService: CardStatusService
private cardStatusService: CardStatusService,
) {
if (data) {
this.description = data.description;
this.label = data.label;
this.code = data.code;
if (data.cardStatus) {
this.description = data.cardStatus.description;
this.label = data.cardStatus.label;
this.code = data.cardStatus.code;
}
this.isEdit = !!data;
this.isEdit = !!data.cardStatus;
}

async onSubmit() {
Expand Down Expand Up @@ -65,4 +71,8 @@ export class CardStatusDialogComponent implements OnInit {
await this.cardStatusService.delete(this.code);
this.dialogRef.close(true);
}

isCodeExisiting(model: NgModel) {
return codeExistsDirectiveValidator(model, this.data.existingCodes, this.code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class CardStatusComponent implements OnInit {
constructor(
private cardStatusService: CardStatusService,
public dialog: MatDialog,
private confirmationDialogService: ConfirmationDialogService
private confirmationDialogService: ConfirmationDialogService,
) {}

ngOnInit(): void {
Expand All @@ -34,6 +34,7 @@ export class CardStatusComponent implements OnInit {
minWidth: '600px',
maxWidth: '800px',
width: '70%',
data: { existingCodes: this.cardStatusDtos.map((cs) => cs.code.toLowerCase()) },
});
dialog.beforeClosed().subscribe(async (result) => {
if (result) {
Expand All @@ -47,7 +48,7 @@ export class CardStatusComponent implements OnInit {
minWidth: '600px',
maxWidth: '800px',
width: '70%',
data: cardStatusDto,
data: { cardStatus: cardStatusDto, existingCodes: this.cardStatusDtos.map((cs) => cs.code.toLowerCase()) },
});
dialog.beforeClosed().subscribe(async (result) => {
if (result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ <h4>{{ isEdit ? 'Edit' : 'Create' }} CEO Criterion</h4>
matInput
id="code"
[(ngModel)]="code"
#codeModel="ngModel"
name="code"
/>
</mat-form-field>
<div *ngIf="isCodeExisting(codeModel) && !isEdit">
<app-error-message message="Code already in use or deteled, pick a different code."></app-error-message>
</div>
</div>

<div class="full-width">
Expand All @@ -50,7 +54,7 @@ <h4>{{ isEdit ? 'Edit' : 'Create' }} CEO Criterion</h4>
mat-flat-button
color="primary"
type="submit"
[disabled]="!form.form.valid"
[disabled]="!form.form.valid || (isCodeExisting(codeModel) && !isEdit)"
>
Save
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,13 @@
.mat-mdc-form-field {
width: 100%;
}

.code {
padding-top: 8px;
}

.number-input {
padding-top: 8px;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('CeoCriterionDialogComponent', () => {
imports: [ReactiveFormsModule, FormsModule],
declarations: [CeoCriterionDialogComponent],
providers: [
{ provide: MAT_DIALOG_DATA, useValue: undefined },
{ provide: MAT_DIALOG_DATA, useValue: { existingCodes: [] } },
{ provide: MatDialogRef, useValue: {} },
{
provide: CeoCriterionService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { CeoCriterionDto } from '../../../../services/application/decision/application-decision-v2/application-decision.dto';
import { CeoCriterionService } from '../../../../services/ceo-criterion/ceo-criterion.service';
import { NgModel } from '@angular/forms';
import { CeoCriterionDto } from '../../../../services/application/decision/application-decision-v2/application-decision.dto';
import { codeExistsDirectiveValidator } from '../../../../shared/validators/code-exists-validator';

@Component({
selector: 'app-ceo-criterion-dialog',
Expand All @@ -18,17 +20,21 @@ export class CeoCriterionDialogComponent {
isEdit = false;

constructor(
@Inject(MAT_DIALOG_DATA) public data: CeoCriterionDto | undefined,
@Inject(MAT_DIALOG_DATA)
public data: {
ceoCriterion: CeoCriterionDto | undefined;
existingCodes: string[];
},
private dialogRef: MatDialogRef<CeoCriterionDialogComponent>,
private ceoCriterionService: CeoCriterionService,
) {
if (data) {
this.description = data.description;
this.label = data.label;
this.code = data.code;
this.number = data.number.toString();
if (data?.ceoCriterion) {
this.description = data.ceoCriterion.description;
this.label = data.ceoCriterion.label;
this.code = data.ceoCriterion.code;
this.number = data.ceoCriterion.number.toString();
}
this.isEdit = !!data;
this.isEdit = !!data?.ceoCriterion;
}

async onSubmit() {
Expand All @@ -53,4 +59,8 @@ export class CeoCriterionDialogComponent {
this.isLoading = false;
this.dialogRef.close(true);
}

isCodeExisting(model: NgModel) {
return codeExistsDirectiveValidator(model, this.data.existingCodes, this.code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class CeoCriterionComponent implements OnInit {
minWidth: '600px',
maxWidth: '800px',
width: '70%',
data: {
existingCodes: this.ceoCriterion.map((cc) => cc.code.toLocaleLowerCase()),
},
});
dialog.beforeClosed().subscribe(async (result) => {
if (result) {
Expand All @@ -49,7 +52,7 @@ export class CeoCriterionComponent implements OnInit {
minWidth: '600px',
maxWidth: '800px',
width: '70%',
data: ceoCriterion,
data: { ceoCriterion: ceoCriterion, existingCodes: this.ceoCriterion.map((cc) => cc.code) },
});
dialog.beforeClosed().subscribe(async (result) => {
if (result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<span class="tab-label">Application</span>
</ng-template>
<br />
<app-decision-condition-types [service]="applicationService" />
<app-decision-condition-types [service]="applicationService" [conditionService]="applicationConditionService" />
</mat-tab>

<mat-tab>
<ng-template mat-tab-label>
<span class="tab-label">Notice of Intent</span>
</ng-template>
<br />
<app-decision-condition-types [service]="noiService" />
<app-decision-condition-types [service]="noiService" [conditionService]="noiConditionService" />
</mat-tab>
</mat-tab-group>
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
import { Component } from '@angular/core';
import { ApplicationDecisionConditionTypesService } from '../../../services/application/application-decision-condition-types/application-decision-condition-types.service';
import { NoticeofIntentDecisionConditionTypesService } from '../../../services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service';
import { NoticeOfIntentDecisionConditionService } from '../../../services/notice-of-intent/decision-v2/notice-of-intent-decision-condition/notice-of-intent-decision-condition.service';
import { ApplicationDecisionConditionService } from '../../../services/application/decision/application-decision-v2/application-decision-condition/application-decision-condition.service';

@Component({
selector: 'app-decision-condition-container',
templateUrl: './decision-condition-container.component.html',
styleUrls: ['./decision-condition-container.component.scss'],
})
export class DecisionConditionContainerComponent {

applicationService: ApplicationDecisionConditionTypesService;
applicationConditionService: ApplicationDecisionConditionService;
noiService: NoticeofIntentDecisionConditionTypesService;
noiConditionService: NoticeOfIntentDecisionConditionService;

constructor(
private aplicationDecisionConditionTypesService: ApplicationDecisionConditionTypesService,
private aplicationDecisionConditionService: ApplicationDecisionConditionService,
private noiDecisionConditionTypesService: NoticeofIntentDecisionConditionTypesService,
private noiDecisionConditionService: NoticeOfIntentDecisionConditionService,
) {
this.applicationService = this.aplicationDecisionConditionTypesService;
this.applicationConditionService = this.aplicationDecisionConditionService;
this.noiService = this.noiDecisionConditionTypesService;
this.noiConditionService = this.noiDecisionConditionService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ <h4>{{ isEdit ? 'Edit' : 'Create' }} Decision Condition Type</h4>
<mat-label>Code</mat-label>
<input required maxlength="4" minlength="4" matInput id="code" formControlName="code" name="code" />
</mat-form-field>
<div *ngIf="conditionTypeForm.get('code')?.hasError('codeExists')">
<app-error-message message="Code already in use or deteled, pick a different code."></app-error-message>
</div>
</div>

<div class="full-width">
Expand Down Expand Up @@ -72,7 +75,13 @@ <h4>{{ isEdit ? 'Edit' : 'Create' }} Decision Condition Type</h4>

<div class="condition-field">
<div class="condition-field-header">
<mat-checkbox formControlName="isDateChecked">Date</mat-checkbox>
<div>
<mat-checkbox formControlName="isDateChecked"> Date </mat-checkbox>
<app-error-message
*ngIf="!conditionTypeForm.controls['isDateChecked'].valid"
[message]="'Field contains data, cannot be removed'"
></app-error-message>
</div>

<div class="toggle" *ngIf="conditionTypeForm.get('isDateChecked')?.value">
<mat-label [ngClass]="{ inactive: conditionTypeForm.get('isDateRequired')?.value ?? false }"
Expand All @@ -87,7 +96,7 @@ <h4>{{ isEdit ? 'Edit' : 'Create' }} Decision Condition Type</h4>
*ngIf="conditionTypeForm.get('isDateChecked')?.value"
class="condition-date-types"
>
<mat-radio-button [value]="DateType.SINGLE">Single- Select date label </mat-radio-button>
<mat-radio-button [value]="DateType.SINGLE">Single - Select date label </mat-radio-button>
<div class="condition-fields-container" *ngIf="conditionTypeForm.value.dateType === 'single'">
<mat-button-toggle-group
id="singleDateLabelId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
flex-direction: row;
justify-content: space-between;
align-items: center;

app-error-message {
position: relative;
left: 11px;
}
}

.single-date-label-toggle {
Expand All @@ -53,6 +58,10 @@
padding-left: 20px;
}

:host::ng-deep & .mat-mdc-checkbox.ng-invalid .mdc-checkbox__background {
border-color: colors.$error-color !important;
}

::ng-deep .mdc-checkbox {
--mdc-checkbox-selected-icon-color: #{colors.$primary-color};
--mdc-checkbox-selected-focus-icon-color: #{colors.$primary-color};
Expand Down
Loading

0 comments on commit 34fa55a

Please sign in to comment.