Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Diamantis Tziotzios 2023-12-01 19:18:48 +02:00
commit 567b09a26b
30 changed files with 308 additions and 69 deletions

View File

@ -165,7 +165,8 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
}
if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._label), this.like),
queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._description), this.like)
queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._description), this.like),
queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._source), this.like)
));
}
if (this.isActives != null) {

View File

@ -4,13 +4,9 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionReferenceEntity;
import eu.eudat.data.UserContactInfoEntity;
import eu.eudat.data.UserEntity;
import eu.eudat.data.*;
import eu.eudat.model.User;
import eu.eudat.model.PublicUser;
import eu.eudat.model.UserContactInfo;
import eu.eudat.query.utils.BuildSubQueryInput;
import eu.eudat.query.utils.QueryUtilsService;
import gr.cite.commons.web.authz.service.AuthorizationService;
@ -36,6 +32,7 @@ public class UserQuery extends QueryBase<UserEntity> {
private Collection<String> emails;
private Collection<UUID> excludedIds;
private Collection<IsActive> isActives;
private UserRoleQuery userRoleQuery;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@ -113,6 +110,11 @@ public class UserQuery extends QueryBase<UserEntity> {
return this;
}
public UserQuery userRoleSubQuery(UserRoleQuery userRoleSubQuery) {
this.userRoleQuery = userRoleSubQuery;
return this;
}
public UserQuery authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
@ -124,7 +126,8 @@ public class UserQuery extends QueryBase<UserEntity> {
this.isEmpty(this.ids) ||
this.isEmpty(this.isActives) ||
this.isEmpty(this.emails) ||
this.isEmpty(this.excludedIds);
this.isEmpty(this.excludedIds) ||
this.isFalseQuery(this.userRoleQuery);
}
@Override
@ -190,6 +193,11 @@ public class UserQuery extends QueryBase<UserEntity> {
));
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(userContactInfoSubquery));
}
if (this.userRoleQuery != null) {
Subquery<UserRoleEntity> subQuery = queryContext.Query.subquery(this.userRoleQuery.entityClass());
this.applySubQuery(this.userRoleQuery, queryContext.CriteriaBuilder, subQuery);
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(subQuery));
}
if (!predicates.isEmpty()) {

View File

@ -1,15 +1,10 @@
package eu.eudat.query.lookup;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.elastic.query.DescriptionElasticQuery;
import eu.eudat.elastic.query.InnerObjectDmpElasticQuery;
import eu.eudat.query.DescriptionQuery;
import eu.eudat.query.UserQuery;
import gr.cite.tools.data.query.Lookup;
import gr.cite.tools.data.query.QueryFactory;
import java.time.Instant;
import java.util.List;
import java.util.UUID;
@ -22,6 +17,7 @@ public class UserLookup extends Lookup {
private List<UUID> excludedIds;
private List<IsActive> isActive;
private UserRoleLookup userRoleSubQuery;
public String getLike() {
return like;
@ -55,11 +51,28 @@ public class UserLookup extends Lookup {
this.isActive = isActive;
}
public List<String> getEmails() {
return emails;
}
public void setEmails(List<String> emails) {
this.emails = emails;
}
public UserRoleLookup getUserRoleSubQuery() {
return userRoleSubQuery;
}
public void setUserRoleSubQuery(UserRoleLookup userRoleSubQuery) {
this.userRoleSubQuery = userRoleSubQuery;
}
public UserQuery enrich(QueryFactory queryFactory) {
UserQuery query = queryFactory.query(UserQuery.class);
if (this.like != null) query.like(this.like);
if (this.ids != null) query.ids(this.ids);
if (this.emails != null) query.emails(this.emails);
if (this.userRoleSubQuery != null) query.userRoleSubQuery(this.userRoleSubQuery.enrich(queryFactory));
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
if (this.isActive != null) query.isActive(this.isActive);

View File

@ -1,12 +1,14 @@
import { Lookup } from "@common/model/lookup";
import { Guid } from "@common/types/guid";
import { IsActive } from "../common/enum/is-active.enum";
import { DescriptionTemplateTypeStatus } from "../common/enum/description-template-type-status";
export class DescriptionTemplateTypeLookup extends Lookup implements DescriptionTemplateTypeFilter {
ids: Guid[];
excludedIds: Guid[];
like: string;
isActive: IsActive[];
statuses: DescriptionTemplateTypeStatus[];
constructor() {
super();
@ -18,4 +20,5 @@ export interface DescriptionTemplateTypeFilter {
excludedIds: Guid[];
like: string;
isActive: IsActive[];
statuses: DescriptionTemplateTypeStatus[];
}

View File

@ -10,7 +10,7 @@ export class ReferenceLookup extends Lookup implements ReferenceFilter {
like: string;
isActive: IsActive[];
sourceTypes: ReferenceSourceType[];
referenceTypes: ReferenceType[];
types: ReferenceType[];
constructor() {
super();
@ -23,5 +23,5 @@ export interface ReferenceFilter {
like: string;
isActive: IsActive[];
sourceTypes: ReferenceSourceType[];
referenceTypes: ReferenceType[];
types: ReferenceType[];
}

View File

@ -0,0 +1,20 @@
import { Lookup } from "@common/model/lookup";
import { Guid } from "@common/types/guid";
export class UserRoleLookup extends Lookup implements UserRoleFilter {
ids: Guid[];
excludedIds: Guid[];
userIds: Guid[];
roles: string[]
constructor() {
super();
}
}
export interface UserRoleFilter {
ids: Guid[];
excludedIds: Guid[];
userIds: Guid[];
roles: string[];
}

View File

@ -1,6 +1,7 @@
import { Lookup } from '@common/model/lookup';
import { Guid } from '@common/types/guid';
import { IsActive } from '../common/enum/is-active.enum';
import { UserRoleLookup } from './user-role.lookup';
export class UserLookup extends Lookup implements UserFilter {
ids: Guid[];
@ -8,6 +9,7 @@ export class UserLookup extends Lookup implements UserFilter {
like: string;
emails: string[];
isActive: IsActive[];
userRoleSubQuery: UserRoleLookup;
constructor() {
super();
@ -20,4 +22,5 @@ export interface UserFilter {
like: string;
emails: string[];
isActive: IsActive[];
userRoleSubQuery: UserRoleLookup;
}

View File

@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { DescriptionTemplateType, DescriptionTemplateTypePersist } from '@app/core/model/description-template-type/description-template-type';
import { DescriptionTemplateTypeLookup } from '@app/core/query/description-template-type.lookup';
import { DmpBlueprintLookup } from '@app/core/query/dmp-blueprint.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';
@ -80,8 +79,8 @@ export class DescriptionTemplateTypeService {
valueAssign: (item: DescriptionTemplateType) => item.id,
};
private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DmpBlueprintLookup {
const lookup: DmpBlueprintLookup = new DmpBlueprintLookup();
private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DescriptionTemplateTypeLookup {
const lookup: DescriptionTemplateTypeLookup = new DescriptionTemplateTypeLookup();
lookup.page = { size: 100, offset: 0 };
if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
if (ids && ids.length > 0) { lookup.ids = ids; }

View File

@ -72,29 +72,29 @@ export class ReferenceService {
//
// Autocomplete Commons
//
public getSingleAutocompleteConfiguration(referenceTypes?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): SingleAutoCompleteConfiguration {
public getSingleAutocompleteConfiguration(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): SingleAutoCompleteConfiguration {
return {
initialItems: (data?: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes)).pipe(map(x => x.items)),
filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, searchQuery)).pipe(map(x => x.items)),
getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, null, null, [selectedItem])).pipe(map(x => x.items[0])),
initialItems: (data?: any) => this.query(this.buildAutocompleteLookup(types, sourceTypes)).pipe(map(x => x.items)),
filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(types, sourceTypes, searchQuery)).pipe(map(x => x.items)),
getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(types, sourceTypes, null, null, [selectedItem])).pipe(map(x => x.items[0])),
displayFn: (item: Reference) => item.label,
titleFn: (item: Reference) => item.label,
valueAssign: (item: Reference) => item.id,
};
};
public getMultipleAutoCompleteConfiguration(referenceTypes?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): MultipleAutoCompleteConfiguration {
public getMultipleAutoCompleteConfiguration(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): MultipleAutoCompleteConfiguration {
return {
initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)),
filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, searchQuery, excludedItems)).pipe(map(x => x.items)),
getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, null, null, selectedItems)).pipe(map(x => x.items)),
initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(types, sourceTypes, null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)),
filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(types, sourceTypes, searchQuery, excludedItems)).pipe(map(x => x.items)),
getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(types, sourceTypes, null, null, selectedItems)).pipe(map(x => x.items)),
displayFn: (item: Reference) => item.label,
titleFn: (item: Reference) => item.label,
valueAssign: (item: Reference) => item.id,
};
}
private buildAutocompleteLookup(referenceTypes?: ReferenceType[], sourceTypes?: ReferenceSourceType[], like?: string, excludedIds?: Guid[], ids?: Guid[]): ReferenceLookup {
private buildAutocompleteLookup(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[], like?: string, excludedIds?: Guid[], ids?: Guid[]): ReferenceLookup {
const lookup: ReferenceLookup = new ReferenceLookup();
lookup.page = { size: 100, offset: 0 };
if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
@ -106,7 +106,7 @@ export class ReferenceService {
nameof<Reference>(x => x.label)
]
};
if (referenceTypes && referenceTypes.length > 0) { lookup.referenceTypes = referenceTypes; }
if (types && types.length > 0) { lookup.types = types; }
if (sourceTypes && sourceTypes.length > 0) { lookup.sourceTypes = sourceTypes; }
lookup.order = { items: [nameof<Reference>(x => x.label)] };
if (like) { lookup.like = this.filterService.transformLike(like); }

View File

@ -27,6 +27,7 @@ import { ImportDescriptionTemplateDialogComponent } from './import-description-t
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
import { DescriptionTemplateStatus } from '@app/core/common/enum/description-template-status';
import { DescriptionTemplateLookup } from '@app/core/query/description-template.lookup';
import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
@Component({
@ -127,6 +128,12 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent<De
languageName: 'DESCRIPTION-TEMPLATE-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
},
{
prop: nameof<DescriptionTemplate>(x => x.isActive),
sortable: true,
languageName: 'DESCRIPTION-TEMPLATE-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{
alwaysShown: true,
cellTemplate: this.actions,

View File

@ -20,6 +20,14 @@
{{'DESCRIPTION-TEMPLATE-LISTING.FILTER.IS-ACTIVE' | translate}}
</mat-slide-toggle>
<div>
<mat-label>{{'DESCRIPTION-TEMPLATE-LISTING.FILTER.STATUS' | translate}}
<mat-select multiple [(ngModel)]="internalFilters.statuses">
<mat-option *ngFor="let descriptionTemplateStatus of descriptionTemplateStatusEnumValues" [value]="descriptionTemplateStatus">{{enumUtils.toDescriptionTemplateTypeStatusString(descriptionTemplateStatus)}}</mat-option>
</mat-select>
</mat-label>
</div>
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">
{{'DESCRIPTION-TEMPLATE-LISTING.FILTER.CANCEL' | translate}}

View File

@ -1,4 +1,5 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { DescriptionTemplateStatus } from '@app/core/common/enum/description-template-status';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { DescriptionTemplateFilter } from '@app/core/query/description-template.lookup';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
@ -16,6 +17,8 @@ export class DescriptionTemplateListingFiltersComponent extends BaseComponent im
@Input() readonly filter: DescriptionTemplateFilter;
@Output() filterChange = new EventEmitter<DescriptionTemplateFilter>();
descriptionTemplateStatusEnumValues = this.enumUtils.getEnumValues<DescriptionTemplateStatus>(DescriptionTemplateStatus);
// * State
internalFilters: DescriptionTemplateListingFilters = this._getEmptyFilters();
@ -46,12 +49,12 @@ export class DescriptionTemplateListingFiltersComponent extends BaseComponent im
}
protected applyFilters(): void {
const { isActive, like, typeIds } = this.internalFilters ?? {}
const { isActive, like, statuses } = this.internalFilters ?? {}
this.filterChange.emit({
...this.filter,
like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
typeIds
statuses
})
}
@ -61,12 +64,12 @@ export class DescriptionTemplateListingFiltersComponent extends BaseComponent im
return this._getEmptyFilters();
}
let { excludedIds, ids, isActive, like, typeIds } = inputFilter;
let { excludedIds, ids, isActive, like, statuses } = inputFilter;
return {
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
like: like,
typeIds: typeIds
statuses: statuses
}
}
@ -75,7 +78,7 @@ export class DescriptionTemplateListingFiltersComponent extends BaseComponent im
return {
isActive: true,
like: null,
typeIds: null,
statuses: null,
}
}
@ -95,5 +98,5 @@ export class DescriptionTemplateListingFiltersComponent extends BaseComponent im
interface DescriptionTemplateListingFilters {
isActive: boolean;
like: string;
typeIds: Guid[];
statuses: DescriptionTemplateStatus[];
}

View File

@ -13,6 +13,7 @@ import { QueryParamsService } from '@app/core/services/utilities/query-params.se
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 { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.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';
@ -110,6 +111,12 @@ export class DescriptionTemplateTypeListingComponent extends BaseListingComponen
languageName: 'DESCRIPTION-TEMPLATE-TYPE-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
},
{
prop: nameof<DescriptionTemplateType>(x => x.isActive),
sortable: true,
languageName: 'DESCRIPTION-TEMPLATE-TYPE-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{
alwaysShown: true,
cellTemplate: this.actions,

View File

@ -20,6 +20,14 @@
{{'DESCRIPTION-TEMPLATE-TYPE-LISTING.FILTER.IS-ACTIVE' | translate}}
</mat-slide-toggle>
<div>
<mat-label>{{'DESCRIPTION-TEMPLATE-TYPE-LISTING.FILTER.STATUS' | translate}}
<mat-select multiple [(ngModel)]="internalFilters.statuses">
<mat-option *ngFor="let descriptionTemplateTypeStatus of descriptionTemplateTypeStatusEnumValues" [value]="descriptionTemplateTypeStatus">{{enumUtils.toDescriptionTemplateTypeStatusString(descriptionTemplateTypeStatus)}}</mat-option>
</mat-select>
</mat-label>
</div>
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">
{{'DESCRIPTION-TEMPLATE-TYPE-LISTING.FILTER.CANCEL' | translate}}

View File

@ -1,4 +1,5 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { DescriptionTemplateTypeStatus } from '@app/core/common/enum/description-template-type-status';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { DescriptionTemplateTypeFilter } from '@app/core/query/description-template-type.lookup';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
@ -15,6 +16,8 @@ export class DescriptionTemplateTypeListingFiltersComponent extends BaseComponen
@Input() readonly filter: DescriptionTemplateTypeFilter;
@Output() filterChange = new EventEmitter<DescriptionTemplateTypeFilter>();
descriptionTemplateTypeStatusEnumValues = this.enumUtils.getEnumValues<DescriptionTemplateTypeStatus>(DescriptionTemplateTypeStatus);
// * State
internalFilters: DescriptionTemplateTypeListingFilters = this._getEmptyFilters();
@ -45,11 +48,12 @@ export class DescriptionTemplateTypeListingFiltersComponent extends BaseComponen
}
protected applyFilters(): void {
const { isActive, like } = this.internalFilters ?? {}
const { isActive, like, statuses } = this.internalFilters ?? {}
this.filterChange.emit({
...this.filter,
like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive]
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
statuses
})
}
@ -59,11 +63,12 @@ export class DescriptionTemplateTypeListingFiltersComponent extends BaseComponen
return this._getEmptyFilters();
}
let { excludedIds, ids, isActive, like } = inputFilter;
let { excludedIds, ids, isActive, like, statuses } = inputFilter;
return {
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
like: like
like: like,
statuses: statuses
}
}
@ -72,6 +77,7 @@ export class DescriptionTemplateTypeListingFiltersComponent extends BaseComponen
return {
isActive: true,
like: null,
statuses: null,
}
}
@ -91,4 +97,5 @@ export class DescriptionTemplateTypeListingFiltersComponent extends BaseComponen
interface DescriptionTemplateTypeListingFilters {
isActive: boolean;
like: string;
statuses: DescriptionTemplateTypeStatus[];
}

View File

@ -20,9 +20,13 @@
{{'DMP-BLUEPRINT-LISTING.FILTER.IS-ACTIVE' | translate}}
</mat-slide-toggle>
<mat-select multiple [(ngModel)]="internalFilters.statuses">
<mat-option *ngFor="let blueprintStatus of dmpBlueprintStatusEnumValues" [value]="blueprintStatus">{{enumUtils.toDmpBlueprintStatusString(blueprintStatus)}}</mat-option>
</mat-select>
<div>
<mat-label>{{'DMP-BLUEPRINT-LISTING.FILTER.STATUS' | translate}}
<mat-select multiple [(ngModel)]="internalFilters.statuses">
<mat-option *ngFor="let blueprintStatus of dmpBlueprintStatusEnumValues" [value]="blueprintStatus">{{enumUtils.toDmpBlueprintStatusString(blueprintStatus)}}</mat-option>
</mat-select>
</mat-label>
</div>
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">

View File

@ -12,6 +12,7 @@ import { QueryParamsService } from '@app/core/services/utilities/query-params.se
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 { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.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';
@ -102,6 +103,12 @@ export class LanguageListingComponent extends BaseListingComponent<Language, Lan
languageName: 'LANGUAGE-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
},
{
prop: nameof<Language>(x => x.isActive),
sortable: true,
languageName: 'LANGUAGE-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{
alwaysShown: true,
cellTemplate: this.actions,

View File

@ -21,6 +21,7 @@ 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: './reference-type-listing.component.html',
@ -95,7 +96,6 @@ export class ReferenceTypeListingComponent extends BaseListingComponent<Referenc
prop: nameof<ReferenceType>(x => x.code),
sortable: true,
languageName: 'REFERENCE-TYPE-LISTING.FIELDS.CODE',
//cellTemplate: this.ReferenceTypeStatus
},
{
prop: nameof<ReferenceType>(x => x.createdAt),
@ -109,6 +109,12 @@ export class ReferenceTypeListingComponent extends BaseListingComponent<Referenc
languageName: 'REFERENCE-TYPE-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
},
{
prop: nameof<ReferenceType>(x => x.isActive),
sortable: true,
languageName: 'REFERENCE-TYPE-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{
alwaysShown: true,
cellTemplate: this.actions,

View File

@ -20,6 +20,22 @@
{{'REFERENCE-LISTING.FILTER.IS-ACTIVE' | translate}}
</mat-slide-toggle>
<div>
<mat-label>{{'REFERENCE-LISTING.FILTER.TYPE' | translate}}
<mat-select multiple [(ngModel)]="internalFilters.types">
<mat-option *ngFor="let referenceType of referenceTypeEnumValues" [value]="referenceType">{{enumUtils.toReferenceTypeString(referenceType)}}</mat-option>
</mat-select>
</mat-label>
</div>
<div>
<mat-label>{{'REFERENCE-LISTING.FILTER.SOURCE-TYPE' | translate}}
<mat-select multiple [(ngModel)]="internalFilters.sourceTypes">
<mat-option *ngFor="let referenceSourceType of referenceSourceTypeEnumValues" [value]="referenceSourceType">{{enumUtils.toReferenceSourceTypeString(referenceSourceType)}}</mat-option>
</mat-select>
</mat-label>
</div>
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">
{{'REFERENCE-LISTING.FILTER.CANCEL' | translate}}

View File

@ -1,6 +1,8 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { TenantFilter } from '@app/core/query/tenant.lookup';
import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type';
import { ReferenceType } from '@app/core/common/enum/reference-type';
import { ReferenceFilter } from '@app/core/query/reference.lookup';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { BaseComponent } from '@common/base/base.component';
import { nameof } from 'ts-simple-nameof';
@ -12,8 +14,11 @@ import { nameof } from 'ts-simple-nameof';
})
export class ReferenceListingFiltersComponent extends BaseComponent implements OnInit, OnChanges {
@Input() readonly filter: TenantFilter;
@Output() filterChange = new EventEmitter<TenantFilter>();
@Input() readonly filter: ReferenceFilter;
@Output() filterChange = new EventEmitter<ReferenceFilter>();
referenceSourceTypeEnumValues = this.enumUtils.getEnumValues<ReferenceSourceType>(ReferenceSourceType)
referenceTypeEnumValues = this.enumUtils.getEnumValues<ReferenceType>(ReferenceType);
// * State
internalFilters: ReferenceListingFilters = this._getEmptyFilters();
@ -27,7 +32,7 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
}
ngOnChanges(changes: SimpleChanges): void {
const filterChange = changes[nameof<ReferenceListingFiltersComponent>(x => x.filter)]?.currentValue as TenantFilter;
const filterChange = changes[nameof<ReferenceListingFiltersComponent>(x => x.filter)]?.currentValue as ReferenceFilter;
if (filterChange) {
this.updateFilters()
}
@ -45,25 +50,29 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
}
protected applyFilters(): void {
const { isActive, like } = this.internalFilters ?? {}
const { isActive, like, types, sourceTypes } = this.internalFilters ?? {}
this.filterChange.emit({
...this.filter,
like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive]
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
types,
sourceTypes
})
}
private _parseToInternalFilters(inputFilter: TenantFilter): ReferenceListingFilters {
private _parseToInternalFilters(inputFilter: ReferenceFilter): ReferenceListingFilters {
if (!inputFilter) {
return this._getEmptyFilters();
}
let { excludedIds, ids, isActive, like } = inputFilter;
let { excludedIds, ids, isActive, like, types, sourceTypes } = inputFilter;
return {
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
like: like
like: like,
types: types,
sourceTypes: sourceTypes
}
}
@ -72,6 +81,8 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
return {
isActive: true,
like: null,
types: null,
sourceTypes: null
}
}
@ -91,4 +102,6 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O
interface ReferenceListingFilters {
isActive: boolean;
like: string;
types: ReferenceType[];
sourceTypes: ReferenceSourceType[];
}

View File

@ -21,6 +21,9 @@ 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';
import { ReferenceTypePipe } from '@common/formatting/pipes/reference-type.pipe';
import { ReferenceSourceTypePipe } from '@common/formatting/pipes/reference-source-type.pipe';
@Component({
templateUrl: './REFERENCE-LISTING.component.html',
@ -38,6 +41,7 @@ export class ReferenceListingComponent extends BaseListingComponent<Reference, R
nameof<Reference>(x => x.id),
nameof<Reference>(x => x.label),
nameof<Reference>(x => x.source),
nameof<Reference>(x => x.sourceType),
nameof<Reference>(x => x.type),
nameof<Reference>(x => x.updatedAt),
nameof<Reference>(x => x.createdAt),
@ -96,10 +100,17 @@ export class ReferenceListingComponent extends BaseListingComponent<Reference, R
sortable: true,
languageName: 'REFERENCE-LISTING.FIELDS.SOURCE',
},
{
prop: nameof<Reference>(x => x.sourceType),
sortable: true,
languageName: 'REFERENCE-LISTING.FIELDS.SOURCE-TYPE',
pipe: this.pipeService.getPipe<ReferenceSourceTypePipe>(ReferenceSourceTypePipe)
},
{
prop: nameof<Reference>(x => x.type),
sortable: true,
languageName: 'REFERENCE-LISTING.FIELDS.TYPE',
pipe: this.pipeService.getPipe<ReferenceTypePipe>(ReferenceTypePipe)
},
{
prop: nameof<Reference>(x => x.createdAt),
@ -113,6 +124,12 @@ export class ReferenceListingComponent extends BaseListingComponent<Reference, R
languageName: 'REFERENCE-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
},
{
prop: nameof<Reference>(x => x.isActive),
sortable: true,
languageName: 'REFERENCE-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{
alwaysShown: true,
cellTemplate: this.actions,

View File

@ -21,6 +21,7 @@ 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: './tenant-listing.component.html',
@ -94,7 +95,6 @@ export class TenantListingComponent extends BaseListingComponent<Tenant, TenantL
prop: nameof<Tenant>(x => x.code),
sortable: true,
languageName: 'TENANT-LISTING.FIELDS.CODE',
//cellTemplate: this.TenantStatus
},
{
prop: nameof<Tenant>(x => x.createdAt),
@ -108,6 +108,12 @@ export class TenantListingComponent extends BaseListingComponent<Tenant, TenantL
languageName: 'TENANT-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
},
{
prop: nameof<Tenant>(x => x.isActive),
sortable: true,
languageName: 'TENANT-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{
alwaysShown: true,
cellTemplate: this.actions,

View File

@ -20,6 +20,14 @@
{{'USER-LISTING.FILTER.IS-ACTIVE' | translate}}
</mat-slide-toggle>
<div>
<mat-label>{{'USER-LISTING.FILTER.ROLES' | translate}}
<mat-select multiple [(ngModel)]="internalFilters.userRoleSubQuery.roles">
<mat-option *ngFor="let appRole of appRoleEnumValues" [value]="appRole">{{enumUtils.toAppRoleString(appRole)}}</mat-option>
</mat-select>
</mat-label>
</div>
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">
{{'USER-LISTING.FILTER.CANCEL' | translate}}

View File

@ -1,5 +1,7 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { AppRole } from '@app/core/common/enum/app-role';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { UserRoleLookup } from '@app/core/query/user-role.lookup';
import { UserFilter } from '@app/core/query/user.lookup';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { BaseComponent } from '@common/base/base.component';
@ -15,6 +17,9 @@ export class UserListingFiltersComponent extends BaseComponent implements OnInit
@Input() readonly filter: UserFilter;
@Output() filterChange = new EventEmitter<UserFilter>();
roles: string[] = []
appRoleEnumValues = this.enumUtils.getEnumValues<AppRole>(AppRole);
// * State
internalFilters: UserListingFilters = this._getEmptyFilters();
@ -45,11 +50,12 @@ export class UserListingFiltersComponent extends BaseComponent implements OnInit
}
protected applyFilters(): void {
const { isActive, like } = this.internalFilters ?? {}
const { isActive, like, userRoleSubQuery } = this.internalFilters ?? {}
this.filterChange.emit({
...this.filter,
like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive]
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
userRoleSubQuery
})
}
@ -59,11 +65,12 @@ export class UserListingFiltersComponent extends BaseComponent implements OnInit
return this._getEmptyFilters();
}
let { excludedIds, ids, isActive, like } = inputFilter;
let { excludedIds, ids, isActive, like, userRoleSubQuery } = inputFilter;
return {
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
like: like
like: like,
userRoleSubQuery: userRoleSubQuery ?? new UserRoleLookup()
}
}
@ -72,6 +79,7 @@ export class UserListingFiltersComponent extends BaseComponent implements OnInit
return {
isActive: true,
like: null,
userRoleSubQuery: new UserRoleLookup()
}
}
@ -91,4 +99,5 @@ export class UserListingFiltersComponent extends BaseComponent implements OnInit
interface UserListingFilters {
isActive: boolean;
like: string;
userRoleSubQuery: UserRoleLookup;
}

