refactor plan + public plan models, re-commit
This commit is contained in:
parent
71243d7fde
commit
af930d9c73
|
@ -1,4 +1,4 @@
|
|||
import { PublicReferenceType } from "../plan/plan";
|
||||
import { ReferenceType } from "../reference-type/reference-type";
|
||||
|
||||
export interface DashboardStatistics {
|
||||
planCount: number;
|
||||
|
@ -8,5 +8,5 @@ export interface DashboardStatistics {
|
|||
|
||||
export interface DashboardReferenceTypeStatistics {
|
||||
count: number;
|
||||
referenceType: PublicReferenceType
|
||||
referenceType: ReferenceType
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
import { BaseEntity } from "@common/base/base-entity.model";
|
||||
import { Reference } from "../reference/reference";
|
||||
import { Plan } from "./plan";
|
||||
import { BaseReference, Reference } from "../reference/reference";
|
||||
import { Plan, PublicPlan } from "./plan";
|
||||
import { Guid } from "@common/types/guid";
|
||||
|
||||
export interface PlanReference extends BaseEntity {
|
||||
plan?: Plan;
|
||||
reference?: Reference;
|
||||
data: PlanReferenceData;
|
||||
plan: Plan;
|
||||
reference: Reference;
|
||||
data?: PlanReferenceData;
|
||||
}
|
||||
|
||||
export interface PlanReferenceData {
|
||||
|
|
|
@ -15,29 +15,41 @@ import { IsActive } from '@app/core/common/enum/is-active.enum';
|
|||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||
import { EntityType } from '@app/core/common/enum/entity-type';
|
||||
|
||||
export interface Plan extends BasePlan {
|
||||
label?: string;
|
||||
export interface BasePlan extends BaseEntity {
|
||||
label?: string;
|
||||
version?: number;
|
||||
versionStatus?: PlanVersionStatus;
|
||||
properties?: PlanProperties;
|
||||
groupId?: String;
|
||||
description?: String;
|
||||
finalizedAt?: Date;
|
||||
publishedAt?: Date;
|
||||
creator?: User;
|
||||
finalizedAt?: Date;
|
||||
accessType?: PlanAccessType;
|
||||
planReferences?: PlanReference[];
|
||||
entityDois?: EntityDoi[];
|
||||
tenantId?: Guid;
|
||||
status?: PlanStatus;
|
||||
descriptions?: BaseDescription[];
|
||||
}
|
||||
export interface Plan extends BasePlan {
|
||||
versionStatus?: PlanVersionStatus;
|
||||
properties?: PlanProperties;
|
||||
creator?: User;
|
||||
blueprint?: PlanBlueprint;
|
||||
language?: String;
|
||||
publicAfter?: Date;
|
||||
planReferences?: PlanReference[];
|
||||
planUsers?: PlanUser[];
|
||||
descriptions?: Description[];
|
||||
planDescriptionTemplates?: PlanDescriptionTemplate[];
|
||||
entityDois?: EntityDoi[];
|
||||
otherPlanVersions?: Plan[];
|
||||
authorizationFlags?: AppPermission[];
|
||||
}
|
||||
|
||||
export interface PublicPlan extends BasePlan {
|
||||
planUsers: PublicPlanUser[];
|
||||
descriptions: PublicDescription[];
|
||||
otherPlanVersions?: PublicPlan[];
|
||||
}
|
||||
|
||||
|
||||
export interface PlanProperties {
|
||||
planBlueprintValues: PlanBlueprintValue[];
|
||||
contacts: PlanContact[];
|
||||
|
@ -56,14 +68,21 @@ export interface PlanContact {
|
|||
email: string;
|
||||
}
|
||||
|
||||
export interface BasePlanUser extends BaseEntity {
|
||||
user: User;
|
||||
role: PlanUserRole;
|
||||
}
|
||||
|
||||
export interface PlanUser extends BaseEntity {
|
||||
export interface PlanUser extends BasePlanUser {
|
||||
plan: Plan;
|
||||
user: User;
|
||||
role: PlanUserRole;
|
||||
sectionId: Guid;
|
||||
}
|
||||
|
||||
export interface PublicPlanUser extends BasePlanUser{
|
||||
plan: PublicPlan;
|
||||
}
|
||||
|
||||
|
||||
export interface PlanDescriptionTemplate extends BaseEntity {
|
||||
plan?: Plan;
|
||||
currentDescriptionTemplate?: DescriptionTemplate;
|
||||
|
@ -162,65 +181,3 @@ export interface PlanUserInvitePersist {
|
|||
//
|
||||
// Public
|
||||
//
|
||||
|
||||
export interface PublicPlan extends BasePlan {
|
||||
label?: string;
|
||||
version?: number;
|
||||
description?: string;
|
||||
finalizedAt?: Date;
|
||||
publishedAt?: Date;
|
||||
groupId?: String;
|
||||
accessType: PlanAccessType;
|
||||
planReferences: PublicPlanReference[];
|
||||
planUsers: PublicPlanUser[];
|
||||
descriptions: PublicDescription[];
|
||||
entityDois: PublicEntityDoi[];
|
||||
otherPlanVersions?: PublicPlan[];
|
||||
}
|
||||
|
||||
export interface PublicPlanReference {
|
||||
id: Guid;
|
||||
plan: PublicPlan;
|
||||
reference: PublicReference;
|
||||
isActive?: IsActive;
|
||||
}
|
||||
|
||||
export interface PublicReference {
|
||||
id: Guid;
|
||||
label: string;
|
||||
type: PublicReferenceType;
|
||||
description?: string;
|
||||
reference?: string;
|
||||
}
|
||||
|
||||
export interface PublicReferenceType {
|
||||
id: Guid;
|
||||
name: string;
|
||||
code: string;
|
||||
}
|
||||
|
||||
export interface PublicPlanUser {
|
||||
id: Guid;
|
||||
plan: PublicPlan;
|
||||
user: PublicUser;
|
||||
role: PlanUserRole;
|
||||
}
|
||||
|
||||
export interface PublicUser {
|
||||
id: Guid;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface PublicEntityDoi {
|
||||
id: Guid;
|
||||
entityType: EntityType;
|
||||
entityId: Guid;
|
||||
repositoryId: string;
|
||||
doi: string;
|
||||
}
|
||||
|
||||
export interface BasePlan extends BaseEntity {
|
||||
tenantId?: Guid;
|
||||
status?: PlanStatus;
|
||||
descriptions?: BaseDescription[];
|
||||
}
|
||||
|
|
|
@ -15,6 +15,14 @@ export interface Reference extends BaseEntity {
|
|||
sourceType: ReferenceSourceType;
|
||||
}
|
||||
|
||||
export interface BaseReference extends BaseEntity{
|
||||
label: string;
|
||||
type: ReferenceType;
|
||||
description?: string;
|
||||
reference?: string;
|
||||
}
|
||||
|
||||
|
||||
export interface Definition {
|
||||
fields: Field[];
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ import { RouterUtilsService } from '@app/core/services/router/router-utils.servi
|
|||
})
|
||||
export class PlanOverviewComponent extends BaseComponent implements OnInit {
|
||||
|
||||
plan: any | Plan | PublicPlan;
|
||||
plan: Plan | PublicPlan;
|
||||
selectedBlueprint: PlanBlueprint;
|
||||
researchers: PlanReference[] = [];
|
||||
isNew = true;
|
||||
|
@ -214,14 +214,14 @@ export class PlanOverviewComponent extends BaseComponent implements OnInit {
|
|||
}
|
||||
|
||||
get isActive(): boolean {
|
||||
return this.plan && this.plan.isActive === IsActive.Active;
|
||||
return this.plan?.isActive != IsActive.Inactive;
|
||||
}
|
||||
|
||||
get selectedPlanVersion(): number {
|
||||
return this.plan?.version;
|
||||
}
|
||||
|
||||
get otherPlanVersions(): Plan | PublicPlan{
|
||||
get otherPlanVersions(): Plan[] | PublicPlan[]{
|
||||
return this.plan?.otherPlanVersions;
|
||||
}
|
||||
|
||||
|
@ -257,53 +257,68 @@ export class PlanOverviewComponent extends BaseComponent implements OnInit {
|
|||
}
|
||||
|
||||
canEditPlan(): boolean {
|
||||
return (this.isDraftPlan()) && (this.plan.authorizationFlags?.some(x => x === AppPermission.EditPlan) || this.authentication.hasPermission(AppPermission.EditPlan)) && this.isPublicView == false && this.plan.belongsToCurrentTenant != false;
|
||||
const authorizationFlags = !this.isPublicView ? (this.plan as Plan).authorizationFlags : [];
|
||||
return (this.isDraftPlan()) && (authorizationFlags?.some(x => x === AppPermission.EditPlan) || this.authentication.hasPermission(AppPermission.EditPlan)) && this.isPublicView == false && this.plan.belongsToCurrentTenant != false;
|
||||
}
|
||||
|
||||
canCreateNewVersion(): boolean {
|
||||
return (this.plan.authorizationFlags?.some(x => x === AppPermission.CreateNewVersionPlan) || this.authentication.hasPermission(AppPermission.CreateNewVersionPlan)) && this.plan.versionStatus === PlanVersionStatus.Current && this.isPublicView == false && this.plan.belongsToCurrentTenant != false;
|
||||
const authorizationFlags = !this.isPublicView ? (this.plan as Plan).authorizationFlags : [];
|
||||
const versionStatus = !this.isPublicView ? (this.plan as Plan)?.versionStatus : null;
|
||||
return (authorizationFlags?.some(x => x === AppPermission.CreateNewVersionPlan) || this.authentication.hasPermission(AppPermission.CreateNewVersionPlan)) && versionStatus === PlanVersionStatus.Current && this.isPublicView == false && this.plan.belongsToCurrentTenant != false;
|
||||
}
|
||||
|
||||
canDeletePlan(): boolean {
|
||||
const authorizationFlags = !this.isPublicView ? (this.plan as Plan).authorizationFlags : [];
|
||||
return (
|
||||
this.isActive &&
|
||||
(this.plan.authorizationFlags?.some(x => x === AppPermission.DeletePlan) || this.authentication.hasPermission(AppPermission.DeletePlan))) &&
|
||||
this.isPublicView == false && this.plan.belongsToCurrentTenant != false;
|
||||
(authorizationFlags?.some(x => x === AppPermission.DeletePlan) || this.authentication.hasPermission(AppPermission.DeletePlan)) &&
|
||||
this.isPublicView == false && this.plan.belongsToCurrentTenant != false
|
||||
)
|
||||
}
|
||||
|
||||
canClonePlan(): boolean {
|
||||
return (this.plan.authorizationFlags?.some(x => x === AppPermission.ClonePlan) || this.authentication.hasPermission(AppPermission.ClonePlan) || (this.authentication.hasPermission(AppPermission.PublicClonePlan) && this.isPublicView));
|
||||
const authorizationFlags = !this.isPublicView ? (this.plan as Plan).authorizationFlags : [];
|
||||
return (
|
||||
authorizationFlags?.some(x => x === AppPermission.ClonePlan) ||
|
||||
this.authentication.hasPermission(AppPermission.ClonePlan) ||
|
||||
(this.authentication.hasPermission(AppPermission.PublicClonePlan) && this.isPublicView)
|
||||
);
|
||||
}
|
||||
|
||||
canFinalizePlan(): boolean {
|
||||
const authorizationFlags = !this.isPublicView ? (this.plan as Plan).authorizationFlags : [];
|
||||
return (
|
||||
this.isActive &&
|
||||
(this.plan.authorizationFlags?.some(x => x === AppPermission.FinalizePlan) || this.authentication.hasPermission(AppPermission.FinalizePlan))) &&
|
||||
(authorizationFlags?.some(x => x === AppPermission.FinalizePlan) || this.authentication.hasPermission(AppPermission.FinalizePlan))) &&
|
||||
this.isPublicView == false && this.plan.belongsToCurrentTenant != false;
|
||||
}
|
||||
|
||||
canExportPlan(): boolean {
|
||||
return (this.plan.authorizationFlags?.some(x => x === AppPermission.ExportPlan) || this.authentication.hasPermission(AppPermission.ExportPlan));
|
||||
const authorizationFlags = !this.isPublicView ? (this.plan as Plan).authorizationFlags : [];
|
||||
return (authorizationFlags?.some(x => x === AppPermission.ExportPlan) || this.authentication.hasPermission(AppPermission.ExportPlan));
|
||||
}
|
||||
|
||||
canInvitePlanUsers(): boolean {
|
||||
const authorizationFlags = !this.isPublicView ? (this.plan as Plan).authorizationFlags : [];
|
||||
return (
|
||||
this.isActive &&
|
||||
(this.plan.authorizationFlags?.some(x => x === AppPermission.InvitePlanUsers) || this.authentication.hasPermission(AppPermission.InvitePlanUsers))) &&
|
||||
(authorizationFlags?.some(x => x === AppPermission.InvitePlanUsers) || this.authentication.hasPermission(AppPermission.InvitePlanUsers))) &&
|
||||
this.isPublicView == false && this.plan.belongsToCurrentTenant != false;
|
||||
}
|
||||
|
||||
canAssignPlanUsers(): boolean {
|
||||
return (this.plan.authorizationFlags?.some(x => x === AppPermission.AssignPlanUsers) || this.authentication.hasPermission(AppPermission.AssignPlanUsers)) && this.isPublicView == false && this.plan.belongsToCurrentTenant != false;
|
||||
const authorizationFlags = !this.isPublicView ? (this.plan as Plan).authorizationFlags : [];
|
||||
return (authorizationFlags?.some(x => x === AppPermission.AssignPlanUsers) || this.authentication.hasPermission(AppPermission.AssignPlanUsers)) && this.isPublicView == false && this.plan.belongsToCurrentTenant != false;
|
||||
}
|
||||
|
||||
canDepositPlan(): boolean {
|
||||
return (this.plan.authorizationFlags?.some(x => x === AppPermission.DepositPlan) || this.authentication.hasPermission(AppPermission.DepositPlan)) && this.isPublicView == false && this.plan.belongsToCurrentTenant != false;
|
||||
const authorizationFlags = !this.isPublicView ? (this.plan as Plan).authorizationFlags : [];
|
||||
return (authorizationFlags?.some(x => x === AppPermission.DepositPlan) || this.authentication.hasPermission(AppPermission.DepositPlan)) && this.isPublicView == false && this.plan.belongsToCurrentTenant != false;
|
||||
}
|
||||
|
||||
|
||||
editClicked() {
|
||||
this.router.navigate([this.routerUtils.generateUrl(['/plans/edit', this.plan.id], '/')]);
|
||||
this.router.navigate([this.routerUtils.generateUrl(['/plans/edit', this.plan.id.toString()], '/')]);
|
||||
}
|
||||
|
||||
cloneClicked() {
|
||||
|
@ -588,8 +603,8 @@ export class PlanOverviewComponent extends BaseComponent implements OnInit {
|
|||
|
||||
getSectionNameById(sectionId: Guid): string {
|
||||
if (sectionId == null) return '';
|
||||
|
||||
let sections: PlanBlueprintDefinitionSection[] = this.plan?.blueprint?.definition?.sections?.filter((section: PlanBlueprintDefinitionSection) => sectionId === section.id);
|
||||
const blueprint = this.isPublicView ? null : (this.plan as Plan)?.blueprint;
|
||||
let sections: PlanBlueprintDefinitionSection[] = blueprint?.definition?.sections?.filter((section: PlanBlueprintDefinitionSection) => sectionId === section.id);
|
||||
|
||||
return sections == null ? '' : sections[0].label;
|
||||
}
|
||||
|
|
|
@ -332,7 +332,7 @@ export class PlanBlueprintValueEditorModel implements PlanBlueprintValuePersist
|
|||
this.fieldValue = item.fieldValue;
|
||||
this.dateValue = item.dateValue;
|
||||
this.numberValue = item.numberValue;
|
||||
const references = planReferences?.filter(x => x.data.blueprintFieldId == this.fieldId && x.isActive == IsActive.Active).map(x => {
|
||||
const references = planReferences?.filter(x => x.data?.blueprintFieldId == this.fieldId && x.isActive == IsActive.Active).map(x => {
|
||||
return {
|
||||
data: x.data,
|
||||
reference: {
|
||||
|
|
Loading…
Reference in New Issue