This commit is contained in:
@@ -19,12 +19,12 @@ router.get('/list', async (req, res) => {
|
||||
if (!hasAccess) return res.json({ status: 'error', msg: 'unauthorized' });
|
||||
|
||||
const folders = await Folder.find({ campaign })
|
||||
.select('_id name date')
|
||||
.select('_id name date color')
|
||||
.sort({ date: -1 })
|
||||
.lean();
|
||||
|
||||
const rootNotes = await Note.find({ campaign, folder: null })
|
||||
.select('_id title content date')
|
||||
.select('_id title content date color')
|
||||
.sort({ date: -1 })
|
||||
.lean();
|
||||
|
||||
@@ -48,12 +48,12 @@ router.get('/subfolder/list', async (req, res) => {
|
||||
if (!folderDoc) return res.json({ status: 'error', msg: 'errors.notfound' });
|
||||
|
||||
const subfolders = await Folder.find({ campaign, parentFolder: folder })
|
||||
.select('_id name date')
|
||||
.select('_id name date color')
|
||||
.sort({ date: -1 })
|
||||
.lean();
|
||||
|
||||
const notes = await Note.find({ campaign, folder: folder })
|
||||
.select('_id title content date')
|
||||
.select('_id title content date color')
|
||||
.sort({ date: -1 })
|
||||
.lean();
|
||||
|
||||
@@ -90,7 +90,7 @@ router.post('/create', async (req, res) => {
|
||||
|
||||
router.post('/update', async (req, res) => {
|
||||
try {
|
||||
const { id, title, content, folder } = req.body;
|
||||
const { id, title, content, folder, color } = req.body;
|
||||
if (!id) return res.json({ status: 'error', msg: 'errors.missing-data' });
|
||||
|
||||
const note = await Note.findById(id);
|
||||
@@ -102,6 +102,7 @@ router.post('/update', async (req, res) => {
|
||||
if (title !== undefined) note.title = title;
|
||||
if (content !== undefined) note.content = content;
|
||||
if (folder !== undefined) note.folder = folder;
|
||||
if (color !== undefined) note.color = color;
|
||||
await note.save();
|
||||
res.json({ status: 'ok', note });
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user