mirror of
https://github.com/documize/community.git
synced 2025-07-28 01:29:43 +02:00
removed start-document redundant code
This commit is contained in:
parent
ab475ede04
commit
9afc4ca98b
4 changed files with 3 additions and 217 deletions
|
@ -1,173 +0,0 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
|
||||||
//
|
|
||||||
// This software (Documize Community Edition) is licensed under
|
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
|
||||||
//
|
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
|
||||||
// by contacting <sales@documize.com>.
|
|
||||||
//
|
|
||||||
// https://documize.com
|
|
||||||
|
|
||||||
import { empty } from '@ember/object/computed';
|
|
||||||
import { schedule } from '@ember/runloop';
|
|
||||||
import Component from '@ember/component';
|
|
||||||
import { inject as service } from '@ember/service';
|
|
||||||
import NotifierMixin from '../../mixins/notifier';
|
|
||||||
|
|
||||||
export default Component.extend(NotifierMixin, {
|
|
||||||
localStorage: service(),
|
|
||||||
appMeta: service(),
|
|
||||||
templateService: service('template'),
|
|
||||||
importedDocuments: [],
|
|
||||||
savedTemplates: [],
|
|
||||||
importStatus: [],
|
|
||||||
dropzone: null,
|
|
||||||
newDocumentName: '',
|
|
||||||
newDocumentNameMissing: empty('newDocumentName'),
|
|
||||||
|
|
||||||
didReceiveAttrs() {
|
|
||||||
this._super(...arguments);
|
|
||||||
|
|
||||||
this.setupTemplates();
|
|
||||||
|
|
||||||
schedule('afterRender', ()=> {
|
|
||||||
this.setupImport();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
willDestroyElement() {
|
|
||||||
this._super(...arguments);
|
|
||||||
|
|
||||||
if (is.not.null(this.get('dropzone'))) {
|
|
||||||
this.get('dropzone').destroy();
|
|
||||||
this.set('dropzone', null);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
setupTemplates() {
|
|
||||||
let templates = this.get('templates');
|
|
||||||
|
|
||||||
if (is.undefined(templates.findBy('id', '0'))) {
|
|
||||||
let emptyTemplate = {
|
|
||||||
id: "0",
|
|
||||||
title: "Blank",
|
|
||||||
description: "An empty canvas for your words",
|
|
||||||
layout: "doc",
|
|
||||||
locked: true
|
|
||||||
};
|
|
||||||
|
|
||||||
templates.unshiftObject(emptyTemplate);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.set('savedTemplates', templates);
|
|
||||||
|
|
||||||
schedule('afterRender', () => {
|
|
||||||
$('#new-document-name').select();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
setupImport() {
|
|
||||||
// already done init?
|
|
||||||
if (is.not.null(this.get('dropzone'))) {
|
|
||||||
this.get('dropzone').destroy();
|
|
||||||
this.set('dropzone', null);
|
|
||||||
}
|
|
||||||
|
|
||||||
let self = this;
|
|
||||||
let folderId = this.get('folder.id');
|
|
||||||
let url = this.get('appMeta.endpoint');
|
|
||||||
let importUrl = `${url}/import/folder/${folderId}`;
|
|
||||||
|
|
||||||
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,.md,.markdown,.htm,.html",
|
|
||||||
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, x); // eslint-disable-line no-console
|
|
||||||
});
|
|
||||||
|
|
||||||
// this.on("queuecomplete", function () {});
|
|
||||||
|
|
||||||
this.on("addedfile", function (file) {
|
|
||||||
self.send('onDocumentImporting', file.name);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
dzone.on("complete", function (file) {
|
|
||||||
dzone.removeFile(file);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.set('dropzone', dzone);
|
|
||||||
},
|
|
||||||
|
|
||||||
actions: {
|
|
||||||
onHideStartDocument() {
|
|
||||||
this.get('onHideStartDocument')();
|
|
||||||
},
|
|
||||||
|
|
||||||
editTemplate(template) {
|
|
||||||
this.get('router').transitionTo('document', this.get('folder.id'), this.get('folder.slug'), template.get('id'), template.get('slug'));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
startDocument(template) {
|
|
||||||
if (this.get('newDocumentNameMissing')) {
|
|
||||||
this.$("#new-document-name").addClass('error').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$("#new-document-name").removeClass('error');
|
|
||||||
this.send("showNotification", "Creating");
|
|
||||||
|
|
||||||
this.get('templateService').importSavedTemplate(this.folder.get('id'), template.id, this.get('newDocumentName')).then((document) => {
|
|
||||||
this.get('router').transitionTo('document', this.get('folder.id'), this.get('folder.slug'), document.get('id'), document.get('slug'));
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
onDocumentImporting(filename) {
|
|
||||||
let status = this.get('importStatus');
|
|
||||||
let documents = this.get('importedDocuments');
|
|
||||||
|
|
||||||
status.pushObject(`Converting ${filename}...`);
|
|
||||||
documents.push(filename);
|
|
||||||
|
|
||||||
this.set('importStatus', status);
|
|
||||||
this.set('importedDocuments', documents);
|
|
||||||
},
|
|
||||||
|
|
||||||
onDocumentImported(filename /*, document*/ ) {
|
|
||||||
let status = this.get('importStatus');
|
|
||||||
let documents = this.get('importedDocuments');
|
|
||||||
|
|
||||||
status.pushObject(`Successfully converted ${filename}`);
|
|
||||||
documents.pop(filename);
|
|
||||||
|
|
||||||
this.set('importStatus', status);
|
|
||||||
this.set('importedDocuments', documents);
|
|
||||||
|
|
||||||
if (documents.length === 0) {
|
|
||||||
this.get('onHideStartDocument')();
|
|
||||||
this.get('onImport')();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
});
|
|
6
gui/app/styles/view/import.scss
vendored
6
gui/app/styles/view/import.scss
vendored
|
@ -1,10 +1,8 @@
|
||||||
.import-zone {
|
.import-zone {
|
||||||
margin: 3rem 1rem;
|
margin: 3rem 1rem;
|
||||||
|
|
||||||
> .import-document-button {
|
.dz-preview, .dz-processing {
|
||||||
> .dz-preview, .dz-processing {
|
display: none !important;
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
> .import-status {
|
> .import-status {
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
<div id="new-document-wizard" class="new-document-wizard">
|
|
||||||
|
|
||||||
<div class="import-zone">
|
|
||||||
<div id="import-document-button" class="import-document-button">
|
|
||||||
Click to select or drag-drop files <br/>(doc, docx, md, markdown)
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="import-status">
|
|
||||||
{{#each importStatus as |status|}}
|
|
||||||
<p>{{status}}</p>
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="fresh-zone">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="new-document-name">Or start new document</label>
|
|
||||||
{{input type='text' id="new-document-name" class="form-control mousetrap" placeholder="Provide document name" value=newDocumentName class=(if newDocumentNameMissing 'document-name is-invalid' 'document-name mousetrap') autocomplete="off"}}
|
|
||||||
</div>
|
|
||||||
<ul class="template-list">
|
|
||||||
{{#each savedTemplates key="id" as |template|}}
|
|
||||||
<li class="item">
|
|
||||||
{{#if permissions.documentTemplate}}
|
|
||||||
{{#unless template.locked}}
|
|
||||||
<div class="template-actions">
|
|
||||||
<i class="material-icons" {{action 'editTemplate' template}}>mode_edit</i>
|
|
||||||
</div>
|
|
||||||
{{/unless}}
|
|
||||||
{{/if}}
|
|
||||||
<div class="details text-truncate" {{action 'startDocument' template}}>
|
|
||||||
<div class='title text-truncate'>{{template.title}}</div>
|
|
||||||
<div class='desc text-truncate'>{{template.description}}</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{{/each}}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
|
@ -154,7 +154,7 @@
|
||||||
<br/>
|
<br/>
|
||||||
Click to select files or drag-drop files
|
Click to select files or drag-drop files
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<span class="font-italic">.doc, .docx, .md, .markdown</span>
|
.doc, .docx, .md, .markdown
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
</button>
|
</button>
|
||||||
<div class="import-status">
|
<div class="import-status">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue