mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
import and new doc functionality moved
This commit is contained in:
parent
10afc1c5dc
commit
183eb92d53
9 changed files with 117 additions and 137 deletions
|
@ -18,36 +18,24 @@ const {
|
|||
} = Ember;
|
||||
|
||||
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||
folderService: Ember.inject.service('folder'),
|
||||
documentService: Ember.inject.service('document'),
|
||||
templateService: Ember.inject.service('template'),
|
||||
folderService: Ember.inject.service('folder'),
|
||||
session: Ember.inject.service(),
|
||||
appMeta: Ember.inject.service(),
|
||||
|
||||
showToolbar: false,
|
||||
folder: {},
|
||||
busy: false,
|
||||
importedDocuments: [],
|
||||
savedTemplates: [],
|
||||
isFolderOwner: computed.equal('folder.userId', 'session.user.id'),
|
||||
moveFolderId: "",
|
||||
|
||||
didReceiveAttrs() {
|
||||
let self = this;
|
||||
|
||||
this.set('isFolderOwner', this.get('folder.userId') === this.get("session.user.id"));
|
||||
|
||||
let show = this.get('isFolderOwner') || this.get('hasSelectedDocuments') || this.get('folderService').get('canEditCurrentFolder');
|
||||
this.set('showToolbar', show);
|
||||
|
||||
this.get('templateService').getSavedTemplates().then(function(saved) {
|
||||
let emptyTemplate = {
|
||||
id: "0",
|
||||
title: "Empty document",
|
||||
selected: true
|
||||
};
|
||||
saved.unshiftObject(emptyTemplate);
|
||||
self.set('savedTemplates', saved);
|
||||
});
|
||||
|
||||
let targets = _.reject(this.get('folders'), {
|
||||
id: this.get('folder').get('id')
|
||||
});
|
||||
|
@ -66,34 +54,61 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
|||
}
|
||||
if (this.get('folderService').get('canEditCurrentFolder')) {
|
||||
this.addTooltip(document.getElementById("import-document-button"));
|
||||
this.addTooltip(document.getElementById("start-document-button"));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
let self = this;
|
||||
let folderId = this.get('folder.id');
|
||||
let url = this.get('appMeta.endpoint');
|
||||
let importUrl = `${url}/import/folder/${folderId}`;
|
||||
|
||||
Dropzone.options.uploadDocuments = false;
|
||||
|
||||
let dzone = new Dropzone("#import-document-button", {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + self.get('session.session.content.authenticated.token')
|
||||
},
|
||||
url: importUrl,
|
||||
method: "post",
|
||||
paramName: 'attachment',
|
||||
acceptedFiles: ".doc,.docx,.txt,.md,.markdown",
|
||||
clickable: true,
|
||||
maxFilesize: 10,
|
||||
parallelUploads: 3,
|
||||
uploadMultiple: false,
|
||||
addRemoveLinks: false,
|
||||
autoProcessQueue: true,
|
||||
|
||||
init: function () {
|
||||
this.on("success", function (document) {
|
||||
self.send('onDocumentImported', document.name, document);
|
||||
});
|
||||
|
||||
this.on("error", function (x) {
|
||||
console.log("Conversion failed for ", x.name, " obj ", x); // TODO proper error handling
|
||||
});
|
||||
|
||||
this.on("queuecomplete", function () {});
|
||||
|
||||
this.on("addedfile", function (file) {
|
||||
self.send('onDocumentImporting', file.name);
|
||||
self.audit.record('converted-document');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
dzone.on("complete", function (file) {
|
||||
dzone.removeFile(file);
|
||||
});
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this.destroyTooltips();
|
||||
},
|
||||
|
||||
navigateToDocument(document) {
|
||||
this.attrs.showDocument(this.get('folder'), document);
|
||||
},
|
||||
|
||||
actions: {
|
||||
onEditTemplate(template) {
|
||||
this.navigateToDocument(template);
|
||||
},
|
||||
|
||||
onDocumentTemplate(id /*, title, type*/ ) {
|
||||
let self = this;
|
||||
|
||||
this.send("showNotification", "Creating");
|
||||
|
||||
this.get('templateService').importSavedTemplate(this.folder.get('id'), id).then(function(document) {
|
||||
self.navigateToDocument(document);
|
||||
});
|
||||
},
|
||||
|
||||
onDocumentImporting(filename) {
|
||||
this.send("showNotification", `Importing ${filename}`);
|
||||
|
||||
|
|
|
@ -12,18 +12,43 @@
|
|||
import Ember from 'ember';
|
||||
import constants from '../../utils/constants';
|
||||
import TooltipMixin from '../../mixins/tooltip';
|
||||
import NotifierMixin from '../../mixins/notifier';
|
||||
|
||||
export default Ember.Component.extend(TooltipMixin, {
|
||||
export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
|
||||
folderService: Ember.inject.service('folder'),
|
||||
templateService: Ember.inject.service('template'),
|
||||
publicFolders: [],
|
||||
protectedFolders: [],
|
||||
privateFolders: [],
|
||||
savedTemplates: [],
|
||||
hasPublicFolders: false,
|
||||
hasProtectedFolders: false,
|
||||
hasPrivateFolders: false,
|
||||
newFolder: "",
|
||||
showScrollTool: false,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
let _this = this;
|
||||
this.get('templateService').getSavedTemplates().then(function(saved) {
|
||||
let emptyTemplate = {
|
||||
id: "0",
|
||||
title: "Empty document",
|
||||
selected: true
|
||||
};
|
||||
|
||||
saved.unshiftObject(emptyTemplate);
|
||||
_this.set('savedTemplates', saved);
|
||||
});
|
||||
},
|
||||
|
||||
didRender() {
|
||||
if (this.get('folderService').get('canEditCurrentFolder')) {
|
||||
this.addTooltip(document.getElementById("start-document-button"));
|
||||
}
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
|
@ -88,7 +113,19 @@ export default Ember.Component.extend(TooltipMixin, {
|
|||
}
|
||||
},
|
||||
|
||||
navigateToDocument(document) {
|
||||
this.attrs.showDocument(this.get('folder'), document);
|
||||
},
|
||||
|
||||
actions: {
|
||||
scrollTop() {
|
||||
this.set('showScrollTool', false);
|
||||
|
||||
$("html,body").animate({
|
||||
scrollTop: 0
|
||||
}, 500, "linear");
|
||||
},
|
||||
|
||||
addFolder() {
|
||||
var folderName = this.get('newFolder');
|
||||
|
||||
|
@ -103,12 +140,18 @@ export default Ember.Component.extend(TooltipMixin, {
|
|||
return true;
|
||||
},
|
||||
|
||||
scrollTop() {
|
||||
this.set('showScrollTool', false);
|
||||
onEditTemplate(template) {
|
||||
this.navigateToDocument(template);
|
||||
},
|
||||
|
||||
$("html,body").animate({
|
||||
scrollTop: 0
|
||||
}, 500, "linear");
|
||||
}
|
||||
onDocumentTemplate(id /*, title, type*/ ) {
|
||||
let self = this;
|
||||
|
||||
this.send("showNotification", "Creating");
|
||||
|
||||
this.get('templateService').importSavedTemplate(this.folder.get('id'), id).then(function(document) {
|
||||
self.navigateToDocument(document);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,20 +19,11 @@ export default Ember.Component.extend(NotifierMixin, {
|
|||
id: "0"
|
||||
},
|
||||
canEditTemplate: "",
|
||||
drop: null,
|
||||
appMeta: Ember.inject.service(),
|
||||
|
||||
didReceiveAttrs() {
|
||||
this.send('setTemplate', this.get('savedTemplates')[0]);
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
if (is.not.null(this.get('drop'))) {
|
||||
this.get('drop').destroy();
|
||||
this.set('drop', null);
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
setTemplate(chosen) {
|
||||
if (is.undefined(chosen)) {
|
||||
|
@ -51,7 +42,6 @@ export default Ember.Component.extend(NotifierMixin, {
|
|||
|
||||
editTemplate() {
|
||||
let template = this.get('selectedTemplate');
|
||||
|
||||
this.audit.record('edited-saved-template');
|
||||
this.attrs.onEditTemplate(template);
|
||||
|
||||
|
@ -60,62 +50,10 @@ export default Ember.Component.extend(NotifierMixin, {
|
|||
|
||||
startDocument() {
|
||||
let template = this.get('selectedTemplate');
|
||||
|
||||
this.audit.record('used-saved-template');
|
||||
this.attrs.onDocumentTemplate(template.id, template.title, "private");
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
onOpenCallback() {
|
||||
if (is.not.null(this.get('drop'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
let self = this;
|
||||
let folderId = this.get('folder.id');
|
||||
let url = this.get('appMeta.endpoint');
|
||||
let importUrl = `${url}/import/folder/${folderId}`;
|
||||
|
||||
Dropzone.options.uploadDocuments = false;
|
||||
|
||||
let dzone = new Dropzone("#upload-documents", {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + self.get('session.session.content.authenticated.token')
|
||||
},
|
||||
url: importUrl,
|
||||
method: "post",
|
||||
paramName: 'attachment',
|
||||
acceptedFiles: ".doc,.docx,.txt,.md,.markdown",
|
||||
clickable: true,
|
||||
maxFilesize: 10,
|
||||
parallelUploads: 3,
|
||||
uploadMultiple: false,
|
||||
addRemoveLinks: false,
|
||||
autoProcessQueue: true,
|
||||
|
||||
init: function () {
|
||||
this.on("success", function (document) {
|
||||
self.attrs.onDocumentImported(document.name, document);
|
||||
});
|
||||
|
||||
this.on("error", function (x) {
|
||||
console.log("Conversion failed for ", x.name, " obj ", x); // TODO proper error handling
|
||||
});
|
||||
|
||||
this.on("queuecomplete", function () {});
|
||||
|
||||
this.on("addedfile", function (file) {
|
||||
self.attrs.onDocumentImporting(file.name);
|
||||
self.audit.record('converted-document');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
dzone.on("complete", function (file) {
|
||||
dzone.removeFile(file);
|
||||
});
|
||||
|
||||
this.set('drop', dzone);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
{{layout/zone-navigation}}
|
||||
|
||||
{{#layout/zone-sidebar}}
|
||||
{{folder/folders-list folders=model.folders folder=model.folder onFolderAdd=(action 'onFolderAdd')}}
|
||||
{{folder/folders-list folders=model.folders folder=model.folder
|
||||
onFolderAdd=(action 'onFolderAdd')
|
||||
showDocument=(action 'showDocument')}}
|
||||
{{/layout/zone-sidebar}}
|
||||
|
||||
{{#layout/zone-content}}
|
||||
|
@ -13,8 +15,7 @@
|
|||
hasSelectedDocuments=hasSelectedDocuments
|
||||
refresh=(action 'refresh')
|
||||
onDeleteDocument=(action 'onDeleteDocument')
|
||||
onMoveDocument=(action 'onMoveDocument')
|
||||
showDocument=(action 'showDocument')}}
|
||||
onMoveDocument=(action 'onMoveDocument')}}
|
||||
|
||||
{{folder/documents-list documents=model.documents folder=model.folder isFolderOwner=isFolderOwner onDocumentsChecked=(action 'onDocumentsChecked') }}
|
||||
{{/layout/zone-content}}
|
||||
|
|
|
@ -173,11 +173,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.upload-container {
|
||||
text-align: center;
|
||||
margin: 2rem 0;
|
||||
}
|
||||
|
||||
.no-documents {
|
||||
margin-top: 50px;
|
||||
text-align: center;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
{{/if}}
|
||||
|
||||
{{#if isEditor}}
|
||||
<div {{action 'showSections'}} id="section-tool" class="round-button round-button-mono button-white section-tool" data-tooltip="Add content" data-tooltip-position="top center">
|
||||
<div {{action 'showSections'}} id="section-tool" class="round-button round-button-mono button-white section-tool" data-tooltip="Content" data-tooltip-position="top center">
|
||||
<i class="material-icons color-green">add</i>
|
||||
</div>
|
||||
{{#if showingSections}}
|
||||
|
|
|
@ -46,19 +46,6 @@
|
|||
<div class="round-button-mono" id="import-document-button" data-tooltip="Import Word / Markdown" data-tooltip-position="top center">
|
||||
<i class="material-icons color-gray">file_upload</i>
|
||||
</div>
|
||||
<div class="button-gap"></div>
|
||||
<div class="round-button button-green" id="start-document-button" data-tooltip="New..." data-tooltip-position="top center">
|
||||
<i class="material-icons">add</i>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if folderService.canEditCurrentFolder}}
|
||||
{{folder/start-document
|
||||
savedTemplates=savedTemplates
|
||||
folder=folder
|
||||
onEditTemplate=(action 'onEditTemplate')
|
||||
onDocumentTemplate=(action 'onDocumentTemplate')
|
||||
onDocumentImporting=(action 'onDocumentImporting')
|
||||
onDocumentImported=(action 'onDocumentImported')}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
|
|
@ -15,9 +15,16 @@
|
|||
{{/if}}
|
||||
|
||||
<div class="folders-list">
|
||||
<div id="new-document" class="round-button button-green doc-tool" data-tooltip="New space" data-tooltip-position="top center">
|
||||
<i class="material-icons">add</i>
|
||||
</div>
|
||||
{{#if folderService.canEditCurrentFolder}}
|
||||
<div id="start-document-button" class="round-button button-green doc-tool" data-tooltip="Document" data-tooltip-position="top center">
|
||||
<i class="material-icons">add</i>
|
||||
</div>
|
||||
{{folder/start-document
|
||||
savedTemplates=savedTemplates
|
||||
folder=folder
|
||||
onEditTemplate=(action 'onEditTemplate')
|
||||
onDocumentTemplate=(action 'onDocumentTemplate')}}
|
||||
{{/if}}
|
||||
|
||||
{{#if showScrollTool}}
|
||||
<div {{action 'scrollTop'}} id="scroll-space-tool" class="round-button round-button-mono button-white scroll-space-tool" data-tooltip="Back to top" data-tooltip-position="top center">
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
{{#dropdown-dialog target="start-document-button" position="bottom right" button="Start" color="flat-green" onAction=(action 'startDocument') button2=canEditTemplate color2="flat-blue" onAction2=(action 'editTemplate') onOpenCallback=(action 'onOpenCallback')}}
|
||||
<div class="upload-container">
|
||||
<div id="upload-documents" class="regular-button button-green">Import Word / Markdown</div>
|
||||
</div>
|
||||
|
||||
<p class="heading">Or use a template:</p>
|
||||
|
||||
{{#dropdown-dialog target="start-document-button" position="bottom left" button="Start" color="flat-green" onAction=(action 'startDocument') button2=canEditTemplate color2="flat-blue" onAction2=(action 'editTemplate')}}
|
||||
<ul class="start-document-options" style="min-width:185px;">
|
||||
{{#each savedTemplates key="id" as |template|}}
|
||||
<li class="option {{if template.selected "selected"}}" {{action 'setTemplate' template}}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue