Skip to content

Commit

Permalink
Merge pull request #41 from documize/doc-toolbar-ux
Browse files Browse the repository at this point in the history
Doc toolbar ux
  • Loading branch information
HarveyKandola authored Oct 9, 2016
2 parents 20f9272 + 6d9abb7 commit 72916ed
Show file tree
Hide file tree
Showing 103 changed files with 1,895 additions and 474 deletions.
9 changes: 8 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@
* text=auto

# These files are text and should be normalized (convert crlf > lf)
*.hbs text
*.hbs text eol=lf
*.js text eol=lf
*.html text eol=lf
*.go text eol=lf
*.sql text eol=lf
*.scss text eol=lf
*.js text eol=lf
*.json text eol=lf
4 changes: 2 additions & 2 deletions app/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
indent_style = tab
indent_size = 4

[*.hbs]
insert_final_newline = false
Expand Down
3 changes: 2 additions & 1 deletion app/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"Drop",
"Dropzone",
"dragula",
"datetimepicker"
"datetimepicker",
"Waypoint"
],
"browser": true,
"boss": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@

import Ember from 'ember';

export default Ember.Component.extend({});
export default Ember.Component.extend({
});
15 changes: 15 additions & 0 deletions app/app/components/back-to-space.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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 Ember from 'ember';

export default Ember.Component.extend({
});
32 changes: 17 additions & 15 deletions app/app/components/document/document-sidebar-toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,29 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {

didInsertElement() {
this.eventBus.subscribe('documentPageAdded', this, 'onDocumentPageAdded');

var s = $(".document-structure");
var pos = s.position();

$(window).scroll(function() {
var windowpos = $(window).scrollTop();
if (windowpos - 200 >= pos.top) {
s.addClass("stick");
s.css('width', s.parent().width());
} else {
s.removeClass("stick");
s.css('width', 'auto');
}
});
},
},

willDestroyElement() {
this.eventBus.unsubscribe('documentPageAdded');
this.destroyTooltips();
},

// positionToc() {
// let s = $(".document-structure");
// let pos = s.position();
//
// $(window).scroll(_.throttle(function() {
// let windowpos = $(window).scrollTop();
// if (windowpos - 200 >= pos.top) {
// s.addClass("stuck-toc");
// s.css('width', s.parent().width());
// } else {
// s.removeClass("stuck-toc");
// s.css('width', 'auto');
// }
// }, 50));
// },

onDocumentPageAdded(pageId) {
this.send('onEntryClick', pageId);
},
Expand Down
72 changes: 64 additions & 8 deletions app/app/components/document/document-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,51 @@

import Ember from 'ember';
import TooltipMixin from '../../mixins/tooltip';
import NotifierMixin from '../../mixins/notifier';

export default Ember.Component.extend(TooltipMixin, {
export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
documentService: Ember.inject.service('document'),
document: {},
folder: {},
showToc: true,
showViews: false,
showContributions: false,
showSections: false,
showScrollTool: false,
showingSections: false,

didRender() {
if (this.session.authenticated) {
this.addTooltip(document.getElementById("owner-avatar"));
this.addTooltip(document.getElementById("section-tool"));
}
},

willDestroyElements() {
this.destroyElements();
didInsertElement() {
this.eventBus.subscribe('resized', this, 'positionTool');
this.eventBus.subscribe('scrolled', this, 'positionTool');
},

willDestroyElement() {
this.destroyTooltips();
},

positionTool() {
if (this.get('isDestroyed') || this.get('isDestroying')) {
return;
}

let s = $(".scroll-tool");
let windowpos = $(window).scrollTop();

if (windowpos >= 300) {
this.set('showScrollTool', true);
s.addClass("stuck-tool");
s.css('left', parseInt($(".zone-sidebar").css('width')) - 18 + 'px');
} else {
this.set('showScrollTool', false);
s.removeClass("stuck-tool");
}
},

actions: {
Expand All @@ -45,27 +73,55 @@ export default Ember.Component.extend(TooltipMixin, {
return this.attrs.gotoPage(id);
},

// close dialog
close() {
return true;
},

showToc() {
this.set('showToc', true);
this.set('showViews', false);
this.set('showContributions', false);
this.set('showSections', false);
this.set('showingSections', false);
},

showViews() {
this.set('showToc', false);
this.set('showViews', true);
this.set('showContributions', false);
this.set('showSections', false);
this.set('showingSections', false);
},

showContributions() {
this.set('showToc', false);
this.set('showViews', false);
this.set('showContributions', true);
this.set('showSections', false);
this.set('showingSections', false);
},

showSections() {
this.set('showToc', false);
this.set('showViews', false);
this.set('showContributions', false);
this.set('showSections', true);
this.set('showingSections', true);
},

onCancel() {
this.send('showToc');
this.set('showingSections', false);
},

onAddSection(section) {
this.attrs.onAddSection(section);

this.set('showingSections', false);
},

scrollTop() {
this.set('showScrollTool', false);

$("html,body").animate({
scrollTop: 0
}, 500, "linear");
}
}
});
3 changes: 1 addition & 2 deletions app/app/components/document/document-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
this.addTooltip(document.getElementById("save-template-button"));
this.addTooltip(document.getElementById("set-meta-button"));
this.addTooltip(document.getElementById("delete-document-button"));
this.addTooltip(document.getElementById("add-section-button"));
}

this.addTooltip(document.getElementById("print-document-button"));
Expand Down Expand Up @@ -139,4 +138,4 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
return true;
},
}
});
});
2 changes: 1 addition & 1 deletion app/app/components/document/document-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
this.get('documentService').save(doc);
}
}
});
});
15 changes: 9 additions & 6 deletions app/app/components/document/page-wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@ import Ember from 'ember';
import NotifierMixin from '../../mixins/notifier';

export default Ember.Component.extend(NotifierMixin, {
sectionService: Ember.inject.service('section'),

didReceiveAttrs() {
let self = this;
this.get('sectionService').getAll().then(function(sections) {
self.set('sections', sections);
});
},

didRender() {
let self = this;

Mousetrap.bind('esc', function() {
self.send('onCancel');
return false;
Expand All @@ -28,12 +37,6 @@ export default Ember.Component.extend(NotifierMixin, {
},

addSection(section) {

if (section.preview) {
this.showNotification("Coming soon!");
return;
}

this.attrs.onAction(section);
}
}
Expand Down
93 changes: 59 additions & 34 deletions app/app/components/folder/folder-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +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: "",
drop: null,

didReceiveAttrs() {
this.set('isFolderOwner', this.get('folder.userId') === this.get("session.user.id"));

let self = this;

this.get('templateService').getSavedTemplates().then(function(saved) {
let emptyTemplate = {
id: "0",
title: "Empty document",
selected: true
};
saved.unshiftObject(emptyTemplate);
self.set('savedTemplates', saved);
});
let show = this.get('isFolderOwner') || this.get('hasSelectedDocuments') || this.get('folderService').get('canEditCurrentFolder');
this.set('showToolbar', show);

let targets = _.reject(this.get('folders'), {
id: this.get('folder').get('id')
Expand All @@ -62,34 +54,67 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
this.addTooltip(document.getElementById("folder-settings-button"));
}
if (this.get('folderService').get('canEditCurrentFolder')) {
this.addTooltip(document.getElementById("start-document-button"));
this.addTooltip(document.getElementById("import-document-button"));
}
}
},

if (this.get('folderService').get('canEditCurrentFolder')) {
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 > i", {
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);
});

this.set('drop', dzone);
}
},

willDestroyElement() {
this.destroyTooltips();
},
if (is.not.null(this.get('drop'))) {
this.get('drop').destroy();
this.set('drop', null);
}

navigateToDocument(document) {
this.attrs.showDocument(this.get('folder'), document);
this.destroyTooltips();
},

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}`);

Expand Down
Loading

0 comments on commit 72916ed

Please sign in to comment.