|
|
|
@ -3,7 +3,6 @@ import _ from 'lodash';
|
|
|
|
|
import * as DataEvent from '../../src/com/events/DataEvent';
|
|
|
|
|
import Settings, { SETTINGS_FILE } from './Settings';
|
|
|
|
|
const settings = new Settings();
|
|
|
|
|
//const settings = require('../../site/settings.json');
|
|
|
|
|
|
|
|
|
|
export default class Navigation {
|
|
|
|
|
//--------------------------
|
|
|
|
@ -13,9 +12,9 @@ export default class Navigation {
|
|
|
|
|
//--------------------------
|
|
|
|
|
// methods
|
|
|
|
|
//--------------------------
|
|
|
|
|
sync(req) {
|
|
|
|
|
sync(body) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
let payload = req.body;
|
|
|
|
|
let payload = body;
|
|
|
|
|
settings.menu = payload;
|
|
|
|
|
let response = [];
|
|
|
|
|
fs.writeJson('site/settings.json', settings)
|
|
|
|
@ -37,18 +36,26 @@ export default class Navigation {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
editMenu(task, item) {
|
|
|
|
|
switch (task) {
|
|
|
|
|
case DataEvent.MENU_ADD_ITEM:
|
|
|
|
|
break;
|
|
|
|
|
case DataEvent.MENU_DELETE_ITEM:
|
|
|
|
|
settings.load(SETTINGS_FILE).then(settings => {
|
|
|
|
|
settings.load(SETTINGS_FILE).then(settings => {
|
|
|
|
|
switch (task) {
|
|
|
|
|
case DataEvent.MENU_ADD_ITEM:
|
|
|
|
|
settings.menu.push({
|
|
|
|
|
title: item.title,
|
|
|
|
|
id: item.id,
|
|
|
|
|
slug: item.slug,
|
|
|
|
|
uuid: item.uuid,
|
|
|
|
|
path: item.path
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case DataEvent.MENU_DELETE_ITEM:
|
|
|
|
|
settings.menu = _.remove(settings.menu, m => {
|
|
|
|
|
return m.uuid != item.uuid;
|
|
|
|
|
});
|
|
|
|
|
fs.writeJSON(SETTINGS_FILE, settings);
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
fs.writeJSON(SETTINGS_FILE, settings);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------
|
|
|
|
|