1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-05 05:25:27 +02:00

document sidebar framework, files, activity

This commit is contained in:
Harvey Kandola 2017-03-07 14:39:06 +00:00
parent 6d481c335a
commit 91cf0d15ae
34 changed files with 633 additions and 1054 deletions

View file

@ -1,68 +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 Ember from 'ember';
export default Ember.Component.extend({
sortedItems: [],
didReceiveAttrs() {
let editors = this.get('activity.editors');
let viewers = this.get('activity.viewers');
let pages = this.get('pages');
let sorted = [];
if (is.null(editors)) {
editors = [];
}
if (is.null(viewers)) {
viewers = [];
}
viewers.forEach((item) => {
Ember.set(item, 'changeLabel', "viewed");
Ember.set(item, "viewed", true);
sorted.pushObject({ date: item.created, item: item });
});
editors.forEach(function (item) {
Ember.set(item, "added", item.action === "add-page");
Ember.set(item, "changed", item.action === "update-page");
Ember.set(item, "deleted", item.action === "remove-page");
let page = pages.findBy('id', item.pageId);
let title = "";
if (item.deleted || is.undefined(page)) {
title = "removed section";
} else {
if (item.added) {
title = "added " + page.get('title');
}
if (item.changed) {
title = "changed " + page.get('title');
}
}
Ember.set(item, 'changeLabel', title);
let exists = sorted.findBy('item.pageId', item.pageId);
if (is.undefined(exists)) {
sorted.pushObject({ date: item.created, item: item });
}
});
this.set('sortedItems', _.sortBy(sorted, 'date').reverse());
}
});

View file

@ -0,0 +1,76 @@
// 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({
documentService: Ember.inject.service('document'),
appMeta: Ember.inject.service(),
sortedItems: [],
didReceiveAttrs() {
this._super(...arguments);
this.get('documentService').getMeta(this.get('document.id')).then((activity) => {
this.set('activity', activity);
let editors = this.get('activity.editors');
let viewers = this.get('activity.viewers');
let pages = this.get('pages');
let sorted = [];
if (is.null(editors)) {
editors = [];
}
if (is.null(viewers)) {
viewers = [];
}
viewers.forEach((item) => {
Ember.set(item, 'changeLabel', "viewed");
Ember.set(item, "viewed", true);
sorted.pushObject({ date: item.created, item: item });
});
editors.forEach(function (item) {
Ember.set(item, "added", item.action === "add-page");
Ember.set(item, "changed", item.action === "update-page");
Ember.set(item, "deleted", item.action === "remove-page");
let page = pages.findBy('id', item.pageId);
let title = "";
if (item.deleted || is.undefined(page)) {
title = "removed section";
} else {
if (item.added) {
title = "added " + page.get('title');
}
if (item.changed) {
title = "changed " + page.get('title');
}
}
Ember.set(item, 'changeLabel', title);
let exists = sorted.findBy('item.pageId', item.pageId);
if (is.undefined(exists)) {
sorted.pushObject({ date: item.created, item: item });
}
});
this.set('sortedItems', _.sortBy(sorted, 'date').reverse());
});
}
});

View file

@ -14,17 +14,24 @@ import NotifierMixin from '../../mixins/notifier';
import TooltipMixin from '../../mixins/tooltip';
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
documentService: Ember.inject.service('document'),
appMeta: Ember.inject.service(),
drop: null,
emptyState: Ember.computed.empty('files'),
deleteAttachment: {
id: "",
name: "",
},
emptyState: Ember.computed('files', function () {
return this.get('files.length') === 0;
}),
init() {
this._super(...arguments);
this.getAttachments();
},
didInsertElement() {
this._super(...arguments);
if (!this.get('isEditor')) {
return;
}
@ -54,7 +61,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
});
this.on("queuecomplete", function () {
self.attrs.onUpload();
self.getAttachments();
});
this.on("addedfile", function ( /*file*/ ) {
@ -71,15 +78,22 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
},
willDestroyElement() {
let drop = this.get('drop');
this._super(...arguments);
let drop = this.get('drop');
if (is.not.null(drop)) {
drop.destroy();
}
},
getAttachments() {
this.get('documentService').getAttachments(this.get('document.id')).then((files) => {
this.set('files', files);
});
},
actions: {
confirmDeleteAttachment(id, name) {
onConfirmDelete(id, name) {
this.set('deleteAttachment', {
id: id,
name: name
@ -103,7 +117,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
this.set('drop', drop);
},
cancel() {
onCancel() {
let drop = this.get('drop');
drop.close();
@ -113,16 +127,19 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
});
},
deleteAttachment() {
onDelete() {
let attachment = this.get('deleteAttachment');
let drop = this.get('drop');
drop.close();
this.attrs.onDelete(this.get('deleteAttachment').id, attachment.name);
this.showNotification(`Deleted ${name}`);
this.set('deleteAttachment', {
id: "",
name: ""
this.get('documentService').deleteAttachment(this.get('document.id'), attachment.id).then(() => {
this.getAttachments();
this.set('deleteAttachment', {
id: "",
name: ""
});
});
return true;

View file

@ -10,114 +10,83 @@
// https://documize.com
import Ember from 'ember';
import NotifierMixin from '../../mixins/notifier';
import TooltipMixin from '../../mixins/tooltip';
import NotifierMixin from '../../mixins/notifier';
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
documentService: Ember.inject.service('document'),
sectionService: Ember.inject.service('section'),
appMeta: Ember.inject.service(),
userService: Ember.inject.service('user'),
localStorage: Ember.inject.service(),
pinned: Ember.inject.service(),
drop: null,
users: [],
menuOpen: false,
saveTemplate: {
name: "",
description: ""
},
pinState : {
isPinned: false,
pinId: '',
newName: '',
},
didReceiveAttrs() {
this.set('saveTemplate.name', this.get('document.name'));
this.set('saveTemplate.description', this.get('document.excerpt'));
let doc = this.get('document');
this.set('layoutLabel', doc.get('layout') === 'doc' ? 'Wiki style' : 'Document style');
this.set('pinState.pinId', this.get('pinned').isDocumentPinned(doc.get('id')));
this.set('pinState.isPinned', this.get('pinState.pinId') !== '');
this.set('pinState.newName', doc.get('name').substring(0,3).toUpperCase());
saveTemplate: {
name: "",
description: ""
},
currentTab: '',
didRender() {
if (this.session.isEditor) {
this.addTooltip(document.getElementById("add-document-tab"));
init() {
this._super(...arguments);
if (is.empty(this.get('currentTab'))) {
this.set('currentTab', 'attachments');
}
},
willDestroyElement() {
this.destroyTooltips();
didReceiveAttrs() {
this._super(...arguments);
this.set('saveTemplate.name', this.get('document.name'));
this.set('saveTemplate.description', this.get('document.excerpt'));
this.set('pinState.pinId', this.get('pinned').isDocumentPinned(this.get('document.id')));
this.set('pinState.isPinned', this.get('pinState.pinId') !== '');
this.set('pinState.newName', this.get('document.name').substring(0,3).toUpperCase());
},
actions: {
didRender() {
this._super(...arguments);
},
didInsertElement() {
this._super(...arguments);
},
willDestroyElement() {
this._super(...arguments);
},
actions: {
onChangeTab(tab) {
this.set('currentTab', tab);
},
onTagChange(tags) {
let doc = this.get('document');
doc.set('tags', tags);
this.get('documentService').save(doc);
},
onMenuOpen() {
this.set('menuOpen', !this.get('menuOpen'));
},
deleteDocument() {
onDeleteDocument() {
this.attrs.onDocumentDelete();
},
printDocument() {
onPrintDocument() {
window.print();
},
changeLayout() {
let doc = this.get('document');
let layout = doc.get('layout') === 'doc' ? 'wiki' : 'doc';
doc.set('layout', layout);
this.attrs.onSaveMeta(doc);
this.set('layoutLabel', doc.get('layout') === 'doc' ? 'Wiki style' : 'Document style');
},
saveTemplate() {
var name = this.get('saveTemplate.name');
var excerpt = this.get('saveTemplate.description');
if (is.empty(name)) {
$("#new-template-name").addClass("error").focus();
return false;
}
if (is.empty(excerpt)) {
$("#new-template-desc").addClass("error").focus();
return false;
}
this.showNotification('Template saved');
this.attrs.onSaveTemplate(name, excerpt);
return true;
},
saveMeta() {
let doc = this.get('document');
if (is.empty(doc.get('name'))) {
$("#meta-name").addClass("error").focus();
return false;
}
if (is.empty(doc.get('excerpt'))) {
$("#meta-excerpt").addClass("error").focus();
return false;
}
doc.set('excerpt', doc.get('excerpt').substring(0, 250));
this.attrs.onSaveMeta(doc);
return true;
},
unpin() {
onUnpin() {
this.audit.record('unpinned-document');
this.get('pinned').unpinItem(this.get('pinState.pinId')).then(() => {
@ -127,7 +96,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
});
},
pin() {
onPin() {
let pin = {
pin: this.get('pinState.newName'),
documentId: this.get('document.id'),
@ -147,7 +116,27 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
this.eventBus.publish('pinChange');
});
return true;
},
onSaveTemplate() {
var name = this.get('saveTemplate.name');
var excerpt = this.get('saveTemplate.description');
if (is.empty(name)) {
$("#new-template-name").addClass("error").focus();
return false;
}
if (is.empty(excerpt)) {
$("#new-template-desc").addClass("error").focus();
return false;
}
this.showNotification('Template saved');
this.attrs.onSaveTemplate(name, excerpt);
return true;
}
}
}
});

View file

@ -1,16 +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 Ember from 'ember';
import NotifierMixin from '../../mixins/notifier';
export default Ember.Component.extend(NotifierMixin, {
});