View File

@ -13,6 +13,7 @@ import { QueryParamsService } from '@app/core/services/utilities/query-params.se
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 { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.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';
@ -124,7 +125,13 @@ export class UserListingComponent extends BaseListingComponent<User, UserLookup>
alwaysShown: true,
maxWidth: 300,
cellTemplate: this.roleCellTemplate
}
},
{
prop: nameof<User>(x => x.isActive),
sortable: true,
languageName: 'USER-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
]);
this.propertiesAvailableForOrder = this.gridColumns.filter(x => x.sortable);
}

View File

@ -1009,11 +1009,13 @@
"STATUS": "Status",
"UPDATED-AT": "Updated",
"CREATED-AT": "Created",
"PUBLISHED-AT": "Published"
"PUBLISHED-AT": "Published",
"IS-ACTIVE":"Is Active"
},
"FILTER": {
"TITLE": "Filters",
"IS-ACTIVE": "Is Active",
"STATUS": "Status",
"CANCEL": "Cancel",
"APPLY-FILTERS": "Apply filters"
},
@ -1049,11 +1051,13 @@
"NAME": "Name",
"STATUS": "Status",
"UPDATED-AT": "Updated",
"CREATED-AT": "Created"
"CREATED-AT": "Created",
"IS-ACTIVE": "Is Active"
},
"FILTER": {
"TITLE": "Filters",
"IS-ACTIVE": "Is Active",
"STATUS": "Status",
"CANCEL": "Cancel",
"APPLY-FILTERS": "Apply filters"
},
@ -1076,7 +1080,8 @@
"NAME": "Name",
"CODE": "Code",
"UPDATED-AT": "Updated",
"CREATED-AT": "Created"
"CREATED-AT": "Created",
"IS-ACTIVE": "Is Active"
},
"FILTER": {
"TITLE": "Filters",
@ -1103,7 +1108,8 @@
"NAME": "Name",
"CODE": "Code",
"UPDATED-AT": "Updated",
"CREATED-AT": "Created"
"CREATED-AT": "Created",
"IS-ACTIVE": "Is Active"
},
"FILTER": {
"TITLE": "Filters",
@ -1129,13 +1135,17 @@
"FIELDS": {
"LABEL": "Label",
"SOURCE": "Source",
"TYPE": "Type",
"SOURCE-TYPE": "Source Type",
"TYPE": "Reference Type",
"UPDATED-AT": "Updated",
"CREATED-AT": "Created"
"CREATED-AT": "Created",
"IS-ACTIVE": "Is Active"
},
"FILTER": {
"TITLE": "Filters",
"IS-ACTIVE": "Is Active",
"TYPE": "Type",
"SOURCE-TYPE": "Source Type",
"CANCEL": "Cancel",
"APPLY-FILTERS": "Apply filters"
},
@ -1157,7 +1167,8 @@
"FIELDS": {
"CODE": "Code",
"UPDATED-AT": "Updated",
"CREATED-AT": "Created"
"CREATED-AT": "Created",
"IS-ACTIVE": "Is Active"
},
"FILTER": {
"TITLE": "Filters",
@ -1590,11 +1601,13 @@
"STATUS": "Status",
"UPDATED-AT": "Updated",
"CREATED-AT": "Created",
"PUBLISHED-AT": "Published"
"PUBLISHED-AT": "Published",
"IS-ACTIVE":"Is Active"
},
"FILTER": {
"TITLE": "Filters",
"IS-ACTIVE": "Is Active",
"STATUS": "Status",
"CANCEL": "Cancel",
"APPLY-FILTERS": "Apply filters"
},
@ -1800,11 +1813,13 @@
"ROLES": "Roles",
"NAME": "Name",
"UPDATED-AT": "Updated",
"CREATED-AT": "Created"
"CREATED-AT": "Created",
"IS-ACTIVE": "Is Active"
},
"FILTER": {
"TITLE": "Filters",
"IS-ACTIVE": "Is Active",
"ROLES": "Roles",
"CANCEL": "Cancel",
"APPLY-FILTERS": "Apply filters"
},
@ -1821,6 +1836,10 @@
"MANAGER": "Manager",
"DESCRIPTION-TEMPLATE-EDITOR": "Description Template Editor"
},
"IS-ACTIVE":{
"ACTIVE":"Active",
"INACTIVE":"Inactive"
},
"DMP-PROFILE-FIELD": {
"DATA-TYPE": {
"DATE": "Date",

View File

@ -5,6 +5,8 @@ import { DataTableDateOnlyFormatPipe, DateOnlyPipe } from '@common/formatting/pi
import { DataTableDateTimeFormatPipe, DateTimeFormatPipe } from '@common/formatting/pipes/date-time-format.pipe';
import { LowercaseFirstLetterPipe } from '@common/formatting/pipes/lowercase-first-letter.pipe';
import { IsActiveTypePipe } from './pipes/is-active-type.pipe';
import { ReferenceTypePipe } from './pipes/reference-type.pipe';
import { ReferenceSourceTypePipe } from './pipes/reference-source-type.pipe';
//
//
@ -21,8 +23,9 @@ import { IsActiveTypePipe } from './pipes/is-active-type.pipe';
ArrayToStringPipe,
DateOnlyPipe,
DataTableDateOnlyFormatPipe,
IsActiveTypePipe
IsActiveTypePipe,
ReferenceTypePipe,
ReferenceSourceTypePipe
],
exports: [
DateFormatPipe,
@ -33,7 +36,9 @@ import { IsActiveTypePipe } from './pipes/is-active-type.pipe';
ArrayToStringPipe,
DateOnlyPipe,
DataTableDateOnlyFormatPipe,
IsActiveTypePipe
IsActiveTypePipe,
ReferenceTypePipe,
ReferenceSourceTypePipe
],
providers: [
DateFormatPipe,
@ -44,7 +49,9 @@ import { IsActiveTypePipe } from './pipes/is-active-type.pipe';
ArrayToStringPipe,
DateOnlyPipe,
DataTableDateOnlyFormatPipe,
IsActiveTypePipe
IsActiveTypePipe,
ReferenceTypePipe,
ReferenceSourceTypePipe
]
})
export class CommonFormattingModule { }

View File

@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from '@angular/core';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
@Pipe({ name: 'AppRoleTypeFormat' })
export class AppRoleTypePipe implements PipeTransform {
constructor(private enumUtils: EnumUtils) { }
public transform(value): any {
return this.enumUtils.toAppRoleString(value);
}
}

View File

@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from '@angular/core';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
@Pipe({ name: 'ReferenceSourceTypeFormat' })
export class ReferenceSourceTypePipe implements PipeTransform {
constructor(private enumUtils: EnumUtils) { }
public transform(value): any {
return this.enumUtils.toReferenceSourceTypeString(value);
}
}

View File

@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from '@angular/core';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
@Pipe({ name: 'ReferenceTypeFormat' })
export class ReferenceTypePipe implements PipeTransform {
constructor(private enumUtils: EnumUtils) { }
public transform(value): any {
return this.enumUtils.toReferenceTypeString(value);
}
}