mirror of
https://github.com/documize/community.git
synced 2025-08-02 03:55:24 +02:00
Improve attachment and link handling
This commit is contained in:
parent
6c07d2e569
commit
b6d9c54667
8 changed files with 762 additions and 740 deletions
|
@ -87,10 +87,10 @@ export default Component.extend(Modals, Notifier, {
|
|||
|
||||
// For authenticated users we send server auth token.
|
||||
let qry = '';
|
||||
if (this.get('session.authenticated')) {
|
||||
qry = '?token=' + this.get('session.authToken');
|
||||
} else {
|
||||
if (this.get('session.hasSecureToken')) {
|
||||
qry = '?secure=' + this.get('session.secureToken');
|
||||
} else if (this.get('session.authenticated')) {
|
||||
qry = '?token=' + this.get('session.authToken');
|
||||
}
|
||||
this.set('downloadQuery', qry);
|
||||
},
|
||||
|
|
|
@ -21,7 +21,7 @@ export default Component.extend(Notifier, {
|
|||
sectionService: service('section'),
|
||||
store: service(),
|
||||
appMeta: service(),
|
||||
link: service(),
|
||||
linkSvc: service('link'),
|
||||
hasPages: notEmpty('pages'),
|
||||
showInsertSectionModal: false,
|
||||
newSectionLocation: '',
|
||||
|
@ -40,24 +40,21 @@ export default Component.extend(Notifier, {
|
|||
this.set('showLikes', this.get('folder.allowLikes') && this.get('document.isLive'));
|
||||
},
|
||||
|
||||
didRender() {
|
||||
this._super(...arguments);
|
||||
this.contentLinkHandler();
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.jumpToSection(this.get('currentPageId'));
|
||||
|
||||
this.contentLinkHandler();
|
||||
},
|
||||
|
||||
contentLinkHandler() {
|
||||
let links = this.get('link');
|
||||
let linkSvc = this.get('linkSvc');
|
||||
let doc = this.get('document');
|
||||
let self = this;
|
||||
|
||||
$("a[data-documize='true']").off('click').on('click', function (e) {
|
||||
let link = links.getLinkObject(self.get('links'), this);
|
||||
let link = linkSvc.getLinkObject(self.get('links'), this);
|
||||
|
||||
// local link? exists?
|
||||
if ((link.linkType === "section" || link.linkType === "tab") && link.documentId === doc.get('id')) {
|
||||
|
@ -79,7 +76,10 @@ export default Component.extend(Notifier, {
|
|||
return false;
|
||||
}
|
||||
|
||||
links.linkClick(doc, link);
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
linkSvc.linkClick(doc, link);
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
|
|
@ -66,13 +66,7 @@ export default Service.extend(Notifier, {
|
|||
result = `<a data-documize='true' data-link-space-id='${link.spaceId}' data-link-id='${link.id}' data-link-target-document-id='${link.documentId}' data-link-target-id='${link.targetId}' data-link-type='${link.linkType}' href='${href}'>${link.title}</a>`;
|
||||
}
|
||||
if (link.linkType === "file") {
|
||||
// For authenticated users we send server auth token.
|
||||
let qry = '';
|
||||
if (this.get('session.authenticated')) {
|
||||
qry = '?token=' + this.get('session.authToken');
|
||||
}
|
||||
|
||||
href = `${endpoint}/public/attachment/${orgId}/${link.targetId}${qry}`;
|
||||
href = `${endpoint}/public/attachment/${orgId}/${link.targetId}`;
|
||||
result = `<a data-documize='true' data-link-space-id='${link.spaceId}' data-link-id='${link.id}' data-link-target-document-id='${link.documentId}' data-link-target-id='${link.targetId}' data-link-type='${link.linkType}' href='${href}'>${link.title}</a>`;
|
||||
}
|
||||
if (link.linkType === "network") {
|
||||
|
@ -136,8 +130,16 @@ export default Service.extend(Notifier, {
|
|||
|
||||
// handle attachment links
|
||||
if (link.linkType === "file") {
|
||||
// For authenticated users we send server auth token.
|
||||
let qry = '';
|
||||
if (this.get('session.hasSecureToken')) {
|
||||
qry = '?secure=' + this.get('session.secureToken');
|
||||
} else if (this.get('session.authenticated')) {
|
||||
qry = '?token=' + this.get('session.authToken');
|
||||
}
|
||||
|
||||
link.url = link.url.replace('attachments/', 'attachment/');
|
||||
window.location.href = link.url;
|
||||
window.location.href = link.url + qry;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,12 @@ export default SimpleAuthSession.extend({
|
|||
currentFolder: null,
|
||||
isMac: false,
|
||||
isMobile: false,
|
||||
|
||||
secureToken: '',
|
||||
hasSecureToken: computed('secureToken', function () {
|
||||
let st = this.get('secureToken');
|
||||
return is.not.null(st) && is.not.undefined(st) && st.length > 0;
|
||||
}),
|
||||
|
||||
hasAccounts: computed('isAuthenticated', 'session.content.authenticated.user', function () {
|
||||
return this.get('session.authenticator') !== 'authenticator:anonymous' && this.get('session.content.authenticated.user.accounts').length > 0;
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
{{ui/ui-spacer size=100}}
|
||||
{{/if}}
|
||||
|
||||
<div class="document-sidebar-toc">
|
||||
|
@ -27,7 +29,7 @@
|
|||
title={{item.page.title}}>
|
||||
<span class="numbering">{{item.page.numbering}}</span>
|
||||
{{#if (or item.userHasChangePending userHasNewPagePending)}}
|
||||
<span class="color-red-600" >[*] </span>
|
||||
<span class="color-red-600">[*] </span>
|
||||
{{#attach-tooltip showDelay=1000}}Pending changes{{/attach-tooltip}}
|
||||
{{/if}}
|
||||
{{#if (or permissions.documentApprove roles.documentApprove)}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue