Commit 03931fbf authored by Florent POITTEVIN's avatar Florent POITTEVIN
Browse files

fix(admin language): [DLCM-1902] avoid to allow to create duplicate language

parent 848c1624
......@@ -22,10 +22,7 @@ import {SharedAbstractCreateEditDialog} from "@shared/components/dialogs/shared-
import {StateEnum} from "@shared/enums/state.enum";
import {CreateEditDialog} from "@shared/models/detail-edit-dialog.model";
import {sharedLanguageActionNameSpace} from "@shared/stores/language/shared-language.action";
import {
OverrideProperty,
ResourceNameSpace,
} from "solidify-frontend";
import {ResourceNameSpace} from "solidify-frontend";
@Component({
selector: "dlcm-language-create-edit-dialog",
......@@ -34,8 +31,7 @@ import {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AdminLanguageCreateEditDialog extends SharedAbstractCreateEditDialog<Language, AdminLanguageStateModel, CreateEditDialog<Language>> {
@OverrideProperty()
checkAvailableResourceNameSpace: ResourceNameSpace = sharedLanguageActionNameSpace;
override checkAvailableResourceNameSpace: ResourceNameSpace = sharedLanguageActionNameSpace;
constructor(@Inject(MAT_DIALOG_DATA) protected readonly data: CreateEditDialog<Language>,
protected readonly _store: Store,
......
......@@ -8,6 +8,7 @@
<mat-label>{{labelTranslateEnum.language | translate}}</mat-label>
<mat-select [formControl]="fd"
[required]="formValidationHelper.hasRequiredField(fd)"
(blur)="checkAvailable(formDefinition.resId, fd)"
>
<mat-option *ngFor="let country of listCountry"
[value]="country.iso"
......
......@@ -29,7 +29,6 @@ import {sharedResearchDomainActionNameSpace} from "@shared/stores/research-domai
import {Observable} from "rxjs";
import {
MemoizedUtil,
OverrideProperty,
ResourceNameSpace,
} from "solidify-frontend";
......@@ -42,8 +41,7 @@ import {
export class AdminResearchDomainCreateEditDialog extends SharedAbstractCreateEditDialog<ResearchDomain, AdminResearchDomainStateModel, CreateEditDialog<ResearchDomain>> {
languagesObs: Observable<Language[]> = MemoizedUtil.list(this._store, SharedLanguageState);
@OverrideProperty()
checkAvailableResourceNameSpace: ResourceNameSpace = sharedResearchDomainActionNameSpace;
override checkAvailableResourceNameSpace: ResourceNameSpace = sharedResearchDomainActionNameSpace;
constructor(@Inject(MAT_DIALOG_DATA) protected readonly data: CreateEditDialog<ResearchDomain>,
protected readonly _store: Store,
......
......@@ -54,6 +54,8 @@ export abstract class SharedAbstractCreateEditDialog<TResourceModel extends Base
current: TResourceModel | undefined;
isLoadingObs: Observable<boolean> = this._store.select(s => StoreUtil.isLoadingState(super.getState(s)));
checkAvailableResourceNameSpace: ResourceNameSpace | undefined;
paramMessage: any = undefined;
titleToTranslate: string = undefined;
tooltipToTranslate: string = undefined;
......@@ -153,6 +155,7 @@ export abstract class SharedAbstractCreateEditDialog<TResourceModel extends Base
}
checkAvailable(formControlKey: FormControlKey): void {
this.subscribe(CrudHelper.checkAvailable(formControlKey, this._store, this._actions$, this._resourceNameSpace, this.current.resId, this.labelTranslateInterface.alreadyUsed));
const resourceNameSpace = isNullOrUndefined(this.checkAvailableResourceNameSpace) ? this._resourceNameSpace : this.checkAvailableResourceNameSpace;
this.subscribe(CrudHelper.checkAvailable(formControlKey, this._store, this._actions$, resourceNameSpace, this.current?.resId, this.labelTranslateInterface.alreadyUsed));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment