moved config, nav updates on page status change in post editor
This commit is contained in:
parent
0021782037
commit
46f2bcf1ec
8 changed files with 99 additions and 12 deletions
|
@ -118,6 +118,23 @@ router.post("/sync", (req, res, next) =>
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.get('/nav', function(req, res, next)
|
||||||
|
{
|
||||||
|
fs.readJson('config/site-settings.json').then(obj =>
|
||||||
|
{
|
||||||
|
fs.writeJson('config/site-settings.json', obj).then(() =>
|
||||||
|
{
|
||||||
|
res.json(obj.menu);
|
||||||
|
}).catch(err =>
|
||||||
|
{
|
||||||
|
console.error(err)
|
||||||
|
})
|
||||||
|
}).catch(err =>
|
||||||
|
{
|
||||||
|
console.error(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
router.post("/nav-sync", (req, res, next) =>
|
router.post("/nav-sync", (req, res, next) =>
|
||||||
{
|
{
|
||||||
let payload = req.body;
|
let payload = req.body;
|
||||||
|
|
44
themes/dash/assets/js/dash.min.js
vendored
44
themes/dash/assets/js/dash.min.js
vendored
|
@ -5875,6 +5875,8 @@ var _DateUtils = _interopRequireDefault(require("../../../../../brain/tools/util
|
||||||
|
|
||||||
var _DBUtils = _interopRequireDefault(require("../../../../../brain/tools/utilities/DBUtils"));
|
var _DBUtils = _interopRequireDefault(require("../../../../../brain/tools/utilities/DBUtils"));
|
||||||
|
|
||||||
|
var DataEvent = _interopRequireWildcard(require("../../../../../brain/tools/events/DataEvent"));
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||||
|
@ -5966,6 +5968,7 @@ function () {
|
||||||
|
|
||||||
self.dbUtils.modify(id, freshData).then(function (response) {
|
self.dbUtils.modify(id, freshData).then(function (response) {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
|
if (id != null) freshData.page == 'true' ? self.updateNav(true, id, freshData) : self.updateNav(false, id, freshData);
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
|
@ -5985,6 +5988,38 @@ function () {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "updateNav",
|
||||||
|
value: function updateNav(add, id, post) {
|
||||||
|
var self = this;
|
||||||
|
this.dataUtils.request('/api/settings/nav', DataEvent.SETTINGS_LOADED).then(function (response) {
|
||||||
|
var menu = JSON.parse(response.request['response']);
|
||||||
|
var item = {
|
||||||
|
id: id,
|
||||||
|
uuid: post.uuid,
|
||||||
|
title: post.title,
|
||||||
|
slug: post.slug
|
||||||
|
};
|
||||||
|
|
||||||
|
if (add) {
|
||||||
|
menu.push(item);
|
||||||
|
} else {
|
||||||
|
for (var index = 0; index < menu.length; index++) {
|
||||||
|
if (menu[index].id == id) {
|
||||||
|
menu.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.dataUtils.request('/api/settings/nav-sync', DataEvent.SETTINGS_UPDATED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_JSON, menu).then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}).catch(function (err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
}).catch(function (err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
} //--------------------------
|
} //--------------------------
|
||||||
// event handlers
|
// event handlers
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
@ -5995,7 +6030,7 @@ function () {
|
||||||
}();
|
}();
|
||||||
|
|
||||||
exports.default = PostActions;
|
exports.default = PostActions;
|
||||||
},{"../../../../../brain//tools/utilities/DataUtils":"../../../../brain/tools/utilities/DataUtils.js","../../../../../brain//tools/utilities/StringUtils":"../../../../brain/tools/utilities/StringUtils.js","../../../../../brain/tools/utilities/DateUtils":"../../../../brain/tools/utilities/DateUtils.js","../../../../../brain/tools/utilities/DBUtils":"../../../../brain/tools/utilities/DBUtils.js","uuid/v4":"../../../../node_modules/uuid/v4.js"}],"../../../../brain/tools/events/EditorEvent.js":[function(require,module,exports) {
|
},{"../../../../../brain//tools/utilities/DataUtils":"../../../../brain/tools/utilities/DataUtils.js","../../../../../brain//tools/utilities/StringUtils":"../../../../brain/tools/utilities/StringUtils.js","../../../../../brain/tools/utilities/DateUtils":"../../../../brain/tools/utilities/DateUtils.js","../../../../../brain/tools/utilities/DBUtils":"../../../../brain/tools/utilities/DBUtils.js","uuid/v4":"../../../../node_modules/uuid/v4.js","../../../../../brain/tools/events/DataEvent":"../../../../brain/tools/events/DataEvent.js"}],"../../../../brain/tools/events/EditorEvent.js":[function(require,module,exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
@ -8044,7 +8079,6 @@ function () {
|
||||||
(0, _tinyDatePicker.default)(document.getElementById('post-date'), {
|
(0, _tinyDatePicker.default)(document.getElementById('post-date'), {
|
||||||
mode: 'dp-below',
|
mode: 'dp-below',
|
||||||
format: function format(date) {
|
format: function format(date) {
|
||||||
//return date;
|
|
||||||
return self.dateUtils.getDate('origin', date);
|
return self.dateUtils.getDate('origin', date);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -8188,8 +8222,7 @@ function () {
|
||||||
image.src = f.target.result;
|
image.src = f.target.result;
|
||||||
image.title = escape(theFile.name);
|
image.title = escape(theFile.name);
|
||||||
var span = document.createElement('div');
|
var span = document.createElement('div');
|
||||||
span.innerHTML = ['<img src="', f.target.result, '" title="', escape(theFile.name), '"/>'].join(''); //document.getElementById('featured-image-drop').insertBefore(span, null);
|
span.innerHTML = ['<img src="', f.target.result, '" title="', escape(theFile.name), '"/>'].join('');
|
||||||
|
|
||||||
document.getElementById('featured-image-drop').innerHTML = '';
|
document.getElementById('featured-image-drop').innerHTML = '';
|
||||||
document.getElementById('featured-image-drop').appendChild(image);
|
document.getElementById('featured-image-drop').appendChild(image);
|
||||||
};
|
};
|
||||||
|
@ -8656,7 +8689,6 @@ function () {
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
self.dataUtils.request('/api/settings/nav-sync', DataEvent.SETTINGS_UPDATED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_JSON, navData).then(function (response) {
|
self.dataUtils.request('/api/settings/nav-sync', DataEvent.SETTINGS_UPDATED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_JSON, navData).then(function (response) {
|
||||||
//console.log("RESPONSE", response)
|
|
||||||
resolve(response);
|
resolve(response);
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
@ -8765,7 +8797,7 @@ function () {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "edit-item":
|
case "edit-item":
|
||||||
console.log("EDIT STUFF");
|
window.location = "/@/dashboard/posts/edit/" + e.target.getAttribute('data-id');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -45,7 +45,6 @@ export default class NavActions
|
||||||
{
|
{
|
||||||
self.dataUtils.request('/api/settings/nav-sync', DataEvent.SETTINGS_UPDATED, REQUEST_TYPE_POST, CONTENT_TYPE_JSON, navData).then((response) =>
|
self.dataUtils.request('/api/settings/nav-sync', DataEvent.SETTINGS_UPDATED, REQUEST_TYPE_POST, CONTENT_TYPE_JSON, navData).then((response) =>
|
||||||
{
|
{
|
||||||
//console.log("RESPONSE", response)
|
|
||||||
resolve(response)
|
resolve(response)
|
||||||
}).catch((err) =>
|
}).catch((err) =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,7 @@ import StringUtils from '../../../../../brain//tools/utilities/StringUtils';
|
||||||
import DateUtils from '../../../../../brain/tools/utilities/DateUtils';
|
import DateUtils from '../../../../../brain/tools/utilities/DateUtils';
|
||||||
import DBUtils from '../../../../../brain/tools/utilities/DBUtils';
|
import DBUtils from '../../../../../brain/tools/utilities/DBUtils';
|
||||||
var uuidv4 = require('uuid/v4');
|
var uuidv4 = require('uuid/v4');
|
||||||
|
import * as DataEvent from '../../../../../brain/tools/events/DataEvent';
|
||||||
export default class PostActions
|
export default class PostActions
|
||||||
{
|
{
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
@ -92,6 +93,8 @@ export default class PostActions
|
||||||
self.dbUtils.modify(id, freshData).then((response) =>
|
self.dbUtils.modify(id, freshData).then((response) =>
|
||||||
{
|
{
|
||||||
resolve(response)
|
resolve(response)
|
||||||
|
if(id != null) (freshData.page == 'true') ? self.updateNav(true, id, freshData) : self.updateNav(false, id, freshData)
|
||||||
|
|
||||||
}).catch((err) =>
|
}).catch((err) =>
|
||||||
{
|
{
|
||||||
reject(err)
|
reject(err)
|
||||||
|
@ -115,6 +118,44 @@ export default class PostActions
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
updateNav(add, id, post)
|
||||||
|
{
|
||||||
|
var self = this;
|
||||||
|
this.dataUtils.request('/api/settings/nav', DataEvent.SETTINGS_LOADED).then((response) =>
|
||||||
|
{
|
||||||
|
let menu = JSON.parse(response.request['response']);
|
||||||
|
let item = {
|
||||||
|
id: id,
|
||||||
|
uuid: post.uuid,
|
||||||
|
title: post.title,
|
||||||
|
slug: post.slug
|
||||||
|
}
|
||||||
|
if (add)
|
||||||
|
{
|
||||||
|
menu.push(item)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (let index = 0; index < menu.length; index++)
|
||||||
|
{
|
||||||
|
if (menu[index].id == id)
|
||||||
|
{
|
||||||
|
menu.splice(index, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.dataUtils.request('/api/settings/nav-sync', DataEvent.SETTINGS_UPDATED, REQUEST_TYPE_POST, CONTENT_TYPE_JSON, menu).then((response) =>
|
||||||
|
{
|
||||||
|
console.log(response)
|
||||||
|
}).catch((err) =>
|
||||||
|
{
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
|
}).catch((err) =>
|
||||||
|
{
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// event handlers
|
// event handlers
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
|
|
@ -59,7 +59,7 @@ export default class NavIndex
|
||||||
new NavActions().removeItem(id);
|
new NavActions().removeItem(id);
|
||||||
break
|
break
|
||||||
case "edit-item":
|
case "edit-item":
|
||||||
console.log("EDIT STUFF");
|
window.location = "/@/dashboard/posts/edit/" + e.target.getAttribute('data-id');
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,6 @@ export default class PostEditor
|
||||||
mode: 'dp-below',
|
mode: 'dp-below',
|
||||||
format(date)
|
format(date)
|
||||||
{
|
{
|
||||||
//return date;
|
|
||||||
return self.dateUtils.getDate('origin', date);
|
return self.dateUtils.getDate('origin', date);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -209,7 +208,6 @@ export default class PostEditor
|
||||||
f.target.result, '" title="',
|
f.target.result, '" title="',
|
||||||
escape(theFile.name), '"/>'
|
escape(theFile.name), '"/>'
|
||||||
].join('');
|
].join('');
|
||||||
//document.getElementById('featured-image-drop').insertBefore(span, null);
|
|
||||||
document.getElementById('featured-image-drop').innerHTML = '';
|
document.getElementById('featured-image-drop').innerHTML = '';
|
||||||
document.getElementById('featured-image-drop').appendChild(image);
|
document.getElementById('featured-image-drop').appendChild(image);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue