mirror of
https://github.com/documize/community.git
synced 2025-07-19 21:29:42 +02:00
changed delete page to use DELETE verb and more Ember idiomatic
This commit is contained in:
parent
e9def2e71f
commit
0655fab204
6 changed files with 24 additions and 23 deletions
|
@ -128,14 +128,14 @@ export default Ember.Controller.extend(NotifierMixin, {
|
||||||
let pendingChanges = [];
|
let pendingChanges = [];
|
||||||
|
|
||||||
// select affected pages
|
// select affected pages
|
||||||
for (var i = pageIndex + 1; i < pages.length; i++) {
|
for (var i = pageIndex + 1; i < pages.get('length'); i++) {
|
||||||
if (pages[i].level <= page.level) {
|
if (pages[i].get('level') <= page.get('level')) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pendingChanges.push({
|
pendingChanges.push({
|
||||||
pageId: pages[i].id,
|
pageId: pages[i].get('id'),
|
||||||
level: pages[i].level - 1
|
level: pages[i].get('level') - 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ export default Ember.Controller.extend(NotifierMixin, {
|
||||||
// page delete followed by re-leveling child pages
|
// page delete followed by re-leveling child pages
|
||||||
this.get('documentService').deletePage(documentId, deleteId).then(function () {
|
this.get('documentService').deletePage(documentId, deleteId).then(function () {
|
||||||
self.set('pages', _.reject(self.get('pages'), function (p) {
|
self.set('pages', _.reject(self.get('pages'), function (p) {
|
||||||
return p.id === deleteId;
|
return p.get('id') === deleteId;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
self.audit.record("deleted-page");
|
self.audit.record("deleted-page");
|
||||||
|
|
|
@ -145,11 +145,12 @@ export default Ember.Service.extend({
|
||||||
|
|
||||||
// Nukes multiple pages from the document.
|
// Nukes multiple pages from the document.
|
||||||
deletePages: function (documentId, pageId, payload) {
|
deletePages: function (documentId, pageId, payload) {
|
||||||
let url = `documents/${documentId}/pages/${pageId}`;
|
let url = `documents/${documentId}/pages`;
|
||||||
|
|
||||||
return this.get('ajax').post(url, {
|
return this.get('ajax').request(url, {
|
||||||
data: JSON.stringify(payload),
|
data: JSON.stringify(payload),
|
||||||
contentType: 'json'
|
contentType: 'json',
|
||||||
|
method: 'DELETE'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ function getState(toc, page) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (page.get('level') === toc[i3].get('level')) {
|
if (page.get('level') === toc[i3].get('level')) {
|
||||||
state.tocTools.downTarget = toc[i3].id;
|
state.tocTools.downTarget = toc[i3].get('id');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ function moveUp(state, pages, current) {
|
||||||
var sequence = (sequence1 + sequence2) / 2;
|
var sequence = (sequence1 + sequence2) / 2;
|
||||||
|
|
||||||
pendingChanges.push({
|
pendingChanges.push({
|
||||||
pageId: current.id,
|
pageId: current.get('id'),
|
||||||
sequence: sequence
|
sequence: sequence
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ function moveUp(state, pages, current) {
|
||||||
sequence = (sequence + page1.get('sequence')) / 2;
|
sequence = (sequence + page1.get('sequence')) / 2;
|
||||||
|
|
||||||
pendingChanges.push({
|
pendingChanges.push({
|
||||||
pageId: pages[i].id,
|
pageId: pages[i].get('id'),
|
||||||
sequence: sequence
|
sequence: sequence
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ function moveDown(state, pages, current) {
|
||||||
var upperSequence = 0;
|
var upperSequence = 0;
|
||||||
var cutOff = _.rest(pages, downTargetIndex);
|
var cutOff = _.rest(pages, downTargetIndex);
|
||||||
var siblings = _.reject(cutOff, function (p) {
|
var siblings = _.reject(cutOff, function (p) {
|
||||||
return p.get('level') !== current.get('level') || p.id === current.id || p.id === downTarget.id;
|
return p.get('level') !== current.get('level') || p.get('id') === current.get('id') || p.get('id') === downTarget.get('id');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (siblings.length > 0) {
|
if (siblings.length > 0) {
|
||||||
|
@ -208,7 +208,7 @@ function moveDown(state, pages, current) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pendingChanges.push({
|
pendingChanges.push({
|
||||||
pageId: current.id,
|
pageId: current.get('id'),
|
||||||
sequence: startingSequence
|
sequence: startingSequence
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ function moveDown(state, pages, current) {
|
||||||
var sequence2 = (sequence + upperSequence) / 2;
|
var sequence2 = (sequence + upperSequence) / 2;
|
||||||
|
|
||||||
pendingChanges.push({
|
pendingChanges.push({
|
||||||
pageId: pages[i].id,
|
pageId: pages[i].get('id'),
|
||||||
sequence: sequence2
|
sequence: sequence2
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ function indent(state, pages, current) {
|
||||||
var pendingChanges = [];
|
var pendingChanges = [];
|
||||||
|
|
||||||
pendingChanges.push({
|
pendingChanges.push({
|
||||||
pageId: current.id,
|
pageId: current.get('id'),
|
||||||
level: current.get('level') + state.tocTools.indentIncrement
|
level: current.get('level') + state.tocTools.indentIncrement
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ function indent(state, pages, current) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pendingChanges.push({
|
pendingChanges.push({
|
||||||
pageId: pages[i].id,
|
pageId: pages[i].get('id'),
|
||||||
level: pages[i].get('level') + state.tocTools.indentIncrement
|
level: pages[i].get('level') + state.tocTools.indentIncrement
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ function outdent(state, pages, current) {
|
||||||
var pendingChanges = [];
|
var pendingChanges = [];
|
||||||
|
|
||||||
pendingChanges.push({
|
pendingChanges.push({
|
||||||
pageId: current.id,
|
pageId: current.get('id'),
|
||||||
level: current.get('level') - 1
|
level: current.get('level') - 1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ function outdent(state, pages, current) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pendingChanges.push({
|
pendingChanges.push({
|
||||||
pageId: pages[i].id,
|
pageId: pages[i].get('id'),
|
||||||
level: pages[i].get('level') - 1
|
level: pages[i].get('level') - 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ import (
|
||||||
"github.com/documize/community/core/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/core/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/core/api/util"
|
"github.com/documize/community/core/api/util"
|
||||||
"github.com/documize/community/core/section/provider"
|
|
||||||
"github.com/documize/community/core/log"
|
"github.com/documize/community/core/log"
|
||||||
|
"github.com/documize/community/core/section/provider"
|
||||||
"github.com/documize/community/core/utility"
|
"github.com/documize/community/core/utility"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
@ -287,7 +287,7 @@ func DeleteDocumentPage(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
pageID := params["pageID"]
|
pageID := params["pageID"]
|
||||||
|
|
||||||
if len(documentID) == 0 {
|
if len(pageID) == 0 {
|
||||||
writeMissingDataError(w, method, "pageID")
|
writeMissingDataError(w, method, "pageID")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ func init() {
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages", []string{"GET", "OPTIONS"}, nil, GetDocumentPages))
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages", []string{"GET", "OPTIONS"}, nil, GetDocumentPages))
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}", []string{"PUT", "OPTIONS"}, nil, UpdateDocumentPage))
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}", []string{"PUT", "OPTIONS"}, nil, UpdateDocumentPage))
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}", []string{"DELETE", "OPTIONS"}, nil, DeleteDocumentPage))
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}", []string{"DELETE", "OPTIONS"}, nil, DeleteDocumentPage))
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}", []string{"POST", "OPTIONS"}, nil, DeleteDocumentPages))
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages", []string{"DELETE", "OPTIONS"}, nil, DeleteDocumentPages))
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}", []string{"GET", "OPTIONS"}, nil, GetDocumentPage))
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}", []string{"GET", "OPTIONS"}, nil, GetDocumentPage))
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages", []string{"POST", "OPTIONS"}, nil, AddDocumentPage))
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages", []string{"POST", "OPTIONS"}, nil, AddDocumentPage))
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/attachments", []string{"GET", "OPTIONS"}, nil, GetAttachments))
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/attachments", []string{"GET", "OPTIONS"}, nil, GetAttachments))
|
||||||
|
|
|
@ -26,8 +26,8 @@ type ProdInfo struct {
|
||||||
// Product returns product edition details
|
// Product returns product edition details
|
||||||
func Product() (p ProdInfo) {
|
func Product() (p ProdInfo) {
|
||||||
p.Major = "0"
|
p.Major = "0"
|
||||||
p.Minor = "24"
|
p.Minor = "25"
|
||||||
p.Patch = "1"
|
p.Patch = "0"
|
||||||
p.Version = fmt.Sprintf("%s.%s.%s", p.Major, p.Minor, p.Patch)
|
p.Version = fmt.Sprintf("%s.%s.%s", p.Major, p.Minor, p.Patch)
|
||||||
p.Edition = "Community"
|
p.Edition = "Community"
|
||||||
p.Title = fmt.Sprintf("%s Edition", p.Edition)
|
p.Title = fmt.Sprintf("%s Edition", p.Edition)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue