From 8597dc3dca74fb405b3314285a8476b904351f63 Mon Sep 17 00:00:00 2001 From: zinyando Date: Thu, 7 Jul 2016 14:11:35 +0200 Subject: [PATCH] Fixes and cleanup --- app/app/components/document/document-view.js | 247 +++++++++--------- app/app/routes/application.js | 68 ++--- app/app/services/local-storage.js | 18 +- .../components/document/document-view.hbs | 2 +- .../components/layout/zone-navigation.hbs | 4 +- 5 files changed, 170 insertions(+), 169 deletions(-) diff --git a/app/app/components/document/document-view.js b/app/app/components/document/document-view.js index 084458e5..bd2ca67d 100644 --- a/app/app/components/document/document-view.js +++ b/app/app/components/document/document-view.js @@ -1,11 +1,11 @@ // Copyright 2016 Documize Inc. . All rights reserved. // -// This software (Documize Community Edition) is licensed under +// 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 . +// by contacting . // // https://documize.com @@ -14,149 +14,150 @@ import NotifierMixin from '../../mixins/notifier'; import TooltipMixin from '../../mixins/tooltip'; export default Ember.Component.extend(NotifierMixin, TooltipMixin, { - documentService: Ember.inject.service('document'), - sectionService: Ember.inject.service('section'), - /* Parameters */ - document: null, - // pages: [], - attachments: [], - folder: null, - folders: [], - isEditor: false, - /* Internal */ - drop: null, - deleteAttachment: { - id: "", - name: "", - }, - deletePage: { - id: "", - title: "", - children: false - }, + documentService: Ember.inject.service('document'), + sectionService: Ember.inject.service('section'), + appMeta: Ember.inject.service(), + /* Parameters */ + document: null, + // pages: [], + attachments: [], + folder: null, + folders: [], + isEditor: false, + /* Internal */ + drop: null, + deleteAttachment: { + id: "", + name: "", + }, + deletePage: { + id: "", + title: "", + children: false + }, - noSections: Ember.computed('pages', function() { - return this.get('pages.length') === 0; - }), + noSections: Ember.computed('pages', function () { + return this.get('pages.length') === 0; + }), - didInsertElement() { - let self = this; + didInsertElement() { + let self = this; - this.get('sectionService').refresh(this.get('document.id')).then(function(changes) { - changes.forEach(function(newPage) { - let oldPage = self.get('pages').findBy('id', newPage.get('id')); - if (is.not.undefined(oldPage)) { - oldPage.set('body', newPage.body); - oldPage.set('revised', newPage.revised); - self.showNotification(`Refreshed ${oldPage.title}`); - } - }); - }); - }, + this.get('sectionService').refresh(this.get('document.id')).then(function (changes) { + changes.forEach(function (newPage) { + let oldPage = self.get('pages').findBy('id', newPage.get('id')); + if (is.not.undefined(oldPage)) { + oldPage.set('body', newPage.body); + oldPage.set('revised', newPage.revised); + self.showNotification(`Refreshed ${oldPage.title}`); + } + }); + }); + }, - willDestroyElement() { - this.destroyTooltips(); + willDestroyElement() { + this.destroyTooltips(); - let drop = this.get('drop'); + let drop = this.get('drop'); - if (is.not.null(drop)) { - drop.destroy(); - } - }, + if (is.not.null(drop)) { + drop.destroy(); + } + }, - actions: { - confirmDeleteAttachment(id, name) { - this.set('deleteAttachment', { - id: id, - name: name - }); + actions: { + confirmDeleteAttachment(id, name) { + this.set('deleteAttachment', { + id: id, + name: name + }); - $(".delete-attachment-dialog").css("display", "block"); + $(".delete-attachment-dialog").css("display", "block"); - let drop = new Drop({ - target: $(".delete-attachment-" + id)[0], - content: $(".delete-attachment-dialog")[0], - classes: 'drop-theme-basic', - position: "bottom right", - openOn: "always", - tetherOptions: { - offset: "5px 0", - targetOffset: "10px 0" - }, - remove: false - }); + let drop = new Drop({ + target: $(".delete-attachment-" + id)[0], + content: $(".delete-attachment-dialog")[0], + classes: 'drop-theme-basic', + position: "bottom right", + openOn: "always", + tetherOptions: { + offset: "5px 0", + targetOffset: "10px 0" + }, + remove: false + }); - this.set('drop', drop); - }, + this.set('drop', drop); + }, - cancel() { - let drop = this.get('drop'); - drop.close(); + cancel() { + let drop = this.get('drop'); + drop.close(); - this.set('deleteAttachment', { - id: "", - name: "" - }); - }, + this.set('deleteAttachment', { + id: "", + name: "" + }); + }, - deleteAttachment() { - let attachment = this.get('deleteAttachment'); - let drop = this.get('drop'); - drop.close(); + deleteAttachment() { + let attachment = this.get('deleteAttachment'); + let drop = this.get('drop'); + drop.close(); - this.showNotification(`Deleted ${attachment.name}`); - this.attrs.onAttachmentDeleted(this.get('deleteAttachment').id); - this.set('deleteAttachment', { - id: "", - name: "" - }); + this.showNotification(`Deleted ${attachment.name}`); + this.attrs.onAttachmentDeleted(this.get('deleteAttachment').id); + this.set('deleteAttachment', { + id: "", + name: "" + }); - return true; - }, + return true; + }, - onDeletePage(id) { - let page = this.get('pages').findBy("id", id); + onDeletePage(id) { + let page = this.get('pages').findBy("id", id); - if (is.undefined(page)) { - return; - } + if (is.undefined(page)) { + return; + } - this.set('deletePage', { - id: id, - title: page.get('title'), - children: false - }); + this.set('deletePage', { + id: id, + title: page.get('title'), + children: false + }); - $(".delete-page-dialog").css("display", "block"); + $(".delete-page-dialog").css("display", "block"); - let drop = new Drop({ - target: $("#page-toolbar-" + id)[0], - content: $(".delete-page-dialog")[0], - classes: 'drop-theme-basic', - position: "bottom right", - openOn: "always", - tetherOptions: { - offset: "5px 0", - targetOffset: "10px 0" - }, - remove: false - }); + let drop = new Drop({ + target: $("#page-toolbar-" + id)[0], + content: $(".delete-page-dialog")[0], + classes: 'drop-theme-basic', + position: "bottom right", + openOn: "always", + tetherOptions: { + offset: "5px 0", + targetOffset: "10px 0" + }, + remove: false + }); - this.set('drop', drop); - }, + this.set('drop', drop); + }, - deletePage() { - let drop = this.get('drop'); - drop.close(); + deletePage() { + let drop = this.get('drop'); + drop.close(); - this.attrs.onDeletePage(this.deletePage); - }, + this.attrs.onDeletePage(this.deletePage); + }, - // onTagChange event emitted from document/tag-editor component - onTagChange(tags) { - let doc = this.get('document'); - doc.set('tags', tags); - this.get('documentService').save(doc); - } - } + // onTagChange event emitted from document/tag-editor component + onTagChange(tags) { + let doc = this.get('document'); + doc.set('tags', tags); + this.get('documentService').save(doc); + } + } }); diff --git a/app/app/routes/application.js b/app/app/routes/application.js index 03c03270..3d2c8398 100644 --- a/app/app/routes/application.js +++ b/app/app/routes/application.js @@ -14,45 +14,45 @@ import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mi import netUtil from '../utils/net'; const { - inject: { service } + inject: { service } } = Ember; export default Ember.Route.extend(ApplicationRouteMixin, { - appMeta: service(), - session: service(), - beforeModel() { - return this.get('appMeta').boot().then(data => { - if (data.allowAnonymousAccess) { - return this.get('session').authenticate('authenticator:anonymous', data); - } - return; - }); - }, + appMeta: service(), + session: service(), + beforeModel() { + return this.get('appMeta').boot().then(data => { + if (data.allowAnonymousAccess) { + return this.get('session').authenticate('authenticator:anonymous', data); + } + return; + }); + }, - actions: { - willTransition: function ( /*transition*/ ) { - $("#zone-sidebar").css('height', 'auto'); - Mousetrap.reset(); - }, + actions: { + willTransition: function ( /*transition*/ ) { + $("#zone-sidebar").css('height', 'auto'); + Mousetrap.reset(); + }, - didTransition() { - Ember.run.schedule("afterRender", this, function () { - $("#zone-sidebar").css('height', $(document).height() - $("#zone-navigation").height() - $("#zone-header").height() - 35); - }); + didTransition() { + Ember.run.schedule("afterRender", this, function () { + $("#zone-sidebar").css('height', $(document).height() - $("#zone-navigation").height() - $("#zone-header").height() - 35); + }); - return true; - }, + return true; + }, - error(error, transition) { // jshint ignore: line - if (error) { - if (netUtil.isAjaxAccessError(error)) { - localStorage.clear(); - return this.transitionTo('auth.login'); - } - } + error(error, transition) { // jshint ignore: line + if (error) { + if (netUtil.isAjaxAccessError(error)) { + localStorage.clear(); + return this.transitionTo('auth.login'); + } + } - // Return true to bubble this event to any parent route. - return true; - } - }, -}); \ No newline at end of file + // Return true to bubble this event to any parent route. + return true; + } + }, +}); diff --git a/app/app/services/local-storage.js b/app/app/services/local-storage.js index 0939d28e..082b7e5e 100644 --- a/app/app/services/local-storage.js +++ b/app/app/services/local-storage.js @@ -2,15 +2,15 @@ import Ember from 'ember'; export default Ember.Service.extend({ - storeSessionItem: function(key, data) { - localStorage[key] = data; - }, + storeSessionItem: function (key, data) { + localStorage[key] = data; + }, - getSessionItem: function(key) { - return localStorage[key]; - }, + getSessionItem: function (key) { + return localStorage[key]; + }, - clearSessionItem: function(key) { - delete localStorage[key]; - } + clearSessionItem: function (key) { + delete localStorage[key]; + } }); diff --git a/app/app/templates/components/document/document-view.hbs b/app/app/templates/components/document/document-view.hbs index 2378d57e..649d4901 100644 --- a/app/app/templates/components/document/document-view.hbs +++ b/app/app/templates/components/document/document-view.hbs @@ -15,7 +15,7 @@ {{#each attachments key="id" as |a index|}}
  • - + {{ a.filename }} {{#if isEditor}} diff --git a/app/app/templates/components/layout/zone-navigation.hbs b/app/app/templates/components/layout/zone-navigation.hbs index bd36b350..90cb95f2 100644 --- a/app/app/templates/components/layout/zone-navigation.hbs +++ b/app/app/templates/components/layout/zone-navigation.hbs @@ -6,13 +6,13 @@ {{else}} {{#link-to 'application' class='title'}} -
    +
    apps
    {{/link-to}} {{/if}} {{#link-to 'application' class='title'}} - {{session.appMeta.title}} + {{appMeta.title}} {{/link-to}}