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