add prefilling source frontend
This commit is contained in:
parent
0e7813cded
commit
69b00a7a26
|
@ -258,6 +258,18 @@ const appRoutes: Routes = [
|
|||
})
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'prefilling-sources',
|
||||
loadChildren: () => import('./ui/admin/prefilling-source/prefilling-source.module').then(m => m.PrefillingSourceModule),
|
||||
data: {
|
||||
authContext: {
|
||||
permissions: [AppPermission.ViewPrefillingSourcePage]
|
||||
},
|
||||
...BreadcrumbService.generateRouteDataConfiguration({
|
||||
title: 'BREADCRUMBS.PREFILLING-SOURCES'
|
||||
})
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'tenants',
|
||||
loadChildren: () => import('./ui/admin/tenant/tenant.module').then(m => m.TenantModule),
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
export enum ExternalFetcherApiHTTPMethodType {
|
||||
GET = 0,
|
||||
POST = 1
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export enum ExternalFetcherSourceType {
|
||||
API = 0,
|
||||
STATIC = 1
|
||||
}
|
|
@ -36,6 +36,7 @@ export enum AppPermission {
|
|||
ViewNotificationTemplatePage = "ViewNotificationTemplatePage",
|
||||
ViewMineInAppNotificationPage = "ViewMineInAppNotificationPage",
|
||||
ViewNotificationPage = "ViewNotificationPage",
|
||||
ViewPrefillingSourcePage = "ViewPrefillingSourcePage",
|
||||
|
||||
//ReferenceType
|
||||
BrowseReferenceType = "BrowseReferenceType",
|
||||
|
@ -67,5 +68,10 @@ export enum AppPermission {
|
|||
BrowseNotificationTemplate = "BrowseNotificationTemplate",
|
||||
EditNotificationTemplate = "EditNotificationTemplate",
|
||||
DeleteNotificationTemplate = "DeleteNotificationTemplate",
|
||||
|
||||
//Prefilling Source
|
||||
BrowsePrefillingSource= "BrowsePrefillingSource",
|
||||
EditPrefillingSource = "EditPrefillingSource",
|
||||
DeletePrefillingSource = "DeletePrefillingSource",
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
export enum ReferenceTypeExternalApiHTTPMethodType {
|
||||
GET = 0,
|
||||
POST = 1
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
export enum ReferenceTypeSourceType {
|
||||
API = 0,
|
||||
STATIC = 1
|
||||
}
|
|
@ -47,6 +47,7 @@ import { FileTransformerHttpService } from './services/file-transformer/file-tra
|
|||
import { InAppNotificationService } from './services/inapp-notification/inapp-notification.service';
|
||||
import { NotificationService } from './services/notification/notification-service';
|
||||
import { SemanticsService } from './services/semantic/semantics.service';
|
||||
import { PrefillingSourceService } from './services/prefilling-source/prefilling-source.service';
|
||||
//
|
||||
//
|
||||
// This is shared module that provides all the services. Its imported only once on the AppModule.
|
||||
|
@ -112,7 +113,8 @@ export class CoreServiceModule {
|
|||
FileTransformerHttpService,
|
||||
InAppNotificationService,
|
||||
NotificationService,
|
||||
SemanticsService
|
||||
SemanticsService,
|
||||
PrefillingSourceService
|
||||
],
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
import { ExternalFetcherApiHTTPMethodType } from "@app/core/common/enum/external-fetcher-api-http-method-type";
|
||||
import { ReferenceType } from "../reference-type/reference-type";
|
||||
import { ExternalFetcherSourceType } from "@app/core/common/enum/external-fetcher-source-type";
|
||||
import { Guid } from "@common/types/guid";
|
||||
|
||||
export interface ExternalFetcherBaseSourceConfiguration extends ExternalFetcherApiSourceConfiguration, ExternalFetcherStaticOptionSourceConfiguration{
|
||||
type: ExternalFetcherSourceType;
|
||||
key: string;
|
||||
label: string;
|
||||
ordinal: number;
|
||||
referenceTypeDependencies?: ReferenceType[];
|
||||
}
|
||||
|
||||
export interface ExternalFetcherApiSourceConfiguration{
|
||||
url: string;
|
||||
results: ResultsConfiguration;
|
||||
paginationPath: string;
|
||||
contentType: string;
|
||||
firstPage: string;
|
||||
httpMethod: ExternalFetcherApiHTTPMethodType;
|
||||
requestBody?: string;
|
||||
filterType?: string;
|
||||
auth: AuthenticationConfiguration;
|
||||
queries?: QueryConfig[];
|
||||
}
|
||||
|
||||
export interface ResultsConfiguration{
|
||||
resultsArrayPath: string;
|
||||
fieldsMapping: ResultFieldsMappingConfiguration[];
|
||||
}
|
||||
|
||||
|
||||
export interface ResultFieldsMappingConfiguration{
|
||||
code: string;
|
||||
responsePath: string;
|
||||
}
|
||||
|
||||
export interface AuthenticationConfiguration{
|
||||
enabled: boolean;
|
||||
authUrl: string;
|
||||
authMethod: ExternalFetcherApiHTTPMethodType;
|
||||
authTokenPath: string;
|
||||
authRequestBody: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface QueryConfig{
|
||||
name: string;
|
||||
defaultValue: string;
|
||||
cases: QueryCaseConfig[];
|
||||
}
|
||||
|
||||
export interface QueryCaseConfig{
|
||||
likePattern: string,
|
||||
separator: string;
|
||||
value: string;
|
||||
referenceType?: ReferenceType;
|
||||
referenceTypeSourceKey: string
|
||||
}
|
||||
|
||||
export interface ExternalFetcherStaticOptionSourceConfiguration{
|
||||
options: StaticOption[];
|
||||
}
|
||||
|
||||
export interface StaticOption{
|
||||
code: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
//
|
||||
// Persist
|
||||
//
|
||||
|
||||
export interface ExternalFetcherBaseSourceConfigurationPersist extends ExternalFetcherApiSourceConfigurationPersist, ExternalFetcherStaticOptionSourceConfigurationPersist{
|
||||
type: ExternalFetcherSourceType;
|
||||
key: string;
|
||||
label: string;
|
||||
ordinal: number;
|
||||
referenceTypeDependencyIds?: Guid[];
|
||||
}
|
||||
|
||||
export interface ExternalFetcherApiSourceConfigurationPersist{
|
||||
url: string;
|
||||
results: ResultsConfigurationPersist;
|
||||
paginationPath: string;
|
||||
contentType: string;
|
||||
firstPage: string;
|
||||
httpMethod: ExternalFetcherApiHTTPMethodType;
|
||||
requestBody?: string;
|
||||
filterType?: string;
|
||||
auth: AuthenticationConfigurationPersist;
|
||||
queries?: QueryConfigPersist[];
|
||||
}
|
||||
|
||||
export interface ResultsConfigurationPersist{
|
||||
resultsArrayPath: string;
|
||||
fieldsMapping: ResultFieldsMappingConfigurationPersist[];
|
||||
}
|
||||
|
||||
|
||||
export interface ResultFieldsMappingConfigurationPersist{
|
||||
code: string;
|
||||
responsePath: string;
|
||||
}
|
||||
|
||||
export interface AuthenticationConfigurationPersist{
|
||||
enabled: boolean;
|
||||
authUrl: string;
|
||||
authMethod: ExternalFetcherApiHTTPMethodType;
|
||||
authTokenPath: string;
|
||||
authRequestBody: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface QueryConfigPersist{
|
||||
name: string;
|
||||
defaultValue: string;
|
||||
cases: QueryCaseConfigPersist[];
|
||||
}
|
||||
|
||||
export interface QueryCaseConfigPersist{
|
||||
likePattern: string,
|
||||
separator: string;
|
||||
value: string;
|
||||
referenceTypeId: Guid;
|
||||
referenceTypeSourceKey: string
|
||||
}
|
||||
|
||||
export interface ExternalFetcherStaticOptionSourceConfigurationPersist {
|
||||
options: StaticOptionPersist[];
|
||||
}
|
||||
|
||||
export interface StaticOptionPersist{
|
||||
code: string;
|
||||
value: string;
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
|
||||
import { ExternalFetcherBaseSourceConfiguration, ExternalFetcherBaseSourceConfigurationPersist} from "../external-fetcher/external-fetcher";
|
||||
|
||||
export interface PrefillingSource extends BaseEntity{
|
||||
label: string;
|
||||
definition: PrefillingSourceDefinition;
|
||||
}
|
||||
|
||||
export interface PrefillingSourceDefinition{
|
||||
fields: PrefillingSourceDefinitionField[];
|
||||
searchConfiguration: ExternalFetcherBaseSourceConfiguration;
|
||||
getConfiguration: ExternalFetcherBaseSourceConfiguration;
|
||||
}
|
||||
|
||||
export interface PrefillingSourceDefinitionField {
|
||||
code: string;
|
||||
systemFieldTarget: string;
|
||||
semanticTarget: string;
|
||||
trimRegex: string;
|
||||
fixedValue: string;
|
||||
}
|
||||
|
||||
// Persist
|
||||
|
||||
export interface PrefillingSourcePersist extends BaseEntityPersist{
|
||||
label: string;
|
||||
definition: PrefillingSourceDefinitionPersist;
|
||||
}
|
||||
|
||||
export interface PrefillingSourceDefinitionPersist{
|
||||
fields: PrefillingSourceDefinitionFieldPersist[];
|
||||
searchConfiguration: ExternalFetcherBaseSourceConfigurationPersist;
|
||||
getConfiguration: ExternalFetcherBaseSourceConfigurationPersist;
|
||||
}
|
||||
|
||||
export interface PrefillingSourceDefinitionFieldPersist {
|
||||
code: string;
|
||||
systemFieldTarget: string;
|
||||
semanticTarget: string;
|
||||
trimRegex: string;
|
||||
fixedValue: string;
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type";
|
||||
import { ReferenceTypeExternalApiHTTPMethodType } from "@app/core/common/enum/reference-type-external-api-http-method-type";
|
||||
import { ReferenceTypeSourceType } from "@app/core/common/enum/reference-type-source-type";
|
||||
import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
|
||||
import { Guid } from "@common/types/guid";
|
||||
import { ExternalFetcherBaseSourceConfiguration, ExternalFetcherBaseSourceConfigurationPersist } from "../external-fetcher/external-fetcher";
|
||||
|
||||
export interface ReferenceType extends BaseEntity{
|
||||
name: string;
|
||||
|
@ -12,7 +10,7 @@ export interface ReferenceType extends BaseEntity{
|
|||
|
||||
export interface ReferenceTypeDefinition{
|
||||
fields: ReferenceTypeField[];
|
||||
sources: ReferenceTypeSourceBaseConfiguration[];
|
||||
sources: ExternalFetcherBaseSourceConfiguration[];
|
||||
}
|
||||
|
||||
export interface ReferenceTypeField {
|
||||
|
@ -22,69 +20,7 @@ export interface ReferenceTypeField {
|
|||
dataType: ReferenceFieldDataType;
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceBaseConfiguration extends ReferenceTypeSourceExternalApiConfiguration, ReferenceTypeSourceStaticOptionConfiguration{
|
||||
type: ReferenceTypeSourceType;
|
||||
key: string;
|
||||
label: string;
|
||||
ordinal: number;
|
||||
referenceTypeDependencies?: ReferenceType[];
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceExternalApiConfiguration{
|
||||
url: string;
|
||||
results: ResultsConfiguration;
|
||||
paginationPath: string;
|
||||
contentType: string;
|
||||
firstPage: string;
|
||||
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
requestBody?: string;
|
||||
filterType?: string;
|
||||
auth: AuthenticationConfiguration;
|
||||
queries?: QueryConfig[];
|
||||
}
|
||||
|
||||
export interface ResultsConfiguration{
|
||||
resultsArrayPath: string;
|
||||
fieldsMapping: ResultFieldsMappingConfiguration[];
|
||||
}
|
||||
|
||||
|
||||
export interface ResultFieldsMappingConfiguration{
|
||||
code: string;
|
||||
responsePath: string;
|
||||
}
|
||||
|
||||
export interface AuthenticationConfiguration{
|
||||
enabled: boolean;
|
||||
authUrl: string;
|
||||
authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
authTokenPath: string;
|
||||
authRequestBody: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface QueryConfig{
|
||||
name: string;
|
||||
defaultValue: string;
|
||||
cases: QueryCaseConfig[];
|
||||
}
|
||||
|
||||
export interface QueryCaseConfig{
|
||||
likePattern: string,
|
||||
separator: string;
|
||||
value: string;
|
||||
referenceType?: ReferenceType;
|
||||
referenceTypeSourceKey: string
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceStaticOptionConfiguration{
|
||||
options: ReferenceTypeStaticOption[];
|
||||
}
|
||||
|
||||
export interface ReferenceTypeStaticOption{
|
||||
code: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
// Persist
|
||||
|
||||
|
@ -96,7 +32,7 @@ export interface ReferenceTypePersist extends BaseEntityPersist{
|
|||
|
||||
export interface ReferenceTypeDefinitionPersist{
|
||||
fields?: ReferenceTypeFieldPersist[];
|
||||
sources: ReferenceTypeSourceBaseConfigurationPersist[];
|
||||
sources: ExternalFetcherBaseSourceConfigurationPersist[];
|
||||
}
|
||||
|
||||
export interface ReferenceTypeFieldPersist {
|
||||
|
@ -105,68 +41,3 @@ export interface ReferenceTypeFieldPersist {
|
|||
description: string;
|
||||
dataType: ReferenceFieldDataType;
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceBaseConfigurationPersist extends ReferenceTypeSourceExternalApiConfigurationPersist, ReferenceTypeSourceStaticOptionConfigurationPersist{
|
||||
type: ReferenceTypeSourceType;
|
||||
key: string;
|
||||
label: string;
|
||||
ordinal: number;
|
||||
referenceTypeDependencyIds?: Guid[];
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceExternalApiConfigurationPersist{
|
||||
url: string;
|
||||
results: ResultsConfigurationPersist;
|
||||
paginationPath: string;
|
||||
contentType: string;
|
||||
firstPage: string;
|
||||
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
requestBody?: string;
|
||||
filterType?: string;
|
||||
auth: AuthenticationConfigurationPersist;
|
||||
queries?: QueryConfigPersist[];
|
||||
}
|
||||
|
||||
export interface ResultsConfigurationPersist{
|
||||
resultsArrayPath: string;
|
||||
fieldsMapping: ResultFieldsMappingConfigurationPersist[];
|
||||
}
|
||||
|
||||
|
||||
|
||||
export interface ResultFieldsMappingConfigurationPersist{
|
||||
code: string;
|
||||
responsePath: string;
|
||||
}
|
||||
|
||||
export interface AuthenticationConfigurationPersist{
|
||||
enabled: boolean;
|
||||
authUrl: string;
|
||||
authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
authTokenPath: string;
|
||||
authRequestBody: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface QueryConfigPersist{
|
||||
name: string;
|
||||
defaultValue: string;
|
||||
cases: QueryCaseConfigPersist[];
|
||||
}
|
||||
|
||||
export interface QueryCaseConfigPersist{
|
||||
likePattern: string,
|
||||
separator: string;
|
||||
value: string;
|
||||
referenceTypeId: Guid;
|
||||
referenceTypeSourceKey: string
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceStaticOptionConfigurationPersist {
|
||||
options: ReferenceTypeStaticOptionPersist[];
|
||||
}
|
||||
|
||||
export interface ReferenceTypeStaticOptionPersist{
|
||||
code: string;
|
||||
value: string;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import { Lookup } from "@common/model/lookup";
|
||||
import { Guid } from "@common/types/guid";
|
||||
import { IsActive } from "../common/enum/is-active.enum";
|
||||
|
||||
export class PrefillingSourceLookup extends Lookup implements PrefillingSourceFilter {
|
||||
ids: Guid[];
|
||||
excludedIds: Guid[];
|
||||
like: string;
|
||||
isActive: IsActive[];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
export interface PrefillingSourceFilter {
|
||||
ids: Guid[];
|
||||
excludedIds: Guid[];
|
||||
like: string;
|
||||
isActive: IsActive[];
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||
import { PrefillingSource, PrefillingSourcePersist } from '@app/core/model/prefilling-source/prefilling-source';
|
||||
import { PrefillingSourceLookup } from '@app/core/query/prefilling-source.lookup';
|
||||
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
||||
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
|
||||
import { QueryResult } from '@common/model/query-result';
|
||||
import { FilterService } from '@common/modules/text-filter/filter-service';
|
||||
import { Guid } from '@common/types/guid';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { nameof } from 'ts-simple-nameof';
|
||||
import { ConfigurationService } from '../configuration/configuration.service';
|
||||
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||
|
||||
@Injectable()
|
||||
export class PrefillingSourceService {
|
||||
|
||||
constructor(
|
||||
private http: BaseHttpV2Service,
|
||||
private configurationService: ConfigurationService,
|
||||
private filterService: FilterService
|
||||
) {
|
||||
}
|
||||
|
||||
private get apiBase(): string { return `${this.configurationService.server}prefilling-source`; }
|
||||
|
||||
query(q: PrefillingSourceLookup): Observable<QueryResult<PrefillingSource>> {
|
||||
const url = `${this.apiBase}/query`;
|
||||
return this.http.post<QueryResult<PrefillingSource>>(url, q).pipe(catchError((error: any) => throwError(error)));
|
||||
}
|
||||
|
||||
getSingle(id: Guid, reqFields: string[] = []): Observable<PrefillingSource> {
|
||||
const url = `${this.apiBase}/${id}`;
|
||||
const options = { params: { f: reqFields } };
|
||||
|
||||
return this.http
|
||||
.get<PrefillingSource>(url, options).pipe(
|
||||
catchError((error: any) => throwError(error)));
|
||||
}
|
||||
|
||||
persist(item: PrefillingSourcePersist): Observable<PrefillingSource> {
|
||||
const url = `${this.apiBase}/persist`;
|
||||
|
||||
return this.http
|
||||
.post<PrefillingSource>(url, item).pipe(
|
||||
catchError((error: any) => throwError(error)));
|
||||
}
|
||||
|
||||
delete(id: Guid): Observable<PrefillingSource> {
|
||||
const url = `${this.apiBase}/${id}`;
|
||||
|
||||
return this.http
|
||||
.delete<PrefillingSource>(url).pipe(
|
||||
catchError((error: any) => throwError(error)));
|
||||
}
|
||||
|
||||
//
|
||||
// Autocomplete Commons
|
||||
//
|
||||
//
|
||||
public singleAutocompleteConfiguration: SingleAutoCompleteConfiguration = {
|
||||
initialItems: (data?: any) => this.query(this.buildAutocompleteLookup()).pipe(map(x => x.items)),
|
||||
filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(searchQuery)).pipe(map(x => x.items)),
|
||||
getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])),
|
||||
displayFn: (item: PrefillingSource) => item.label,
|
||||
titleFn: (item: PrefillingSource) => item.label,
|
||||
valueAssign: (item: PrefillingSource) => item.id,
|
||||
};
|
||||
|
||||
public multipleAutocompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)),
|
||||
filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(searchQuery, excludedItems)).pipe(map(x => x.items)),
|
||||
getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(null, null, selectedItems)).pipe(map(x => x.items)),
|
||||
displayFn: (item: PrefillingSource) => item.label,
|
||||
titleFn: (item: PrefillingSource) => item.label,
|
||||
valueAssign: (item: PrefillingSource) => item.id,
|
||||
};
|
||||
|
||||
private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): PrefillingSourceLookup {
|
||||
const lookup: PrefillingSourceLookup = new PrefillingSourceLookup();
|
||||
lookup.page = { size: 100, offset: 0 };
|
||||
if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
|
||||
if (ids && ids.length > 0) { lookup.ids = ids; }
|
||||
lookup.isActive = [IsActive.Active];
|
||||
lookup.project = {
|
||||
fields: [
|
||||
nameof<PrefillingSource>(x => x.id),
|
||||
nameof<PrefillingSource>(x => x.label)
|
||||
]
|
||||
};
|
||||
lookup.order = { items: [nameof<PrefillingSource>(x => x.label)] };
|
||||
if (like) { lookup.like = this.filterService.transformLike(like); }
|
||||
return lookup;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ import { catchError, map } from 'rxjs/operators';
|
|||
import { ConfigurationService } from '../configuration/configuration.service';
|
||||
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||
import { SemanticsLookup } from '@app/core/query/semantic.lookup';
|
||||
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
|
||||
|
||||
@Injectable()
|
||||
export class SemanticsService {
|
||||
|
@ -26,6 +27,15 @@ export class SemanticsService {
|
|||
|
||||
|
||||
// Autocomplete
|
||||
|
||||
singleAutocompleteConfiguration: SingleAutoCompleteConfiguration = {
|
||||
initialItems: (data?: any) => this.searchSemantics(this.buildSemanticsAutocompleteLookup()).pipe(map(x => x)),
|
||||
filterFn: (searchQuery: string, data?: any) => this.searchSemantics(this.buildSemanticsAutocompleteLookup(searchQuery)).pipe(map(x => x)),
|
||||
displayFn: (item) => item,
|
||||
titleFn: (item) => item,
|
||||
valueAssign: (item) => item,
|
||||
};
|
||||
|
||||
multipleAutocompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
initialItems: (data?: any) => this.searchSemantics(this.buildSemanticsAutocompleteLookup()).pipe(map(x => x)),
|
||||
filterFn: (searchQuery: string, data?: any) => this.searchSemantics(this.buildSemanticsAutocompleteLookup(searchQuery)).pipe(map(x => x)),
|
||||
|
|
|
@ -24,8 +24,8 @@ import { NotificationType } from '@app/core/common/enum/notification-type';
|
|||
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
|
||||
import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type';
|
||||
import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type';
|
||||
import { ReferenceTypeExternalApiHTTPMethodType } from '@app/core/common/enum/reference-type-external-api-http-method-type';
|
||||
import { ReferenceTypeSourceType } from '@app/core/common/enum/reference-type-source-type';
|
||||
import { ExternalFetcherApiHTTPMethodType } from '@app/core/common/enum/external-fetcher-api-http-method-type';
|
||||
import { ExternalFetcherSourceType } from '@app/core/common/enum/external-fetcher-source-type';
|
||||
import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type';
|
||||
import { SupportiveMaterialFieldType } from '@app/core/common/enum/supportive-material-field-type';
|
||||
import { UserDescriptionTemplateRole } from '@app/core/common/enum/user-description-template-role';
|
||||
|
@ -174,10 +174,10 @@ export class EnumUtils {
|
|||
}
|
||||
}
|
||||
|
||||
toReferenceTypeSourceTypeString(status: ReferenceTypeSourceType): string {
|
||||
toExternalFetcherSourceTypeString(status: ExternalFetcherSourceType): string {
|
||||
switch (status) {
|
||||
case ReferenceTypeSourceType.API: return this.language.instant('TYPES.REFERENCE-TYPE-SOURCE-TYPE.API');
|
||||
case ReferenceTypeSourceType.STATIC: return this.language.instant('TYPES.REFERENCE-TYPE-SOURCE-TYPE.STATIC');
|
||||
case ExternalFetcherSourceType.API: return this.language.instant('TYPES.REFERENCE-TYPE-SOURCE-TYPE.API');
|
||||
case ExternalFetcherSourceType.STATIC: return this.language.instant('TYPES.REFERENCE-TYPE-SOURCE-TYPE.STATIC');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,10 +189,10 @@ export class EnumUtils {
|
|||
}
|
||||
|
||||
|
||||
toReferenceTypeExternalApiHTTPMethodTypeString(status: ReferenceTypeExternalApiHTTPMethodType): string {
|
||||
toExternalFetcherApiHTTPMethodTypeString(status: ExternalFetcherApiHTTPMethodType): string {
|
||||
switch (status) {
|
||||
case ReferenceTypeExternalApiHTTPMethodType.GET: return this.language.instant('TYPES.REFERENCE-TYPE-EXTERNAL-API-HTTP-METHOD-TYPE.GET');
|
||||
case ReferenceTypeExternalApiHTTPMethodType.POST: return this.language.instant('TYPES.REFERENCE-TYPE-EXTERNAL-API-HTTP-METHOD-TYPE.POST');
|
||||
case ExternalFetcherApiHTTPMethodType.GET: return this.language.instant('TYPES.REFERENCE-TYPE-EXTERNAL-API-HTTP-METHOD-TYPE.GET');
|
||||
case ExternalFetcherApiHTTPMethodType.POST: return this.language.instant('TYPES.REFERENCE-TYPE-EXTERNAL-API-HTTP-METHOD-TYPE.POST');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
<div class="prefilling-source-editor">
|
||||
<div class="col-md-8 offset-md-2 colums-gapped" *ngIf="formGroup">
|
||||
|
||||
<div class="row justify-content-between align-items-center">
|
||||
<div class="col">
|
||||
<h3 *ngIf="isNew">{{'PREFILLING-SOURCE-EDITOR.NEW' | translate}}</h3>
|
||||
<app-navigation-breadcrumb />
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button mat-button class="action-btn" (click)="cancel()" type="button">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.CANCEL' | translate}}</button>
|
||||
</div>
|
||||
<div class="col-auto" *ngIf="canDelete">
|
||||
<button mat-button class="action-btn" type="button" (click)="delete()">
|
||||
<mat-icon>delete</mat-icon>
|
||||
{{'PREFILLING-SOURCE-EDITOR.ACTIONS.DELETE' | translate}}
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-auto" *ngIf="canSave">
|
||||
<button mat-button class="action-btn" (click)="formSubmit()">
|
||||
<mat-icon>save</mat-icon>
|
||||
{{'PREFILLING-SOURCE-EDITOR.ACTIONS.SAVE' | translate}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form *ngIf="formGroup" (ngSubmit)="formSubmit()">
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-header>
|
||||
<mat-card-title *ngIf="isNew">{{'PREFILLING-SOURCE-EDITOR.NEW' | translate}}</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.LABEL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="label" [formControl]="formGroup.get('label')" required>
|
||||
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">{{formGroup.get('label').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<!-- Fields -->
|
||||
<div class="col-12">
|
||||
<h3>
|
||||
<button mat-button class="action-btn" type="button" (click)="addField()" [disabled]="formGroup.disabled">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.ADD-FIELD' | translate}}</button>
|
||||
</h3>
|
||||
<div *ngFor="let field of formGroup.get('definition').get('fields').controls; let fieldIndex=index;" class="row mb-3">
|
||||
<div class="col-12">
|
||||
<div class="row mb-3 d-flex align-items-center">
|
||||
<div class="col-auto d-flex">
|
||||
<mat-card-title>{{'PREFILLING-SOURCE-EDITOR.FIELDS.FIELD' | translate}} {{fieldIndex + 1}}</mat-card-title>
|
||||
</div>
|
||||
<div class="col-auto d-flex">
|
||||
<button mat-icon-button class="action-list-icon" matTooltip="{{'PREFILLING-SOURCE-EDITOR.ACTIONS.REMOVE-FIELD' | translate}}" (click)="removeField(fieldIndex)" [disabled]="formGroup.disabled">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" >
|
||||
<div class="col">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="code" [formControl]="field.get('code')">
|
||||
<mat-error *ngIf="field.get('code').hasError('backendError')">{{field.get('code').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="field.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.SYSTEM-TARGET' | translate}}</mat-label>
|
||||
<input matInput type="text" name="systemFieldTarget" [formControl]="field.get('systemFieldTarget')">
|
||||
<mat-error *ngIf="field.get('systemFieldTarget').hasError('backendError')">{{field.get('systemFieldTarget').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="field.get('systemFieldTarget').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.SEMANTIC-TARGET' | translate}}</mat-label>
|
||||
<app-single-auto-complete placeholder="{{'PREFILLING-SOURCE-EDITOR.FIELDS.SEMANTIC-TARGET' | translate}}" [formControl]="field.get('semanticTarget')" [configuration]="semanticsService.singleAutocompleteConfiguration"> </app-single-auto-complete>
|
||||
<mat-error *ngIf="field.get('semanticTarget').hasError('backendError')">{{field.get('semanticTarget').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="field.get('semanticTarget').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.TRIM-REGEX' | translate}}</mat-label>
|
||||
<input matInput type="text" name="trimRegex" [formControl]="field.get('trimRegex')">
|
||||
<mat-error *ngIf="field.get('trimRegex').hasError('backendError')">{{field.get('trimRegex').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="field.get('trimRegex').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.FIXED-VALUE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="fixedValue" [formControl]="field.get('fixedValue')">
|
||||
<mat-error *ngIf="field.get('fixedValue').hasError('backendError')">{{field.get('fixedValue').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="field.get('fixedValue').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button mat-button class="action-btn" *ngIf="formGroup.get('definition').get('fields').value != ''"
|
||||
type="button" (click)="submitFields()" [disabled]="!formGroup.get('definition').get('fields').valid">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.SUBMIT-FIELDS' | translate}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-header>
|
||||
<mat-card-title >{{'PREFILLING-SOURCE-EDITOR.FIELDS.SOURCE-CONFIGURATION' | translate}}</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<app-external-fetcher-source-component [formGroup]="formGroup.get('definition').get('searchConfiguration')" [validationErrorModel]="editorModel.validationErrorModel" [validationRootPath]="'definition.searchConfiguration.'"></app-external-fetcher-source-component>
|
||||
<div>
|
||||
<mat-checkbox [formControl]="formGroup.get('definition').get('getEnabled')">
|
||||
{{'PREFILLING-SOURCE-EDITOR.FIELDS.GET-SOURCE-CONFIGURATION' | translate}}
|
||||
<mat-error *ngIf="formGroup.get('definition').get('getEnabled').hasError('backendError')">{{formGroup.get('definition').get('getEnabled').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('definition').get('getEnabled').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-checkbox>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
<mat-card appearance="outlined" *ngIf="formGroup.get('definition').get('getEnabled').value == true">
|
||||
<mat-card-header>
|
||||
<mat-card-title >{{'PREFILLING-SOURCE-EDITOR.FIELDS.GET-SOURCE-CONFIGURATION' | translate}}</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<app-external-fetcher-source-component [formGroup]="formGroup.get('definition').get('getConfiguration')" [validationErrorModel]="editorModel.validationErrorModel" [validationRootPath]="'definition.getConfiguration.'"></app-external-fetcher-source-component>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,43 @@
|
|||
.prefilling-source-editor {
|
||||
margin-top: 1.3rem;
|
||||
margin-left: 1em;
|
||||
margin-right: 3em;
|
||||
|
||||
.remove {
|
||||
background-color: white;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.add {
|
||||
background-color: white;
|
||||
color: #009700;
|
||||
}
|
||||
}
|
||||
|
||||
::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background, .mat-checkbox-indeterminate.mat-accent .mat-checkbox-background {
|
||||
background-color: var(--primary-color-3);
|
||||
// background-color: #0070c0;
|
||||
}
|
||||
|
||||
::ng-deep .mat-checkbox-disabled.mat-checkbox-checked .mat-checkbox-background, .mat-checkbox-disabled.mat-checkbox-indeterminate .mat-checkbox-background {
|
||||
background-color: #b0b0b0;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
border-radius: 30px;
|
||||
background-color: var(--secondary-color);
|
||||
border: 1px solid transparent;
|
||||
padding-left: 2em;
|
||||
padding-right: 2em;
|
||||
box-shadow: 0px 3px 6px #1E202029;
|
||||
|
||||
transition-property: background-color, color;
|
||||
transition-duration: 200ms;
|
||||
transition-delay: 50ms;
|
||||
transition-timing-function: ease-in-out;
|
||||
&:disabled{
|
||||
background-color: #CBCBCB;
|
||||
color: #FFF;
|
||||
border: 0px;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,264 @@
|
|||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormArray, FormGroup, UntypedFormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { PrefillingSourceService } from '@app/core/services/prefilling-source/prefilling-source.service';
|
||||
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
||||
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
||||
// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||
import { PrefillingSource, PrefillingSourcePersist } from '@app/core/model/prefilling-source/prefilling-source';
|
||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||
import { LoggingService } from '@app/core/services/logging/logging-service';
|
||||
import { MatomoService } from '@app/core/services/matomo/matomo-service';
|
||||
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
|
||||
import { BaseEditor } from '@common/base/base-editor';
|
||||
import { FormService } from '@common/forms/form-service';
|
||||
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
||||
import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service';
|
||||
import { FilterService } from '@common/modules/text-filter/filter-service';
|
||||
import { Guid } from '@common/types/guid';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { PrefillingSourceEditorResolver } from './prefilling-source-editor.resolver';
|
||||
import { PrefillingSourceEditorService } from './prefilling-source-editor.service';
|
||||
import { PrefillingSourceEditorModel } from './prefilling-source-editor.model';
|
||||
import { ResultFieldsMappingConfigurationEditorModel } from '@app/ui/external-fetcher/external-fetcher-source-editor.model';
|
||||
import { SemanticsService } from '@app/core/services/semantic/semantics.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-prefilling-source-editor-component',
|
||||
templateUrl: 'prefilling-source-editor.component.html',
|
||||
styleUrls: ['./prefilling-source-editor.component.scss'],
|
||||
providers: [PrefillingSourceEditorService]
|
||||
})
|
||||
export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSourceEditorModel, PrefillingSource> implements OnInit {
|
||||
|
||||
isNew = true;
|
||||
isDeleted = false;
|
||||
formGroup: UntypedFormGroup = null;
|
||||
showInactiveDetails = false;
|
||||
|
||||
protected get canDelete(): boolean {
|
||||
return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeletePrefillingSource);
|
||||
}
|
||||
|
||||
protected get canSave(): boolean {
|
||||
return !this.isDeleted && this.hasPermission(this.authService.permissionEnum.EditPrefillingSource);
|
||||
}
|
||||
|
||||
private hasPermission(permission: AppPermission): boolean {
|
||||
return this.authService.hasPermission(permission) || this.editorModel?.permissions?.includes(permission);
|
||||
}
|
||||
|
||||
constructor(
|
||||
// BaseFormEditor injected dependencies
|
||||
protected dialog: MatDialog,
|
||||
protected language: TranslateService,
|
||||
protected formService: FormService,
|
||||
protected router: Router,
|
||||
protected uiNotificationService: UiNotificationService,
|
||||
protected httpErrorHandlingService: HttpErrorHandlingService,
|
||||
protected filterService: FilterService,
|
||||
protected datePipe: DatePipe,
|
||||
protected route: ActivatedRoute,
|
||||
protected queryParamsService: QueryParamsService,
|
||||
// Rest dependencies. Inject any other needed deps here:
|
||||
public authService: AuthService,
|
||||
public enumUtils: EnumUtils,
|
||||
private prefillingSourceService: PrefillingSourceService,
|
||||
private logger: LoggingService,
|
||||
private prefillingSourceEditorService: PrefillingSourceEditorService,
|
||||
public semanticsService: SemanticsService,
|
||||
private matomoService: MatomoService
|
||||
) {
|
||||
super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.matomoService.trackPageView('Admin: PrefillingSources');
|
||||
super.ngOnInit();
|
||||
}
|
||||
|
||||
getItem(itemId: Guid, successFunction: (item: PrefillingSource) => void) {
|
||||
this.prefillingSourceService.getSingle(itemId, PrefillingSourceEditorResolver.lookupFields())
|
||||
.pipe(map(data => data as PrefillingSource), takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
data => successFunction(data),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
|
||||
prepareForm(data: PrefillingSource) {
|
||||
try {
|
||||
this.editorModel = data ? new PrefillingSourceEditorModel().fromModel(data) : new PrefillingSourceEditorModel();
|
||||
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
||||
this.buildForm();
|
||||
} catch (error) {
|
||||
this.logger.error('Could not parse PrefillingSource item: ' + data + error);
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('COMMONS.ERRORS.DEFAULT'), SnackBarNotificationLevel.Error);
|
||||
}
|
||||
}
|
||||
|
||||
buildForm() {
|
||||
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.authService.hasPermission(AppPermission.EditPrefillingSource));
|
||||
this.prefillingSourceEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
|
||||
this.addFieldMapping("prefilling_id", "searchConfiguration");
|
||||
this.addFieldMapping("label", "searchConfiguration");
|
||||
this.addFieldMapping("description", "searchConfiguration");
|
||||
|
||||
this.addFieldMapping("prefilling_id", "getConfiguration");
|
||||
this.addFieldMapping("label", "getConfiguration");
|
||||
this.addFieldMapping("description", "getConfiguration");
|
||||
}
|
||||
|
||||
refreshData(): void {
|
||||
this.getItem(this.editorModel.id, (data: PrefillingSource) => this.prepareForm(data));
|
||||
}
|
||||
|
||||
refreshOnNavigateToData(id?: Guid): void {
|
||||
this.formGroup.markAsPristine();
|
||||
let route = [];
|
||||
|
||||
if (id === null) {
|
||||
route.push('../..');
|
||||
} else if (this.isNew) {
|
||||
route.push('../' + id);
|
||||
} else {
|
||||
route.push('..');
|
||||
}
|
||||
|
||||
this.router.navigate(route, { queryParams: { 'lookup': this.queryParamsService.serializeLookup(this.lookupParams), 'lv': ++this.lv }, replaceUrl: true, relativeTo: this.route });
|
||||
}
|
||||
|
||||
persistEntity(onSuccess?: (response) => void): void {
|
||||
const formData = this.formService.getValue(this.formGroup.value) as PrefillingSourcePersist;
|
||||
|
||||
this.prefillingSourceService.persist(formData)
|
||||
.pipe(takeUntil(this._destroyed)).subscribe(
|
||||
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
|
||||
formSubmit(): void {
|
||||
this.formService.touchAllFormFields(this.formGroup);
|
||||
// if (!this.isFormValid()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
this.persistEntity();
|
||||
}
|
||||
|
||||
public delete() {
|
||||
const value = this.formGroup.value;
|
||||
if (value.id) {
|
||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
maxWidth: '300px',
|
||||
data: {
|
||||
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
|
||||
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
||||
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL')
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result) {
|
||||
this.prefillingSourceService.delete(value.id).pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
clearErrorModel() {
|
||||
this.editorModel.validationErrorModel.clear();
|
||||
this.formService.validateAllFormFields(this.formGroup);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// fields
|
||||
//
|
||||
//
|
||||
addField(): void {
|
||||
(this.formGroup.get('definition').get('fields') as FormArray).push(this.editorModel.createChildField((this.formGroup.get('definition').get('fields') as FormArray).length));
|
||||
}
|
||||
|
||||
removeField(fieldIndex: number): void {
|
||||
const fieldForm = this.formGroup.get('definition').get('fields') as FormArray;
|
||||
const fieldCode = fieldForm.at(fieldIndex).get('code').value;
|
||||
|
||||
fieldForm.removeAt(fieldIndex);
|
||||
|
||||
//Reapply validators
|
||||
PrefillingSourceEditorModel.reApplyDefinitionValidators(
|
||||
{
|
||||
formGroup: this.formGroup,
|
||||
validationErrorModel: this.editorModel.validationErrorModel
|
||||
}
|
||||
)
|
||||
fieldForm.markAsDirty();
|
||||
|
||||
this.removeFieldMapping((this.formGroup.get('definition').get('searchConfiguration') as FormGroup), fieldCode);
|
||||
this.removeFieldMapping((this.formGroup.get('definition').get('getConfiguration') as FormGroup), fieldCode);
|
||||
}
|
||||
|
||||
submitFields(): void {
|
||||
const fieldsFormArray = (this.formGroup.get('definition').get('fields') as FormArray);
|
||||
|
||||
if (fieldsFormArray.valid) {
|
||||
for (let i = 0; i < fieldsFormArray.length; i++) {
|
||||
const code = fieldsFormArray.at(i).get('code').value;
|
||||
this.addFieldMapping(code, "searchConfiguration");
|
||||
this.addFieldMapping(code, "getConfiguration");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// resultFieldsMapping
|
||||
//
|
||||
//
|
||||
addFieldMapping(code: string, controlName: string): void {
|
||||
const formArray = (this.formGroup.get('definition').get(controlName).get('results').get('fieldsMapping') as FormArray);
|
||||
const fieldMappingSize = formArray.length;
|
||||
|
||||
if (fieldMappingSize > 0) {
|
||||
for (let i = 0; i < fieldMappingSize; i++) {
|
||||
if (formArray.at(i).get('code').getRawValue() == code) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
const fieldsMapping = new ResultFieldsMappingConfigurationEditorModel(this.editorModel.validationErrorModel);
|
||||
fieldsMapping.code = code;
|
||||
formArray.push(fieldsMapping.buildForm({rootPath: "definition." + controlName + ".results.fieldsMapping[" + fieldMappingSize + "]."}));
|
||||
}
|
||||
|
||||
removeFieldMapping(baseFormGroup: any, fieldCode: string){
|
||||
if(baseFormGroup){
|
||||
const fieldMappingFormArray = (baseFormGroup.get('results').get('fieldsMapping') as FormArray);
|
||||
for (let j = 0; j < fieldMappingFormArray.length; j++) {
|
||||
if (fieldCode == fieldMappingFormArray.at(j).get('code').getRawValue()) {
|
||||
fieldMappingFormArray.removeAt(j);
|
||||
|
||||
PrefillingSourceEditorModel.reApplyDefinitionValidators({
|
||||
formGroup: this.formGroup,
|
||||
validationErrorModel: this.editorModel.validationErrorModel
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,244 @@
|
|||
import { UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
|
||||
import { PrefillingSource, PrefillingSourceDefinition, PrefillingSourceDefinitionField, PrefillingSourceDefinitionFieldPersist, PrefillingSourceDefinitionPersist, PrefillingSourcePersist } from "@app/core/model/prefilling-source/prefilling-source";
|
||||
import { ExternalFetcherBaseSourceConfigurationEditorModel, QueryCaseConfigEditorModel, QueryConfigEditorModel } from "@app/ui/external-fetcher/external-fetcher-source-editor.model";
|
||||
|
||||
import { BaseEditorModel } from "@common/base/base-form-editor-model";
|
||||
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
|
||||
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
|
||||
import { Validation, ValidationContext } from "@common/forms/validation/validation-context";
|
||||
|
||||
export class PrefillingSourceEditorModel extends BaseEditorModel implements PrefillingSourcePersist {
|
||||
label: string;
|
||||
definition: PrefillingSourceDefinitionEditorModel = new PrefillingSourceDefinitionEditorModel();
|
||||
permissions: string[];
|
||||
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor() { super(); }
|
||||
|
||||
public fromModel(item: PrefillingSource): PrefillingSourceEditorModel {
|
||||
if (item) {
|
||||
super.fromModel(item);
|
||||
this.label = item.label;
|
||||
if (item.definition) this.definition = new PrefillingSourceDefinitionEditorModel(this.validationErrorModel).fromModel(item.definition);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup {
|
||||
if (context == null) { context = this.createValidationContext(); }
|
||||
|
||||
return this.formBuilder.group({
|
||||
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
|
||||
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
||||
definition: this.definition.buildForm({
|
||||
rootPath: `definition.`,
|
||||
}),
|
||||
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
|
||||
});
|
||||
}
|
||||
|
||||
createValidationContext(): ValidationContext {
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
||||
baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
|
||||
baseValidationArray.push({ key: 'definition', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'definition')] });
|
||||
baseValidationArray.push({ key: 'hash', validators: [] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reApplyDefinitionValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
}): void {
|
||||
|
||||
const { formGroup, validationErrorModel } = params;
|
||||
const control = formGroup?.get('definition');
|
||||
PrefillingSourceDefinitionEditorModel.reapplyValidators({
|
||||
formArray: control.get('fields') as UntypedFormArray,
|
||||
rootPath: `definition.`,
|
||||
validationErrorModel: validationErrorModel
|
||||
});
|
||||
}
|
||||
|
||||
createChildField(index: number): UntypedFormGroup {
|
||||
const field: PrefillingSourceDefinitionFieldEditorModel = new PrefillingSourceDefinitionFieldEditorModel(this.validationErrorModel);
|
||||
return field.buildForm({ rootPath: 'definition.fields[' + index + '].' });
|
||||
}
|
||||
}
|
||||
|
||||
export class PrefillingSourceDefinitionEditorModel implements PrefillingSourceDefinitionPersist {
|
||||
fields: PrefillingSourceDefinitionFieldEditorModel[] = [];
|
||||
searchConfiguration: ExternalFetcherBaseSourceConfigurationEditorModel = new ExternalFetcherBaseSourceConfigurationEditorModel();
|
||||
getConfiguration: ExternalFetcherBaseSourceConfigurationEditorModel = new ExternalFetcherBaseSourceConfigurationEditorModel();
|
||||
getEnabled = false;
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
public fromModel(item: PrefillingSourceDefinition): PrefillingSourceDefinitionEditorModel {
|
||||
if (item) {
|
||||
if (item.fields) { item.fields.map(x => this.fields.push(new PrefillingSourceDefinitionFieldEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
if (item.searchConfiguration) this.searchConfiguration = new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel).fromModel(item.searchConfiguration);
|
||||
if (item.getConfiguration) {
|
||||
this.getConfiguration = new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel).fromModel(item.getConfiguration);
|
||||
this.getEnabled = true;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = PrefillingSourceDefinitionEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
fields: this.formBuilder.array(
|
||||
(this.fields ?? []).map(
|
||||
(item, index) => item.buildForm({
|
||||
rootPath: `${rootPath}fields[${index}].`
|
||||
}), context.getValidation('fields')
|
||||
)
|
||||
),
|
||||
searchConfiguration: this.searchConfiguration.buildForm({
|
||||
rootPath: `${rootPath}searchConfiguration.`
|
||||
}),
|
||||
getConfiguration: this.getConfiguration.buildForm({
|
||||
rootPath: `${rootPath}getConfiguration.`
|
||||
}),
|
||||
getEnabled: [{ value: this.getEnabled, disabled: disabled }, context.getValidation('getEnabled').validators],
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'fields', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
|
||||
baseValidationArray.push({ key: 'searchConfiguration', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}searchConfiguration`)] });
|
||||
baseValidationArray.push({ key: 'getConfiguration', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}getConfiguration`)] });
|
||||
baseValidationArray.push({ key: 'getEnabled', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}getConfiguration`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyValidators(params: {
|
||||
formArray: UntypedFormArray,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
const { validationErrorModel, rootPath, formArray } = params;
|
||||
formArray?.controls?.forEach(
|
||||
(control, index) => PrefillingSourceDefinitionFieldEditorModel.reapplyValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}fields[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class PrefillingSourceDefinitionFieldEditorModel implements PrefillingSourceDefinitionFieldPersist {
|
||||
code: string;
|
||||
systemFieldTarget: string;
|
||||
semanticTarget: string;
|
||||
trimRegex: string;
|
||||
fixedValue: string;
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
public fromModel(item: PrefillingSourceDefinitionField): PrefillingSourceDefinitionFieldEditorModel {
|
||||
if (item) {
|
||||
this.code = item.code;
|
||||
this.systemFieldTarget = item.systemFieldTarget;
|
||||
this.semanticTarget = item.semanticTarget;
|
||||
this.trimRegex = item.trimRegex;
|
||||
this.fixedValue = item.fixedValue;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = PrefillingSourceDefinitionFieldEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
|
||||
systemFieldTarget: [{ value: this.systemFieldTarget, disabled: disabled }, context.getValidation('systemFieldTarget').validators],
|
||||
semanticTarget: [{ value: this.semanticTarget, disabled: disabled }, context.getValidation('semanticTarget').validators],
|
||||
trimRegex: [{ value: this.trimRegex, disabled: disabled }, context.getValidation('trimRegex').validators],
|
||||
fixedValue: [{ value: this.fixedValue, disabled: disabled }, context.getValidation('fixedValue').validators],
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
||||
baseValidationArray.push({ key: 'systemFieldTarget', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}systemFieldTarget`)] });
|
||||
baseValidationArray.push({ key: 'semanticTarget', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}semanticTarget`)] });
|
||||
baseValidationArray.push({ key: 'trimRegex', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}trimRegex`)] });
|
||||
baseValidationArray.push({ key: 'fixedValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}clientSecret`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = PrefillingSourceDefinitionFieldEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['code', 'systemFieldTarget', 'semanticTarget', 'trimRegex', 'fixedValue'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
})
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||
import { AuthenticationConfiguration, ExternalFetcherBaseSourceConfiguration, QueryCaseConfig, QueryConfig, ResultFieldsMappingConfiguration, ResultsConfiguration } from '@app/core/model/external-fetcher/external-fetcher';
|
||||
import { PrefillingSource, PrefillingSourceDefinition, PrefillingSourceDefinitionField } from '@app/core/model/prefilling-source/prefilling-source';
|
||||
import { PrefillingSourceService } from '@app/core/services/prefilling-source/prefilling-source.service';
|
||||
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
||||
import { BaseEditorResolver } from '@common/base/base-editor.resolver';
|
||||
import { Guid } from '@common/types/guid';
|
||||
import { takeUntil, tap } from 'rxjs/operators';
|
||||
import { nameof } from 'ts-simple-nameof';
|
||||
|
||||
@Injectable()
|
||||
export class PrefillingSourceEditorResolver extends BaseEditorResolver {
|
||||
|
||||
constructor(private prefillingSourceService: PrefillingSourceService, private breadcrumbService: BreadcrumbService) {
|
||||
super();
|
||||
}
|
||||
|
||||
public static lookupFields(): string[] {
|
||||
return [
|
||||
...BaseEditorResolver.lookupFields(),
|
||||
nameof<PrefillingSource>(x => x.id),
|
||||
nameof<PrefillingSource>(x => x.label),
|
||||
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.code)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.systemFieldTarget)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.semanticTarget)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.trimRegex)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.fixedValue)].join('.'),
|
||||
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.type)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.key)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.label)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.ordinal)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.url)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.resultsArrayPath)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.code)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.responsePath)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.paginationPath)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.contentType)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.firstPage)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.httpMethod)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.requestBody)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.filterType)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.enabled)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authUrl)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authMethod)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authTokenPath)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authRequestBody)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.type)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.name)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.defaultValue)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.likePattern)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.separator)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.value)].join('.'),
|
||||
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.type)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.key)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.label)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.ordinal)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.url)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.resultsArrayPath)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.code)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.responsePath)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.paginationPath)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.contentType)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.firstPage)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.httpMethod)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.requestBody)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.filterType)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.enabled)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authUrl)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authMethod)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authTokenPath)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authRequestBody)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.type)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.name)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.defaultValue)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.likePattern)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.separator)].join('.'),
|
||||
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.value)].join('.'),
|
||||
|
||||
nameof<PrefillingSource>(x => x.createdAt),
|
||||
nameof<PrefillingSource>(x => x.updatedAt),
|
||||
nameof<PrefillingSource>(x => x.hash),
|
||||
nameof<PrefillingSource>(x => x.isActive)
|
||||
]
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
||||
|
||||
const fields = [
|
||||
...PrefillingSourceEditorResolver.lookupFields()
|
||||
];
|
||||
const id = route.paramMap.get('id');
|
||||
|
||||
if (id != null) {
|
||||
return this.prefillingSourceService.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import { Injectable } from "@angular/core";
|
||||
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
|
||||
|
||||
@Injectable()
|
||||
export class PrefillingSourceEditorService {
|
||||
private validationErrorModel: ValidationErrorModel;
|
||||
|
||||
public setValidationErrorModel(validationErrorModel: ValidationErrorModel): void {
|
||||
this.validationErrorModel = validationErrorModel;
|
||||
}
|
||||
|
||||
public getValidationErrorModel(): ValidationErrorModel {
|
||||
return this.validationErrorModel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<div class="d-flex align-items-center gap-1-rem">
|
||||
|
||||
<button mat-flat-button [matMenuTriggerFor]="filterMenu" #filterMenuTrigger="matMenuTrigger" (click)="updateFilters()" class="filter-button">
|
||||
<mat-icon aria-hidden="false" [matBadgeHidden]="!appliedFilterCount" [matBadge]="appliedFilterCount" matBadgeColor="warn" matBadgeSize="small">filter_alt</mat-icon>
|
||||
{{'COMMONS.LISTING-COMPONENT.SEARCH-FILTER-BTN' | translate}}
|
||||
</button>
|
||||
|
||||
|
||||
<mat-menu #filterMenu>
|
||||
<div class="p-3" (click)="$event?.stopPropagation?.()">
|
||||
<div class="search-listing-filters-container">
|
||||
<div class="d-flex align-items-center justify-content-between">
|
||||
<h4>{{'PREFILLING-SOURCE-LISTING.FILTER.TITLE' | translate}}</h4>
|
||||
<button color="accent" mat-button (click)="clearFilters()">
|
||||
{{'COMMONS.LISTING-COMPONENT.CLEAR-ALL-FILTERS' | translate}}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<mat-slide-toggle labelPosition="before" [(ngModel)]="internalFilters.isActive">
|
||||
{{'PREFILLING-SOURCE-LISTING.FILTER.IS-ACTIVE' | translate}}
|
||||
</mat-slide-toggle>
|
||||
|
||||
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
|
||||
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">
|
||||
{{'PREFILLING-SOURCE-LISTING.FILTER.CANCEL' | translate}}
|
||||
</button>
|
||||
<button mat-raised-button color="primary" (click)="filterMenuTrigger.closeMenu(); applyFilters();">
|
||||
{{'PREFILLING-SOURCE-LISTING.FILTER.APPLY-FILTERS' | translate}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</mat-menu>
|
||||
|
||||
<app-expandable-search-field [(value)]=internalFilters.like (valueChange)="onSearchTermChange($event)" />
|
||||
</div>
|
|
@ -0,0 +1,25 @@
|
|||
.prefilling-source-listing-filters {
|
||||
|
||||
}
|
||||
|
||||
::ng-deep.mat-mdc-menu-panel {
|
||||
max-width: 100% !important;
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
:host::ng-deep.mat-mdc-menu-content:not(:empty) {
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
|
||||
|
||||
.filter-button{
|
||||
padding-top: .6rem;
|
||||
padding-bottom: .6rem;
|
||||
// .mat-icon{
|
||||
// font-size: 1.5em;
|
||||
// width: 1.2em;
|
||||
// height: 1.2em;
|
||||
// }
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||
import { PrefillingSourceFilter } from '@app/core/query/prefilling-source.lookup';
|
||||
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
||||
import { BaseComponent } from '@common/base/base.component';
|
||||
import { nameof } from 'ts-simple-nameof';
|
||||
|
||||
@Component({
|
||||
selector: 'app-prefilling-source-listing-filters',
|
||||
templateUrl: './prefilling-source-listing-filters.component.html',
|
||||
styleUrls: ['./prefilling-source-listing-filters.component.scss']
|
||||
})
|
||||
export class PrefillingSourceListingFiltersComponent extends BaseComponent implements OnInit, OnChanges {
|
||||
|
||||
@Input() readonly filter: PrefillingSourceFilter;
|
||||
@Output() filterChange = new EventEmitter<PrefillingSourceFilter>();
|
||||
|
||||
// * State
|
||||
internalFilters: PrefillingSourceListingFilters = this._getEmptyFilters();
|
||||
|
||||
protected appliedFilterCount: number = 0;
|
||||
constructor(
|
||||
public enumUtils: EnumUtils,
|
||||
) { super(); }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
const filterChange = changes[nameof<PrefillingSourceListingFiltersComponent>(x => x.filter)]?.currentValue as PrefillingSourceFilter;
|
||||
if (filterChange) {
|
||||
this.updateFilters()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onSearchTermChange(searchTerm: string): void {
|
||||
this.applyFilters()
|
||||
}
|
||||
|
||||
|
||||
protected updateFilters(): void {
|
||||
this.internalFilters = this._parseToInternalFilters(this.filter);
|
||||
this.appliedFilterCount = this._computeAppliedFilters(this.internalFilters);
|
||||
}
|
||||
|
||||
protected applyFilters(): void {
|
||||
const { isActive, like } = this.internalFilters ?? {}
|
||||
this.filterChange.emit({
|
||||
...this.filter,
|
||||
like,
|
||||
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
private _parseToInternalFilters(inputFilter: PrefillingSourceFilter): PrefillingSourceListingFilters {
|
||||
if (!inputFilter) {
|
||||
return this._getEmptyFilters();
|
||||
}
|
||||
|
||||
let { excludedIds, ids, isActive, like } = inputFilter;
|
||||
|
||||
return {
|
||||
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
|
||||
like: like
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private _getEmptyFilters(): PrefillingSourceListingFilters {
|
||||
return {
|
||||
isActive: true,
|
||||
like: null,
|
||||
}
|
||||
}
|
||||
|
||||
private _computeAppliedFilters(filters: PrefillingSourceListingFilters): number {
|
||||
let count = 0;
|
||||
if (filters?.isActive) {
|
||||
count++
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
clearFilters() {
|
||||
this.internalFilters = this._getEmptyFilters();
|
||||
}
|
||||
}
|
||||
|
||||
interface PrefillingSourceListingFilters {
|
||||
isActive: boolean;
|
||||
like: string;
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
<div class="row prefilling-source-listing">
|
||||
<div class="col-md-8 offset-md-2">
|
||||
|
||||
<div class="row mb-4 mt-3">
|
||||
<div class="col">
|
||||
<h4>{{'PREFILLING-SOURCE-LISTING.TITLE' | translate}}</h4>
|
||||
<app-navigation-breadcrumb />
|
||||
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button mat-raised-button class="create-btn"
|
||||
*ngIf="authService.hasPermission(authService.permissionEnum.EditPrefillingSource)"
|
||||
[routerLink]="['/prefilling-sources/new']">
|
||||
<mat-icon>add</mat-icon>
|
||||
{{'PREFILLING-SOURCE-LISTING.CREATE' | translate}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<app-hybrid-listing [rows]="gridRows" [columns]="gridColumns" [visibleColumns]="visibleColumns"
|
||||
[count]="totalElements" [offset]="currentPageNumber" [limit]="lookup.page.size"
|
||||
[defaultSort]="lookup.order?.items" [externalSorting]="true" (rowActivated)="onRowActivated($event)"
|
||||
(pageLoad)="alterPage($event)" (columnSort)="onColumnSort($event)"
|
||||
(columnsChanged)="onColumnsChanged($event)" [listItemTemplate]="listItemTemplate">
|
||||
|
||||
<app-prefilling-source-listing-filters hybrid-listing-filters [(filter)]="lookup"
|
||||
(filterChange)="filterChanged($event)" />
|
||||
|
||||
<app-user-settings-picker [key]="userSettingsKey" [userPreference]="lookup"
|
||||
(onSettingSelected)="changeSetting($event)" [autoSelectUserSettings]="autoSelectUserSettings"
|
||||
user-preference-settings />
|
||||
</app-hybrid-listing>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ng-template #listItemTemplate let-item="item" let-isColumnSelected="isColumnSelected">
|
||||
|
||||
|
||||
<div class="d-flex align-items-center p-3 gap-1-rem">
|
||||
<div class="row">
|
||||
<ng-container *ngIf="isColumnSelected('name')">
|
||||
<a class="buttonLinkClass" [routerLink]="'./' + item?.id" class="col-12"
|
||||
(click)="$event.stopPropagation()">{{item?.name | nullifyValue}}</a>
|
||||
<br />
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="isColumnSelected('label')">
|
||||
<span class="col-12">
|
||||
{{'PREFILLING-SOURCE-LISTING.FIELDS.CODE' | translate}}:
|
||||
<small>
|
||||
{{item?.code | nullifyValue}}
|
||||
</small>
|
||||
</span>
|
||||
<br>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="isColumnSelected('createdAt')">
|
||||
<span class="col-12">
|
||||
{{'PREFILLING-SOURCE-LISTING.FIELDS.CREATED-AT' | translate}}:
|
||||
<small>
|
||||
{{item?.createdAt | dateTimeFormatter : 'short' | nullifyValue}}
|
||||
</small>
|
||||
</span>
|
||||
<br>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="isColumnSelected('updatedAt')">
|
||||
<span class="col-12">
|
||||
{{'PREFILLING-SOURCE-LISTING.FIELDS.UPDATED-AT' | translate}}:
|
||||
<small>
|
||||
{{item?.updatedAt | dateTimeFormatter : 'short' | nullifyValue}}
|
||||
</small>
|
||||
</span>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #actions let-row="row" let-item>
|
||||
<div class="row" (click)="$event.stopPropagation()">
|
||||
<div class="col-auto">
|
||||
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
|
||||
<mat-icon>more_horiz</mat-icon>
|
||||
</button>
|
||||
<mat-menu #actionsMenu="matMenu">
|
||||
<button mat-menu-item [routerLink]="['/prefilling-sources/' + row.id]">
|
||||
<mat-icon>edit</mat-icon>{{'PREFILLING-SOURCE-LISTING.ACTIONS.EDIT' | translate}}
|
||||
</button>
|
||||
<button mat-menu-item (click)="deleteType(row.id)">
|
||||
<mat-icon>delete</mat-icon>
|
||||
{{'PREFILLING-SOURCE-LISTING.ACTIONS.DELETE' | translate}}
|
||||
</button>
|
||||
</mat-menu>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
|
@ -0,0 +1,83 @@
|
|||
.mat-table {
|
||||
margin-top: 47px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.prefilling-source-listing {
|
||||
margin-top: 1.3rem;
|
||||
margin-left: 1rem;
|
||||
margin-right: 2rem;
|
||||
|
||||
.mat-header-row {
|
||||
background: #f3f5f8;
|
||||
}
|
||||
|
||||
.mat-card {
|
||||
margin: 16px 0;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.mat-row {
|
||||
cursor: pointer;
|
||||
min-height: 4.5em;
|
||||
}
|
||||
|
||||
mat-row:hover {
|
||||
background-color: #eef5f6;
|
||||
}
|
||||
|
||||
.mat-fab-bottom-right {
|
||||
float: right;
|
||||
z-index: 5;
|
||||
}
|
||||
}
|
||||
|
||||
// PAGINATOR
|
||||
:host ::ng-deep .mat-paginator-container {
|
||||
flex-direction: row-reverse !important;
|
||||
justify-content: space-between !important;
|
||||
background-color: #f6f6f6;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.create-btn {
|
||||
border-radius: 30px;
|
||||
background-color: var(--secondary-color);
|
||||
padding-left: 2em;
|
||||
padding-right: 2em;
|
||||
// color: #000;
|
||||
|
||||
.button-text {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
.import-btn {
|
||||
background: #ffffff 0% 0% no-repeat padding-box;
|
||||
border-radius: 30px;
|
||||
// color: var(--primary-color);
|
||||
// border: 1px solid var(--primary-color);
|
||||
padding-left: 2em;
|
||||
padding-right: 2em;
|
||||
color: #000;
|
||||
border: 1px solid #000;
|
||||
}
|
||||
|
||||
.status-chip {
|
||||
|
||||
border-radius: 20px;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
padding-top: 0.2em;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
.status-chip-finalized {
|
||||
color: #568b5a;
|
||||
background: #9dd1a1 0% 0% no-repeat padding-box;
|
||||
}
|
||||
|
||||
.status-chip-draft {
|
||||
color: #00c4ff;
|
||||
background: #d3f5ff 0% 0% no-repeat padding-box;
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||
import { PrefillingSource } from '@app/core/model/prefilling-source/prefilling-source';
|
||||
import { PrefillingSourceLookup } from '@app/core/query/prefilling-source.lookup';
|
||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||
import { PrefillingSourceService } from '@app/core/services/prefilling-source/prefilling-source.service';
|
||||
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
||||
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
||||
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
|
||||
import { BaseListingComponent } from '@common/base/base-listing-component';
|
||||
import { PipeService } from '@common/formatting/pipe.service';
|
||||
import { DataTableDateTimeFormatPipe } from '@common/formatting/pipes/date-time-format.pipe';
|
||||
import { QueryResult } from '@common/model/query-result';
|
||||
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
||||
import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service';
|
||||
import { ColumnDefinition, ColumnsChangedEvent, HybridListingComponent, PageLoadEvent } from '@common/modules/hybrid-listing/hybrid-listing.component';
|
||||
import { Guid } from '@common/types/guid';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { nameof } from 'ts-simple-nameof';
|
||||
import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
|
||||
|
||||
@Component({
|
||||
templateUrl: './prefilling-source-listing.component.html',
|
||||
styleUrls: ['./prefilling-source-listing.component.scss']
|
||||
})
|
||||
export class PrefillingSourceListingComponent extends BaseListingComponent<PrefillingSource, PrefillingSourceLookup> implements OnInit {
|
||||
publish = false;
|
||||
userSettingsKey = { key: 'PrefillingSourceListingUserSettings' };
|
||||
propertiesAvailableForOrder: ColumnDefinition[];
|
||||
|
||||
// @ViewChild('PrefillingSourceStatus', { static: true }) PrefillingSourceStatus?: TemplateRef<any>;
|
||||
@ViewChild('actions', { static: true }) actions?: TemplateRef<any>;
|
||||
@ViewChild(HybridListingComponent, { static: true }) hybridListingComponent: HybridListingComponent;
|
||||
|
||||
private readonly lookupFields: string[] = [
|
||||
nameof<PrefillingSource>(x => x.id),
|
||||
nameof<PrefillingSource>(x => x.label),
|
||||
nameof<PrefillingSource>(x => x.updatedAt),
|
||||
nameof<PrefillingSource>(x => x.createdAt),
|
||||
nameof<PrefillingSource>(x => x.hash),
|
||||
nameof<PrefillingSource>(x => x.isActive)
|
||||
];
|
||||
|
||||
rowIdentity = x => x.id;
|
||||
|
||||
constructor(
|
||||
protected router: Router,
|
||||
protected route: ActivatedRoute,
|
||||
protected uiNotificationService: UiNotificationService,
|
||||
protected httpErrorHandlingService: HttpErrorHandlingService,
|
||||
protected queryParamsService: QueryParamsService,
|
||||
private PrefillingSourceService: PrefillingSourceService,
|
||||
public authService: AuthService,
|
||||
private pipeService: PipeService,
|
||||
public enumUtils: EnumUtils,
|
||||
private language: TranslateService,
|
||||
private dialog: MatDialog
|
||||
) {
|
||||
super(router, route, uiNotificationService, httpErrorHandlingService, queryParamsService);
|
||||
// Lookup setup
|
||||
// Default lookup values are defined in the user settings class.
|
||||
this.lookup = this.initializeLookup();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
}
|
||||
|
||||
protected initializeLookup(): PrefillingSourceLookup {
|
||||
const lookup = new PrefillingSourceLookup();
|
||||
lookup.metadata = { countAll: true };
|
||||
lookup.page = { offset: 0, size: this.ITEMS_PER_PAGE };
|
||||
lookup.isActive = [IsActive.Active];
|
||||
lookup.order = { items: [this.toDescSortField(nameof<PrefillingSource>(x => x.createdAt))] };
|
||||
this.updateOrderUiFields(lookup.order);
|
||||
|
||||
lookup.project = {
|
||||
fields: this.lookupFields
|
||||
};
|
||||
|
||||
return lookup;
|
||||
}
|
||||
|
||||
protected setupColumns() {
|
||||
this.gridColumns.push(...[{
|
||||
prop: nameof<PrefillingSource>(x => x.label),
|
||||
sortable: true,
|
||||
languageName: 'PREFILLING-SOURCE-LISTING.FIELDS.LABEL'
|
||||
},
|
||||
{
|
||||
prop: nameof<PrefillingSource>(x => x.createdAt),
|
||||
sortable: true,
|
||||
languageName: 'PREFILLING-SOURCE-LISTING.FIELDS.CREATED-AT',
|
||||
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
|
||||
},
|
||||
{
|
||||
prop: nameof<PrefillingSource>(x => x.updatedAt),
|
||||
sortable: true,
|
||||
languageName: 'PREFILLING-SOURCE-LISTING.FIELDS.UPDATED-AT',
|
||||
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
|
||||
},
|
||||
{
|
||||
prop: nameof<PrefillingSource>(x => x.isActive),
|
||||
sortable: true,
|
||||
languageName: 'PREFILLING-SOURCE-LISTING.FIELDS.IS-ACTIVE',
|
||||
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
|
||||
},
|
||||
{
|
||||
alwaysShown: true,
|
||||
cellTemplate: this.actions,
|
||||
maxWidth: 120
|
||||
}
|
||||
]);
|
||||
this.propertiesAvailableForOrder = this.gridColumns.filter(x => x.sortable);
|
||||
}
|
||||
|
||||
//
|
||||
// Listing Component functions
|
||||
//
|
||||
onColumnsChanged(event: ColumnsChangedEvent) {
|
||||
super.onColumnsChanged(event);
|
||||
this.onColumnsChangedInternal(event.properties.map(x => x.toString()));
|
||||
}
|
||||
|
||||
private onColumnsChangedInternal(columns: string[]) {
|
||||
// Here are defined the projection fields that always requested from the api.
|
||||
const fields = new Set(this.lookupFields);
|
||||
this.gridColumns.map(x => x.prop)
|
||||
.filter(x => !columns?.includes(x as string))
|
||||
.forEach(item => {
|
||||
fields.delete(item as string)
|
||||
});
|
||||
this.lookup.project = { fields: [...fields] };
|
||||
this.onPageLoad({ offset: 0 } as PageLoadEvent);
|
||||
}
|
||||
|
||||
protected loadListing(): Observable<QueryResult<PrefillingSource>> {
|
||||
return this.PrefillingSourceService.query(this.lookup);
|
||||
}
|
||||
|
||||
public deleteType(id: Guid) {
|
||||
if (id) {
|
||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
data: {
|
||||
isDeleteConfirmation: true,
|
||||
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
|
||||
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
||||
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL')
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
if (result) {
|
||||
this.PrefillingSourceService.delete(id).pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onCallbackSuccess(): void {
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success);
|
||||
this.refresh();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||
import { NgModule } from "@angular/core";
|
||||
import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module";
|
||||
import { CommonFormattingModule } from '@common/formatting/common-formatting.module';
|
||||
import { CommonFormsModule } from '@common/forms/common-forms.module';
|
||||
import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module';
|
||||
import { HybridListingModule } from "@common/modules/hybrid-listing/hybrid-listing.module";
|
||||
import { TextFilterModule } from "@common/modules/text-filter/text-filter.module";
|
||||
import { UserSettingsModule } from "@common/modules/user-settings/user-settings.module";
|
||||
import { CommonUiModule } from '@common/ui/common-ui.module';
|
||||
import { NgxDropzoneModule } from "ngx-dropzone";
|
||||
import { PrefillingSourceRoutingModule } from './prefilling-source.routing';
|
||||
import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-editor.module';
|
||||
import { PrefillingSourceListingComponent } from './listing/prefilling-source-listing.component';
|
||||
import { PrefillingSourceListingFiltersComponent } from './listing/filters/prefilling-source-listing-filters.component';
|
||||
import { PrefillingSourceEditorComponent } from './editor/prefilling-source-editor.component';
|
||||
import { ExternalFetcherSourceModule } from '@app/ui/external-fetcher/external-fetcher-source.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonUiModule,
|
||||
CommonFormsModule,
|
||||
ConfirmationDialogModule,
|
||||
PrefillingSourceRoutingModule,
|
||||
NgxDropzoneModule,
|
||||
DragDropModule,
|
||||
AutoCompleteModule,
|
||||
HybridListingModule,
|
||||
TextFilterModule,
|
||||
UserSettingsModule,
|
||||
CommonFormattingModule,
|
||||
RichTextEditorModule,
|
||||
ExternalFetcherSourceModule
|
||||
],
|
||||
declarations: [
|
||||
PrefillingSourceEditorComponent,
|
||||
PrefillingSourceListingComponent,
|
||||
PrefillingSourceListingFiltersComponent ]
|
||||
})
|
||||
export class PrefillingSourceModule { }
|
|
@ -0,0 +1,58 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { AdminAuthGuard } from '@app/core/admin-auth-guard.service';
|
||||
import { PrefillingSourceEditorComponent } from './editor/prefilling-source-editor.component';
|
||||
import { PrefillingSourceListingComponent } from './listing/prefilling-source-listing.component';
|
||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||
import { AuthGuard } from '@app/core/auth-guard.service';
|
||||
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
||||
import { PendingChangesGuard } from '@common/forms/pending-form-changes/pending-form-changes-guard.service';
|
||||
import { PrefillingSourceEditorResolver } from './editor/prefilling-source-editor.resolver';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: PrefillingSourceListingComponent,
|
||||
canActivate: [AuthGuard]
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
canActivate: [AuthGuard],
|
||||
component: PrefillingSourceEditorComponent,
|
||||
canDeactivate: [PendingChangesGuard],
|
||||
data: {
|
||||
authContext: {
|
||||
permissions: [AppPermission.EditPrefillingSource]
|
||||
},
|
||||
...BreadcrumbService.generateRouteDataConfiguration({
|
||||
title: 'BREADCRUMBS.NEW-PREFILLING-SOURCE'
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
canActivate: [AuthGuard],
|
||||
component: PrefillingSourceEditorComponent,
|
||||
canDeactivate: [PendingChangesGuard],
|
||||
resolve: {
|
||||
'entity': PrefillingSourceEditorResolver
|
||||
},
|
||||
data: {
|
||||
...BreadcrumbService.generateRouteDataConfiguration({
|
||||
title: 'BREADCRUMBS.EDIT-PREFILLING-SOURCE'
|
||||
}),
|
||||
authContext: {
|
||||
permissions: [AppPermission.EditPrefillingSource]
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
{ path: '**', loadChildren: () => import('@common/modules/page-not-found/page-not-found.module').then(m => m.PageNotFoundModule) },
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: [PrefillingSourceEditorResolver]
|
||||
})
|
||||
export class PrefillingSourceRoutingModule { }
|
|
@ -123,7 +123,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<button mat-button class="action-btn" *ngIf="formGroup.get('definition').get('fields').value != ''"
|
||||
type="button" (click)="submitFields()" [disabled]="!formGroup.get('definition').get('fields').valid">Submit</button>
|
||||
type="button" (click)="submitFields()" [disabled]="!formGroup.get('definition').get('fields').valid">{{'REFERENCE-TYPE-EDITOR.ACTIONS.SUBMIT-FIELDS' | translate}}</button>
|
||||
</div>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
|
@ -153,7 +153,15 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" >
|
||||
<app-external-fetcher-source-component
|
||||
[formGroup]="source"
|
||||
[validationErrorModel]="editorModel.validationErrorModel"
|
||||
[validationRootPath]="'definition.sources[' + sourceIndex + '].'"
|
||||
[referenceTypeSourceIndex]="sourceIndex"
|
||||
[referenceTypes]="referenceTypes"
|
||||
[sourceKeysMap]="sourceKeysMap">
|
||||
</app-external-fetcher-source-component>
|
||||
<!-- <div class="row" >
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
|
||||
|
@ -181,8 +189,11 @@
|
|||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DEPENDENCIES' | translate}}</mat-label>
|
||||
<app-multiple-auto-complete [formControl]="source.get('referenceTypeDependencyIds')" [configuration]="referenceTypeService.multipleAutocompleteConfiguration"></app-multiple-auto-complete>
|
||||
<mat-error *ngIf="source.get('referenceTypeDependencyIds').hasError('backendError')">{{source.get('referenceTypeDependencyIds').getError('backendError').message}}</mat-error>
|
||||
<mat-select multiple (selectionChange)="setReferenceTypeDependenciesMap($event.value, sourceIndex)" [formControl]="source.get('referenceTypeDependencyIds')">
|
||||
<mat-option *ngFor="let referenceType of referenceTypes" [value]="referenceType.id">{{referenceType.name}}</mat-option>
|
||||
</mat-select> -->
|
||||
<!-- <app-multiple-auto-complete [formControl]="source.get('referenceTypeDependencyIds')" [configuration]="referenceTypeService.multipleAutocompleteConfiguration"></app-multiple-auto-complete> -->
|
||||
<!-- <mat-error *ngIf="source.get('referenceTypeDependencyIds').hasError('backendError')">{{source.get('referenceTypeDependencyIds').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="source.get('referenceTypeDependencyIds').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
@ -260,7 +271,7 @@
|
|||
<mat-error *ngIf="source.get('filterType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<!-- Results info -->
|
||||
Results info
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.RESULTS' | translate}}</h3>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
|
@ -270,7 +281,7 @@
|
|||
<mat-error *ngIf="source.get('results').get('resultsArrayPath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<!-- fields mapping -->
|
||||
fields mapping
|
||||
<div class="col-12">
|
||||
<div *ngFor="let field of source.get('results').get('fieldsMapping').controls; let fieldMappingIndex=index;" class="row mb-3">
|
||||
<div class="col-12">
|
||||
|
@ -304,7 +315,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Auth info -->
|
||||
Auth info
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.AUTHENTICATION' | translate}}
|
||||
<mat-checkbox [formControl]="source.get('auth').get('enabled')"></mat-checkbox>
|
||||
</h3>
|
||||
|
@ -354,7 +365,7 @@
|
|||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Queries info -->
|
||||
Queries info
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERIES' | translate}}
|
||||
<button mat-button type="button" class="action-btn" (click)="addQuery(sourceIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-QUERY' | translate}}</button>
|
||||
</h3>
|
||||
|
@ -397,7 +408,7 @@
|
|||
</div>
|
||||
</mat-card-content>
|
||||
</div>
|
||||
<!-- Query Cases -->
|
||||
Query Cases
|
||||
<div *ngFor="let case of query.get('cases').controls; let caseIndex=index;" class="row mb-3">
|
||||
<div class="col-12">
|
||||
<mat-card-header>
|
||||
|
@ -438,15 +449,16 @@
|
|||
<mat-error *ngIf="case.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="col-6" *ngIf="source.get('referenceTypeDependencyIds').value">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}</mat-label>
|
||||
<mat-select (selectionChange)="selectedReferenceTypeChanged($event.value)" name="referenceTypeId" [formControl]="case.get('referenceTypeId')">
|
||||
<mat-option *ngFor="let referenceType of referenceTypes" [value]="referenceType.id">
|
||||
<mat-select name="referenceTypeId" [formControl]="case.get('referenceTypeId')">
|
||||
<mat-option *ngFor="let referenceType of referenceTypeDependenciesMap.get(sourceIndex)" [value]="referenceType.id">
|
||||
{{referenceType.code}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="case.get('referenceTypeId').hasError('backendError')">{{case.get('referenceTypeId').getError('backendError').message}}</mat-error>
|
||||
</mat-select> -->
|
||||
<!-- <app-single-auto-complete [formControl]="case.get('referenceTypeId')" [configuration]="selectedDepedencies(sourceIndex)"></app-single-auto-complete> -->
|
||||
<!-- <mat-error *ngIf="case.get('referenceTypeId').hasError('backendError')">{{case.get('referenceTypeId').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="case.get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
@ -469,7 +481,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Options -->
|
||||
Options
|
||||
<div class="row" *ngIf="source.get('type').value == referenceTypeSourceType.STATIC">
|
||||
<div class="col-12">
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.OPTIONS' | translate}}</h3>
|
||||
|
@ -506,7 +518,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</mat-card-content>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -514,7 +526,6 @@
|
|||
<mat-error *ngIf="formGroup.get('definition').get('sources').hasError('backendError')">{{formGroup.get('definition').get('sources').getError('backendError').message}}</mat-error>
|
||||
</div>
|
||||
</form>
|
||||
{{formGroup.value | json}}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import { DatePipe } from '@angular/common';
|
|||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||
import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type';
|
||||
import { ReferenceTypeExternalApiHTTPMethodType } from '@app/core/common/enum/reference-type-external-api-http-method-type';
|
||||
import { ReferenceTypeSourceType } from '@app/core/common/enum/reference-type-source-type';
|
||||
import { ExternalFetcherApiHTTPMethodType } from '@app/core/common/enum/external-fetcher-api-http-method-type';
|
||||
import { ExternalFetcherSourceType } from '@app/core/common/enum/external-fetcher-source-type';
|
||||
import { ReferenceType, ReferenceTypeDefinition, ReferenceTypePersist } from '@app/core/model/reference-type/reference-type';
|
||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||
import { LoggingService } from '@app/core/services/logging/logging-service';
|
||||
|
@ -42,11 +42,11 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
isDeleted = false;
|
||||
formGroup: UntypedFormGroup = null;
|
||||
showInactiveDetails = false;
|
||||
referenceTypeSourceType = ReferenceTypeSourceType;
|
||||
referenceTypeExternalApiHTTPMethodType = ReferenceTypeExternalApiHTTPMethodType;
|
||||
public referenceTypeSourceTypeEnum = this.enumUtils.getEnumValues<ReferenceTypeSourceType>(ReferenceTypeSourceType);
|
||||
referenceTypeSourceType = ExternalFetcherSourceType;
|
||||
referenceTypeExternalApiHTTPMethodType = ExternalFetcherApiHTTPMethodType;
|
||||
public referenceTypeSourceTypeEnum = this.enumUtils.getEnumValues<ExternalFetcherSourceType>(ExternalFetcherSourceType);
|
||||
public referenceFieldDataTypeEnum = this.enumUtils.getEnumValues<ReferenceFieldDataType>(ReferenceFieldDataType);
|
||||
public referenceTypeExternalApiHTTPMethodTypeEnum = this.enumUtils.getEnumValues<ReferenceTypeExternalApiHTTPMethodType>(ReferenceTypeExternalApiHTTPMethodType);
|
||||
public referenceTypeExternalApiHTTPMethodTypeEnum = this.enumUtils.getEnumValues<ExternalFetcherApiHTTPMethodType>(ExternalFetcherApiHTTPMethodType);
|
||||
referenceTypes: ReferenceType[] = null;
|
||||
sourceKeysMap: Map<Guid, string[]> = new Map<Guid, string[]>();
|
||||
|
||||
|
@ -111,14 +111,6 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
|
||||
this.getReferenceTypes(this.editorModel.id);
|
||||
|
||||
if (data) {
|
||||
data.definition.sources?.forEach(source => source.queries?.forEach(query => {
|
||||
query?.cases?.forEach(queryCase => {
|
||||
if(queryCase.referenceType && queryCase.referenceType.id) this.selectedReferenceTypeChanged(queryCase.referenceType.id);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
||||
this.buildForm();
|
||||
} catch (error) {
|
||||
|
@ -163,9 +155,9 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
|
||||
formSubmit(): void {
|
||||
this.formService.touchAllFormFields(this.formGroup);
|
||||
if (!this.isFormValid()) {
|
||||
return;
|
||||
}
|
||||
// if (!this.isFormValid()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
this.persistEntity();
|
||||
}
|
||||
|
@ -330,49 +322,6 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// queries
|
||||
//
|
||||
//
|
||||
addQuery(sourceIndex: number): void {
|
||||
const queryArray= ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray);
|
||||
queryArray.push(this.editorModel.createQuery(sourceIndex, queryArray.length));
|
||||
|
||||
}
|
||||
|
||||
removeQuery(sourceIndex: number, queryIndex: number): void {
|
||||
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray);
|
||||
formArray.removeAt(queryIndex);
|
||||
ReferenceTypeEditorModel.reApplyDefinitionSourcesValidators(
|
||||
{
|
||||
formGroup: this.formGroup,
|
||||
validationErrorModel: this.editorModel.validationErrorModel
|
||||
}
|
||||
);
|
||||
formArray.markAsDirty();
|
||||
}
|
||||
|
||||
// cases
|
||||
|
||||
addCase(sourceIndex: number, queryIndex: number): void {
|
||||
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray).at(queryIndex).get('cases') as FormArray;
|
||||
formArray.push(this.editorModel.createCase(sourceIndex, queryIndex, formArray.length));
|
||||
}
|
||||
|
||||
removeCase(sourceIndex: number, queryIndex: number, index: number): void {
|
||||
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray).at(queryIndex).get('cases') as FormArray;
|
||||
formArray.removeAt(index);
|
||||
|
||||
ReferenceTypeEditorModel.reApplyDefinitionSourcesValidators(
|
||||
{
|
||||
formGroup: this.formGroup,
|
||||
validationErrorModel: this.editorModel.validationErrorModel
|
||||
}
|
||||
);
|
||||
formArray.markAsDirty();
|
||||
}
|
||||
|
||||
// Options
|
||||
|
||||
addOption(sourceIndex: number, code: string): void {
|
||||
|
@ -404,6 +353,7 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
}
|
||||
|
||||
private getReferenceTypes(excludedId?: Guid): void {
|
||||
let sourceKeys: string[] = [];
|
||||
|
||||
const lookup = ReferenceTypeService.DefaultReferenceTypeLookup();
|
||||
if (excludedId) lookup.excludedIds = [excludedId];
|
||||
|
@ -413,7 +363,8 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
.subscribe(response => {
|
||||
this.referenceTypes = response.items as ReferenceType[];
|
||||
this.referenceTypes.forEach(referenceType => {
|
||||
this.sourceKeysMap.set(referenceType.id, []);
|
||||
sourceKeys = referenceType.definition.sources.map(x => x.key);
|
||||
this.sourceKeysMap.set(referenceType.id, sourceKeys);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import { FormArray, UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
|
||||
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type";
|
||||
import { ReferenceTypeExternalApiHTTPMethodType } from "@app/core/common/enum/reference-type-external-api-http-method-type";
|
||||
import { ReferenceTypeSourceType } from "@app/core/common/enum/reference-type-source-type";
|
||||
import { AuthenticationConfiguration, AuthenticationConfigurationPersist, QueryCaseConfig, QueryCaseConfigPersist, QueryConfig, QueryConfigPersist, ReferenceType, ReferenceTypeDefinition, ReferenceTypeDefinitionPersist, ReferenceTypeField, ReferenceTypeFieldPersist, ReferenceTypePersist, ReferenceTypeSourceBaseConfiguration, ReferenceTypeSourceBaseConfigurationPersist, ReferenceTypeStaticOption, ReferenceTypeStaticOptionPersist, ResultFieldsMappingConfiguration, ResultFieldsMappingConfigurationPersist, ResultsConfiguration, ResultsConfigurationPersist } from "@app/core/model/reference-type/reference-type";
|
||||
import { ReferenceType, ReferenceTypeDefinition, ReferenceTypeDefinitionPersist, ReferenceTypeField, ReferenceTypeFieldPersist, ReferenceTypePersist } from "@app/core/model/reference-type/reference-type";
|
||||
import { BaseEditorModel } from "@common/base/base-form-editor-model";
|
||||
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
|
||||
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
|
||||
import { Validation, ValidationContext } from "@common/forms/validation/validation-context";
|
||||
import { Guid } from "@common/types/guid";
|
||||
import { ExternalFetcherBaseSourceConfigurationEditorModel, QueryCaseConfigEditorModel, QueryConfigEditorModel, ResultFieldsMappingConfigurationEditorModel, StaticOptionEditorModel } from "@app/ui/external-fetcher/external-fetcher-source-editor.model";
|
||||
|
||||
export class ReferenceTypeEditorModel extends BaseEditorModel implements ReferenceTypePersist {
|
||||
name: string;
|
||||
|
@ -66,7 +64,7 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
|
|||
}
|
||||
|
||||
createChildSource(index: number): UntypedFormGroup {
|
||||
const source: ReferenceTypeSourceBaseConfigurationEditorModel = new ReferenceTypeSourceBaseConfigurationEditorModel(this.validationErrorModel);
|
||||
const source: ExternalFetcherBaseSourceConfigurationEditorModel = new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel);
|
||||
return source.buildForm({ rootPath: 'definition.sources[' + index + '].' });
|
||||
}
|
||||
|
||||
|
@ -76,7 +74,7 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
|
|||
}
|
||||
|
||||
createOptions(sourceIndex: number, index: number): UntypedFormGroup {
|
||||
const fieldMapping: ReferenceTypeStaticOptionEditorModel = new ReferenceTypeStaticOptionEditorModel(this.validationErrorModel);
|
||||
const fieldMapping: StaticOptionEditorModel = new StaticOptionEditorModel(this.validationErrorModel);
|
||||
return fieldMapping.buildForm({ rootPath: 'definition.sources[' + sourceIndex + '].options[' + index + '].'});
|
||||
}
|
||||
|
||||
|
@ -121,7 +119,7 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
|
|||
|
||||
export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefinitionPersist {
|
||||
fields: ReferenceTypeFieldEditorModel[] = [];
|
||||
sources: ReferenceTypeSourceBaseConfigurationEditorModel[] = [];
|
||||
sources: ExternalFetcherBaseSourceConfigurationEditorModel[] = [];
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
|
@ -132,7 +130,7 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
|
|||
public fromModel(item: ReferenceTypeDefinition): ReferenceTypeDefinitionEditorModel {
|
||||
if (item) {
|
||||
if (item.fields) { item.fields.map(x => this.fields.push(new ReferenceTypeFieldEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
if (item.sources) { item.sources.map(x => this.sources.push(new ReferenceTypeSourceBaseConfigurationEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
if (item.sources) { item.sources.map(x => this.sources.push(new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -207,7 +205,7 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
|
|||
}): void {
|
||||
const { validationErrorModel, rootPath, formArray } = params;
|
||||
formArray?.controls?.forEach(
|
||||
(control, index) => ReferenceTypeSourceBaseConfigurationEditorModel.reapplyValidators({
|
||||
(control, index) => ExternalFetcherBaseSourceConfigurationEditorModel.reapplyValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}sources[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
|
@ -296,693 +294,3 @@ export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class ReferenceTypeSourceBaseConfigurationEditorModel implements ReferenceTypeSourceBaseConfigurationPersist {
|
||||
type: ReferenceTypeSourceType;
|
||||
key: string;
|
||||
label: string;
|
||||
ordinal: number;
|
||||
|
||||
url: string;
|
||||
results: ResultsConfigurationEditorModel = new ResultsConfigurationEditorModel(this.validationErrorModel);
|
||||
paginationPath: string;
|
||||
contentType: string;
|
||||
firstPage: string;
|
||||
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
requestBody?: string;
|
||||
filterType?: string;
|
||||
auth: AuthenticationConfigurationEditorModel = new AuthenticationConfigurationEditorModel(this.validationErrorModel);
|
||||
queries?: QueryConfigEditorModel[] = [];
|
||||
|
||||
options: ReferenceTypeStaticOptionEditorModel[] = [];
|
||||
|
||||
referenceTypeDependencyIds: Guid[] = [];
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
public fromModel(item: ReferenceTypeSourceBaseConfiguration): ReferenceTypeSourceBaseConfigurationEditorModel {
|
||||
if (item) {
|
||||
this.type = item.type;
|
||||
this.key = item.key;
|
||||
this.label = item.label;
|
||||
this.ordinal = item.ordinal;
|
||||
|
||||
if (item.url) this.url = item.url;
|
||||
if (item.results) this.results = new ResultsConfigurationEditorModel(this.validationErrorModel).fromModel(item.results);
|
||||
if (item.paginationPath) this.paginationPath = item.paginationPath;
|
||||
if (item.contentType) this.contentType = item.contentType;
|
||||
if (item.firstPage) this.firstPage = item.firstPage;
|
||||
if (item.httpMethod != null) this.httpMethod = item.httpMethod;
|
||||
if (item.requestBody) this.requestBody = item.requestBody;
|
||||
if (item.filterType) this.filterType = item.filterType;
|
||||
if (item.auth) this.auth = new AuthenticationConfigurationEditorModel(this.validationErrorModel).fromModel(item.auth);
|
||||
if (item.queries) { item.queries.map(x => this.queries.push(new QueryConfigEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
|
||||
if (item.options) {
|
||||
item.options.map(x => this.options.push(new ReferenceTypeStaticOptionEditorModel(this.validationErrorModel).fromModel(x)));
|
||||
} else {
|
||||
this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'reference_id', value: undefined }));
|
||||
this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'label', value: undefined }));
|
||||
this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'description', value: undefined }));
|
||||
}
|
||||
|
||||
if (item.referenceTypeDependencies) { item.referenceTypeDependencies.forEach(referenceType => this.referenceTypeDependencyIds.push(referenceType.id))}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = ReferenceTypeSourceBaseConfigurationEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators],
|
||||
key: [{ value: this.key, disabled: disabled }, context.getValidation('key').validators],
|
||||
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
||||
ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators],
|
||||
|
||||
url: [{ value: this.url, disabled: disabled }, context.getValidation('url').validators],
|
||||
results: this.results.buildForm({
|
||||
rootPath: `${rootPath}results.`,
|
||||
}),
|
||||
paginationPath: [{ value: this.paginationPath, disabled: disabled }, context.getValidation('paginationPath').validators],
|
||||
contentType: [{ value: this.contentType, disabled: disabled }, context.getValidation('contentType').validators],
|
||||
firstPage: [{ value: this.firstPage, disabled: disabled }, context.getValidation('firstPage').validators],
|
||||
httpMethod: [{ value: this.httpMethod, disabled: disabled }, context.getValidation('httpMethod').validators],
|
||||
requestBody: [{ value: this.requestBody, disabled: disabled }, context.getValidation('requestBody').validators],
|
||||
filterType: [{ value: this.filterType, disabled: disabled }, context.getValidation('filterType').validators],
|
||||
auth: this.auth.buildForm({
|
||||
rootPath: `${rootPath}auth.`
|
||||
}),
|
||||
queries: this.formBuilder.array(
|
||||
(this.queries ?? []).map(
|
||||
(item, index) => item.buildForm({
|
||||
rootPath: `${rootPath}queries[${index}].`
|
||||
})
|
||||
), context.getValidation('queries').validators
|
||||
),
|
||||
options: this.formBuilder.array(
|
||||
(this.options ?? []).map(
|
||||
(item, index) => new ReferenceTypeStaticOptionEditorModel(
|
||||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
rootPath: `${rootPath}options[${index}].`
|
||||
})
|
||||
), context.getValidation('options').validators
|
||||
),
|
||||
referenceTypeDependencyIds: [{ value: this.referenceTypeDependencyIds, disabled: disabled }, context.getValidation('referenceTypeDependencyIds').validators],
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
||||
baseValidationArray.push({ key: 'key', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}key`)] });
|
||||
baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
||||
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
|
||||
|
||||
baseValidationArray.push({ key: 'url', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}url`)] });
|
||||
baseValidationArray.push({ key: 'paginationPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}paginationPath`)] });
|
||||
baseValidationArray.push({ key: 'contentType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}contentType`)] });
|
||||
baseValidationArray.push({ key: 'firstPage', validators: [Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}firstPage`)] });
|
||||
baseValidationArray.push({ key: 'httpMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}httpMethod`)] });
|
||||
baseValidationArray.push({ key: 'requestBody', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}requestBody`)] });
|
||||
baseValidationArray.push({ key: 'filterType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}filterType`)] });
|
||||
baseValidationArray.push({ key: 'results', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}results`)] });
|
||||
baseValidationArray.push({ key: 'queries', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}queries`)] });
|
||||
|
||||
baseValidationArray.push({ key: 'options', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}options`)] });
|
||||
|
||||
baseValidationArray.push({ key: 'referenceTypeDependencyIds', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeDependencyIds`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = ReferenceTypeSourceBaseConfigurationEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['type', 'key', 'label', 'ordinal', 'url', 'paginationPath', 'contentType', 'firstPage', 'httpMethod', 'requestBody','filterType', 'referenceTypeDependencyIds'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
});
|
||||
|
||||
AuthenticationConfigurationEditorModel.reapplyAuthValidators({
|
||||
formGroup: formGroup?.get('auth') as UntypedFormGroup,
|
||||
rootPath: `${rootPath}auth.`,
|
||||
validationErrorModel: validationErrorModel
|
||||
});
|
||||
|
||||
ResultsConfigurationEditorModel.reapplyValidators({
|
||||
formGroup: formGroup?.get('results') as UntypedFormGroup,
|
||||
rootPath: `${rootPath}results.`,
|
||||
validationErrorModel: validationErrorModel
|
||||
});
|
||||
|
||||
(formGroup.get('options') as FormArray).controls?.forEach(
|
||||
(control, index) => ReferenceTypeStaticOptionEditorModel.reapplyStaticOptionsValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}options[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
(formGroup.get('queries') as FormArray).controls?.forEach(
|
||||
(control, index) => QueryConfigEditorModel.reapplyValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}queries[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
})
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export class ResultsConfigurationEditorModel implements ResultsConfigurationPersist {
|
||||
public resultsArrayPath: string;
|
||||
public fieldsMapping: ResultFieldsMappingConfigurationEditorModel[] = [];
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: ResultsConfiguration): ResultsConfigurationEditorModel {
|
||||
this.resultsArrayPath = item.resultsArrayPath;
|
||||
if (item.fieldsMapping) { item.fieldsMapping.map(x => this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
else {
|
||||
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'reference_id', responsePath: undefined }));
|
||||
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'label', responsePath: undefined }));
|
||||
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'description', responsePath: undefined }));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = ResultsConfigurationEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
resultsArrayPath: [{ value: this.resultsArrayPath, disabled: disabled }, context.getValidation('resultsArrayPath').validators],
|
||||
fieldsMapping: this.formBuilder.array(
|
||||
(this.fieldsMapping ?? []).map(
|
||||
(item, index) => new ResultFieldsMappingConfigurationEditorModel(
|
||||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
rootPath: `${rootPath}fieldsMapping[${index}].`
|
||||
})
|
||||
), context.getValidation('fieldsMapping').validators
|
||||
)
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'resultsArrayPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}resultsArrayPath`)] });
|
||||
baseValidationArray.push({ key: 'fieldsMapping', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fieldsMapping`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = ResultsConfigurationEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['resultsArrayPath'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
});
|
||||
|
||||
(formGroup.get('fieldsMapping') as FormArray).controls?.forEach(
|
||||
(control, index) => ResultFieldsMappingConfigurationEditorModel.reapplyFieldsMappingValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}fieldsMapping[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class ResultFieldsMappingConfigurationEditorModel implements ResultFieldsMappingConfigurationPersist {
|
||||
public code: string;
|
||||
public responsePath: string;
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: ResultFieldsMappingConfiguration): ResultFieldsMappingConfigurationEditorModel {
|
||||
this.code = item.code;
|
||||
this.responsePath = item.responsePath;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = ResultFieldsMappingConfigurationEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
code: [{ value: this.code, disabled: true }, context.getValidation('code').validators],
|
||||
responsePath: [{ value: this.responsePath, disabled: disabled }, context.getValidation('responsePath').validators],
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'code', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
||||
baseValidationArray.push({ key: 'responsePath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}responsePath`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyFieldsMappingValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = ResultFieldsMappingConfigurationEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['code', 'responsePath'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class AuthenticationConfigurationEditorModel implements AuthenticationConfigurationPersist {
|
||||
public enabled: boolean = false;
|
||||
public authUrl: string;
|
||||
public authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
public authTokenPath: string;
|
||||
public authRequestBody: string;
|
||||
public type: string;
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: AuthenticationConfiguration): AuthenticationConfigurationEditorModel {
|
||||
this.enabled = item.enabled;
|
||||
this.authUrl = item.authUrl;
|
||||
this.authMethod = item.authMethod;
|
||||
this.authTokenPath = item.authTokenPath;
|
||||
this.authRequestBody = item.authRequestBody;
|
||||
this.type = item.type;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = AuthenticationConfigurationEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
enabled: [{ value: this.enabled, disabled: disabled }, context.getValidation('enabled').validators],
|
||||
authUrl: [{ value: this.authUrl, disabled: disabled }, context.getValidation('authUrl').validators],
|
||||
authMethod: [{ value: this.authMethod, disabled: disabled }, context.getValidation('authMethod').validators],
|
||||
authTokenPath: [{ value: this.authTokenPath, disabled: disabled }, context.getValidation('authTokenPath').validators],
|
||||
authRequestBody: [{ value: this.authRequestBody, disabled: disabled }, context.getValidation('authRequestBody').validators],
|
||||
type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators],
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'enabled', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}enabled`)] });
|
||||
baseValidationArray.push({ key: 'authUrl', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authUrl`)] });
|
||||
baseValidationArray.push({ key: 'authMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authMethod`)] });
|
||||
baseValidationArray.push({ key: 'authTokenPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authTokenPath`)] });
|
||||
baseValidationArray.push({ key: 'authRequestBody', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authRequestBody`)] });
|
||||
baseValidationArray.push({ key: 'type', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyAuthValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = AuthenticationConfigurationEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['enabled', 'authUrl', 'authMethod', 'authTokenPath', 'authRequestBody', 'type'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class QueryConfigEditorModel implements QueryConfigPersist {
|
||||
public name: string;
|
||||
public defaultValue: string;
|
||||
public cases: QueryCaseConfigEditorModel[] = [];
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: QueryConfig): QueryConfigEditorModel {
|
||||
this.name = item.name;
|
||||
this.defaultValue = item.defaultValue;
|
||||
if (item.cases) { item.cases.map(x => this.cases.push(new QueryCaseConfigEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = QueryConfigEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
name: [{ value: this.name, disabled: disabled }, context.getValidation('name').validators],
|
||||
defaultValue: [{ value: this.defaultValue, disabled: disabled }, context.getValidation('defaultValue').validators],
|
||||
cases: this.formBuilder.array(
|
||||
(this.cases ?? []).map(
|
||||
(item, index) => item.buildForm({
|
||||
rootPath: `${rootPath}cases[${index}].`
|
||||
})
|
||||
), context.getValidation('cases').validators
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}name`)] });
|
||||
baseValidationArray.push({ key: 'defaultValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}defaultValue`)] });
|
||||
baseValidationArray.push({ key: 'cases', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}cases`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = QueryConfigEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['name', 'defaultValue'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
});
|
||||
|
||||
(formGroup.get('cases') as FormArray).controls?.forEach(
|
||||
(control, index) => QueryCaseConfigEditorModel.reapplyValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}cases[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class QueryCaseConfigEditorModel implements QueryCaseConfigPersist {
|
||||
public likePattern: string;
|
||||
public separator: string;
|
||||
public value: string;
|
||||
public referenceTypeId: Guid;
|
||||
public referenceTypeSourceKey: string;
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: QueryCaseConfig): QueryCaseConfigEditorModel {
|
||||
this.likePattern = item.likePattern;
|
||||
this.separator = item.separator;
|
||||
this.value = item.value;
|
||||
if(item?.referenceType?.id) this.referenceTypeId = item.referenceType.id;
|
||||
this.referenceTypeSourceKey = item.referenceTypeSourceKey;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = QueryCaseConfigEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
likePattern: [{ value: this.likePattern, disabled: disabled }, context.getValidation('likePattern').validators],
|
||||
separator: [{ value: this.separator, disabled: disabled }, context.getValidation('separator').validators],
|
||||
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
|
||||
referenceTypeId: [{ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators],
|
||||
referenceTypeSourceKey: [{ value: this.referenceTypeSourceKey, disabled: disabled }, context.getValidation('referenceTypeSourceKey').validators],
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'likePattern', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}likePattern`)] });
|
||||
baseValidationArray.push({ key: 'separator', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}separator`)] });
|
||||
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
|
||||
baseValidationArray.push({ key: 'referenceTypeId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeId`)] });
|
||||
baseValidationArray.push({ key: 'referenceTypeSourceKey', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeSourceKey`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = QueryCaseConfigEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['likePattern', 'separator', 'value', 'referenceTypeId', 'referenceTypeSourceKey'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class ReferenceTypeStaticOptionEditorModel implements ReferenceTypeStaticOptionPersist {
|
||||
public code: string;
|
||||
public value: string;
|
||||
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: ReferenceTypeStaticOption): ReferenceTypeStaticOptionEditorModel {
|
||||
this.code = item.code;
|
||||
this.value = item.value;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = ReferenceTypeStaticOptionEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
code: [{ value: this.code, disabled: true }, context.getValidation('code').validators],
|
||||
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'code', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
||||
baseValidationArray.push({ key: 'value', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyStaticOptionsValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = ReferenceTypeStaticOptionEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['code', 'value'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||
import { AuthenticationConfiguration, QueryConfig, ReferenceType, ReferenceTypeDefinition, ReferenceTypeField, ReferenceTypeSourceBaseConfiguration, ResultsConfiguration, ResultFieldsMappingConfiguration, ReferenceTypeStaticOption, QueryCaseConfig } from '@app/core/model/reference-type/reference-type';
|
||||
import { AuthenticationConfiguration, ExternalFetcherBaseSourceConfiguration, QueryCaseConfig, QueryConfig, ResultFieldsMappingConfiguration, ResultsConfiguration, StaticOption } from '@app/core/model/external-fetcher/external-fetcher';
|
||||
import { ReferenceType, ReferenceTypeDefinition, ReferenceTypeField } from '@app/core/model/reference-type/reference-type';
|
||||
import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service';
|
||||
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
||||
import { BaseEditorResolver } from '@common/base/base-editor.resolver';
|
||||
|
@ -27,45 +28,45 @@ export class ReferenceTypeEditorResolver extends BaseEditorResolver {
|
|||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.fields), nameof<ReferenceTypeField>(x => x.description)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.fields), nameof<ReferenceTypeField>(x => x.dataType)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.type)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.key)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.label)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.ordinal)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.referenceTypeDependencies),nameof<ReferenceType>(x => x.id)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.referenceTypeDependencies),nameof<ReferenceType>(x => x.name)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.type)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.key)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.label)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.ordinal)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.referenceTypeDependencies),nameof<ReferenceType>(x => x.id)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.referenceTypeDependencies),nameof<ReferenceType>(x => x.name)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.url)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.resultsArrayPath)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.url)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.resultsArrayPath)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.code)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.responsePath)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.code)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.responsePath)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.paginationPath)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.contentType)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.firstPage)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.httpMethod)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.requestBody)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.filterType)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.paginationPath)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.contentType)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.firstPage)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.httpMethod)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.requestBody)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.filterType)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.enabled)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authUrl)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authMethod)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authTokenPath)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authRequestBody)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.type)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.enabled)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authUrl)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authMethod)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authTokenPath)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authRequestBody)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.type)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.name)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.defaultValue)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.likePattern)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.separator)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.value)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType),nameof<ReferenceType>(x => x.id)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType),nameof<ReferenceType>(x => x.name)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceTypeSourceKey)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.name)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.defaultValue)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.likePattern)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.separator)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.value)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType),nameof<ReferenceType>(x => x.id)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType),nameof<ReferenceType>(x => x.name)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceTypeSourceKey)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.options),nameof<ReferenceTypeStaticOption>(x => x.code)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.options),nameof<ReferenceTypeStaticOption>(x => x.value)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.options),nameof<StaticOption>(x => x.code)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.options),nameof<StaticOption>(x => x.value)].join('.'),
|
||||
|
||||
nameof<ReferenceType>(x => x.createdAt),
|
||||
nameof<ReferenceType>(x => x.updatedAt),
|
||||
|
|
|
@ -15,6 +15,7 @@ import { DragDropModule } from '@angular/cdk/drag-drop';
|
|||
import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module';
|
||||
import { CommonFormattingModule } from '@common/formatting/common-formatting.module';
|
||||
import { ReferenceTypeListingComponent } from './listing/reference-type-listing.component';
|
||||
import { ExternalFetcherSourceModule } from '@app/ui/external-fetcher/external-fetcher-source.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
|
@ -36,7 +37,8 @@ import { ReferenceTypeListingComponent } from './listing/reference-type-listing.
|
|||
NgxDropzoneModule,
|
||||
DragDropModule,
|
||||
AutoCompleteModule,
|
||||
CommonFormattingModule
|
||||
CommonFormattingModule,
|
||||
ExternalFetcherSourceModule
|
||||
]
|
||||
})
|
||||
export class ReferenceTypeModule { }
|
||||
|
|
|
@ -162,7 +162,7 @@
|
|||
<button mat-mini-fab class="frame-btn">
|
||||
<mat-icon class="mat-mini-fab-icon">add_to_photos</mat-icon>
|
||||
</button>
|
||||
<p class="mb-0 pl-2 frame-txt">{{ 'DMP-OVERVIEW.OVERVIEW.NEW-VERSION' | translate }}
|
||||
<p class="mb-0 pl-2 frame-txt">{{ 'DMP-OVERVIEW.ACTIONS.NEW-VERSION' | translate }}
|
||||
</p>
|
||||
</div>
|
||||
<mat-menu #exportMenu="matMenu" xPosition="before">
|
||||
|
|
|
@ -0,0 +1,697 @@
|
|||
import { FormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
|
||||
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
|
||||
import { Validation, ValidationContext } from "@common/forms/validation/validation-context";
|
||||
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
|
||||
import { ExternalFetcherApiHTTPMethodType } from "@app/core/common/enum/external-fetcher-api-http-method-type";
|
||||
import { ExternalFetcherSourceType } from "@app/core/common/enum/external-fetcher-source-type";
|
||||
import { AuthenticationConfiguration, AuthenticationConfigurationPersist, ExternalFetcherBaseSourceConfiguration, ExternalFetcherBaseSourceConfigurationPersist, QueryCaseConfig, QueryCaseConfigPersist, QueryConfig, QueryConfigPersist, ResultFieldsMappingConfiguration, ResultFieldsMappingConfigurationPersist, ResultsConfiguration, ResultsConfigurationPersist, StaticOption, StaticOptionPersist } from "@app/core/model/external-fetcher/external-fetcher";
|
||||
import { Guid } from "@common/types/guid";
|
||||
|
||||
export class ExternalFetcherBaseSourceConfigurationEditorModel implements ExternalFetcherBaseSourceConfigurationPersist {
|
||||
type: ExternalFetcherSourceType = ExternalFetcherSourceType.API;
|
||||
key: string;
|
||||
label: string;
|
||||
ordinal: number;
|
||||
|
||||
url: string;
|
||||
results: ResultsConfigurationEditorModel = new ResultsConfigurationEditorModel(this.validationErrorModel);
|
||||
paginationPath: string;
|
||||
contentType: string;
|
||||
firstPage: string;
|
||||
httpMethod: ExternalFetcherApiHTTPMethodType;
|
||||
requestBody?: string;
|
||||
filterType?: string;
|
||||
auth: AuthenticationConfigurationEditorModel = new AuthenticationConfigurationEditorModel(this.validationErrorModel);
|
||||
queries?: QueryConfigEditorModel[] = [];
|
||||
|
||||
options: StaticOptionEditorModel[] = [];
|
||||
|
||||
referenceTypeDependencyIds: Guid[];
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
public fromModel(item: ExternalFetcherBaseSourceConfiguration): ExternalFetcherBaseSourceConfigurationEditorModel {
|
||||
if (item) {
|
||||
this.type = item.type;
|
||||
this.key = item.key;
|
||||
this.label = item.label;
|
||||
this.ordinal = item.ordinal;
|
||||
|
||||
if (item.url) this.url = item.url;
|
||||
if (item.results) this.results = new ResultsConfigurationEditorModel(this.validationErrorModel).fromModel(item.results);
|
||||
if (item.paginationPath) this.paginationPath = item.paginationPath;
|
||||
if (item.contentType) this.contentType = item.contentType;
|
||||
if (item.firstPage) this.firstPage = item.firstPage;
|
||||
if (item.httpMethod != null) this.httpMethod = item.httpMethod;
|
||||
if (item.requestBody) this.requestBody = item.requestBody;
|
||||
if (item.filterType) this.filterType = item.filterType;
|
||||
if (item.auth) this.auth = new AuthenticationConfigurationEditorModel(this.validationErrorModel).fromModel(item.auth);
|
||||
if (item.queries) { item.queries.map(x => this.queries.push(new QueryConfigEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
|
||||
if (item.options) {
|
||||
item.options.map(x => this.options.push(new StaticOptionEditorModel(this.validationErrorModel).fromModel(x)));
|
||||
} else {
|
||||
this.options.push(new StaticOptionEditorModel().fromModel({ code: 'reference_id', value: undefined }));
|
||||
this.options.push(new StaticOptionEditorModel().fromModel({ code: 'label', value: undefined }));
|
||||
this.options.push(new StaticOptionEditorModel().fromModel({ code: 'description', value: undefined }));
|
||||
}
|
||||
|
||||
if (item.referenceTypeDependencies) { this.referenceTypeDependencyIds = item.referenceTypeDependencies.map(x => x.id)}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = ExternalFetcherBaseSourceConfigurationEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators],
|
||||
key: [{ value: this.key, disabled: disabled }, context.getValidation('key').validators],
|
||||
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
||||
ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators],
|
||||
|
||||
url: [{ value: this.url, disabled: disabled }, context.getValidation('url').validators],
|
||||
results: this.results.buildForm({
|
||||
rootPath: `${rootPath}results.`,
|
||||
}),
|
||||
paginationPath: [{ value: this.paginationPath, disabled: disabled }, context.getValidation('paginationPath').validators],
|
||||
contentType: [{ value: this.contentType, disabled: disabled }, context.getValidation('contentType').validators],
|
||||
firstPage: [{ value: this.firstPage, disabled: disabled }, context.getValidation('firstPage').validators],
|
||||
httpMethod: [{ value: this.httpMethod, disabled: disabled }, context.getValidation('httpMethod').validators],
|
||||
requestBody: [{ value: this.requestBody, disabled: disabled }, context.getValidation('requestBody').validators],
|
||||
filterType: [{ value: this.filterType, disabled: disabled }, context.getValidation('filterType').validators],
|
||||
auth: this.auth.buildForm({
|
||||
rootPath: `${rootPath}auth.`
|
||||
}),
|
||||
queries: this.formBuilder.array(
|
||||
(this.queries ?? []).map(
|
||||
(item, index) => item.buildForm({
|
||||
rootPath: `${rootPath}queries[${index}].`
|
||||
})
|
||||
), context.getValidation('queries').validators
|
||||
),
|
||||
options: this.formBuilder.array(
|
||||
(this.options ?? []).map(
|
||||
(item, index) => new StaticOptionEditorModel(
|
||||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
rootPath: `${rootPath}options[${index}].`
|
||||
})
|
||||
), context.getValidation('options').validators
|
||||
),
|
||||
referenceTypeDependencyIds: [{ value: this.referenceTypeDependencyIds, disabled: disabled }, context.getValidation('referenceTypeDependencyIds').validators],
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
||||
baseValidationArray.push({ key: 'key', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}key`)] });
|
||||
baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
||||
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
|
||||
|
||||
baseValidationArray.push({ key: 'url', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}url`)] });
|
||||
baseValidationArray.push({ key: 'paginationPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}paginationPath`)] });
|
||||
baseValidationArray.push({ key: 'contentType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}contentType`)] });
|
||||
baseValidationArray.push({ key: 'firstPage', validators: [Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}firstPage`)] });
|
||||
baseValidationArray.push({ key: 'httpMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}httpMethod`)] });
|
||||
baseValidationArray.push({ key: 'requestBody', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}requestBody`)] });
|
||||
baseValidationArray.push({ key: 'filterType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}filterType`)] });
|
||||
baseValidationArray.push({ key: 'results', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}results`)] });
|
||||
baseValidationArray.push({ key: 'queries', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}queries`)] });
|
||||
|
||||
baseValidationArray.push({ key: 'options', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}options`)] });
|
||||
|
||||
baseValidationArray.push({ key: 'referenceTypeDependencyIds', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeDependencyIds`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = ExternalFetcherBaseSourceConfigurationEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['type', 'key', 'label', 'ordinal', 'url', 'paginationPath', 'contentType', 'firstPage', 'httpMethod', 'requestBody','filterType', 'referenceTypeDependencyIds'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
});
|
||||
|
||||
AuthenticationConfigurationEditorModel.reapplyAuthValidators({
|
||||
formGroup: formGroup?.get('auth') as UntypedFormGroup,
|
||||
rootPath: `${rootPath}auth.`,
|
||||
validationErrorModel: validationErrorModel
|
||||
});
|
||||
|
||||
ResultsConfigurationEditorModel.reapplyValidators({
|
||||
formGroup: formGroup?.get('results') as UntypedFormGroup,
|
||||
rootPath: `${rootPath}results.`,
|
||||
validationErrorModel: validationErrorModel
|
||||
});
|
||||
|
||||
(formGroup.get('options') as FormArray).controls?.forEach(
|
||||
(control, index) => StaticOptionEditorModel.reapplyStaticOptionsValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}options[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
(formGroup.get('queries') as FormArray).controls?.forEach(
|
||||
(control, index) => QueryConfigEditorModel.reapplyValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}queries[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
})
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export class ResultsConfigurationEditorModel implements ResultsConfigurationPersist {
|
||||
public resultsArrayPath: string;
|
||||
public fieldsMapping: ResultFieldsMappingConfigurationEditorModel[] = [];
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: ResultsConfiguration): ResultsConfigurationEditorModel {
|
||||
this.resultsArrayPath = item.resultsArrayPath;
|
||||
if (item.fieldsMapping) { item.fieldsMapping.map(x => this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
else {
|
||||
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'reference_id', responsePath: undefined }));
|
||||
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'label', responsePath: undefined }));
|
||||
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'description', responsePath: undefined }));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = ResultsConfigurationEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
resultsArrayPath: [{ value: this.resultsArrayPath, disabled: disabled }, context.getValidation('resultsArrayPath').validators],
|
||||
fieldsMapping: this.formBuilder.array(
|
||||
(this.fieldsMapping ?? []).map(
|
||||
(item, index) => new ResultFieldsMappingConfigurationEditorModel(
|
||||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
rootPath: `${rootPath}fieldsMapping[${index}].`
|
||||
})
|
||||
), context.getValidation('fieldsMapping').validators
|
||||
)
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'resultsArrayPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}resultsArrayPath`)] });
|
||||
baseValidationArray.push({ key: 'fieldsMapping', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fieldsMapping`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = ResultsConfigurationEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['resultsArrayPath'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
});
|
||||
|
||||
(formGroup.get('fieldsMapping') as FormArray).controls?.forEach(
|
||||
(control, index) => ResultFieldsMappingConfigurationEditorModel.reapplyFieldsMappingValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}fieldsMapping[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class ResultFieldsMappingConfigurationEditorModel implements ResultFieldsMappingConfigurationPersist {
|
||||
public code: string;
|
||||
public responsePath: string;
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: ResultFieldsMappingConfiguration): ResultFieldsMappingConfigurationEditorModel {
|
||||
this.code = item.code;
|
||||
this.responsePath = item.responsePath;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = ResultFieldsMappingConfigurationEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
|
||||
responsePath: [{ value: this.responsePath, disabled: disabled }, context.getValidation('responsePath').validators],
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'code', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
||||
baseValidationArray.push({ key: 'responsePath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}responsePath`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyFieldsMappingValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = ResultFieldsMappingConfigurationEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['code', 'responsePath'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class AuthenticationConfigurationEditorModel implements AuthenticationConfigurationPersist {
|
||||
public enabled: boolean = false;
|
||||
public authUrl: string;
|
||||
public authMethod: ExternalFetcherApiHTTPMethodType;
|
||||
public authTokenPath: string;
|
||||
public authRequestBody: string;
|
||||
public type: string;
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: AuthenticationConfiguration): AuthenticationConfigurationEditorModel {
|
||||
this.enabled = item.enabled;
|
||||
this.authUrl = item.authUrl;
|
||||
this.authMethod = item.authMethod;
|
||||
this.authTokenPath = item.authTokenPath;
|
||||
this.authRequestBody = item.authRequestBody;
|
||||
this.type = item.type;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = AuthenticationConfigurationEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
enabled: [{ value: this.enabled, disabled: disabled }, context.getValidation('enabled').validators],
|
||||
authUrl: [{ value: this.authUrl, disabled: disabled }, context.getValidation('authUrl').validators],
|
||||
authMethod: [{ value: this.authMethod, disabled: disabled }, context.getValidation('authMethod').validators],
|
||||
authTokenPath: [{ value: this.authTokenPath, disabled: disabled }, context.getValidation('authTokenPath').validators],
|
||||
authRequestBody: [{ value: this.authRequestBody, disabled: disabled }, context.getValidation('authRequestBody').validators],
|
||||
type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators],
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'enabled', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}enabled`)] });
|
||||
baseValidationArray.push({ key: 'authUrl', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authUrl`)] });
|
||||
baseValidationArray.push({ key: 'authMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authMethod`)] });
|
||||
baseValidationArray.push({ key: 'authTokenPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authTokenPath`)] });
|
||||
baseValidationArray.push({ key: 'authRequestBody', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authRequestBody`)] });
|
||||
baseValidationArray.push({ key: 'type', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyAuthValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = AuthenticationConfigurationEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['enabled', 'authUrl', 'authMethod', 'authTokenPath', 'authRequestBody', 'type'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class QueryConfigEditorModel implements QueryConfigPersist {
|
||||
public name: string;
|
||||
public defaultValue: string;
|
||||
public cases: QueryCaseConfigEditorModel[] = [];
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: QueryConfig): QueryConfigEditorModel {
|
||||
this.name = item.name;
|
||||
this.defaultValue = item.defaultValue;
|
||||
if (item.cases) { item.cases.map(x => this.cases.push(new QueryCaseConfigEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = QueryConfigEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
name: [{ value: this.name, disabled: disabled }, context.getValidation('name').validators],
|
||||
defaultValue: [{ value: this.defaultValue, disabled: disabled }, context.getValidation('defaultValue').validators],
|
||||
cases: this.formBuilder.array(
|
||||
(this.cases ?? []).map(
|
||||
(item, index) => item.buildForm({
|
||||
rootPath: `${rootPath}cases[${index}].`
|
||||
})
|
||||
), context.getValidation('cases').validators
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}name`)] });
|
||||
baseValidationArray.push({ key: 'defaultValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}defaultValue`)] });
|
||||
baseValidationArray.push({ key: 'cases', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}cases`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = QueryConfigEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['name', 'defaultValue'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
});
|
||||
|
||||
(formGroup.get('cases') as FormArray).controls?.forEach(
|
||||
(control, index) => QueryCaseConfigEditorModel.reapplyValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}cases[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class QueryCaseConfigEditorModel implements QueryCaseConfigPersist {
|
||||
public likePattern: string;
|
||||
public separator: string;
|
||||
public value: string;
|
||||
public referenceTypeId: Guid;
|
||||
public referenceTypeSourceKey: string;
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: QueryCaseConfig): QueryCaseConfigEditorModel {
|
||||
this.likePattern = item.likePattern;
|
||||
this.separator = item.separator;
|
||||
this.value = item.value;
|
||||
if(item?.referenceType?.id) this.referenceTypeId = item.referenceType.id;
|
||||
this.referenceTypeSourceKey = item.referenceTypeSourceKey;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = QueryCaseConfigEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
likePattern: [{ value: this.likePattern, disabled: disabled }, context.getValidation('likePattern').validators],
|
||||
separator: [{ value: this.separator, disabled: disabled }, context.getValidation('separator').validators],
|
||||
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
|
||||
referenceTypeId: [{ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators],
|
||||
referenceTypeSourceKey: [{ value: this.referenceTypeSourceKey, disabled: disabled }, context.getValidation('referenceTypeSourceKey').validators],
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'likePattern', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}likePattern`)] });
|
||||
baseValidationArray.push({ key: 'separator', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}separator`)] });
|
||||
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
|
||||
baseValidationArray.push({ key: 'referenceTypeId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeId`)] });
|
||||
baseValidationArray.push({ key: 'referenceTypeSourceKey', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeSourceKey`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = QueryCaseConfigEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['likePattern', 'separator', 'value', 'referenceTypeId', 'referenceTypeSourceKey'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class StaticOptionEditorModel implements StaticOptionPersist {
|
||||
public code: string;
|
||||
public value: string;
|
||||
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: StaticOption): StaticOptionEditorModel {
|
||||
this.code = item.code;
|
||||
this.value = item.value;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = StaticOptionEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
code: [{ value: this.code, disabled: true }, context.getValidation('code').validators],
|
||||
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'code', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
||||
baseValidationArray.push({ key: 'value', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyStaticOptionsValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = StaticOptionEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['code', 'value'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,359 @@
|
|||
<div class="col-12">
|
||||
<div class="row" >
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
|
||||
<input matInput type="text" name="key" [formControl]="formGroup.get('key')" required>
|
||||
<mat-error *ngIf="formGroup.get('key').hasError('backendError')">{{formGroup.get('key').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('key').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LABEL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="label" [formControl]="formGroup.get('label')" required>
|
||||
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">{{formGroup.get('label').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.ORDINAL' | translate}}</mat-label>
|
||||
<input matInput type="number" name="ordinal" [formControl]="formGroup.get('ordinal')" required>
|
||||
<mat-error *ngIf="formGroup.get('ordinal').hasError('backendError')">{{formGroup.get('ordinal').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('ordinal').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6" *ngIf="referenceTypeSourceIndex != null">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DEPENDENCIES' | translate}}</mat-label>
|
||||
<mat-select multiple (selectionChange)="setReferenceTypeDependenciesMap($event.value, referenceTypeSourceIndex)" [formControl]="formGroup.get('referenceTypeDependencyIds')">
|
||||
<mat-option *ngFor="let referenceType of referenceTypes" [value]="referenceType.id">{{referenceType.name}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="formGroup.get('referenceTypeDependencyIds').hasError('backendError')">{{formGroup.get('referenceTypeDependencyIds').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('referenceTypeDependencyIds').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SOURCE-TYPE' | translate}}</mat-label>
|
||||
<mat-select name="type" [formControl]="formGroup.get('type')" required>
|
||||
<mat-option *ngFor="let sourceType of externalFetcherSourceTypeEnum" [value]="sourceType">
|
||||
{{enumUtils.toExternalFetcherSourceTypeString(sourceType)}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="formGroup.get('type').hasError('backendError')">{{formGroup.get('type').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('type').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<div class="row" *ngIf="formGroup.get('type').value == externalFetcherSourceType.API">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.URL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="ordinal" [formControl]="formGroup.get('url')">
|
||||
<mat-error *ngIf="formGroup.get('url').hasError('backendError')">{{formGroup.get('url').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('url').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.PAGINATION-PATH' | translate}}</mat-label>
|
||||
<input matInput type="text" name="paginationPath" [formControl]="formGroup.get('paginationPath')">
|
||||
<mat-error *ngIf="formGroup.get('paginationPath').hasError('backendError')">{{formGroup.get('paginationPath').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('paginationPath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CONTENT-TYPE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="contentType" [formControl]="formGroup.get('contentType')">
|
||||
<mat-error *ngIf="formGroup.get('contentType').hasError('backendError')">{{formGroup.get('contentType').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('contentType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.FIRST-PAGE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="firstPage" [formControl]="formGroup.get('firstPage')">
|
||||
<mat-error *ngIf="formGroup.get('firstPage').hasError('backendError')">{{formGroup.get('firstPage').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('firstPage').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.HTTP-METHOD' | translate}}</mat-label>
|
||||
<mat-select name="httpMethod" [formControl]="formGroup.get('httpMethod')">
|
||||
<mat-option *ngFor="let httpMethod of externalFetcherApiHTTPMethodTypeEnum" [value]="httpMethod">
|
||||
{{enumUtils.toExternalFetcherApiHTTPMethodTypeString(httpMethod)}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="formGroup.get('httpMethod').hasError('backendError')">{{formGroup.get('httpMethod').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('httpMethod').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6" *ngIf="formGroup.get('httpMethod').value == externalFetcherApiHTTPMethodType.POST" >
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REQUEST-BODY' | translate}}</mat-label>
|
||||
<input matInput type="text" name="requestBody" [formControl]="formGroup.get('requestBody')">
|
||||
<mat-error *ngIf="formGroup.get('requestBody').hasError('backendError')">{{formGroup.get('requestBody').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('requestBody').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.FILTER-TYPE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="filterType" [formControl]="formGroup.get('filterType')">
|
||||
<mat-error *ngIf="formGroup.get('filterType').hasError('backendError')">{{formGroup.get('filterType').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('filterType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<!-- Results info -->
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.RESULTS' | translate}}</h3>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.RESULTS-PATH' | translate}}</mat-label>
|
||||
<input matInput type="text" name="resultsArrayPath" [formControl]="formGroup.get('results').get('resultsArrayPath')">
|
||||
<mat-error *ngIf="formGroup.get('results').get('resultsArrayPath').hasError('backendError')">{{formGroup.get('results').get('resultsArrayPath').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('results').get('resultsArrayPath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<!-- fields mapping -->
|
||||
<div class="col-12">
|
||||
<div *ngFor="let field of formGroup.get('results').get('fieldsMapping').controls; let fieldMappingIndex=index;" class="row mb-3">
|
||||
<div class="col-12">
|
||||
<mat-card-header>
|
||||
<div class="row mb-3 d-flex align-items-center">
|
||||
<div class="col-auto d-flex">
|
||||
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.FIELD-MAPPING' | translate}} {{fieldMappingIndex + 1}}</h4>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||
<input matInput type="text" [readonly]="field.get('code').disabled" name="code" [formControl]="field.get('code')" [readOnly]="true">
|
||||
<mat-error *ngIf="field.get('code').hasError('backendError')">{{field.get('code').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="field.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.RESPONSE-PATH' | translate}}</mat-label>
|
||||
<input matInput type="text" name="responsePath" [formControl]="field.get('responsePath')">
|
||||
<mat-error *ngIf="field.get('responsePath').hasError('backendError')">{{field.get('responsePath').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="field.get('responsePath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Auth info -->
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.AUTHENTICATION' | translate}}
|
||||
<mat-checkbox [formControl]="formGroup.get('auth').get('enabled')"></mat-checkbox>
|
||||
</h3>
|
||||
<div class="row" *ngIf="formGroup.get('auth').get('enabled').value == true">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.URL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="authUrl" [formControl]="formGroup.get('auth').get('authUrl')">
|
||||
<mat-error *ngIf="formGroup.get('auth').get('authUrl').hasError('backendError')">{{formGroup.get('auth').get('authUrl').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('auth').get('authUrl').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.HTTP-METHOD' | translate}}</mat-label>
|
||||
<mat-select name="httpMethod" [formControl]="formGroup.get('auth').get('authMethod')">
|
||||
<mat-option *ngFor="let httpMethod of externalFetcherApiHTTPMethodTypeEnum" [value]="httpMethod">
|
||||
{{enumUtils.toExternalFetcherApiHTTPMethodTypeString(httpMethod)}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="formGroup.get('auth').get('authMethod').hasError('backendError')">{{formGroup.get('auth').get('authMethod').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('auth').get('authMethod').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TOKEN-PATH' | translate}}</mat-label>
|
||||
<input matInput type="text" name="authTokenPath" [formControl]="formGroup.get('auth').get('authTokenPath')">
|
||||
<mat-error *ngIf="formGroup.get('auth').get('authTokenPath').hasError('backendError')">{{formGroup.get('auth').get('authTokenPath').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('auth').get('authTokenPath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REQUEST-BODY' | translate}}</mat-label>
|
||||
<input matInput type="text" name="authRequestBody" [formControl]="formGroup.get('auth').get('authRequestBody')">
|
||||
<mat-error *ngIf="formGroup.get('auth').get('authRequestBody').hasError('backendError')">{{formGroup.get('auth').get('authRequestBody').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('auth').get('authRequestBody').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TYPE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="type" [formControl]="formGroup.get('auth').get('type')">
|
||||
<mat-error *ngIf="formGroup.get('auth').get('type').hasError('backendError')">{{formGroup.get('auth').get('type').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('auth').get('type').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Queries info -->
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERIES' | translate}}
|
||||
<button mat-button type="button" class="action-btn" (click)="addQuery()" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-QUERY' | translate}}</button>
|
||||
</h3>
|
||||
<div class="col-12">
|
||||
<div *ngFor="let query of formGroup.get('queries').controls; let queryIndex=index;" class="row mb-3">
|
||||
<div class="col-12">
|
||||
<mat-card-header>
|
||||
<div class="row mb-3 d-flex align-items-center">
|
||||
<div class="col-auto d-flex">
|
||||
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERY' | translate}} {{queryIndex + 1}}</h4>
|
||||
</div>
|
||||
<div class="col-auto d-flex">
|
||||
<button mat-icon-button class="action-list-icon" matTooltip="{{'REFERENCE-TYPE-EDITOR.ACTIONS.REMOVE-QUERY' | translate}}" (click)="removeQuery(queryIndex)" [disabled]="formGroup.disabled">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button mat-button class="action-btn" type="button" (click)="addCase(queryIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-CASE' | translate}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.NAME' | translate}}</mat-label>
|
||||
<input matInput type="text" name="name" [formControl]="query.get('name')" required>
|
||||
<mat-error *ngIf="query.get('name').hasError('backendError')">{{query.get('name').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="query.get('name').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DEFAULT-VALUE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="defaultValue" [formControl]="query.get('defaultValue')">
|
||||
<mat-error *ngIf="query.get('defaultValue').hasError('backendError')">{{query.get('defaultValue').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="query.get('defaultValue').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</div>
|
||||
<!-- Query Cases -->
|
||||
<div *ngFor="let case of query.get('cases').controls; let caseIndex=index;" class="row mb-3">
|
||||
<div class="col-12">
|
||||
<mat-card-header>
|
||||
<div class="row mb-3 d-flex align-items-center">
|
||||
<div class="col-auto d-flex">
|
||||
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.CASE' | translate}} {{caseIndex + 1}}</h4>
|
||||
</div>
|
||||
<div class="col-auto d-flex">
|
||||
<button mat-icon-button class="action-list-icon" matTooltip="{{'REFERENCE-TYPE-EDITOR.ACTIONS.REMOVE-CASE' | translate}}" (click)="removeCase(queryIndex, caseIndex)" [disabled]="formGroup.disabled">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LIKE-PATTERN' | translate}}</mat-label>
|
||||
<input matInput type="text" name="likePattern" [formControl]="case.get('likePattern')">
|
||||
<mat-error *ngIf="case.get('likePattern').hasError('backendError')">{{case.get('likePattern').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="case.get('likePattern').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SEPARATOR' | translate}}</mat-label>
|
||||
<input matInput type="text" name="separator" [formControl]="case.get('separator')">
|
||||
<mat-error *ngIf="case.get('separator').hasError('backendError')">{{case.get('separator').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="case.get('separator').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="value" [formControl]="case.get('value')">
|
||||
<mat-error *ngIf="case.get('value').hasError('backendError')">{{case.get('value').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="case.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6" *ngIf="formGroup.get('referenceTypeDependencyIds').value">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}</mat-label>
|
||||
<mat-select name="referenceTypeId" [formControl]="case.get('referenceTypeId')">
|
||||
<mat-option *ngFor="let referenceType of referenceTypeDependenciesMap.get(referenceTypeSourceIndex)" [value]="referenceType.id">
|
||||
{{referenceType.code}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="case.get('referenceTypeId').hasError('backendError')">{{case.get('referenceTypeId').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="case.get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6" *ngIf="case.get('referenceTypeId').value">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SOURCE-KEY' | translate}}</mat-label>
|
||||
<mat-select name = 'referenceTypeSourceKey' [formControl]="case.get('referenceTypeSourceKey')">
|
||||
<mat-option *ngFor="let sourceKey of sourceKeysMap.get(case.get('referenceTypeId').value)" [value]="sourceKey">
|
||||
{{sourceKey}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="case.get('referenceTypeSourceKey').hasError('backendError')">{{case.get('referenceTypeSourceKey').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="case.get('referenceTypeSourceKey').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Options -->
|
||||
<div class="row" *ngIf="formGroup.get('type').value == externalFetcherSourceType.STATIC">
|
||||
<div class="col-12">
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.OPTIONS' | translate}}</h3>
|
||||
<div *ngFor="let option of formGroup.get('options').controls; let optionsIndex=index;" class="row mb-3">
|
||||
<div class="col-12">
|
||||
<mat-card-header>
|
||||
<div class="row mb-3 d-flex align-items-center">
|
||||
<div class="col-auto d-flex">
|
||||
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.OPTION' | translate}} {{optionsIndex + 1}}</h4>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||
<input matInput type="text" [readonly]="option.get('code').disabled" name="code" [formControl]="option.get('code')">
|
||||
<mat-error *ngIf="option.get('code').hasError('backendError')">{{option.get('code').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="option.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="value" [formControl]="option.get('value')">
|
||||
<mat-error *ngIf="option.get('value').hasError('backendError')">{{option.get('value').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="option.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{formGroup.value | json}}
|
||||
</div>
|
|
@ -0,0 +1,103 @@
|
|||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { FormArray, UntypedFormGroup } from '@angular/forms';
|
||||
import { ExternalFetcherApiHTTPMethodType } from '@app/core/common/enum/external-fetcher-api-http-method-type';
|
||||
import { ExternalFetcherSourceType } from '@app/core/common/enum/external-fetcher-source-type';
|
||||
import { ReferenceType } from '@app/core/model/reference-type/reference-type';
|
||||
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
||||
import { BaseComponent } from '@common/base/base.component';
|
||||
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
|
||||
import { QueryCaseConfigEditorModel, QueryConfigEditorModel, StaticOptionEditorModel } from './external-fetcher-source-editor.model';
|
||||
import { Guid } from '@common/types/guid';
|
||||
|
||||
@Component({
|
||||
selector: 'app-external-fetcher-source-component',
|
||||
templateUrl: 'external-fetcher-source.component.html',
|
||||
styleUrls: ['./external-fetcher-source.component.scss']
|
||||
})
|
||||
export class ExternalFetcherSourceComponent extends BaseComponent implements OnInit {
|
||||
|
||||
@Input() formGroup: UntypedFormGroup = null;
|
||||
@Input() validationErrorModel: ValidationErrorModel = null;
|
||||
@Input() validationRootPath: string = null;
|
||||
@Input() referenceTypeSourceIndex: number = null;
|
||||
@Input() referenceTypes: ReferenceType[] = null;
|
||||
@Input() sourceKeysMap: Map<Guid, string[]> = new Map<Guid, string[]>();
|
||||
|
||||
externalFetcherSourceType = ExternalFetcherSourceType;
|
||||
externalFetcherApiHTTPMethodType = ExternalFetcherApiHTTPMethodType;
|
||||
externalFetcherSourceTypeEnum = this.enumUtils.getEnumValues<ExternalFetcherSourceType>(ExternalFetcherSourceType);
|
||||
externalFetcherApiHTTPMethodTypeEnum = this.enumUtils.getEnumValues<ExternalFetcherApiHTTPMethodType>(ExternalFetcherApiHTTPMethodType);
|
||||
referenceTypeDependenciesMap: Map<number, ReferenceType[]> = new Map<number, ReferenceType[]>();
|
||||
|
||||
constructor(
|
||||
public enumUtils: EnumUtils,
|
||||
) { super(); }
|
||||
|
||||
ngOnInit() {
|
||||
console.log(this.referenceTypeSourceIndex);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// queries
|
||||
//
|
||||
//
|
||||
addQuery(): void {
|
||||
const formArray= this.formGroup.get('queries') as FormArray;
|
||||
const query: QueryConfigEditorModel = new QueryConfigEditorModel(this.validationErrorModel);
|
||||
formArray.push(query.buildForm({rootPath: this.validationRootPath + 'queries[' + formArray.length + '].'}));
|
||||
}
|
||||
|
||||
removeQuery(queryIndex: number): void {
|
||||
const formArray = (this.formGroup.get('queries') as FormArray);
|
||||
formArray.removeAt(queryIndex);
|
||||
}
|
||||
|
||||
// cases
|
||||
|
||||
addCase(queryIndex: number): void {
|
||||
const formArray = (this.formGroup.get('queries') as FormArray).at(queryIndex).get('cases') as FormArray;
|
||||
const queryCase: QueryCaseConfigEditorModel = new QueryCaseConfigEditorModel(this.validationErrorModel);
|
||||
formArray.push(queryCase.buildForm({rootPath: this.validationRootPath + 'queries[' + queryIndex + '].cases[' + formArray.length + '].'}));
|
||||
|
||||
}
|
||||
|
||||
removeCase(queryIndex: number, index: number): void {
|
||||
const formArray = (this.formGroup.get('queries') as FormArray).at(queryIndex).get('cases') as FormArray;
|
||||
formArray.removeAt(index);
|
||||
}
|
||||
|
||||
// Options
|
||||
|
||||
addOption(code: string): void {
|
||||
const optionsSize = (this.formGroup.get('options') as FormArray).length;
|
||||
|
||||
if (optionsSize > 0) {
|
||||
for (let i = 0; i < optionsSize; i++) {
|
||||
if ((this.formGroup.get('options') as FormArray).at(i).get('code').getRawValue() == code) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const option = new StaticOptionEditorModel(this.validationErrorModel);
|
||||
(this.formGroup.get('options') as FormArray).push(option.buildForm());
|
||||
(this.formGroup.get('options') as FormArray).at(optionsSize).get('code').patchValue(code);
|
||||
}
|
||||
|
||||
removeOption(optionIndex: number): void {
|
||||
const formArray = (this.formGroup.get('options') as FormArray);
|
||||
formArray.removeAt(optionIndex);
|
||||
}
|
||||
|
||||
setReferenceTypeDependenciesMap(ids: Guid[], index: number){
|
||||
let mapValues :ReferenceType[] = [];
|
||||
this.referenceTypes.forEach(x => {
|
||||
if(ids.includes(x.id)){
|
||||
mapValues.push(x);
|
||||
}
|
||||
})
|
||||
this.referenceTypeDependenciesMap.set(index, mapValues);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { FormattingModule } from '@app/core/formatting.module';
|
||||
import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module';
|
||||
import { DescriptionRoutingModule } from '@app/ui/description/description.routing';
|
||||
import { CommonFormsModule } from '@common/forms/common-forms.module';
|
||||
import { CommonUiModule } from '@common/ui/common-ui.module';
|
||||
import { ExternalFetcherSourceComponent } from './external-fetcher-source.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonUiModule,
|
||||
CommonFormsModule,
|
||||
FormattingModule,
|
||||
DescriptionRoutingModule,
|
||||
AutoCompleteModule
|
||||
],
|
||||
declarations: [
|
||||
ExternalFetcherSourceComponent
|
||||
],
|
||||
exports: [
|
||||
ExternalFetcherSourceComponent
|
||||
]
|
||||
})
|
||||
export class ExternalFetcherSourceModule { }
|
|
@ -53,6 +53,7 @@ export const ADMIN_ROUTES: RouteInfo[] = [
|
|||
{ path: '/description-template-type', title: 'SIDE-BAR.DESCRIPTION-TEMPLATE-TYPES', icon: 'stack' },
|
||||
{ path: '/references', title: 'SIDE-BAR.REFERENCES', icon: 'dataset_linked' },
|
||||
{ path: '/reference-type', title: 'SIDE-BAR.REFERENCE-TYPES', icon: 'add_link' },
|
||||
{ path: '/prefilling-sources', title: 'SIDE-BAR.PREFILLING-SOURCES', icon: 'add_link' },
|
||||
{ path: '/tenants', title: 'SIDE-BAR.TENANTS', icon: 'tenancy' },
|
||||
{ path: '/users', title: 'SIDE-BAR.USERS', icon: 'people' },
|
||||
{ path: '/languages', title: 'SIDE-BAR.LANGUAGES', icon: 'language' },
|
||||
|
|
|
@ -256,7 +256,10 @@
|
|||
"EDIT-LANGUAGE": "Edit",
|
||||
"NOTIFICATION-TEMPLATES": "Notification Templates",
|
||||
"INAPP-NOTIFICATIONS":"Notifications",
|
||||
"NOTIFICATIONS": "Notifications"
|
||||
"NOTIFICATIONS": "Notifications",
|
||||
"PREFILLING-SOURCES": "Prefilling Sources",
|
||||
"NEW-PREFILLING-SOURCE": "New",
|
||||
"EDIT-PREFILLING-SOURCE": "Edit"
|
||||
},
|
||||
"COOKIE": {
|
||||
"MESSAGE": "This website uses cookies to enhance the user experience.",
|
||||
|
@ -359,7 +362,8 @@
|
|||
"LANGUAGES": "Languages",
|
||||
"MAINTENANCE": "Maintenance",
|
||||
"NOTIFICATION-TEMPLATES": "Notification Templates",
|
||||
"NOTIFICATIONS":"Notifications"
|
||||
"NOTIFICATIONS":"Notifications",
|
||||
"PREFILLING-SOURCES":"Prefilling Sources"
|
||||
},
|
||||
"DESCRIPTION-TEMPLATE-EDITOR": {
|
||||
"TITLE": {
|
||||
|
@ -1196,6 +1200,33 @@
|
|||
"SUCCESSFUL-DELETE": "Successful Delete",
|
||||
"UNSUCCESSFUL-DELETE": "This item could not be deleted."
|
||||
},
|
||||
"PREFILLING-SOURCE-LISTING": {
|
||||
"TITLE": "Prefilling Sources",
|
||||
"CREATE": "Create Prefilling Source",
|
||||
"FIELDS": {
|
||||
"LABEL": "Label",
|
||||
"UPDATED-AT": "Updated",
|
||||
"CREATED-AT": "Created",
|
||||
"IS-ACTIVE": "Is Active"
|
||||
},
|
||||
"FILTER": {
|
||||
"TITLE": "Filters",
|
||||
"IS-ACTIVE": "Is Active",
|
||||
"CANCEL": "Cancel",
|
||||
"APPLY-FILTERS": "Apply filters"
|
||||
},
|
||||
"CONFIRM-DELETE-DIALOG": {
|
||||
"MESSAGE": "Would you like to delete this Preffiling Source?",
|
||||
"CONFIRM-BUTTON": "Yes, delete",
|
||||
"CANCEL-BUTTON": "No"
|
||||
},
|
||||
"ACTIONS": {
|
||||
"DELETE": "Delete",
|
||||
"EDIT": "Edit"
|
||||
},
|
||||
"SUCCESSFUL-DELETE": "Successful Delete",
|
||||
"UNSUCCESSFUL-DELETE": "This item could not be deleted."
|
||||
},
|
||||
"REFERENCE-LISTING": {
|
||||
"TITLE": "References",
|
||||
"CREATE": "Create Reference",
|
||||
|
@ -1515,7 +1546,8 @@
|
|||
"ADD-QUERY": "Add Query",
|
||||
"REMOVE-QUERY": "Remove Query",
|
||||
"ADD-CASE": "Add Case",
|
||||
"REMOVE-CASE": "Remove Case"
|
||||
"REMOVE-CASE": "Remove Case",
|
||||
"SUBMIT-FIELDS": "Submit"
|
||||
},
|
||||
"CONFIRM-DELETE-DIALOG": {
|
||||
"MESSAGE": "Would you like to delete this Reference type?",
|
||||
|
@ -1556,6 +1588,32 @@
|
|||
"CANCEL-BUTTON": "No"
|
||||
}
|
||||
},
|
||||
"PREFILLING-SOURCE-EDITOR": {
|
||||
"NEW": "New Prefilling Source",
|
||||
"FIELDS": {
|
||||
"LABEL": "Label",
|
||||
"FIELD": "Field",
|
||||
"CODE": "Code",
|
||||
"TARGET": "Target",
|
||||
"SYSTEM-TARGET": "System Target",
|
||||
"SEMANTIC-TARGET": "Semantic Target",
|
||||
"TRIM-REGEX": "Trim Regex",
|
||||
"FIXED-VALUE": "Fixed Value"
|
||||
},
|
||||
"ACTIONS": {
|
||||
"SAVE": "Save",
|
||||
"CANCEL": "Cancel",
|
||||
"DELETE": "Delete",
|
||||
"ADD-FIELD": "Add Field",
|
||||
"REMOVE-FIELD": "Remove Field",
|
||||
"SUBMIT-FIELDS": "Submit"
|
||||
},
|
||||
"CONFIRM-DELETE-DIALOG": {
|
||||
"MESSAGE": "Would you like to delete this Prefilling Source?",
|
||||
"CONFIRM-BUTTON": "Yes, delete",
|
||||
"CANCEL-BUTTON": "No"
|
||||
}
|
||||
},
|
||||
"REFERENCE-EDITOR": {
|
||||
"NEW": "New Reference",
|
||||
"FIELDS": {
|
||||
|
|
Loading…
Reference in New Issue