Skip to content

Commit 5d4a37e

Browse files
committed
task assignment
1 parent 581e4ae commit 5d4a37e

File tree

10 files changed

+183
-23
lines changed

10 files changed

+183
-23
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "one-task",
33
"version": "1.0.0",
44
"description": "Vue.js app featuring a task manager with chatbot installed to assist with each task",
5-
"author": "Deep Chakraborty (deep9c@gmail.com)",
5+
"author": "Deep Chakraborty (contact@deepchakraborty.com)",
66
"private": true,
77
"scripts": {
88
"dev": "node build/dev-server.js",

src/components/AssignTask.vue

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<template>
2+
<div class='ui basic content center aligned segment'>
3+
<button v-on:click="openForm" v-show="!isCreating">
4+
<i class='glyphicon glyphicon-plus'></i>
5+
</button>
6+
<div class='ui centered card' v-show="isCreating">
7+
<div class='content'>
8+
<div class='ui form'>
9+
<div class='field'>
10+
<label>Assign task to </label>
11+
<input v-model="usernameText" type='text' ref='title' defaultValue="">
12+
</div>
13+
<div class='ui two button attached buttons'>
14+
<button class='ui basic blue button' v-on:click="assignTask">
15+
Assign
16+
</button>
17+
<button class='ui basic red button' v-on:click="closeForm">
18+
Cancel
19+
</button>
20+
</div>
21+
</div>
22+
</div>
23+
</div>
24+
</div>
25+
</template>
26+
27+
<script>
28+
import api from '../utils/api'
29+
30+
export default {
31+
name: 'AssignTask',
32+
33+
data() {
34+
return {
35+
usernameText: '',
36+
isCreating: false,
37+
};
38+
},
39+
40+
props: {
41+
42+
},
43+
44+
methods: {
45+
openForm() {
46+
//console.log("open form");
47+
this.isCreating = true;
48+
},
49+
closeForm() {
50+
this.isCreating = false;
51+
},
52+
assignTask() {
53+
//console.log("send form " + this.usernameText.length);
54+
//take WSID from prop; take userid as input; call Node... Node will respond 404 NotFound is user doesnt exist; or the user details if 200 Success
55+
if (this.usernameText.length > 0) {
56+
const assigneeusername = this.usernameText;
57+
this.$emit('assign-task', {
58+
assigneeusername,
59+
});
60+
/*
61+
var assignTaskToUser = {
62+
assigneeusername: this.usernameText
63+
}
64+
api.assignTaskToUser(assignTaskToUser)
65+
.then((resp)=>{
66+
console.log('assignTaskToUser response');
67+
});
68+
*/
69+
70+
this.usernameText='';
71+
}
72+
this.isCreating = false;
73+
},
74+
},
75+
};
76+
</script>
77+
78+
<style>
79+
#memberIds {
80+
color: #ffffff;
81+
font-size:small;
82+
}
83+
</style>

src/components/Comments.vue

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<template>
22
<div class="detailBox">
33
<div class="titleBox">
4-
<label>Comments: {{selectedTask.title}}</label>
5-
<button type="button" class="close" aria-hidden="true">&times;</button>
4+
<!--label>Comments: {{selectedTask.title}}</label-->
5+
<table> <tr> <td> <b>Assignee:</b> {{selectedTask.AssigneeUserId}} </td><td>
6+
<AssignTask v-on:assign-task="assignTask"></AssignTask> </td></tr> </table>
7+
<!--button type="button" class="close" aria-hidden="true">&times;</button-->
68
</div>
79
<div class="commentBox">
810

@@ -41,9 +43,14 @@
4143

