Skip to content

Commit 8bc34a5

Browse files
author
vinod
committed
update contributor to task
1 parent da76d41 commit 8bc34a5

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

controllers/notes.controller.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,24 @@ notesCtrl.renderNotes = (req, res) => {
4747
};
4848
notesCtrl.renderEditForm = (req, res) => {
4949
async.waterfall([
50-
(callback) => { return callback(null,req.params); },
50+
(callback) => { return callback(null, req.params); },
5151
myFirstFunction,
5252
mySecondFunction
53-
], function(err, result) {
54-
res.render("notes/edit-note", { notes:result });
53+
], function (err, result) {
54+
res.render("notes/edit-note", { notes: result });
5555
});
56-
56+
5757
};
5858

5959
notesCtrl.updateNote = (req, res) => {
60-
const { title, description } = req.body;
61-
Note.findByIdAndUpdate(req.params.id, { title, description })
60+
const { title, description, userid } = req.body;
61+
let obj = {
62+
"$addToSet": { "contributor": { "$each": [userid] } },
63+
"$set": {
64+
title, description
65+
}
66+
}
67+
Note.findByIdAndUpdate(req.params.id, obj)
6268
.then(note => {
6369
req.flash("success_msg", "Note Updated Successfully");
6470
res.redirect("/notes");
@@ -79,7 +85,7 @@ notesCtrl.deleteNote = (req, res) => {
7985
};
8086
notesCtrl.updateStatus = (req, res) => {
8187
// const { title, description } = req.body;
82-
Note.findByIdAndUpdate(req.params.id, { status:true })
88+
Note.findByIdAndUpdate(req.params.id, { status: true })
8389
.then(note => {
8490
req.flash("success_msg", "Note Updated Successfully");
8591
res.redirect("/notes");
@@ -89,11 +95,11 @@ notesCtrl.updateStatus = (req, res) => {
8995
});
9096
};
9197
function myFirstFunction(data, callback) {
92-
Note.findById({_id:data.id})
98+
Note.findById({ _id: data.id })
9399
.then(note => {
94-
callback(null,note)
100+
callback(null, note)
95101
}).catch(err => {
96-
callback(null,[])
102+
callback(null, [])
97103
});
98104
}
99105
function mySecondFunction(data, callback) {

models/Note.js

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const NoteSchema = new Schema(
1818
type: Boolean,
1919
default:false
2020
},
21+
contributor: [],
2122
approval: {
2223
type: Boolean,
2324
default:false

public/css/main.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ body {
3030
.zc-ref {
3131
display: none;
3232
}
33-
33+

views/notes/all-notes.hbs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
<div class="card">
55
<div class="card-body">
66
<h5 class="card-title d-flex justify-content-between align-items-center">
7-
{{ title }} <a href="/notes/edit/{{_id}}"><i class="fas fa-edit"></i></a>
7+
{{ title }} <a href="/notes/edit/{{_id}}"><i class="fas fa-edit" title="Edit Task"></i></a>
88
</h5>
99
<p class="card-text">{{ description }} </p>
1010
</div>
1111
<div class="card-footer d-flex justify-content-between align-items-center">{{ date }}
1212
{{#if status}}
1313
<button type="submit" class="btn">
14-
<i class="fa fa-window-close" style="color:#FF5733;"></i></button>
14+
<i class="fa fa-window-close" title="Close Task" style="color:#FF5733;"></i></button>
1515
{{else}}
1616
<form action="/notes/statusUpdate/{{_id}}" method="POST">
1717
<input type="hidden" name="_method" value="POST">
1818
<button type="submit" class="btn">
19-
<i class="fa fa-check-square" style="color:#008000;"></i></button>
19+
<i class="fa fa-check-square" title="Open Task" style="color:#008000;"></i></button>
2020
</form>
2121
{{/if}}
2222

2323
<form action="/notes/delete/{{_id}}?_method=DELETE" method="POST">
2424
<input type="hidden" name="_method" value="DELETE">
2525
<button type="submit" class="btn">
26-
<i class="fa fa-trash"></i></button>
26+
<i class="fa fa-trash" title="Delete Task" style="color:rgb(8, 8, 8);"></i></button>
2727
</form>
2828

2929

0 commit comments

Comments
 (0)