OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Create bcf issue if not exists
Oliver Günthera9812a1d9505
diff --git a/frontend/src/app/components/work-packages/wp-single-view/wp-single-view.component.ts b/frontend/src/app/components/work-packages/wp-single-view/wp-single-view.component.tsindex 6e09fcdb9d9..550224d17ad 100644--- a/frontend/src/app/components/work-packages/wp-single-view/wp-single-view.component.ts+++ b/frontend/src/app/components/work-packages/wp-single-view/wp-single-view.component.ts@@ -27,14 +27,15 @@// ++import {- ChangeDetectionStrategy, ChangeDetectorRef,+ ChangeDetectionStrategy,+ ChangeDetectorRef,Component,ElementRef,- Inject,Injector,Input,OnDestroy,- OnInit+ OnInit,+ Optional} from '@angular/core';import {I18nService} from 'core-app/modules/common/i18n/i18n.service';import {PathHelperService} from 'core-app/modules/common/path-helper/path-helper.service';@@ -47,7 +48,6 @@ import {WorkPackageResource} from 'core-app/modules/hal/resources/work-package-rimport {HalResourceEditingService} from "core-app/modules/fields/edit/services/hal-resource-editing.service";import {WorkPackageCacheService} from '../work-package-cache.service';-import {input, InputState} from 'reactivestates';import {DisplayFieldService} from 'core-app/modules/fields/display/display-field.service';import {DisplayField} from 'core-app/modules/fields/display/display-field.module';import {QueryResource} from 'core-app/modules/hal/resources/query-resource';@@ -58,6 +58,7 @@ import {randomString} from "core-app/helpers/random-string";import {BrowserDetector} from "core-app/modules/common/browser/browser-detector.service";import {PortalCleanupService} from "core-app/modules/fields/display/display-portal/portal-cleanup.service";import {HalResourceService} from "core-app/modules/hal/services/hal-resource.service";+import {ViewerBridgeService} from "core-app/modules/bim/bcf/bcf-viewer-bridge/viewer-bridge.service";export interface FieldDescriptor {name:string;@@ -149,7 +150,8 @@ export class WorkPackageSingleViewComponent implements OnInit, OnDestroy {protected cdRef:ChangeDetectorRef,readonly elementRef:ElementRef,readonly cleanupService:PortalCleanupService,- readonly browserDetector:BrowserDetector) {+ readonly browserDetector:BrowserDetector,+ @Optional() readonly viewerBridge:ViewerBridgeService) {}public ngOnInit() {@@ -192,7 +194,7 @@ export class WorkPackageSingleViewComponent implements OnInit, OnDestroy {const resource = change.projectedResource;if (!resource.project) {- this.projectContext = {matches: false, href: null};+ this.projectContext = { matches: false, href: null };} else {this.projectContext = {href: this.PathHelper.projectWorkPackagePath(resource.project.idFromLink, this.workPackage.id!),diff --git a/frontend/src/app/components/work-packages/wp-single-view/wp-single-view.html b/frontend/src/app/components/work-packages/wp-single-view/wp-single-view.htmlindex 628ddab8780..bdff98445bc 100644--- a/frontend/src/app/components/work-packages/wp-single-view/wp-single-view.html+++ b/frontend/src/app/components/work-packages/wp-single-view/wp-single-view.html@@ -71,9 +71,8 @@</div></div>- <div *ngIf="workPackage.bcfTopic">- <bcf-wp-single-view [workPackage]="workPackage"></bcf-wp-single-view>- </div>+ <bcf-wp-single-view *ngIf="workPackage.bcfTopic || !!viewerBridge"+ [workPackage]="workPackage"></bcf-wp-single-view><div class="attributes-group description-group"><div class="attributes-group--header">diff --git a/frontend/src/app/modules/bim/bcf/api/projects/bcf-project.paths.ts b/frontend/src/app/modules/bim/bcf/api/projects/bcf-project.paths.tsindex 18efb6b78d0..0c35a419d1d 100644--- a/frontend/src/app/modules/bim/bcf/api/projects/bcf-project.paths.ts+++ b/frontend/src/app/modules/bim/bcf/api/projects/bcf-project.paths.ts@@ -1,14 +1,14 @@-import {BcfResourceCollectionPath, BcfResourcePath} from "core-app/modules/bim/bcf/api/bcf-path-resources";-import {BcfTopicPaths} from "core-app/modules/bim/bcf/api/topics/bcf-topic.paths";+import {BcfResourcePath} from "core-app/modules/bim/bcf/api/bcf-path-resources";import {BcfApiRequestService} from "core-app/modules/bim/bcf/api/bcf-api-request.service";import {BcfProjectResource} from "core-app/modules/bim/bcf/api/projects/bcf-project.resource";import {HTTPClientHeaders, HTTPClientParamMap} from "core-app/modules/hal/http/http.interfaces";+import {BcfTopicCollectionPath} from "core-app/modules/bim/bcf/api/topics/bcf-viewpoint-collection.paths";export class BcfProjectPaths extends BcfResourcePath {readonly bcfProjectService = new BcfApiRequestService(this.injector, BcfProjectResource);/** /topics */- public readonly topics = new BcfResourceCollectionPath(this.injector, this.path, 'topics', BcfTopicPaths);+ public readonly topics = new BcfTopicCollectionPath(this.injector, this.path, 'topics');get(params:HTTPClientParamMap = {}, headers:HTTPClientHeaders = {}) {return this.bcfProjectService.get(this.toPath(), params, headers);diff --git a/frontend/src/app/modules/bim/bcf/api/topics/bcf-viewpoint-collection.paths.ts b/frontend/src/app/modules/bim/bcf/api/topics/bcf-viewpoint-collection.paths.tsnew file mode 100644index 00000000000..6bca6cc5ba1--- /dev/null+++ b/frontend/src/app/modules/bim/bcf/api/topics/bcf-viewpoint-collection.paths.ts@@ -0,0 +1,34 @@+import {BcfResourceCollectionPath} from "core-app/modules/bim/bcf/api/bcf-path-resources";+import {BcfApiRequestService} from "core-app/modules/bim/bcf/api/bcf-api-request.service";+import {HTTPClientHeaders, HTTPClientParamMap} from "core-app/modules/hal/http/http.interfaces";+import {Observable} from "rxjs";+import {BcfTopicPaths} from "core-app/modules/bim/bcf/api/topics/bcf-topic.paths";+import {Injector} from "@angular/core";+import {BcfTopicResource} from "core-app/modules/bim/bcf/api/topics/bcf-topic.resource";++export class BcfTopicCollectionPath extends BcfResourceCollectionPath<BcfTopicPaths> {+ readonly bcfTopicService = new BcfApiRequestService<BcfTopicResource>(this.injector, BcfTopicResource);++ constructor(readonly injector:Injector,+ protected basePath:string,+ segment:string) {+ super(injector, basePath, segment, BcfTopicPaths);+ }++ get(params:HTTPClientParamMap = {}, headers:HTTPClientHeaders = {}) {+ throw new Error("Not implemented");+ }++ /**+ * Create a topic from its to-be-associated work package+ */+ post(payload:any):Observable<BcfTopicResource> {+ return this+ .bcfTopicService+ .request(+ 'post',+ this.toPath(),+ payload+ );+ }+}\ No newline at end of filediff --git a/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.html b/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.htmlindex f7ba4c0cc3a..02926a9b3c7 100644--- a/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.html+++ b/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.html@@ -6,7 +6,7 @@</div></div>- <div class="bcf--viewpoints">+ <div class="bcf--viewpoints" *ngIf="galleryImages.length > 0"><ngx-gallery [options]="galleryOptions"[images]="galleryImages"(previewOpen)="galleryPreviewOpen()"diff --git a/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.ts b/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.tsindex c7bacb6b0c6..f218030a0c2 100644--- a/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.ts+++ b/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.ts@@ -9,9 +9,9 @@ import {BcfViewpointPaths} from "core-app/modules/bim/bcf/api/viewpoints/bcf-vieimport {CurrentProjectService} from "core-components/projects/current-project.service";import {I18nService} from "core-app/modules/common/i18n/i18n.service";import {ViewerBridgeService} from "core-app/modules/bim/bcf/bcf-viewer-bridge/viewer-bridge.service";+import {WorkPackageCacheService} from "core-components/work-packages/work-package-cache.service";-export type ViewPointOriginal = { uuid:string, snapshot_id:string, snapshot_file_name:string };-export type ViewPoint = { snapshotId:string, snapshotFileName?:string, snapshotFullPath:string };+export type ViewPoint = { snapshotId:string, snapshotFullPath:string };@Component({selector: 'bcf-wp-single-view',@@ -84,8 +84,6 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {viewpoints:ViewPoint[];- topicUUID:string;-text = {bcf: this.I18n.t('js.bcf.label_bcf'),viewpoint: this.I18n.t('js.bcf.viewpoint'),@@ -97,19 +95,16 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {readonly currentProject:CurrentProjectService,readonly bcfApi:BcfApiService,readonly viewerBridge:ViewerBridgeService,+ readonly wpCache:WorkPackageCacheService,readonly I18n:I18nService) {}ngOnInit():void {- const topicHref = this.workPackage.bcfTopic.href;- this.topicUUID = this.bcfApi.parse(topicHref)!.id as string;-- this.viewpoints = this.workPackage.bcfViewpoints.map((vp:HalLink) => {+ this.viewpoints = (this.workPackage.bcfViewpoints || []).map((vp:HalLink) => {const viewpointResource = this.bcfApi.parse(vp.href!) as BcfViewpointPaths;return {snapshotId: viewpointResource.id,- /* snapshotFileName: vp.snapshot_file_name, TODO NEEDED? */snapshotFullPath: `${vp.href}/snapshot`} as ViewPoint;});@@ -135,7 +130,7 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {this.bcfApi.projects.id(this.workPackage.project.idFromLink)- .topics.id(this.topicUUID)+ .topics.id(this.topicUUID!).viewpoints.id(viewpointUuid).get().subscribe(data => {@@ -145,14 +140,16 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {async saveCurrentAsViewpoint() {const viewpoint = await this.viewerBridge.getViewpoint();+ const uuid = this.topicUUID || await this.createBcfTopic();this.bcfApi.projects.id(this.workPackage.project.idFromLink)- .topics.id(this.topicUUID)+ .topics.id(uuid).viewpoints.post(viewpoint).subscribe((result) => {- console.log(result);+ // Update the work package to reload the viewpoint+ this.wpCache.require(this.workPackage.id!, true);});}@@ -163,4 +160,23 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {galleryPreviewClose():void {jQuery('#top-menu')[0].style.zIndex = '';}++ private get topicUUID():string|null {+ const topicHref:string|undefined = this.workPackage.bcfTopic?.href;++ if (topicHref) {+ return this.bcfApi.parse(topicHref)!.id as string;+ }++ return null;+ }++ private async createBcfTopic():Promise<string> {+ return this.bcfApi+ .projects.id(this.workPackage.project.idFromLink)+ .topics+ .post(this.workPackage.convertBCF.payload)+ .toPromise()+ .then(resource => resource.guid);+ }}