1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-25 08:09:43 +02:00

Allow content to contain links to network locations

This commit is contained in:
Harvey Kandola 2018-07-09 14:41:55 -04:00
parent 19736aab04
commit 4cfbd57871
13 changed files with 129 additions and 30 deletions

View file

@ -12,9 +12,10 @@
import { debounce } from '@ember/runloop';
import { computed, set } from '@ember/object';
import { inject as service } from '@ember/service';
import Component from '@ember/component';
import stringUtil from '../../utils/string';
import TooltipMixin from '../../mixins/tooltip';
import ModalMixin from '../../mixins/modal';
import Component from '@ember/component';
export default Component.extend(ModalMixin, TooltipMixin, {
link: service(),
@ -26,6 +27,8 @@ export default Component.extend(ModalMixin, TooltipMixin, {
showSections: computed('tab1Selected', function() { return this.get('tab1Selected'); }),
showAttachments: computed('tab2Selected', function() { return this.get('tab2Selected'); }),
showSearch: computed('tab3Selected', function() { return this.get('tab3Selected'); }),
showNetwork: computed('tab4Selected', function() { return this.get('tab4Selected'); }),
networkLocation: '',
keywords: '',
hasMatches: computed('matches', function () {
let m = this.get('matches');
@ -66,6 +69,8 @@ export default Component.extend(ModalMixin, TooltipMixin, {
didRender() {
this._super(...arguments);
this.$('#content-linker-networklocation').removeClass('is-invalid');
this.renderTooltips();
},
@ -114,7 +119,25 @@ export default Component.extend(ModalMixin, TooltipMixin, {
onInsertLink() {
let selection = this.get('selection');
if (this.get('tab4Selected')) {
let loc = this.get('networkLocation').trim();
let folderId = this.get('folder.id');
let documentId = this.get('document.id');
selection = {
context: '',
documentId: documentId,
folderId: folderId,
id: stringUtil.makeId(16),
linkType: 'network',
targetId: '',
externalId: loc,
title: loc
}
}
if (is.null(selection)) {
if (this.get('tab4Selected')) this.$('#content-linker-networklocation').addClass('is-invalid').focus();
return;
}
@ -125,6 +148,7 @@ export default Component.extend(ModalMixin, TooltipMixin, {
this.set('tab1Selected', id === 1);
this.set('tab2Selected', id === 2);
this.set('tab3Selected', id === 3);
this.set('tab4Selected', id === 4);
}
}
});

View file

@ -17,6 +17,10 @@ export default Component.extend({
classNames: ['layout-footer', 'non-printable'],
tagName: 'footer',
appMeta: service(),
showWait: false,
showDone: false,
showMessage: false,
message: '',
init() {
this._super(...arguments);
@ -40,5 +44,17 @@ export default Component.extend({
$('.progress-done').removeClass('zoomIn').addClass('zoomOut');
}, 3000);
}
if (msg !== 'done' && msg !== 'wait') {
$('.progress-notification').removeClass('zoomOut').addClass('zoomIn');
this.set('showWait', false);
this.set('showDone', false);
this.set('showMessage', true);
this.set('message', msg);
setTimeout(function() {
$('.progress-notification').removeClass('zoomIn').addClass('zoomOut');
}, 3000);
}
}
});

View file

@ -10,12 +10,14 @@
// https://documize.com
import Service, { inject as service } from '@ember/service';
import Notifier from '../mixins/notifier';
export default Service.extend({
export default Service.extend(Notifier, {
sessionService: service('session'),
ajax: service(),
appMeta: service(),
store: service(),
eventBus: service(),
// Returns links within specified document
getDocumentLinks(documentId) {
@ -67,6 +69,10 @@ export default Service.extend({
href = `${endpoint}/public/attachments/${orgId}/${link.targetId}`;
result = `<a data-documize='true' data-link-space-id='${link.folderId}' 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") {
href = `fileto://${link.externalId}`;
result = `<a data-documize='true' data-link-space-id='${link.folderId}' data-link-id='${link.id}' data-link-target-document-id='${link.documentId}' data-link-target-id='${link.targetId}' data-link-external-id='${link.externalId}' data-link-type='${link.linkType}' href='${href}'>${link.title}</a>`;
}
return result;
},
@ -78,11 +84,12 @@ export default Service.extend({
documentId: a.attributes["data-link-target-document-id"].value,
folderId: a.attributes["data-link-space-id"].value,
targetId: a.attributes["data-link-target-id"].value,
externalId: a.attributes["data-link-external-id"].value,
url: a.attributes["href"].value,
orphan: false
};
link.orphan = _.isEmpty(link.linkId) || _.isEmpty(link.documentId) || _.isEmpty(link.folderId) || _.isEmpty(link.targetId);
link.orphan = _.isEmpty(link.linkId) || _.isEmpty(link.documentId) || _.isEmpty(link.folderId) || (_.isEmpty(link.targetId) && _.isEmpty(link.externalId));
// we check latest state of link using database data
let existing = outboundLinks.findBy('id', link.linkId);
@ -126,5 +133,23 @@ export default Service.extend({
window.location.href = link.url;
return;
}
// handle network share/drive links
if (link.linkType === "network") {
// window.location.href = link.externalId;
const el = document.createElement('textarea');
el.value = link.externalId;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
this.showNotification('Copied location to clipboard');
return;
}
}
});

View file

@ -22,6 +22,7 @@ footer {
> .progress {
display: inline-block;
text-align: right;
> img {
padding: 0;
@ -40,4 +41,11 @@ footer {
width: 20px;
@include border-radius(20px);
}
> .progress-notification {
display: inline-block;
font-size: 1rem;
color: $color-green;
font-weight: 500;
}
}

View file

@ -3,15 +3,14 @@
<div class="modal-content">
<div class="modal-header">Insert Link</div>
<div class="modal-body">
<div class="container">
<div class="row">
<div class="col mt-3 mb-5">
<ul class="tabnav-control text-center">
<li class="tab {{if tab1Selected 'selected'}}" {{action 'onTabSelect' 1}}>Section</li>
<li class="tab {{if tab2Selected 'selected'}}" {{action 'onTabSelect' 2}}>Attachment</li>
<li class="tab {{if tab3Selected 'selected'}}" {{action 'onTabSelect' 3}}>Search</li>
<li class="tab {{if tab4Selected 'selected'}}" {{action 'onTabSelect' 4}}>Network</li>
</ul>
</div>
</div>
@ -98,8 +97,19 @@
</div>
{{/if}}
</div>
{{#if showNetwork}}
<div class="row">
<div class="col content-linker-modal-container">
<p>Specify network drive/share/folder location</p>
<div class="form-group">
{{focus-input id="content-linker-networklocation" type="input" class="form-control" value=networkLocation placeholder="e.g. //share/folder" autocomplete="off"}}
<small class="form-text text-muted"></small>
</div>
</div>
</div>
{{/if}}
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" {{action 'onCancel'}}>Cancel</button>

View file

@ -1,5 +1,11 @@
<div class="row no-gutters d-flex align-items-center">
<div class="col d-flex justify-content-start">
<div class="footer">
<a href="https://documize.com?ref=af">Documize {{appMeta.version}}</a>
</div>
{{yield}}
</div>
<div class="col d-flex justify-content-end">
<div class="footer">
{{#if showWait}}
<div class="progress progress-wait animated fadeIn">
@ -9,12 +15,9 @@
{{#if showDone}}
<div class="progress progress-done animated zoomIn">&check;</div>
{{/if}}
</div>
{{yield}}
</div>
<div class="col d-flex justify-content-end">
<div class="footer">
<a href="https://documize.com?ref=af">Documize {{appMeta.version}}</a>
{{#if showMessage}}
<div class="progress-notification animated zoomIn">{{message}}</div>
{{/if}}
</div>
</div>
</div>