Skip to content

Commit bcb3080

Browse files
committed
WS members feature
1 parent e619a1f commit bcb3080

File tree

6 files changed

+133
-10
lines changed

6 files changed

+133
-10
lines changed

src/components/Comments.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
</ul>
2626
<form class="form-inline" role="form">
2727
<div class="form-group">
28-
<input class="form-control" type="text" id="box" style="width: 300px; height: 20px" placeholder="Your comments" v-model="newcomment" v-on:focus='textboxFocus($event)' v-on:blur='textboxBlur($event)'/>
28+
<input class="form-control" type="text" id="box" style="width: 300px; height: 20px" placeholder="Your comments"
29+
v-model="newcomment" v-on:focus='textboxFocus($event)' v-on:blur='textboxBlur($event)'/>
2930
</div>
3031
<div class="form-group">
3132
<!-- <button class="btn btn-default" v-on:click='submit($event)'>Add</button> -->
@@ -85,7 +86,7 @@
8586
8687
textboxFocus(e){
8788
$(e.currentTarget).animate({
88-
width: '150px',
89+
width: '300px',
8990
height: '100px'
9091
}, 500, function() {
9192
// Animation complete.
@@ -94,7 +95,7 @@
9495
9596
textboxBlur(e){
9697
$(e.currentTarget).animate({
97-
width: '100px',
98+
width: '300px',
9899
height: '20px'
99100
}, 500, function() {
100101
// Animation complete.

src/components/Navbar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<a id="menu-toggle" href="#" class="glyphicon glyphicon-align-justify btn-menu toggle" v-on:click="toggleMenu($event)">
1313
<i class="fa fa-bars"></i>
1414
</a>
15-
<a href="#">OneTask</a>
15+
<a href="#">OneTask</a>
1616
</div>
1717
</div>
1818
<div id="navbar" class="collapse navbar-collapse">

src/components/Tasks.vue

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
-->
1515

1616
<div class="list-group">
17-
<todo v-on:delete-todo="deleteTodo" v-on:complete-todo="completeTodo" v-for="(todo,index) in tasks.tasks"
17+
<todo v-on:delete-todo="deleteTodo" v-on:complete-todo="completeTodo" v-on:edit-todo="editTodo"
18+
v-for="(todo,index) in tasks.tasks"
1819
v-bind:todo="todo" :key="index" :todo.sync="todo" v-on:select-task="selectTask">
1920
</todo>
2021
<!-- todo.sync used for completeTodo function to work -->
@@ -113,11 +114,44 @@
113114
deleteTodo(todo) {
114115
const todoIndex = this.tasks.tasks.indexOf(todo);
115116
this.tasks.tasks.splice(todoIndex, 1);
117+
var updateTaskInputs = {
118+
operation: 'delete',
119+
workspaceid: this.selectedWsId,
120+
projectid: this.selectedProj._id,
121+
taskid: todo._id,
122+
};
123+
api.updateTask(updateTaskInputs)
124+
.then((resp)=>{
125+
console.log('updateTask resp');
126+
});
127+
},
128+
129+
editTodo(todo) {
130+
console.log("editTodo() called");
131+
var updateTaskInputs = {
132+
operation: 'update',
133+
taskid: todo._id,
134+
title: todo.title,
135+
description: todo.description
136+
};
137+
api.updateTask(updateTaskInputs)
138+
.then((resp)=>{
139+
console.log('updateTask resp');
140+
});
116141
},
117142
118143
completeTodo(todo){
119144
console.log("completeTodo() called");
120145
this.tasks.tasks[this.tasks.tasks.indexOf(todo)].status = 'completed';
146+
var updateTaskInputs = {
147+
operation: 'update',
148+
taskid: todo._id,
149+
status: 'completed'
150+
};
151+
api.updateTask(updateTaskInputs)
152+
.then((resp)=>{
153+
console.log('updateTask resp');
154+
});
121155
},
122156
},
123157

src/components/Todo.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424

2525
<span class='badge' v-on:click="showForm">
2626
<i class='edit icon'></i>
27-
</span>
28-
29-
27+
</span>
3028
</a>
3129

3230
<!-- form is visible when we are in editing mode -->
@@ -41,7 +39,7 @@
4139
<input type='text' v-model="todo.description" >
4240
</div>
4341
<div class='ui two button attached buttons'>
44-
<button class='ui basic blue button' v-on:click="hideForm">
42+
<button class='ui basic blue button' v-on:click="hideForm(todo)">
4543
Close X
4644
</button>
4745
</div>
@@ -65,8 +63,9 @@ export default {
6563
showForm() {
6664
this.isEditing = true;
6765
},
68-
hideForm() {
66+
hideForm(todo) {
6967
this.isEditing = false;
68+
this.$emit('edit-todo', todo);
7069
},
7170
deleteTodo(todo) {
7271
this.$emit('delete-todo', todo);
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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>Username</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="addMember">
15+
Create
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: 'WorkspaceMembers',
32+
33+
data() {
34+
return {
35+
usernameText: '',
36+
isCreating: false,
37+
};
38+
},
39+
40+
props: {
41+
selectedWs: {
42+
type: Object,
43+
required: true,
44+
},
45+
},
46+
47+
methods: {
48+
openForm() {
49+
//console.log("open form");
50+
this.isCreating = true;
51+
},
52+
closeForm() {
53+
this.isCreating = false;
54+
},
55+
addMember() {
56+
//console.log("send form " + this.usernameText.length);
57+
//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
58+
if (this.usernameText.length > 0) {
59+
const name = this.usernameText;
60+
/*this.$emit('add-project', {
61+
name,
62+
});*/
63+
64+
var addWorkspaceMemberInputs = {
65+
wsid: this.selectedWs._id,
66+
userid: this.usernameText
67+
}
68+
api.addWorkspaceMember(addWorkspaceMemberInputs)
69+
.then((resp)=>{
70+
console.log('addWorkspaceMember response');
71+
});
72+
73+
74+
this.usernameText='';
75+
}
76+
this.isCreating = false;
77+
},
78+
},
79+
};
80+
</script>

src/utils/api.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ export default {
100100
return axios.post(nodeurl + '/api/task', createTaskInputs);
101101
},
102102

103+
updateTask(updateTaskInputs){
104+
return axios.put(nodeurl + '/api/task', updateTaskInputs);
105+
},
106+
107+
/*deleteTask(deleteTaskInputs){
108+
console.log('deleteTaskInputs:- ' + JSON.stringify(deleteTaskInputs));
109+
return axios.delete(nodeurl + '/api/task', deleteTaskInputs);
110+
},*/
111+
103112
getComments(taskId){
104113
return axios.get(nodeurl + '/api/comment/' + taskId);
105114
},

0 commit comments

Comments
 (0)