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', method: 'POST',
url: '/admin/settings/page', url: '/admin/settings/page',
data: { data: {
page_id: $('#page_id').val(), pageId: $('#pageId').val(),
pageName: $('#pageName').val(), pageName: $('#pageName').val(),
pageSlug: $('#pageSlug').val(), pageSlug: $('#pageSlug').val(),
pageEnabled: $('#pageEnabled').is(':checked'), 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 pageContent: req.body.pageContent
}; };
if(req.body.page_id){ if(req.body.pageId){
// existing page // 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){ if(!page){
res.status(400).json({ message: 'Page not found' }); res.status(400).json({ message: 'Page not found' });
} }
try{ try{
await db.pages.updateOne({ _id: common.getId(req.body.page_id) }, { $set: doc }, {}); const updatedPage = await db.pages.findOneAndUpdate({ _id: common.getId(req.body.pageId) }, { $set: doc }, { returnOriginal: false });
res.status(200).json({ message: 'Page updated successfully', page_id: req.body.page_id }); res.status(200).json({ message: 'Page updated successfully', pageId: req.body.pageId, page: updatedPage.value });
}catch(ex){ }catch(ex){
res.status(400).json({ message: 'Error updating page. Please try again.' }); 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 // insert page
try{ try{
const newDoc = await db.pages.insertOne(doc); 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; return;
}catch(ex){ }catch(ex){
res.status(400).json({ message: 'Error creating page. Please try again.' }); res.status(400).json({ message: 'Error creating page. Please try again.' });