mirror of
https://github.com/documize/community.git
synced 2025-08-08 15:05:28 +02:00
Fixes and cleanup
This commit is contained in:
parent
f41517872b
commit
8597dc3dca
5 changed files with 170 additions and 169 deletions
|
@ -14,149 +14,150 @@ import NotifierMixin from '../../mixins/notifier';
|
||||||
import TooltipMixin from '../../mixins/tooltip';
|
import TooltipMixin from '../../mixins/tooltip';
|
||||||
|
|
||||||
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||||
documentService: Ember.inject.service('document'),
|
documentService: Ember.inject.service('document'),
|
||||||
sectionService: Ember.inject.service('section'),
|
sectionService: Ember.inject.service('section'),
|
||||||
/* Parameters */
|
appMeta: Ember.inject.service(),
|
||||||
document: null,
|
/* Parameters */
|
||||||
// pages: [],
|
document: null,
|
||||||
attachments: [],
|
// pages: [],
|
||||||
folder: null,
|
attachments: [],
|
||||||
folders: [],
|
folder: null,
|
||||||
isEditor: false,
|
folders: [],
|
||||||
/* Internal */
|
isEditor: false,
|
||||||
drop: null,
|
/* Internal */
|
||||||
deleteAttachment: {
|
drop: null,
|
||||||
id: "",
|
deleteAttachment: {
|
||||||
name: "",
|
id: "",
|
||||||
},
|
name: "",
|
||||||
deletePage: {
|
},
|
||||||
id: "",
|
deletePage: {
|
||||||
title: "",
|
id: "",
|
||||||
children: false
|
title: "",
|
||||||
},
|
children: false
|
||||||
|
},
|
||||||
|
|
||||||
noSections: Ember.computed('pages', function() {
|
noSections: Ember.computed('pages', function () {
|
||||||
return this.get('pages.length') === 0;
|
return this.get('pages.length') === 0;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
this.get('sectionService').refresh(this.get('document.id')).then(function(changes) {
|
this.get('sectionService').refresh(this.get('document.id')).then(function (changes) {
|
||||||
changes.forEach(function(newPage) {
|
changes.forEach(function (newPage) {
|
||||||
let oldPage = self.get('pages').findBy('id', newPage.get('id'));
|
let oldPage = self.get('pages').findBy('id', newPage.get('id'));
|
||||||
if (is.not.undefined(oldPage)) {
|
if (is.not.undefined(oldPage)) {
|
||||||
oldPage.set('body', newPage.body);
|
oldPage.set('body', newPage.body);
|
||||||
oldPage.set('revised', newPage.revised);
|
oldPage.set('revised', newPage.revised);
|
||||||
self.showNotification(`Refreshed ${oldPage.title}`);
|
self.showNotification(`Refreshed ${oldPage.title}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this.destroyTooltips();
|
this.destroyTooltips();
|
||||||
|
|
||||||
let drop = this.get('drop');
|
let drop = this.get('drop');
|
||||||
|
|
||||||
if (is.not.null(drop)) {
|
if (is.not.null(drop)) {
|
||||||
drop.destroy();
|
drop.destroy();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
confirmDeleteAttachment(id, name) {
|
confirmDeleteAttachment(id, name) {
|
||||||
this.set('deleteAttachment', {
|
this.set('deleteAttachment', {
|
||||||
id: id,
|
id: id,
|
||||||
name: name
|
name: name
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".delete-attachment-dialog").css("display", "block");
|
$(".delete-attachment-dialog").css("display", "block");
|
||||||
|
|
||||||
let drop = new Drop({
|
let drop = new Drop({
|
||||||
target: $(".delete-attachment-" + id)[0],
|
target: $(".delete-attachment-" + id)[0],
|
||||||
content: $(".delete-attachment-dialog")[0],
|
content: $(".delete-attachment-dialog")[0],
|
||||||
classes: 'drop-theme-basic',
|
classes: 'drop-theme-basic',
|
||||||
position: "bottom right",
|
position: "bottom right",
|
||||||
openOn: "always",
|
openOn: "always",
|
||||||
tetherOptions: {
|
tetherOptions: {
|
||||||
offset: "5px 0",
|
offset: "5px 0",
|
||||||
targetOffset: "10px 0"
|
targetOffset: "10px 0"
|
||||||
},
|
},
|
||||||
remove: false
|
remove: false
|
||||||
});
|
});
|
||||||
|
|
||||||
this.set('drop', drop);
|
this.set('drop', drop);
|
||||||
},
|
},
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
let drop = this.get('drop');
|
let drop = this.get('drop');
|
||||||
drop.close();
|
drop.close();
|
||||||
|
|
||||||
this.set('deleteAttachment', {
|
this.set('deleteAttachment', {
|
||||||
id: "",
|
id: "",
|
||||||
name: ""
|
name: ""
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteAttachment() {
|
deleteAttachment() {
|
||||||
let attachment = this.get('deleteAttachment');
|
let attachment = this.get('deleteAttachment');
|
||||||
let drop = this.get('drop');
|
let drop = this.get('drop');
|
||||||
drop.close();
|
drop.close();
|
||||||
|
|
||||||
this.showNotification(`Deleted ${attachment.name}`);
|
this.showNotification(`Deleted ${attachment.name}`);
|
||||||
this.attrs.onAttachmentDeleted(this.get('deleteAttachment').id);
|
this.attrs.onAttachmentDeleted(this.get('deleteAttachment').id);
|
||||||
this.set('deleteAttachment', {
|
this.set('deleteAttachment', {
|
||||||
id: "",
|
id: "",
|
||||||
name: ""
|
name: ""
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
onDeletePage(id) {
|
onDeletePage(id) {
|
||||||
let page = this.get('pages').findBy("id", id);
|
let page = this.get('pages').findBy("id", id);
|
||||||
|
|
||||||
if (is.undefined(page)) {
|
if (is.undefined(page)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set('deletePage', {
|
this.set('deletePage', {
|
||||||
id: id,
|
id: id,
|
||||||
title: page.get('title'),
|
title: page.get('title'),
|
||||||
children: false
|
children: false
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".delete-page-dialog").css("display", "block");
|
$(".delete-page-dialog").css("display", "block");
|
||||||
|
|
||||||
let drop = new Drop({
|
let drop = new Drop({
|
||||||
target: $("#page-toolbar-" + id)[0],
|
target: $("#page-toolbar-" + id)[0],
|
||||||
content: $(".delete-page-dialog")[0],
|
content: $(".delete-page-dialog")[0],
|
||||||
classes: 'drop-theme-basic',
|
classes: 'drop-theme-basic',
|
||||||
position: "bottom right",
|
position: "bottom right",
|
||||||
openOn: "always",
|
openOn: "always",
|
||||||
tetherOptions: {
|
tetherOptions: {
|
||||||
offset: "5px 0",
|
offset: "5px 0",
|
||||||
targetOffset: "10px 0"
|
targetOffset: "10px 0"
|
||||||
},
|
},
|
||||||
remove: false
|
remove: false
|
||||||
});
|
});
|
||||||
|
|
||||||
this.set('drop', drop);
|
this.set('drop', drop);
|
||||||
},
|
},
|
||||||
|
|
||||||
deletePage() {
|
deletePage() {
|
||||||
let drop = this.get('drop');
|
let drop = this.get('drop');
|
||||||
drop.close();
|
drop.close();
|
||||||
|
|
||||||
this.attrs.onDeletePage(this.deletePage);
|
this.attrs.onDeletePage(this.deletePage);
|
||||||
},
|
},
|
||||||
|
|
||||||
// onTagChange event emitted from document/tag-editor component
|
// onTagChange event emitted from document/tag-editor component
|
||||||
onTagChange(tags) {
|
onTagChange(tags) {
|
||||||
let doc = this.get('document');
|
let doc = this.get('document');
|
||||||
doc.set('tags', tags);
|
doc.set('tags', tags);
|
||||||
this.get('documentService').save(doc);
|
this.get('documentService').save(doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,45 +14,45 @@ import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mi
|
||||||
import netUtil from '../utils/net';
|
import netUtil from '../utils/net';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
inject: { service }
|
inject: { service }
|
||||||
} = Ember;
|
} = Ember;
|
||||||
|
|
||||||
export default Ember.Route.extend(ApplicationRouteMixin, {
|
export default Ember.Route.extend(ApplicationRouteMixin, {
|
||||||
appMeta: service(),
|
appMeta: service(),
|
||||||
session: service(),
|
session: service(),
|
||||||
beforeModel() {
|
beforeModel() {
|
||||||
return this.get('appMeta').boot().then(data => {
|
return this.get('appMeta').boot().then(data => {
|
||||||
if (data.allowAnonymousAccess) {
|
if (data.allowAnonymousAccess) {
|
||||||
return this.get('session').authenticate('authenticator:anonymous', data);
|
return this.get('session').authenticate('authenticator:anonymous', data);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
willTransition: function ( /*transition*/ ) {
|
willTransition: function ( /*transition*/ ) {
|
||||||
$("#zone-sidebar").css('height', 'auto');
|
$("#zone-sidebar").css('height', 'auto');
|
||||||
Mousetrap.reset();
|
Mousetrap.reset();
|
||||||
},
|
},
|
||||||
|
|
||||||
didTransition() {
|
didTransition() {
|
||||||
Ember.run.schedule("afterRender", this, function () {
|
Ember.run.schedule("afterRender", this, function () {
|
||||||
$("#zone-sidebar").css('height', $(document).height() - $("#zone-navigation").height() - $("#zone-header").height() - 35);
|
$("#zone-sidebar").css('height', $(document).height() - $("#zone-navigation").height() - $("#zone-header").height() - 35);
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
error(error, transition) { // jshint ignore: line
|
error(error, transition) { // jshint ignore: line
|
||||||
if (error) {
|
if (error) {
|
||||||
if (netUtil.isAjaxAccessError(error)) {
|
if (netUtil.isAjaxAccessError(error)) {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
return this.transitionTo('auth.login');
|
return this.transitionTo('auth.login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true to bubble this event to any parent route.
|
// Return true to bubble this event to any parent route.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
|
@ -2,15 +2,15 @@ import Ember from 'ember';
|
||||||
|
|
||||||
export default Ember.Service.extend({
|
export default Ember.Service.extend({
|
||||||
|
|
||||||
storeSessionItem: function(key, data) {
|
storeSessionItem: function (key, data) {
|
||||||
localStorage[key] = data;
|
localStorage[key] = data;
|
||||||
},
|
},
|
||||||
|
|
||||||
getSessionItem: function(key) {
|
getSessionItem: function (key) {
|
||||||
return localStorage[key];
|
return localStorage[key];
|
||||||
},
|
},
|
||||||
|
|
||||||
clearSessionItem: function(key) {
|
clearSessionItem: function (key) {
|
||||||
delete localStorage[key];
|
delete localStorage[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
{{#each attachments key="id" as |a index|}}
|
{{#each attachments key="id" as |a index|}}
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<img class="icon" src="assets/img/attachments/{{document/file-icon a.extension}}" />
|
<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>
|
<span class="file">{{ a.filename }}</span>
|
||||||
</a>
|
</a>
|
||||||
{{#if isEditor}}
|
{{#if isEditor}}
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#link-to 'application' class='title'}}
|
{{#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>
|
<i class="material-icons">apps</i>
|
||||||
</div>
|
</div>
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#link-to 'application' class='title'}}
|
{{#link-to 'application' class='title'}}
|
||||||
{{session.appMeta.title}}
|
{{appMeta.title}}
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue