mirror of
https://github.com/documize/community.git
synced 2025-07-22 22:59:43 +02:00
WIP new document UX/UI
This commit is contained in:
parent
21ba55a58f
commit
36be6243ad
23 changed files with 910 additions and 4231 deletions
|
@ -11,16 +11,18 @@
|
|||
|
||||
import { Promise as EmberPromise } from 'rsvp';
|
||||
import { inject as service } from '@ember/service';
|
||||
import Tooltips from '../../../mixins/tooltip';
|
||||
import Notifier from '../../../mixins/notifier';
|
||||
import Controller from '@ember/controller';
|
||||
import TooltipMixin from '../../../mixins/tooltip';
|
||||
|
||||
export default Controller.extend(TooltipMixin, {
|
||||
export default Controller.extend(Tooltips, Notifier, {
|
||||
documentService: service('document'),
|
||||
templateService: service('template'),
|
||||
sectionService: service('section'),
|
||||
linkService: service('link'),
|
||||
// currentPageId: '',
|
||||
tab: 'content',
|
||||
tabCount: 0, // how many items inside the tab?
|
||||
queryParams: ['currentPageId'],
|
||||
|
||||
actions: {
|
||||
|
@ -28,16 +30,19 @@ export default Controller.extend(TooltipMixin, {
|
|||
this.set('tab', tab);
|
||||
if (tab === 'content') {
|
||||
this.send('refresh');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onShowPage(pageId) {
|
||||
this.set('tab', 'content');
|
||||
this.get('browser').scrollTo(`#page-${pageId}`);
|
||||
this.get('browser').scrollTo(`#page-${pageId}`);
|
||||
},
|
||||
|
||||
onSaveDocument(doc) {
|
||||
this.get('documentService').save(doc);
|
||||
this.showWait();
|
||||
this.get('documentService').save(doc).then(() => {
|
||||
this.showDone();
|
||||
});
|
||||
this.get('browser').setTitle(doc.get('name'));
|
||||
this.get('browser').setMetaDescription(doc.get('excerpt'));
|
||||
},
|
||||
|
@ -67,11 +72,13 @@ export default Controller.extend(TooltipMixin, {
|
|||
},
|
||||
|
||||
onSavePage(page, meta) {
|
||||
this.showWait();
|
||||
|
||||
let document = this.get('document');
|
||||
let documentId = document.get('id');
|
||||
let constants = this.get('constants');
|
||||
|
||||
// if document approval mode is locked return
|
||||
// if document approval mode is locked return
|
||||
if (document.get('protection') == constants.ProtectionType.Lock) {
|
||||
// should not really happen
|
||||
return;
|
||||
|
@ -84,6 +91,8 @@ export default Controller.extend(TooltipMixin, {
|
|||
};
|
||||
|
||||
this.get('documentService').updatePage(documentId, page.get('id'), model).then((/*up*/) => {
|
||||
this.showDone();
|
||||
|
||||
this.get('documentService').fetchPages(documentId, this.get('session.user.id')).then((pages) => {
|
||||
this.set('pages', pages);
|
||||
this.get('linkService').getDocumentLinks(documentId).then((links) => {
|
||||
|
@ -98,7 +107,7 @@ export default Controller.extend(TooltipMixin, {
|
|||
let deleteId = deletePage.id;
|
||||
let deleteChildren = deletePage.children;
|
||||
let pendingChanges = [];
|
||||
|
||||
|
||||
let pages = this.get('pages');
|
||||
let pageIndex = _.findIndex(pages, function(i) { return i.get('page.id') === deleteId; });
|
||||
let item = pages[pageIndex];
|
||||
|
@ -118,7 +127,7 @@ export default Controller.extend(TooltipMixin, {
|
|||
|
||||
this.get('documentService').deletePages(documentId, deleteId, pendingChanges).then(() => {
|
||||
this.get('documentService').fetchPages(this.get('document.id'), this.get('session.user.id')).then((pages) => {
|
||||
this.set('pages', pages);
|
||||
this.set('pages', pages);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
@ -131,10 +140,13 @@ export default Controller.extend(TooltipMixin, {
|
|||
},
|
||||
|
||||
onInsertSection(data) {
|
||||
this.showWait();
|
||||
|
||||
return new EmberPromise((resolve) => {
|
||||
this.get('documentService').addPage(this.get('document.id'), data).then((newPage) => {
|
||||
let data = this.get('store').normalize('page', newPage);
|
||||
this.get('store').push(data);
|
||||
this.showDone();
|
||||
|
||||
this.get('documentService').fetchPages(this.get('document.id'), this.get('session.user.id')).then((pages) => {
|
||||
this.set('pages', pages);
|
||||
|
@ -179,14 +191,18 @@ export default Controller.extend(TooltipMixin, {
|
|||
},
|
||||
|
||||
onSaveTemplate(name, desc) {
|
||||
this.get('templateService').saveAsTemplate(this.get('document.id'), name, desc).then(function () {});
|
||||
this.showWait();
|
||||
|
||||
this.get('templateService').saveAsTemplate(this.get('document.id'), name, desc).then(function () {
|
||||
this.showDone();
|
||||
});
|
||||
},
|
||||
|
||||
onPageSequenceChange(currentPageId, changes) {
|
||||
this.set('currentPageId', currentPageId);
|
||||
this.get('documentService').changePageSequence(this.get('document.id'), changes).then(() => {
|
||||
this.get('documentService').fetchPages(this.get('document.id'), this.get('session.user.id')).then( (pages) => {
|
||||
this.set('pages', pages);
|
||||
this.set('pages', pages);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -195,15 +211,19 @@ export default Controller.extend(TooltipMixin, {
|
|||
this.set('currentPageId', currentPageId);
|
||||
this.get('documentService').changePageLevel(this.get('document.id'), changes).then(() => {
|
||||
this.get('documentService').fetchPages(this.get('document.id'), this.get('session.user.id')).then( (pages) => {
|
||||
this.set('pages', pages);
|
||||
this.set('pages', pages);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
onTagChange(tags) {
|
||||
this.showDone();
|
||||
|
||||
let doc = this.get('document');
|
||||
doc.set('tags', tags);
|
||||
this.get('documentService').save(doc);
|
||||
this.get('documentService').save(doc).then(()=> {
|
||||
this.showWait();
|
||||
});
|
||||
},
|
||||
|
||||
onRollback(pageId, revisionId) {
|
||||
|
@ -225,6 +245,10 @@ export default Controller.extend(TooltipMixin, {
|
|||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
onReady(count) {
|
||||
this.set('tabCount', count);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue