1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-08 06:55:28 +02:00

Fixes and cleanup

This commit is contained in:
zinyando 2016-07-07 14:11:35 +02:00
parent f41517872b
commit 8597dc3dca
5 changed files with 170 additions and 169 deletions

View file

@ -1,11 +1,11 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
// by contacting <sales@documize.com>.
//
// 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);
}
}
});

View file

@ -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;
}
},
});
// Return true to bubble this event to any parent route.
return true;
}
},
});

View file

@ -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];
}
});

View file

@ -15,7 +15,7 @@
{{#each attachments key="id" as |a index|}}
<li class="item">
<img class="icon" src="assets/img/attachments/{{document/file-icon a.extension}}" />
<a href="{{ session.appMeta.apiUrl }}api/public/attachments/{{ session.appMeta.orgId }}/{{ a.job }}/{{ a.fileId }}">
<a href="{{ appMeta.apiUrl }}api/public/attachments/{{ appMeta.orgId }}/{{ a.job }}/{{ a.fileId }}">
<span class="file">{{ a.filename }}</span>
</a>
{{#if isEditor}}

View file

@ -6,13 +6,13 @@
</div>
{{else}}
{{#link-to 'application' class='title'}}
<div class="header-button" title=session.appMeta.title>
<div class="header-button" title=appMeta.title>
<i class="material-icons">apps</i>
</div>
{{/link-to}}
{{/if}}
{{#link-to 'application' class='title'}}
{{session.appMeta.title}}
{{appMeta.title}}
{{/link-to}}
</div>