From c80cf9bdd28293544e609bf9cfd7580bb86f8cb4 Mon Sep 17 00:00:00 2001 From: Cilibiu Bogdan Date: Tue, 17 Mar 2020 08:37:47 +0200 Subject: [PATCH] MNT-21394 Edit in Microsoft Office opens MS Excel documents then immediately prompts that a newer version exists (#1355) * aos path * node info allowableOperations and path * fallback when path elements are not defined * fallback for no path * fix tests * call default optionals params * node info include path --- .../src/lib/services/content-api.service.ts | 2 +- .../src/lib/aos-extension.service.ts | 25 ++++++++++++++++--- 2 files changed, 23 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..883b0cbc4 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,28 @@ 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);