Skip to content

Commit

Permalink
fix: remove unused validator on project form (#1339)
Browse files Browse the repository at this point in the history
  • Loading branch information
derschnee68 committed Jan 11, 2024
1 parent bf9aecc commit 0b9ad0c
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 342 deletions.
2 changes: 0 additions & 2 deletions apps/dsp-app/src/app/app.module.ts
Expand Up @@ -53,7 +53,6 @@ import { DialogHeaderComponent } from './main/dialog/dialog-header/dialog-header
import { DialogComponent } from './main/dialog/dialog.component';
import { AdminImageDirective } from './main/directive/admin-image/admin-image.directive';
import { DisableContextMenuDirective } from './main/directive/disable-context-menu.directive';
import { ExistingNameDirective } from './main/directive/existing-name/existing-name.directive';
import { InvalidControlScrollDirective } from './main/directive/invalid-control-scroll.directive';
import { FooterComponent } from './main/footer/footer.component';
import { GridComponent } from './main/grid/grid.component';
Expand Down Expand Up @@ -221,7 +220,6 @@ export function httpLoaderFactory(httpClient: HttpClient) {
DragDropDirective,
EditListItemComponent,
EditResourceClassDialogComponent,
ExistingNameDirective,
ExpertSearchComponent,
FooterComponent,
FormattedBooleanPipe,
Expand Down

This file was deleted.

This file was deleted.

@@ -0,0 +1,27 @@
import { AbstractControl, ValidatorFn } from '@angular/forms';

/**
* validation of existing name values. Array method (list of values)
* Use it in a "formbuilder" group as a validator property
*
* @param {RegExp} valArrayRegexp List of regular expression values
* @returns ValidatorFn
*/
export function existingNamesValidator(valArrayRegexp: [RegExp]): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } => {
let name;

if (control.value) {
name = control.value.toLowerCase();
}

let no;
for (const existing of valArrayRegexp) {
no = existing.test(name);
if (no) {
return no ? { existingName: { name } } : null;
}
}
return no ? { existingName: { name } } : null;
};
}
Expand Up @@ -21,7 +21,7 @@ import { MatChipInputEvent } from '@angular/material/chips';
(matChipInputTokenEnd)="addKeyword($event)" />
</mat-chip-grid>
</mat-form-field>
<mat-error *ngIf="formControl.errors as errors">{{ errors | humanReadableError }}</mat-error>
<mat-error *ngIf="formControl.touched && formControl.errors as errors">{{ errors | humanReadableError }}</mat-error>
`,
})
export class ChipListInputComponent {
Expand Down
Expand Up @@ -26,7 +26,7 @@ import { Store } from '@ngxs/store';
import { Observable } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { DialogComponent } from '../../../main/dialog/dialog.component';
import { existingNamesValidator } from '../../../main/directive/existing-name/existing-name.directive';
import { existingNamesValidator } from '../../../main/directive/existing-name/existing-names.validator';
import { AutocompleteItem } from '../../../workspace/search/operator';

@Component({
Expand Down
@@ -1,7 +1,6 @@
import { Component } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { ProjectApiService } from '@dasch-swiss/vre/shared/app-api';
import { finalize, tap } from 'rxjs/operators';

@Component({
selector: 'app-create-project-form-page',
Expand All @@ -21,6 +20,7 @@ import { finalize, tap } from 'rxjs/operators';
<button color="primary" mat-button type="reset" [routerLink]="['..']">
{{ 'appLabels.form.action.cancel' | translate }}
</button>
<button
mat-raised-button
type="submit"
Expand Down Expand Up @@ -54,11 +54,8 @@ export class CreateProjectFormPageComponent {
selfjoin: true,
status: true,
})
.pipe(
tap(() => {
this.loading = false;
})
)
.subscribe();
.subscribe(() => {
this.loading = false;
});
}
}

0 comments on commit 0b9ad0c

Please sign in to comment.