Skip to content

Commit

Permalink
feat: Use open preview action from common attachment item component - E…
Browse files Browse the repository at this point in the history
…XO-64500 (#863)

Use open preview action from common attachment item component
  • Loading branch information
hakermi authored and azayati committed Aug 16, 2023
1 parent efdf55e commit 9d15422
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@
<div
v-for="attachedFile in attachments"
:key="attachedFile.id"
class="newsAttachment"
@click="openPreview(attachedFile)">
class="newsAttachment">
<exo-attachment-item :file="attachedFile" />
</div>
</div>
Expand Down Expand Up @@ -220,41 +219,6 @@ export default {
},
},
methods: {
openPreview(attachedFile) {
const self = this;
window.require(['SHARED/documentPreview'], function(documentPreview) {
documentPreview.init({
doc: {
id: attachedFile.id,
repository: 'repository',
workspace: 'collaboration',
title: attachedFile.name,
downloadUrl: `/portal/rest/v1/news/attachments/${attachedFile.id}/file`,
openUrl: `/portal/rest/v1/news/attachments/${attachedFile.id}/open`
},
showComments: false
});
self.hideDocPreviewComments();
});
},
/**
* Hack to hide the document preview comments panel because the document preview component
* does not allow to hide it through its API
* @returns {void} when the comments panel appeared and has been hidden
*/
hideDocPreviewComments() {
const intervalCheck = 100;
const commentsPanel = document.querySelector('.uiDocumentPreview .commentArea');
const collapsedCommentsButton = document.querySelector('.uiDocumentPreview .resizeButton');
if (commentsPanel != null && collapsedCommentsButton != null) {
commentsPanel.style.display = 'none';
collapsedCommentsButton.style.display = 'none';
document.querySelector('.uiDocumentPreview').classList += ' collapsed';
} else {
setTimeout(this.hideDocPreviewComments, intervalCheck);
}
},
targetBlank: function (content) {
const internal = location.host + eXo.env.portal.context;
const domParser = new DOMParser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
<div
v-for="attachedFile in attachments"
:key="attachedFile.id"
class="newsAttachment text-truncate"
@click="openPreview(attachedFile)">
class="newsAttachment text-truncate">
<exo-attachment-item :file="attachedFile" />
</div>
</div>
Expand Down Expand Up @@ -122,23 +121,6 @@ export default {
}
return docElement.innerHTML;
},
openPreview(attachedFile) {
const self = this;
window.require(['SHARED/documentPreview'], function(documentPreview) {
documentPreview.init({
doc: {
id: attachedFile.id,
repository: 'repository',
workspace: 'collaboration',
title: attachedFile.name,
downloadUrl: `/portal/rest/v1/news/attachments/${attachedFile.id}/file`,
openUrl: `/portal/rest/v1/news/attachments/${attachedFile.id}/open`
},
showComments: false
});
self.hideDocPreviewComments();
});
},
}
};
</script>

0 comments on commit 9d15422

Please sign in to comment.