mirror of
https://github.com/documize/community.git
synced 2025-07-25 16:19:46 +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;
|
} = Ember;
|
||||||
|
|
||||||
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||||
|
folderService: Ember.inject.service('folder'),
|
||||||
documentService: Ember.inject.service('document'),
|
documentService: Ember.inject.service('document'),
|
||||||
templateService: Ember.inject.service('template'),
|
|
||||||
folderService: Ember.inject.service('folder'),
|
|
||||||
session: Ember.inject.service(),
|
session: Ember.inject.service(),
|
||||||
|
appMeta: Ember.inject.service(),
|
||||||
|
|
||||||
showToolbar: false,
|
showToolbar: false,
|
||||||
folder: {},
|
folder: {},
|
||||||
busy: false,
|
busy: false,
|
||||||
importedDocuments: [],
|
importedDocuments: [],
|
||||||
savedTemplates: [],
|
|
||||||
isFolderOwner: computed.equal('folder.userId', 'session.user.id'),
|
isFolderOwner: computed.equal('folder.userId', 'session.user.id'),
|
||||||
moveFolderId: "",
|
moveFolderId: "",
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
let self = this;
|
|
||||||
|
|
||||||
this.set('isFolderOwner', this.get('folder.userId') === this.get("session.user.id"));
|
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');
|
let show = this.get('isFolderOwner') || this.get('hasSelectedDocuments') || this.get('folderService').get('canEditCurrentFolder');
|
||||||
this.set('showToolbar', show);
|
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'), {
|
let targets = _.reject(this.get('folders'), {
|
||||||
id: this.get('folder').get('id')
|
id: this.get('folder').get('id')
|
||||||
});
|
});
|
||||||
|
@ -66,34 +54,61 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||||
}
|
}
|
||||||
if (this.get('folderService').get('canEditCurrentFolder')) {
|
if (this.get('folderService').get('canEditCurrentFolder')) {
|
||||||
this.addTooltip(document.getElementById("import-document-button"));
|
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() {
|
willDestroyElement() {
|
||||||
this.destroyTooltips();
|
this.destroyTooltips();
|
||||||
},
|
},
|
||||||
|
|
||||||
navigateToDocument(document) {
|
|
||||||
this.attrs.showDocument(this.get('folder'), document);
|
|
||||||
},
|
|
||||||
|
|
||||||
actions: {
|
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) {
|
onDocumentImporting(filename) {
|
||||||
this.send("showNotification", `Importing ${filename}`);
|
this.send("showNotification", `Importing ${filename}`);
|
||||||
|
|
||||||
|
|
|
@ -12,18 +12,43 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import constants from '../../utils/constants';
|
import constants from '../../utils/constants';
|
||||||
import TooltipMixin from '../../mixins/tooltip';
|
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'),
|
folderService: Ember.inject.service('folder'),
|
||||||
|
templateService: Ember.inject.service('template'),
|
||||||
publicFolders: [],
|
publicFolders: [],
|
||||||
protectedFolders: [],
|
protectedFolders: [],
|
||||||
privateFolders: [],
|
privateFolders: [],
|
||||||
|
savedTemplates: [],
|
||||||
hasPublicFolders: false,
|
hasPublicFolders: false,
|
||||||
hasProtectedFolders: false,
|
hasProtectedFolders: false,
|
||||||
hasPrivateFolders: false,
|
hasPrivateFolders: false,
|
||||||
newFolder: "",
|
newFolder: "",
|
||||||
showScrollTool: false,
|
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() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
|
@ -88,7 +113,19 @@ export default Ember.Component.extend(TooltipMixin, {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
navigateToDocument(document) {
|
||||||
|
this.attrs.showDocument(this.get('folder'), document);
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
scrollTop() {
|
||||||
|
this.set('showScrollTool', false);
|
||||||
|
|
||||||
|
$("html,body").animate({
|
||||||
|
scrollTop: 0
|
||||||
|
}, 500, "linear");
|
||||||
|
},
|
||||||
|
|
||||||
addFolder() {
|
addFolder() {
|
||||||
var folderName = this.get('newFolder');
|
var folderName = this.get('newFolder');
|
||||||
|
|
||||||
|
@ -103,12 +140,18 @@ export default Ember.Component.extend(TooltipMixin, {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollTop() {
|
onEditTemplate(template) {
|
||||||
this.set('showScrollTool', false);
|
this.navigateToDocument(template);
|
||||||
|
},
|
||||||
|
|
||||||
$("html,body").animate({
|
onDocumentTemplate(id /*, title, type*/ ) {
|
||||||
scrollTop: 0
|
let self = this;
|
||||||
}, 500, "linear");
|
|
||||||
}
|
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"
|
id: "0"
|
||||||
},
|
},
|
||||||
canEditTemplate: "",
|
canEditTemplate: "",
|
||||||
drop: null,
|
|
||||||
appMeta: Ember.inject.service(),
|
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this.send('setTemplate', this.get('savedTemplates')[0]);
|
this.send('setTemplate', this.get('savedTemplates')[0]);
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
|
||||||
if (is.not.null(this.get('drop'))) {
|
|
||||||
this.get('drop').destroy();
|
|
||||||
this.set('drop', null);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
setTemplate(chosen) {
|
setTemplate(chosen) {
|
||||||
if (is.undefined(chosen)) {
|
if (is.undefined(chosen)) {
|
||||||
|
@ -51,7 +42,6 @@ export default Ember.Component.extend(NotifierMixin, {
|
||||||
|
|
||||||
editTemplate() {
|
editTemplate() {
|
||||||
let template = this.get('selectedTemplate');
|
let template = this.get('selectedTemplate');
|
||||||
|
|
||||||
this.audit.record('edited-saved-template');
|
this.audit.record('edited-saved-template');
|
||||||
this.attrs.onEditTemplate(template);
|
this.attrs.onEditTemplate(template);
|
||||||
|
|
||||||
|
@ -60,62 +50,10 @@ export default Ember.Component.extend(NotifierMixin, {
|
||||||
|
|
||||||
startDocument() {
|
startDocument() {
|
||||||
let template = this.get('selectedTemplate');
|
let template = this.get('selectedTemplate');
|
||||||
|
|
||||||
this.audit.record('used-saved-template');
|
this.audit.record('used-saved-template');
|
||||||
this.attrs.onDocumentTemplate(template.id, template.title, "private");
|
this.attrs.onDocumentTemplate(template.id, template.title, "private");
|
||||||
|
|
||||||
return true;
|
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-navigation}}
|
||||||
|
|
||||||
{{#layout/zone-sidebar}}
|
{{#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-sidebar}}
|
||||||
|
|
||||||
{{#layout/zone-content}}
|
{{#layout/zone-content}}
|
||||||
|
@ -13,8 +15,7 @@
|
||||||
hasSelectedDocuments=hasSelectedDocuments
|
hasSelectedDocuments=hasSelectedDocuments
|
||||||
refresh=(action 'refresh')
|
refresh=(action 'refresh')
|
||||||
onDeleteDocument=(action 'onDeleteDocument')
|
onDeleteDocument=(action 'onDeleteDocument')
|
||||||
onMoveDocument=(action 'onMoveDocument')
|
onMoveDocument=(action 'onMoveDocument')}}
|
||||||
showDocument=(action 'showDocument')}}
|
|
||||||
|
|
||||||
{{folder/documents-list documents=model.documents folder=model.folder isFolderOwner=isFolderOwner onDocumentsChecked=(action 'onDocumentsChecked') }}
|
{{folder/documents-list documents=model.documents folder=model.folder isFolderOwner=isFolderOwner onDocumentsChecked=(action 'onDocumentsChecked') }}
|
||||||
{{/layout/zone-content}}
|
{{/layout/zone-content}}
|
||||||
|
|
|
@ -173,11 +173,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.upload-container {
|
|
||||||
text-align: center;
|
|
||||||
margin: 2rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.no-documents {
|
.no-documents {
|
||||||
margin-top: 50px;
|
margin-top: 50px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if isEditor}}
|
{{#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>
|
<i class="material-icons color-green">add</i>
|
||||||
</div>
|
</div>
|
||||||
{{#if showingSections}}
|
{{#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">
|
<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>
|
<i class="material-icons color-gray">file_upload</i>
|
||||||
</div>
|
</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}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,9 +15,16 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<div class="folders-list">
|
<div class="folders-list">
|
||||||
<div id="new-document" class="round-button button-green doc-tool" data-tooltip="New space" data-tooltip-position="top center">
|
{{#if folderService.canEditCurrentFolder}}
|
||||||
<i class="material-icons">add</i>
|
<div id="start-document-button" class="round-button button-green doc-tool" data-tooltip="Document" data-tooltip-position="top center">
|
||||||
</div>
|
<i class="material-icons">add</i>
|
||||||
|
</div>
|
||||||
|
{{folder/start-document
|
||||||
|
savedTemplates=savedTemplates
|
||||||
|
folder=folder
|
||||||
|
onEditTemplate=(action 'onEditTemplate')
|
||||||
|
onDocumentTemplate=(action 'onDocumentTemplate')}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#if showScrollTool}}
|
{{#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">
|
<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')}}
|
{{#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')}}
|
||||||
<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>
|
|
||||||
|
|
||||||
<ul class="start-document-options" style="min-width:185px;">
|
<ul class="start-document-options" style="min-width:185px;">
|
||||||
{{#each savedTemplates key="id" as |template|}}
|
{{#each savedTemplates key="id" as |template|}}
|
||||||
<li class="option {{if template.selected "selected"}}" {{action 'setTemplate' template}}>
|
<li class="option {{if template.selected "selected"}}" {{action 'setTemplate' template}}>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue