From a9b278af18c35b70b791e8f3d9425fd8f29a1130 Mon Sep 17 00:00:00 2001 From: Adina Parpalita Date: Mon, 16 Mar 2020 07:18:52 -0700 Subject: [PATCH] fix for [MNT-21394] Edit in Microsoft Office opens MS Excel documents then immediately prompts that a newer version exists (#1363) --- .../src/lib/services/content-api.service.ts | 2 +- .../src/lib/aos-extension.service.ts | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/projects/aca-shared/src/lib/services/content-api.service.ts b/projects/aca-shared/src/lib/services/content-api.service.ts index e080f8fbd..c1d68b3c5 100644 --- a/projects/aca-shared/src/lib/services/content-api.service.ts +++ b/projects/aca-shared/src/lib/services/content-api.service.ts @@ -84,7 +84,7 @@ export class ContentApiService { getNodeInfo(nodeId: string, options?: any): Observable { const defaults = { - include: ['isFavorite', 'allowableOperations'] + include: ['isFavorite', 'allowableOperations', 'path'] }; const queryOptions = Object.assign(defaults, options || {}); diff --git a/projects/adf-office-services-ext/src/lib/aos-extension.service.ts b/projects/adf-office-services-ext/src/lib/aos-extension.service.ts index dbc75f64d..df770bbae 100644 --- a/projects/adf-office-services-ext/src/lib/aos-extension.service.ts +++ b/projects/adf-office-services-ext/src/lib/aos-extension.service.ts @@ -92,9 +92,27 @@ export class AosEditOnlineService { private triggerEditOnlineAos(node: MinimalNodeEntryEntity): void { const aosHost = this.appConfigService.get('aosHost'); - const url = `${aosHost}/_aos_nodeid/${this.getNodeId( - node - )}/${encodeURIComponent(node.name)}`; + let url: string; + const pathElements = (node.path.elements || []).map( + segment => segment.name + ); + + if (!pathElements.length) { + url = `${aosHost}/Company Home/_aos_nodeid/${this.getNodeId( + node + )}/${encodeURIComponent(node.name)}`; + } + + if (pathElements.length === 1) { + url = `${aosHost}/${encodeURIComponent(node.name)}`; + } + + if (pathElements.length > 1) { + const root = pathElements[1]; + url = `${aosHost}/${root}/_aos_nodeid/${this.getNodeId( + node + )}/${encodeURIComponent(node.name)}`; + } const fileExtension = getFileExtension(node.name); const protocolHandler = this.getProtocolForFileExtension(fileExtension);