|
@@ -137,7 +137,7 @@ class PageService {
|
|
|
await this.deleteCompletely(id, path);
|
|
await this.deleteCompletely(id, path);
|
|
|
|
|
|
|
|
if (socketClientId != null) {
|
|
if (socketClientId != null) {
|
|
|
- pageEvent.emit('deleteCompletely', [pageData], user, socketClientId); // update as renamed page
|
|
|
|
|
|
|
+ pageEvent.emit('delete', pageData, user, socketClientId); // update as renamed page
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -155,19 +155,20 @@ class PageService {
|
|
|
await this.completelyDeletePages(pages, user, options);
|
|
await this.completelyDeletePages(pages, user, options);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- async revertDeletedPage(page, user, options = {}) {
|
|
|
|
|
|
|
+ // revert pages recursively
|
|
|
|
|
+ async revertDeletedPages(page, user, options = {}) {
|
|
|
const Page = this.crowi.model('Page');
|
|
const Page = this.crowi.model('Page');
|
|
|
const newPath = Page.getRevertDeletedPageName(page.path);
|
|
const newPath = Page.getRevertDeletedPageName(page.path);
|
|
|
const originPage = await Page.findByPath(newPath);
|
|
const originPage = await Page.findByPath(newPath);
|
|
|
if (originPage != null) {
|
|
if (originPage != null) {
|
|
|
- // When the page is deleted, it will always be created with "redirectTo" in the path of the original page.
|
|
|
|
|
- // So, it's ok to delete the page
|
|
|
|
|
- // However, If a page exists that is not "redirectTo", something is wrong. (Data correction is needed).
|
|
|
|
|
|
|
+ // When the page is deleted, it will always be created with "redirectTo" in the path of the original page.
|
|
|
|
|
+ // So, it's ok to delete the page
|
|
|
|
|
+ // However, If a page exists that is not "redirectTo", something is wrong. (Data correction is needed).
|
|
|
if (originPage.redirectTo !== page.path) {
|
|
if (originPage.redirectTo !== page.path) {
|
|
|
throw new Error('The new page of to revert is exists and the redirect path of the page is not the deleted page.');
|
|
throw new Error('The new page of to revert is exists and the redirect path of the page is not the deleted page.');
|
|
|
}
|
|
}
|
|
|
- await this.completelyDeletePage(originPage, options);
|
|
|
|
|
|
|
+ // originPage is object.
|
|
|
|
|
+ await this.completelyDeletePages([originPage], options);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
page.status = STATUS_PUBLISHED;
|
|
page.status = STATUS_PUBLISHED;
|
|
@@ -177,8 +178,7 @@ class PageService {
|
|
|
return updatedPage;
|
|
return updatedPage;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // revert pages recursively
|
|
|
|
|
- async revertDeletedPages(page, user, options = {}) {
|
|
|
|
|
|
|
+ async revertDeletedPage(page, user, options = {}) {
|
|
|
const Page = this.crowi.model('Page');
|
|
const Page = this.crowi.model('Page');
|
|
|
const newPath = Page.getRevertDeletedPageName(page.path);
|
|
const newPath = Page.getRevertDeletedPageName(page.path);
|
|
|
const originPage = await Page.findByPath(newPath);
|
|
const originPage = await Page.findByPath(newPath);
|
|
@@ -189,7 +189,7 @@ class PageService {
|
|
|
if (originPage.redirectTo !== page.path) {
|
|
if (originPage.redirectTo !== page.path) {
|
|
|
throw new Error('The new page of to revert is exists and the redirect path of the page is not the deleted page.');
|
|
throw new Error('The new page of to revert is exists and the redirect path of the page is not the deleted page.');
|
|
|
}
|
|
}
|
|
|
- await this.completelyDeletePages(originPage, options);
|
|
|
|
|
|
|
+ await this.completelyDeletePage(originPage, options);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
page.status = STATUS_PUBLISHED;
|
|
page.status = STATUS_PUBLISHED;
|