Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions documents-webapp/src/main/webapp/js/DocumentsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ export function getEditorUrl(file, mode) {
return url;
}

export function openLink(url, target = '_blank') {
if (target === '_self') {
window.location.href = url;
return;
}
const link = document.createElement('a');
link.href = url;
link.target = target;
link.style.display = 'none';
document.body.appendChild(link);
link.click();
link.remove();
}

export function getViewType(appId) {
return localStorage.getItem(`documents-stored-view-type-${appId}`) || 'listView';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export default {
openFileInEditor(mode) {
if (this.attachment && this.attachment.id) {
const url = this.$documentsUtils.getEditorUrl(this.attachment,mode);
window.open(url, '_blank');
this.$documentsUtils.openLink(url, '_blank');
}
},
showInfo(event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default {
openFileInEditor(mode) {
if (this.attachment && this.attachmentId) {
const url = this.$documentsUtils.getEditorUrl(this.attachment,mode);
window.open(url,'_blank');
this.$documentsUtils.openLink(url,'_blank');
}
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ export default {
this.$root.$emit('alert-message', this.$t('attachments.upload.success'), 'success');
this.resetNewDocInput();
if (openInEditor) {
window.open(`${eXo.env.portal.context}/${eXo.env.portal.portalName}/oeditor?docId=${doc.id}&backTo=${window.location.pathname}`, '_blank');
this.$documentsUtils.openLink(`${eXo.env.portal.context}/${eXo.env.portal.portalName}/oeditor?docId=${doc.id}&backTo=${window.location.pathname}`, '_blank');
}
// Return to the level-1 attachments drawer (attachment host) or simply
// close the standalone drawer (drive host).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ export default {
openFileInEditor(mode) {
if (this.attachment && this.attachment.id) {
const url = this.$documentsUtils.getEditorUrl(this.attachment,mode);
window.open(url, '_blank');
this.$documentsUtils.openLink(url, '_blank');
}
},
openFile() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default {
openFileInEditor(mode) {
if (this.attachment && this.attachment.id) {
const url = this.$documentsUtils.getEditorUrl(this.attachment,mode);
window.open(url, '_blank');
this.$documentsUtils.openLink(url, '_blank');
}
},
showInfo(event) {
Expand Down
4 changes: 2 additions & 2 deletions documents-webapp/src/main/webapp/vue-app/attachment/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ export function init(entityId, entityType, defaultDrive, defaultFolder, spaceId)
},
openInEditMode(file) {
const fileId = file.sourceID ? file.sourceID : file.id;
window.open(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&backTo=${window.location.pathname}`, '_blank');
this.$documentsUtils.openLink(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&backTo=${window.location.pathname}`, '_blank');
},
openInReadOnlyMode(file) {
const fileId = file.sourceID ? file.sourceID : file.id;
window.open(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&mode=view&backTo=${window.location.pathname}`, '_blank');
this.$documentsUtils.openLink(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&mode=view&backTo=${window.location.pathname}`, '_blank');
},
},
template: `<attachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export default {
openDrive() {
const target = this.$root?.settings?.opensInSameTab ? '_self' : '_blank';
const url = this.$root?.settings?.driveUrl;
window.open(url, target);
this.$documentsUtils.openLink(url, target);
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ export function init(settings) {
},
openInEditMode(file) {
const fileId = file.sourceID ? file.sourceID : file.id;
window.open(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&backTo=${window.location.pathname}`, '_blank');
this.$documentsUtils.openLink(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&backTo=${window.location.pathname}`, '_blank');
},
openInReadOnlyMode(file) {
const fileId = file.sourceID ? file.sourceID : file.id;
window.open(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&mode=view&backTo=${window.location.pathname}`, '_blank');
this.$documentsUtils.openLink(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&mode=view&backTo=${window.location.pathname}`, '_blank');
},
},
template: `<document-list id="${settings?.id}" />`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ export default {
folderPath = `${eXo.env.portal.defaultPath}/dashboard/drive/${folderPath}`;
}
}
window.open(folderPath,'_self');
this.$documentsUtils.openLink(folderPath,'_self');
},
openPreview() {
if (this.file.folder) {
Expand Down Expand Up @@ -609,7 +609,7 @@ export default {
openFileInEditor(mode) {
if (this.file && this.fileId) {
const url = this.$documentsUtils.getEditorUrl(this.file,mode);
window.open(url,'_blank');
this.$documentsUtils.openLink(url,'_blank');
}
},
favoriteRemoved() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ export default {
openFileInEditor(attachment,mode,tab) {
if (attachment && attachment.id) {
const url = this.$documentsUtils.getEditorUrl(attachment,mode);
window.open(url,tab ? tab:'_blank');
this.$documentsUtils.openLink(url,tab ? tab:'_blank');
}
},
async dragFile(e){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
dense
link
class="ps-3"
@click.stop.prevent="handleClick">
:href="href"
:target="href && target"
@click.stop="handleClick">
<v-list-item-icon class="me-2">
<v-icon
:class="iconExtraClass"
Expand Down Expand Up @@ -87,10 +89,21 @@ export default {
isGroup: {
type: Boolean,
default: false
}
},
href: {
type: String,
default: null
},
target: {
type: String,
default: '_blank'
},
},
methods: {
handleClick() {
handleClick(event) {
if (!this.href) {
event.preventDefault();
}
this.$emit('click');
if (!this.isGroup) {
this.$root.$emit('close-action-context-menu');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<document-action-item
icon="fas fa-edit"
:label="$t('document.label.edit')"
@click="editFile" />
:href="editLink"
target="_blank" />
</template>
<script>
export default {
Expand All @@ -20,12 +21,8 @@ export default {
fileId() {
return this.file && this.file.sourceID || this.file.id;
},
},
methods: {
editFile() {
if (this.fileId) {
window.open(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${this.fileId}&backTo=${window.location.pathname}`, '_blank');
}
editLink() {
return this.fileId && `${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${this.fileId}&backTo=${window.location.pathname}` || null;
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<document-action-item
icon="fab fa-readme"
:label="$t('document.label.open.read.only')"
@click="openReadOnlyFile" />
:href="readOnlyLink"
target="_blank" />
</template>
<script>
export default {
Expand All @@ -20,12 +21,8 @@ export default {
fileId() {
return this.file && this.file.sourceID || this.file.id;
},
},
methods: {
openReadOnlyFile() {
if (this.fileId) {
window.open(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${this.fileId}&mode=view&backTo=${window.location.pathname}`, '_blank');
}
readOnlyLink() {
return this.fileId && `${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${this.fileId}&mode=view&backTo=${window.location.pathname}` || null;
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,11 @@ export default {
},
openInEditMode(file) {
const fileId = file.sourceID? file.sourceID: file.id;
window.open(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&backTo=${window.location.pathname}`, '_blank');
this.$documentsUtils.openLink(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&backTo=${window.location.pathname}`, '_blank');
},
openInReadOnlyMode(file) {
const fileId = file.sourceID? file.sourceID: file.id;
window.open(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&mode=view&backTo=${window.location.pathname}`, '_blank');
this.$documentsUtils.openLink(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&mode=view&backTo=${window.location.pathname}`, '_blank');
},
openPreview() {
this.loading = true;
Expand Down
4 changes: 2 additions & 2 deletions documents-webapp/src/main/webapp/vue-app/documents/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ export async function init(appId, canEdit, settings, settingsSaveUrl) {
},
openInEditMode(file) {
const fileId = file.sourceID ? file.sourceID : file.id;
window.open(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&backTo=${window.location.pathname}`, '_blank');
this.$documentsUtils.openLink(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&backTo=${window.location.pathname}`, '_blank');
},
openInReadOnlyMode(file) {
const fileId = file.sourceID ? file.sourceID : file.id;
window.open(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&mode=view&backTo=${window.location.pathname}`, '_blank');
this.$documentsUtils.openLink(`${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/oeditor?docId=${fileId}&mode=view&backTo=${window.location.pathname}`, '_blank');
},
},
template: `<documents-main id="${appId}" />`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ export default {
openFilePreview() {
this.result.path = this.result.nodePath;
if (this.isFileEditable) {
window.open(this.$documentsUtils.getEditorUrl(this.result,''), '_blank');
this.$documentsUtils.openLink(this.$documentsUtils.getEditorUrl(this.result,''), '_blank');
} else if (this.isFileReadable) {
window.open(this.$documentsUtils.getEditorUrl(this.result,'view'), '_blank');
this.$documentsUtils.openLink(this.$documentsUtils.getEditorUrl(this.result,'view'), '_blank');
} else {
const file = {
'id': this.fileId,
Expand Down
Loading