fixed listings with versions-mode
This commit is contained in:
parent
83091ee428
commit
ee7acec75b
|
@ -27,11 +27,12 @@ import { Guid } from '@common/types/guid';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import * as FileSaver from 'file-saver';
|
import * as FileSaver from 'file-saver';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil, tap } from 'rxjs/operators';
|
||||||
import { nameof } from 'ts-simple-nameof';
|
import { nameof } from 'ts-simple-nameof';
|
||||||
import { ImportDescriptionTemplateDialogComponent } from './import-description-template/import-description-template.dialog.component';
|
import { ImportDescriptionTemplateDialogComponent } from './import-description-template/import-description-template.dialog.component';
|
||||||
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
|
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
|
||||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||||
|
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -46,6 +47,7 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent<De
|
||||||
descriptionTemplateStatuses = DescriptionTemplateStatus;
|
descriptionTemplateStatuses = DescriptionTemplateStatus;
|
||||||
mode;
|
mode;
|
||||||
|
|
||||||
|
groupId: Guid | null = null;
|
||||||
|
|
||||||
public permissionEnum = AppPermission;
|
public permissionEnum = AppPermission;
|
||||||
|
|
||||||
|
@ -101,12 +103,14 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent<De
|
||||||
private sumarizeTextPipe: SumarizeTextPipe,
|
private sumarizeTextPipe: SumarizeTextPipe,
|
||||||
private analyticsService: AnalyticsService,
|
private analyticsService: AnalyticsService,
|
||||||
public routerUtils: RouterUtilsService,
|
public routerUtils: RouterUtilsService,
|
||||||
|
private breadcrumbService: BreadcrumbService,
|
||||||
) {
|
) {
|
||||||
super(router, route, uiNotificationService, httpErrorHandlingService, queryParamsService);
|
super(router, route, uiNotificationService, httpErrorHandlingService, queryParamsService);
|
||||||
// Lookup setup
|
// Lookup setup
|
||||||
// Default lookup values are defined in the user settings class.
|
// Default lookup values are defined in the user settings class.
|
||||||
this.mode = this.route.snapshot?.data['mode'];
|
this.mode = this.route.snapshot?.data['mode'];
|
||||||
this.lookup = this.initializeLookup();
|
this.lookup = this.initializeLookup();
|
||||||
|
this.breadcrumbService.addExcludedParam("versions", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -121,9 +125,12 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent<De
|
||||||
lookup.isActive = [IsActive.Active];
|
lookup.isActive = [IsActive.Active];
|
||||||
lookup.order = { items: [this.toDescSortField(nameof<DescriptionTemplate>(x => x.createdAt))] };
|
lookup.order = { items: [this.toDescSortField(nameof<DescriptionTemplate>(x => x.createdAt))] };
|
||||||
if (this.mode && this.mode == 'versions-listing') {
|
if (this.mode && this.mode == 'versions-listing') {
|
||||||
lookup.groupIds = [Guid.parse(this.route.snapshot.paramMap.get('groupid'))];
|
this.groupId = Guid.parse(this.route.snapshot.paramMap.get('groupid'));
|
||||||
|
this.breadcrumbService.addExcludedParam(this.groupId.toString(), true);
|
||||||
|
lookup.groupIds = [this.groupId];
|
||||||
lookup.versionStatuses = null;
|
lookup.versionStatuses = null;
|
||||||
} else {
|
} else {
|
||||||
|
this.groupId = null;
|
||||||
lookup.versionStatuses = [DescriptionTemplateVersionStatus.Current, DescriptionTemplateVersionStatus.NotFinalized];
|
lookup.versionStatuses = [DescriptionTemplateVersionStatus.Current, DescriptionTemplateVersionStatus.NotFinalized];
|
||||||
}
|
}
|
||||||
this.updateOrderUiFields(lookup.order);
|
this.updateOrderUiFields(lookup.order);
|
||||||
|
@ -246,7 +253,15 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent<De
|
||||||
|
|
||||||
protected loadListing(): Observable<QueryResult<DescriptionTemplate>> {
|
protected loadListing(): Observable<QueryResult<DescriptionTemplate>> {
|
||||||
this.lookup.onlyCanEdit = true;
|
this.lookup.onlyCanEdit = true;
|
||||||
return this.descriptionTemplateService.query(this.lookup);
|
return this.descriptionTemplateService.query(this.lookup).pipe(
|
||||||
|
takeUntil(this._destroyed),
|
||||||
|
tap((descriptionTemplates: QueryResult<DescriptionTemplate>) => {
|
||||||
|
const groupCode = descriptionTemplates.items?.[0]?.code;
|
||||||
|
if (this.groupId != null && groupCode != null) {
|
||||||
|
this.breadcrumbService.addIdResolvedValue(this.groupId.toString(), groupCode);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public delete(id: Guid) {
|
public delete(id: Guid) {
|
||||||
|
|
|
@ -26,11 +26,12 @@ import { Guid } from '@common/types/guid';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import * as FileSaver from 'file-saver';
|
import * as FileSaver from 'file-saver';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil, tap } from 'rxjs/operators';
|
||||||
import { nameof } from 'ts-simple-nameof';
|
import { nameof } from 'ts-simple-nameof';
|
||||||
import { ImportPlanBlueprintDialogComponent } from './import-plan-blueprint/import-plan-blueprint.dialog.component';
|
import { ImportPlanBlueprintDialogComponent } from './import-plan-blueprint/import-plan-blueprint.dialog.component';
|
||||||
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
|
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
|
||||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||||
|
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -46,6 +47,8 @@ export class PlanBlueprintListingComponent extends BaseListingComponent<PlanBlue
|
||||||
isActive = IsActive;
|
isActive = IsActive;
|
||||||
mode;
|
mode;
|
||||||
|
|
||||||
|
groupId: Guid | null = null;
|
||||||
|
|
||||||
@ViewChild('planBlueprintStatus', { static: true }) planBlueprintStatus?: TemplateRef<any>;
|
@ViewChild('planBlueprintStatus', { static: true }) planBlueprintStatus?: TemplateRef<any>;
|
||||||
@ViewChild('actions', { static: true }) actions?: TemplateRef<any>;
|
@ViewChild('actions', { static: true }) actions?: TemplateRef<any>;
|
||||||
@ViewChild(HybridListingComponent, { static: true }) hybridListingComponent: HybridListingComponent;
|
@ViewChild(HybridListingComponent, { static: true }) hybridListingComponent: HybridListingComponent;
|
||||||
|
@ -80,13 +83,15 @@ export class PlanBlueprintListingComponent extends BaseListingComponent<PlanBlue
|
||||||
private language: TranslateService,
|
private language: TranslateService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private fileUtils: FileUtils,
|
private fileUtils: FileUtils,
|
||||||
private analyticsService: AnalyticsService
|
private analyticsService: AnalyticsService,
|
||||||
|
private breadcrumbService: BreadcrumbService,
|
||||||
) {
|
) {
|
||||||
super(router, route, uiNotificationService, httpErrorHandlingService, queryParamsService);
|
super(router, route, uiNotificationService, httpErrorHandlingService, queryParamsService);
|
||||||
// Lookup setup
|
// Lookup setup
|
||||||
// Default lookup values are defined in the user settings class.
|
// Default lookup values are defined in the user settings class.
|
||||||
this.mode = this.route.snapshot?.data['mode'];
|
this.mode = this.route.snapshot?.data['mode'];
|
||||||
this.lookup = this.initializeLookup();
|
this.lookup = this.initializeLookup();
|
||||||
|
this.breadcrumbService.addExcludedParam("versions", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -121,9 +126,12 @@ export class PlanBlueprintListingComponent extends BaseListingComponent<PlanBlue
|
||||||
lookup.isActive = [IsActive.Active];
|
lookup.isActive = [IsActive.Active];
|
||||||
lookup.order = { items: [this.toDescSortField(nameof<PlanBlueprint>(x => x.createdAt))] };
|
lookup.order = { items: [this.toDescSortField(nameof<PlanBlueprint>(x => x.createdAt))] };
|
||||||
if (this.mode && this.mode == 'versions-listing') {
|
if (this.mode && this.mode == 'versions-listing') {
|
||||||
lookup.groupIds = [Guid.parse(this.route.snapshot.paramMap.get('groupid'))];
|
this.groupId = Guid.parse(this.route.snapshot.paramMap.get('groupid'));
|
||||||
|
this.breadcrumbService.addIdResolvedValue(this.groupId.toString(), "");
|
||||||
|
lookup.groupIds = [this.groupId];
|
||||||
lookup.versionStatuses = null;
|
lookup.versionStatuses = null;
|
||||||
} else {
|
} else {
|
||||||
|
this.groupId = null;
|
||||||
lookup.versionStatuses = [PlanBlueprintVersionStatus.Current, PlanBlueprintVersionStatus.NotFinalized];
|
lookup.versionStatuses = [PlanBlueprintVersionStatus.Current, PlanBlueprintVersionStatus.NotFinalized];
|
||||||
}
|
}
|
||||||
this.updateOrderUiFields(lookup.order);
|
this.updateOrderUiFields(lookup.order);
|
||||||
|
@ -205,7 +213,15 @@ export class PlanBlueprintListingComponent extends BaseListingComponent<PlanBlue
|
||||||
}
|
}
|
||||||
|
|
||||||
protected loadListing(): Observable<QueryResult<PlanBlueprint>> {
|
protected loadListing(): Observable<QueryResult<PlanBlueprint>> {
|
||||||
return this.planBlueprintService.query(this.lookup);
|
return this.planBlueprintService.query(this.lookup).pipe(
|
||||||
|
takeUntil(this._destroyed),
|
||||||
|
tap((blueprints: QueryResult<PlanBlueprint>) => {
|
||||||
|
const groupCode = blueprints.items?.[0]?.code;
|
||||||
|
if (this.groupId != null && groupCode != null) {
|
||||||
|
this.breadcrumbService.addIdResolvedValue(this.groupId.toString(), groupCode);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected delete(id: Guid) {
|
protected delete(id: Guid) {
|
||||||
|
|
|
@ -40,6 +40,8 @@ import { Tenant } from '@app/core/model/tenant/tenant';
|
||||||
import { BaseHttpParams } from '@common/http/base-http-params';
|
import { BaseHttpParams } from '@common/http/base-http-params';
|
||||||
import { InterceptorType } from '@common/http/interceptors/interceptor-type';
|
import { InterceptorType } from '@common/http/interceptors/interceptor-type';
|
||||||
import { PrincipalService } from '@app/core/services/http/principal.service';
|
import { PrincipalService } from '@app/core/services/http/principal.service';
|
||||||
|
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
||||||
|
import { PlanStatusEnum } from '@app/core/common/enum/plan-status';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-plan-listing-component',
|
selector: 'app-plan-listing-component',
|
||||||
|
@ -53,7 +55,7 @@ export class PlanListingComponent extends BaseListingComponent<BasePlan, PlanLoo
|
||||||
@ViewChild(MatPaginator, { static: true }) _paginator: MatPaginator;
|
@ViewChild(MatPaginator, { static: true }) _paginator: MatPaginator;
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
lookup: PlanLookup;
|
lookup: PlanLookup;
|
||||||
groupId: string;
|
// groupId: string;
|
||||||
totalCount: number;
|
totalCount: number;
|
||||||
listingItems: any[] = [];
|
listingItems: any[] = [];
|
||||||
isPublic: boolean = false;
|
isPublic: boolean = false;
|
||||||
|
@ -67,6 +69,9 @@ export class PlanListingComponent extends BaseListingComponent<BasePlan, PlanLoo
|
||||||
order: new UntypedFormControl()
|
order: new UntypedFormControl()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
groupId: Guid | null = null;
|
||||||
|
mode;
|
||||||
|
|
||||||
scrollbar: boolean;
|
scrollbar: boolean;
|
||||||
order = RecentActivityOrder;
|
order = RecentActivityOrder;
|
||||||
|
|
||||||
|
@ -113,8 +118,11 @@ export class PlanListingComponent extends BaseListingComponent<BasePlan, PlanLoo
|
||||||
private guidedTourService: GuidedTourService,
|
private guidedTourService: GuidedTourService,
|
||||||
private analyticsService: AnalyticsService,
|
private analyticsService: AnalyticsService,
|
||||||
private principalService: PrincipalService,
|
private principalService: PrincipalService,
|
||||||
|
private breadcrumbService: BreadcrumbService,
|
||||||
) {
|
) {
|
||||||
super(router, route, uiNotificationService, httpErrorHandlingService, queryParamsService);
|
super(router, route, uiNotificationService, httpErrorHandlingService, queryParamsService);
|
||||||
|
this.mode = this.route.snapshot?.data['mode'];
|
||||||
|
this.breadcrumbService.addExcludedParam("versions", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -195,6 +203,11 @@ export class PlanListingComponent extends BaseListingComponent<BasePlan, PlanLoo
|
||||||
if (this.isPublic) {
|
if (this.isPublic) {
|
||||||
return this.planService.publicQuery(this.lookup).pipe(takeUntil(this._destroyed))
|
return this.planService.publicQuery(this.lookup).pipe(takeUntil(this._destroyed))
|
||||||
.pipe(tap(result => {
|
.pipe(tap(result => {
|
||||||
|
if (this.groupId != null) {
|
||||||
|
const latestVersionPlan: BasePlan = this._getLatestVersion(result.items);
|
||||||
|
this.breadcrumbService.addIdResolvedValue(this.groupId.toString(), latestVersionPlan.label);
|
||||||
|
}
|
||||||
|
|
||||||
if (!result) { return []; }
|
if (!result) { return []; }
|
||||||
this.totalCount = result.count;
|
this.totalCount = result.count;
|
||||||
if (this.lookup?.page?.offset === 0) this.listingItems = [];
|
if (this.lookup?.page?.offset === 0) this.listingItems = [];
|
||||||
|
@ -204,6 +217,11 @@ export class PlanListingComponent extends BaseListingComponent<BasePlan, PlanLoo
|
||||||
} else {
|
} else {
|
||||||
return this.planService.query(this.lookup).pipe(takeUntil(this._destroyed))
|
return this.planService.query(this.lookup).pipe(takeUntil(this._destroyed))
|
||||||
.pipe(tap(result => {
|
.pipe(tap(result => {
|
||||||
|
if (this.groupId != null) {
|
||||||
|
const latestVersionPlan: BasePlan = this._getLatestVersion(result.items);
|
||||||
|
this.breadcrumbService.addIdResolvedValue(this.groupId.toString(), latestVersionPlan.label);
|
||||||
|
}
|
||||||
|
|
||||||
this.hasLoadedListingItems = true;
|
this.hasLoadedListingItems = true;
|
||||||
if (!result) { return []; }
|
if (!result) { return []; }
|
||||||
this.totalCount = result.count;
|
this.totalCount = result.count;
|
||||||
|
@ -224,6 +242,15 @@ export class PlanListingComponent extends BaseListingComponent<BasePlan, PlanLoo
|
||||||
let recentActivityOrder = this.isPublic ? this.toDescSortField(nameof<Description>(x => x.finalizedAt)) : this.toDescSortField(nameof<Description>(x => x.updatedAt));
|
let recentActivityOrder = this.isPublic ? this.toDescSortField(nameof<Description>(x => x.finalizedAt)) : this.toDescSortField(nameof<Description>(x => x.updatedAt));
|
||||||
lookup.order = { items: [recentActivityOrder] };
|
lookup.order = { items: [recentActivityOrder] };
|
||||||
|
|
||||||
|
if (this.mode && this.mode == 'versions-listing') {
|
||||||
|
this.groupId = Guid.parse(this.route.snapshot.paramMap.get('groupId'));
|
||||||
|
lookup.groupIds = [this.groupId];
|
||||||
|
|
||||||
|
this.breadcrumbService.addIdResolvedValue(this.groupId.toString(), "");
|
||||||
|
} else {
|
||||||
|
lookup.groupIds = null;
|
||||||
|
}
|
||||||
|
|
||||||
this.updateOrderUiFields(lookup.order);
|
this.updateOrderUiFields(lookup.order);
|
||||||
|
|
||||||
lookup.project = {
|
lookup.project = {
|
||||||
|
@ -522,4 +549,10 @@ export class PlanListingComponent extends BaseListingComponent<BasePlan, PlanLoo
|
||||||
[nameof<Plan>(x => x.planDescriptionTemplates), nameof<PlanDescriptionTemplate>(x => x.isActive)].join('.'),
|
[nameof<Plan>(x => x.planDescriptionTemplates), nameof<PlanDescriptionTemplate>(x => x.isActive)].join('.'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _getLatestVersion(plans: BasePlan[]): BasePlan {
|
||||||
|
const maxVersion: number = Math.max(...plans.map(p => p.version));
|
||||||
|
|
||||||
|
return plans.find(p => p.version == maxVersion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@ const routes: Routes = [
|
||||||
path: 'versions/:groupId',
|
path: 'versions/:groupId',
|
||||||
component: PlanListingComponent,
|
component: PlanListingComponent,
|
||||||
data: {
|
data: {
|
||||||
breadcrumb: true
|
breadcrumb: true,
|
||||||
|
mode: 'versions-listing'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue