mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
improve level code
This commit is contained in:
parent
049b83e0b9
commit
5f59e95495
25 changed files with 1104 additions and 461 deletions
|
@ -10,12 +10,10 @@
|
|||
// https://documize.com
|
||||
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
import Component from '@ember/component';
|
||||
import NotifierMixin from '../../mixins/notifier';
|
||||
import TooltipMixin from '../../mixins/tooltip';
|
||||
|
||||
export default Component.extend(NotifierMixin, TooltipMixin, {
|
||||
export default Component.extend(TooltipMixin, {
|
||||
documentService: service('document'),
|
||||
sectionService: service('section'),
|
||||
editMode: false,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
// https://documize.com
|
||||
|
||||
import { computed } from '@ember/object';
|
||||
import { schedule } from '@ember/runloop'
|
||||
import { schedule } from '@ember/runloop';
|
||||
import { inject as service } from '@ember/service';
|
||||
import Component from '@ember/component';
|
||||
import tocUtil from '../../utils/toc';
|
||||
|
|
|
@ -57,7 +57,6 @@ export default Component.extend(ModalMixin, {
|
|||
this.attrs.onCancel();
|
||||
},
|
||||
|
||||
|
||||
onAction() {
|
||||
if (this.get('busy')) {
|
||||
return;
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
import { computed } from '@ember/object';
|
||||
import Model from 'ember-data/model';
|
||||
import attr from 'ember-data/attr';
|
||||
// import { hasMany } from 'ember-data/relationships';
|
||||
|
||||
export default Model.extend({
|
||||
documentId: attr('string'),
|
||||
|
@ -28,10 +27,11 @@ export default Model.extend({
|
|||
body: attr('string'),
|
||||
rawBody: attr('string'),
|
||||
meta: attr(),
|
||||
approval: attr('number', { defaultValue: 0 }),
|
||||
relativeId: attr('string'),
|
||||
|
||||
tagName: computed('level', function () {
|
||||
return "h2";
|
||||
// return "h" + (this.get('level') + 1);
|
||||
}),
|
||||
|
||||
tocIndent: computed('level', function () {
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
// https://documize.com
|
||||
|
||||
import { set } from '@ember/object';
|
||||
|
||||
import { A } from '@ember/array';
|
||||
import ArrayProxy from '@ember/array/proxy';
|
||||
import Service, { inject as service } from '@ember/service';
|
||||
|
@ -21,6 +20,10 @@ export default Service.extend({
|
|||
ajax: service(),
|
||||
store: service(),
|
||||
|
||||
//**************************************************
|
||||
// Document
|
||||
//**************************************************
|
||||
|
||||
// Returns document model for specified document id.
|
||||
getDocument(documentId) {
|
||||
return this.get('ajax').request(`documents/${documentId}`, {
|
||||
|
@ -62,24 +65,6 @@ export default Service.extend({
|
|||
});
|
||||
},
|
||||
|
||||
changePageSequence(documentId, payload) {
|
||||
let url = `documents/${documentId}/pages/sequence`;
|
||||
|
||||
return this.get('ajax').post(url, {
|
||||
data: JSON.stringify(payload),
|
||||
contentType: 'json'
|
||||
});
|
||||
},
|
||||
|
||||
changePageLevel(documentId, payload) {
|
||||
let url = `documents/${documentId}/pages/level`;
|
||||
|
||||
return this.get('ajax').post(url, {
|
||||
data: JSON.stringify(payload),
|
||||
contentType: 'json'
|
||||
});
|
||||
},
|
||||
|
||||
deleteDocument(documentId) {
|
||||
let url = `documents/${documentId}`;
|
||||
|
||||
|
@ -88,6 +73,20 @@ export default Service.extend({
|
|||
});
|
||||
},
|
||||
|
||||
//**************************************************
|
||||
// Page
|
||||
//**************************************************
|
||||
|
||||
// addPage inserts new page to an existing document.
|
||||
addPage(documentId, payload) {
|
||||
let url = `documents/${documentId}/pages`;
|
||||
|
||||
return this.get('ajax').post(url, {
|
||||
data: JSON.stringify(payload),
|
||||
contentType: 'json'
|
||||
});
|
||||
},
|
||||
|
||||
updatePage(documentId, pageId, payload, skipRevision) {
|
||||
var revision = skipRevision ? "?r=true" : "?r=false";
|
||||
let url = `documents/${documentId}/pages/${pageId}${revision}`;
|
||||
|
@ -104,106 +103,6 @@ export default Service.extend({
|
|||
});
|
||||
},
|
||||
|
||||
// addPage inserts new page to an existing document.
|
||||
addPage(documentId, payload) {
|
||||
let url = `documents/${documentId}/pages`;
|
||||
|
||||
return this.get('ajax').post(url, {
|
||||
data: JSON.stringify(payload),
|
||||
contentType: 'json'
|
||||
});
|
||||
},
|
||||
|
||||
// Nukes multiple pages from the document.
|
||||
deletePages(documentId, pageId, payload) {
|
||||
let url = `documents/${documentId}/pages`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
data: JSON.stringify(payload),
|
||||
contentType: 'json',
|
||||
method: 'DELETE'
|
||||
});
|
||||
},
|
||||
|
||||
// Nukes a single page from the document.
|
||||
deletePage(documentId, pageId) {
|
||||
let url = `documents/${documentId}/pages/${pageId}`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
},
|
||||
|
||||
getDocumentRevisions(documentId) {
|
||||
let url = `documents/${documentId}/revisions`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
method: "GET"
|
||||
});
|
||||
},
|
||||
|
||||
getPageRevisions(documentId, pageId) {
|
||||
let url = `documents/${documentId}/pages/${pageId}/revisions`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
method: "GET"
|
||||
});
|
||||
},
|
||||
|
||||
getPageRevisionDiff(documentId, pageId, revisionId) {
|
||||
let url = `documents/${documentId}/pages/${pageId}/revisions/${revisionId}`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
method: "GET",
|
||||
dataType: 'text'
|
||||
}).then((response) => {
|
||||
return response;
|
||||
}).catch(() => {
|
||||
return "";
|
||||
});
|
||||
},
|
||||
|
||||
rollbackPage(documentId, pageId, revisionId) {
|
||||
let url = `documents/${documentId}/pages/${pageId}/revisions/${revisionId}`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
method: "POST"
|
||||
});
|
||||
},
|
||||
|
||||
// document meta referes to number of views, edits, approvals, etc.
|
||||
getActivity(documentId) {
|
||||
return this.get('ajax').request(`documents/${documentId}/activity`, {
|
||||
method: "GET"
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('documentActivity', obj);
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return data;
|
||||
}).catch(() => {
|
||||
return [];
|
||||
});
|
||||
},
|
||||
|
||||
// Returns all pages without the content
|
||||
getTableOfContents(documentId) {
|
||||
|
||||
return this.get('ajax').request(`documents/${documentId}/pages?content=0`, {
|
||||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('page', obj);
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
// Returns all document pages with content
|
||||
getPages(documentId) {
|
||||
return this.get('ajax').request(`documents/${documentId}/pages`, {
|
||||
|
@ -243,6 +142,130 @@ export default Service.extend({
|
|||
});
|
||||
},
|
||||
|
||||
// Nukes multiple pages from the document.
|
||||
deletePages(documentId, pageId, payload) {
|
||||
let url = `documents/${documentId}/pages`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
data: JSON.stringify(payload),
|
||||
contentType: 'json',
|
||||
method: 'DELETE'
|
||||
});
|
||||
},
|
||||
|
||||
// Nukes a single page from the document.
|
||||
deletePage(documentId, pageId) {
|
||||
let url = `documents/${documentId}/pages/${pageId}`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
},
|
||||
|
||||
//**************************************************
|
||||
// Page Revisions
|
||||
//**************************************************
|
||||
|
||||
getDocumentRevisions(documentId) {
|
||||
let url = `documents/${documentId}/revisions`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
method: "GET"
|
||||
});
|
||||
},
|
||||
|
||||
getPageRevisions(documentId, pageId) {
|
||||
let url = `documents/${documentId}/pages/${pageId}/revisions`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
method: "GET"
|
||||
});
|
||||
},
|
||||
|
||||
getPageRevisionDiff(documentId, pageId, revisionId) {
|
||||
let url = `documents/${documentId}/pages/${pageId}/revisions/${revisionId}`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
method: "GET",
|
||||
dataType: 'text'
|
||||
}).then((response) => {
|
||||
return response;
|
||||
}).catch(() => {
|
||||
return "";
|
||||
});
|
||||
},
|
||||
|
||||
rollbackPage(documentId, pageId, revisionId) {
|
||||
let url = `documents/${documentId}/pages/${pageId}/revisions/${revisionId}`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
method: "POST"
|
||||
});
|
||||
},
|
||||
|
||||
//**************************************************
|
||||
// Activity
|
||||
//**************************************************
|
||||
|
||||
// document meta referes to number of views, edits, approvals, etc.
|
||||
getActivity(documentId) {
|
||||
return this.get('ajax').request(`documents/${documentId}/activity`, {
|
||||
method: "GET"
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('documentActivity', obj);
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return data;
|
||||
}).catch(() => {
|
||||
return [];
|
||||
});
|
||||
},
|
||||
|
||||
//**************************************************
|
||||
// Table of contents
|
||||
//**************************************************
|
||||
|
||||
// Returns all pages without the content
|
||||
getTableOfContents(documentId) {
|
||||
|
||||
return this.get('ajax').request(`documents/${documentId}/pages?content=0`, {
|
||||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('page', obj);
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
changePageSequence(documentId, payload) {
|
||||
let url = `documents/${documentId}/pages/sequence`;
|
||||
|
||||
return this.get('ajax').post(url, {
|
||||
data: JSON.stringify(payload),
|
||||
contentType: 'json'
|
||||
});
|
||||
},
|
||||
|
||||
changePageLevel(documentId, payload) {
|
||||
let url = `documents/${documentId}/pages/level`;
|
||||
|
||||
return this.get('ajax').post(url, {
|
||||
data: JSON.stringify(payload),
|
||||
contentType: 'json'
|
||||
});
|
||||
},
|
||||
|
||||
//**************************************************
|
||||
// Attachments
|
||||
//**************************************************
|
||||
|
||||
// document attachments without the actual content
|
||||
getAttachments(documentId) {
|
||||
|
||||
|
|
|
@ -10,18 +10,20 @@
|
|||
// https://documize.com
|
||||
|
||||
html {
|
||||
overflow-y: scroll;
|
||||
font-family: $font-regular;
|
||||
font-size: 0.875rem;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-ms-overflow-style: -ms-autohiding-scrollbar;
|
||||
overflow-y: scroll;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
a {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue