Update old variable name

master
Mark Moffat 2019-12-07 17:52:46 +10:30
parent b3cc17aee0
commit 980c467444
3 changed files with 7 additions and 7 deletions

View File

@ -319,7 +319,7 @@ $(document).ready(function (){
method: 'POST',
url: '/admin/settings/page',
data: {
page_id: $('#page_id').val(),
pageId: $('#pageId').val(),
pageName: $('#pageName').val(),
pageSlug: $('#pageSlug').val(),
pageEnabled: $('#pageEnabled').is(':checked'),

File diff suppressed because one or more lines are too long

View File

@ -271,16 +271,16 @@ router.post('/admin/settings/page', restrict, checkAccess, async (req, res) => {
pageContent: req.body.pageContent
};
if(req.body.page_id){
if(req.body.pageId){
// existing page
const page = await db.pages.findOne({ _id: common.getId(req.body.page_id) });
const page = await db.pages.findOne({ _id: common.getId(req.body.pageId) });
if(!page){
res.status(400).json({ message: 'Page not found' });
}
try{
await db.pages.updateOne({ _id: common.getId(req.body.page_id) }, { $set: doc }, {});
res.status(200).json({ message: 'Page updated successfully', page_id: req.body.page_id });
const updatedPage = await db.pages.findOneAndUpdate({ _id: common.getId(req.body.pageId) }, { $set: doc }, { returnOriginal: false });
res.status(200).json({ message: 'Page updated successfully', pageId: req.body.pageId, page: updatedPage.value });
}catch(ex){
res.status(400).json({ message: 'Error updating page. Please try again.' });
}
@ -288,7 +288,7 @@ router.post('/admin/settings/page', restrict, checkAccess, async (req, res) => {
// insert page
try{
const newDoc = await db.pages.insertOne(doc);
res.status(200).json({ message: 'New page successfully created', page_id: newDoc._id });
res.status(200).json({ message: 'New page successfully created', pageId: newDoc.insertedId });
return;
}catch(ex){
res.status(400).json({ message: 'Error creating page. Please try again.' });