4244
<script>
4345
import api from '../utils/api'
46+
import AssignTask from './AssignTask'
4447
4548
export default{
4649
name: 'Comments',
50+
51+
components: {
52+
AssignTask,
53+
},
4754
4855
props: {
4956
selectedTask: {
@@ -99,8 +106,21 @@
99106
height: '20px'
100107
}, 500, function() {
101108
// Animation complete.
102-
});
109+
});
103110
},
111+
112+
assignTask(assigneeusername){
113+
var assignTaskToUser = {
114+
operation: 'update',
115+
taskid: this.selectedTask._id,
116+
AssigneeUserId: assigneeusername.assigneeusername
117+
}
118+
api.assignTaskToUser(assignTaskToUser)
119+
.then((resp)=>{
120+
console.log('assignTaskToUser response:- ' + JSON.stringify(resp));
121+
this.selectedTask.AssigneeUserId = assigneeusername.assigneeusername;
122+
});
123+
},
104124
},
105125
106126
beforeUpdate(){

src/components/CreateProject.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default {
4949
},
5050
sendForm() {
5151
//console.log("send form " + this.nameText.length);
52-
if (this.nameText.length > 0 && this.description.length > 0) {
52+
if (this.nameText.length > 0) {
5353
const name = this.nameText;
5454
const description = this.description;
5555
this.$emit('add-project', {

src/components/Dashboard.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<!-- Top Navbar -->
77
<Navbar v-bind:username="user.username" v-bind:selectedWs="selectedWs" v-bind:enrolledWorkspaces="enrolledWorkspaces"
8-
v-on:select-ws="selectWorkspace"></Navbar>
8+
v-on:select-ws="selectWorkspace" v-on:show-mytasks="showMyTasks"></Navbar>
99

1010
<!-- Projects in Sidebar -->
1111
<Sidebar v-bind:selectedWs="selectedWs" v-on:select-proj="selectProj"></Sidebar>
@@ -25,7 +25,8 @@
2525

2626
<!-- Panel 2 -->
2727
<div class="col-md-6">
28-
<Comments v-if="selectedTask._id && taskComments.comments" v-bind:selectedTask="selectedTask" v-bind:taskComments="taskComments.comments" v-bind:username="user.username"></Comments>
28+
<Comments v-if="selectedTask._id && taskComments.comments" v-bind:selectedTask="selectedTask"
29+
v-bind:taskComments="taskComments.comments" v-bind:username="user.username"></Comments>
2930
</div>
3031
</div>
3132
</div>
@@ -145,6 +146,15 @@ export default {
145146
console.log('selectWorkspace called in dashboard' + JSON.stringify(ws));
146147
this.selectedWs = ws;
147148
this.selectProj(0);
149+
},
150+
151+
showMyTasks(){
152+
api.getTasksByAssignee(this.user.username)
153+
.then((resp)=>{
154+
console.log('getTasksByAssignee resp::- ' + JSON.stringify(resp.data));
155+
this.tasks = resp.data;
156+
this.taskComments = {};
157+
});
148158
}
149159
},
150160

src/components/Navbar.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
</div>
1818
<div id="navbar" class="collapse navbar-collapse">
1919
<ul class="nav navbar-nav">
20-
<li class="active"><router-link to="/dashboard">Dashboard</router-link></li>
21-
<li><a href="#about">About</a></li>
20+
<li class="active" v-on:click="showDashboard($event)"><router-link to="/dashboard">Dashboard</router-link></li>
21+
<li v-on:click="showMyTasks($event)"><a href="#">My Tasks</a></li>
2222
</ul>
2323
<ul class="nav navbar-nav pull-right">
24-
24+
<li>
25+
<WorkspaceMembers v-bind:selectedWs='selectedWs' v-bind:username='username'></WorkspaceMembers>
26+
</li>
2527
<li class="dropdown">
2628
<a href="#" id="nbAcctDD" class="dropdown-toggle" data-toggle="dropdown"><li v-if="selectedWs">{{selectedWs.name}}</li></a>
2729
<ul class="dropdown-menu pull-right">
@@ -47,11 +49,12 @@
4749
<script>
4850
import api from '../utils/api'
4951
import CreateWorkspace from './CreateWorkspace';
52+
import WorkspaceMembers from './WorkspaceMembers';
5053
5154
export default{
5255
name: 'Navbar',
5356
54-
components: {CreateWorkspace},
57+
components: {CreateWorkspace,WorkspaceMembers},
5558
5659
props: {
5760
username: {
@@ -107,6 +110,18 @@
107110
selectWorkspace(ws){
108111
this.$emit('select-ws', ws);
109112
},
113+
114+
showMyTasks(event){
115+
$("li").removeClass("active");
116+
$(event.currentTarget).addClass('active');
117+
this.$emit('show-mytasks');
118+
},
119+
120+
showDashboard(event){
121+
$("li").removeClass("active");
122+
$(event.currentTarget).addClass('active');
123+
},
124+
110125
},
111126
}
112127
</script>

src/components/Sidebar.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
createProject(newproj){
6161
var createProjInputs = {
6262
wsid: this.selectedWs._id,
63+
username:api.username,
6364
name: newproj.name,
6465
description: newproj.description
6566
};

src/components/Tasks.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</div>
2323

2424

25-
<create-todo v-on:add-todo="addTodo"></create-todo>
25+
<create-todo v-if="selectedWsId && selectedProj" v-on:add-todo="addTodo"></create-todo>
2626
</div>
2727
</div>
2828
</template>
@@ -43,7 +43,7 @@
4343
props: {
4444
selectedWsId: {
4545
//type: Object,
46-
required: true
46+
required: false
4747
},
4848
selectedProj: {
4949
type: Object,
@@ -118,8 +118,8 @@
118118
operation: 'delete',
119119
workspaceid: this.selectedWsId,
120120
projectid: this.selectedProj._id,
121-
taskid: todo._id,
122-
};
121+
taskid: todo._id,
122+
};
123123
api.updateTask(updateTaskInputs)
124124
.then((resp)=>{
125125
console.log('updateTask resp');

src/components/WorkspaceMembers.vue

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
22
<div class='ui basic content center aligned segment'>
3+
<label v-for="(members,index) in selectedWs.MemberUserIds" :key="index">
4+
<label id="memberIds" v-if="members!=username"> {{members}} &nbsp; </label>
5+
</label>
36
<button v-on:click="openForm" v-show="!isCreating">
47
<i class='glyphicon glyphicon-plus'></i>
58
</button>
@@ -12,7 +15,7 @@
1215
</div>
1316
<div class='ui two button attached buttons'>
1417
<button class='ui basic blue button' v-on:click="addMember">
15-
Create
18+
Add
1619
</button>
1720
<button class='ui basic red button' v-on:click="closeForm">
1821
Cancel
@@ -41,13 +44,18 @@ export default {
4144
selectedWs: {
4245
type: Object,
4346
required: true,
44-
},
47+
},
48+
username: {
49+
type: String,
50+
required: true,
51+
},
4552
},
4653
4754
methods: {
4855
openForm() {
4956
//console.log("open form");
5057
this.isCreating = true;
58+
console.log('selectedws= '+JSON.stringify(this.selectedWs));
5159
},
5260
closeForm() {
5361
this.isCreating = false;
@@ -67,7 +75,8 @@ export default {
6775
}
6876
api.addWorkspaceMember(addWorkspaceMemberInputs)
6977
.then((resp)=>{
70-
console.log('addWorkspaceMember response');
78+
console.log('addWorkspaceMember response:- ' + JSON.stringify(resp));
79+
this.selectedWs.MemberUserIds.push(name);
7180
});
7281
7382
@@ -77,4 +86,11 @@ export default {
7786
},
7887
},
7988
};
80-
</script>
89+
</script>
90+
91+
<style>
92+
#memberIds {
93+
color: #ffffff;
94+
font-size:small;
95+
}
96+
</style>

src/utils/api.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,16 @@ export default {
8787
return axios.post(nodeurl + '/auth/register', userdetails);
8888
},
8989

90-
getWorkspace(workspaceId){
91-
return axios.get(nodeurl + '/api/workspace/' + workspaceId);
92-
},
93-
9490
getTasks(workspaceId, projId, userId){
9591
//console.log('getTasks URL --->> '+ nodeurl + '/api/task/' + userId + '/' + workspaceId + '/' + projId);
9692
return axios.get(nodeurl + '/api/task/' + userId + '/' + workspaceId + '/' + projId);
9793
},
9894

95+
getTasksByAssignee(userId){
96+
//console.log('getTasks URL --->> '+ nodeurl + '/api/task/' + userId + '/' + workspaceId + '/' + projId);
97+
return axios.get(nodeurl + '/api/task/' + userId);
98+
},
99+
99100
createTask(createTaskInputs){
100101
return axios.post(nodeurl + '/api/task', createTaskInputs);
101102
},
@@ -121,8 +122,22 @@ export default {
121122
return axios.post(nodeurl + '/api/project', createProjInputs);
122123
},
123124

125+
getWorkspace(workspaceId){
126+
return axios.get(nodeurl + '/api/workspace/' + workspaceId);
127+
},
128+
124129
createWorkspace(createWorkspaceInputs){
125130
return axios.post(nodeurl + '/api/workspace', createWorkspaceInputs);
126131
},
127132

133+
addWorkspaceMember(addWorkspaceMemberInputs){
134+
console.log('addWorkspaceMemberInputs requests= ' + JSON.stringify(addWorkspaceMemberInputs));
135+
return axios.put(nodeurl + '/api/workspace', addWorkspaceMemberInputs);
136+
},
137+
138+
assignTaskToUser(assignTaskToUserInputs){
139+
console.log('assignTaskToUserInputs requests= ' + JSON.stringify(assignTaskToUserInputs));
140+
return axios.put(nodeurl + '/api/task', assignTaskToUserInputs);
141+
},
142+
128143
}

0 commit comments

Comments
 (0)