forked from projects/fipamo
sets page menu status to false when corresponding menu item is removed from menu
This commit is contained in:
parent
75b4cb9ac2
commit
0fa1bebc8a
6 changed files with 21 additions and 8 deletions
|
@ -66,6 +66,13 @@ router.post('/sync', (req, res) => {
|
|||
router.post('/nav-sync', (req, res) => {
|
||||
auth.authCheck(req)
|
||||
.then(() => {
|
||||
// find removoed menu item page and set menu to false
|
||||
book.getPage(req.body.remove).then(page => {
|
||||
let body = page.metadata;
|
||||
body.content = page.content;
|
||||
body.menu = false;
|
||||
book.editPage(body, body.uuid, DataEvent.API_PAGE_WRITE, req.session.user);
|
||||
});
|
||||
nav.sync(req.body)
|
||||
.then(response => {
|
||||
res.json({
|
||||
|
@ -187,8 +194,8 @@ router.post('/add-feature-background', background_upload, (req, res) => {
|
|||
url: '/' + image
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('ERROR', err);
|
||||
.catch(() => {
|
||||
//console.log('ERROR', err);
|
||||
});
|
||||
} else {
|
||||
res.json({
|
||||
|
|
|
@ -49,6 +49,9 @@ export default class Book {
|
|||
} else {
|
||||
setTimeout(() => {
|
||||
//TODO: Duct tape solution until something better created
|
||||
|
||||
//make check against menu to see if page should be marked as menu item
|
||||
//if it doesnt' exist in menu change, edit page to
|
||||
let page = _.find(pages, list => {
|
||||
return list.metadata.uuid === id;
|
||||
});
|
||||
|
@ -89,9 +92,9 @@ export default class Book {
|
|||
moment(body.created).format('YYYY') +
|
||||
'/' +
|
||||
moment(body.created).format('MM');
|
||||
nav.editMenu(DataEvent.MENU_ADD_ITEM, body);
|
||||
nav.editMenu(DataEvent.MENU_ADD_ITEM, body, user);
|
||||
} else {
|
||||
nav.editMenu(DataEvent.MENU_DELETE_ITEM, body);
|
||||
nav.editMenu(DataEvent.MENU_DELETE_ITEM, body, user);
|
||||
}
|
||||
if (body.layout !== 'page') layout = body.layout;
|
||||
if (body.layout === null || body.layout === 'null') layout = 'page';
|
||||
|
|
|
@ -19,7 +19,7 @@ export default class Navigation {
|
|||
.load(SETTINGS_FILE)
|
||||
.then(settings => {
|
||||
let payload = body;
|
||||
settings.menu = payload;
|
||||
settings.menu = payload.nav;
|
||||
fs.writeJson('site/settings.json', settings)
|
||||
.then(() => {
|
||||
response = {
|
||||
|
|
|
@ -12,5 +12,5 @@ block main-content
|
|||
= menu[index].title
|
||||
#nav-btns
|
||||
button.nav-btn#edit-item(data-id=menu[index].uuid) EDIT
|
||||
button.nav-btn#remove-item(data-id=menu[index].id) REMOVE
|
||||
button.nav-btn#remove-item(data-id=menu[index].id, data-uuid=menu[index].uuid) REMOVE
|
||||
|
||||
|
|
|
@ -18,8 +18,10 @@ export default class NavActions {
|
|||
path: items[index].getAttribute('data-path')
|
||||
});
|
||||
}
|
||||
|
||||
let data = { nav: navData, remove: null };
|
||||
return new Promise(function (resolve) {
|
||||
resolve(navData);
|
||||
resolve(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ export default class NavIndex {
|
|||
id = e.target.getAttribute('data-id');
|
||||
new NavActions().removeItem(id);
|
||||
new NavActions().syncMenu().then(data => {
|
||||
data.remove = e.target.getAttribute('data-uuid');
|
||||
api.syncNav(data).then(r => {
|
||||
if (r.type == DataEvent.MENU_UPDATED) {
|
||||
notify.alert(r.message, true);
|
||||
|
@ -53,7 +54,7 @@ export default class NavIndex {
|
|||
});
|
||||
break;
|
||||
case 'edit-item':
|
||||
window.location = '/@/dashboard/pages/edit/' + e.target.getAttribute('data-id');
|
||||
window.location = '/@/dashboard/page/edit/' + e.target.getAttribute('data-id');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue