Skip to content

Commit

Permalink
WS members feature
Browse files Browse the repository at this point in the history
  • Loading branch information
deep9c committed Jul 7, 2017
1 parent e619a1f commit bcb3080
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/components/Comments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
</ul>
<form class="form-inline" role="form">
<div class="form-group">
<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)'/>
<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)'/>
</div>
<div class="form-group">
<!-- <button class="btn btn-default" v-on:click='submit($event)'>Add</button> -->
Expand Down Expand Up @@ -85,7 +86,7 @@
textboxFocus(e){
$(e.currentTarget).animate({
width: '150px',
width: '300px',
height: '100px'
}, 500, function() {
// Animation complete.
Expand All @@ -94,7 +95,7 @@
textboxBlur(e){
$(e.currentTarget).animate({
width: '100px',
width: '300px',
height: '20px'
}, 500, function() {
// Animation complete.
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<a id="menu-toggle" href="#" class="glyphicon glyphicon-align-justify btn-menu toggle" v-on:click="toggleMenu($event)">
<i class="fa fa-bars"></i>
</a>
<a href="#">OneTask</a>
<a href="#">OneTask</a>
</div>
</div>
<div id="navbar" class="collapse navbar-collapse">
Expand Down
36 changes: 35 additions & 1 deletion src/components/Tasks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
-->

<div class="list-group">
<todo v-on:delete-todo="deleteTodo" v-on:complete-todo="completeTodo" v-for="(todo,index) in tasks.tasks"
<todo v-on:delete-todo="deleteTodo" v-on:complete-todo="completeTodo" v-on:edit-todo="editTodo"
v-for="(todo,index) in tasks.tasks"
v-bind:todo="todo" :key="index" :todo.sync="todo" v-on:select-task="selectTask">
</todo>
<!-- todo.sync used for completeTodo function to work -->
Expand Down Expand Up @@ -113,11 +114,44 @@
deleteTodo(todo) {
const todoIndex = this.tasks.tasks.indexOf(todo);
this.tasks.tasks.splice(todoIndex, 1);
var updateTaskInputs = {
operation: 'delete',
workspaceid: this.selectedWsId,
projectid: this.selectedProj._id,
taskid: todo._id,
};
api.updateTask(updateTaskInputs)
.then((resp)=>{
console.log('updateTask resp');
});
},
editTodo(todo) {
console.log("editTodo() called");
var updateTaskInputs = {
operation: 'update',
taskid: todo._id,
title: todo.title,
description: todo.description
};
api.updateTask(updateTaskInputs)
.then((resp)=>{
console.log('updateTask resp');
});
},
completeTodo(todo){
console.log("completeTodo() called");
this.tasks.tasks[this.tasks.tasks.indexOf(todo)].status = 'completed';
var updateTaskInputs = {
operation: 'update',
taskid: todo._id,
status: 'completed'
};
api.updateTask(updateTaskInputs)
.then((resp)=>{
console.log('updateTask resp');
});
},
},
Expand Down
9 changes: 4 additions & 5 deletions src/components/Todo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@

<span class='badge' v-on:click="showForm">
<i class='edit icon'></i>
</span>


</span>
</a>

<!-- form is visible when we are in editing mode -->
Expand All @@ -41,7 +39,7 @@
<input type='text' v-model="todo.description" >
</div>
<div class='ui two button attached buttons'>
<button class='ui basic blue button' v-on:click="hideForm">
<button class='ui basic blue button' v-on:click="hideForm(todo)">
Close X
</button>
</div>
Expand All @@ -65,8 +63,9 @@ export default {
showForm() {
this.isEditing = true;
},
hideForm() {
hideForm(todo) {
this.isEditing = false;
this.$emit('edit-todo', todo);
},
deleteTodo(todo) {
this.$emit('delete-todo', todo);
Expand Down
80 changes: 80 additions & 0 deletions src/components/WorkspaceMembers.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<template>
<div class='ui basic content center aligned segment'>
<button v-on:click="openForm" v-show="!isCreating">
<i class='glyphicon glyphicon-plus'></i>
</button>
<div class='ui centered card' v-show="isCreating">
<div class='content'>
<div class='ui form'>
<div class='field'>
<label>Username</label>
<input v-model="usernameText" type='text' ref='title' defaultValue="">
</div>
<div class='ui two button attached buttons'>
<button class='ui basic blue button' v-on:click="addMember">
Create
</button>
<button class='ui basic red button' v-on:click="closeForm">
Cancel
</button>
</div>
</div>
</div>
</div>
</div>
</template>

<script>
import api from '../utils/api'
export default {
name: 'WorkspaceMembers',
data() {
return {
usernameText: '',
isCreating: false,
};
},
props: {
selectedWs: {
type: Object,
required: true,
},
},
methods: {
openForm() {
//console.log("open form");
this.isCreating = true;
},
closeForm() {
this.isCreating = false;
},
addMember() {
//console.log("send form " + this.usernameText.length);
//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
if (this.usernameText.length > 0) {
const name = this.usernameText;
/*this.$emit('add-project', {
name,
});*/
var addWorkspaceMemberInputs = {
wsid: this.selectedWs._id,
userid: this.usernameText
}
api.addWorkspaceMember(addWorkspaceMemberInputs)
.then((resp)=>{
console.log('addWorkspaceMember response');
});
this.usernameText='';
}
this.isCreating = false;
},
},
};
</script>
9 changes: 9 additions & 0 deletions src/utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ export default {
return axios.post(nodeurl + '/api/task', createTaskInputs);
},

updateTask(updateTaskInputs){
return axios.put(nodeurl + '/api/task', updateTaskInputs);
},

/*deleteTask(deleteTaskInputs){
console.log('deleteTaskInputs:- ' + JSON.stringify(deleteTaskInputs));
return axios.delete(nodeurl + '/api/task', deleteTaskInputs);
},*/

getComments(taskId){
return axios.get(nodeurl + '/api/comment/' + taskId);
},
Expand Down

0 comments on commit bcb3080

Please sign in to comment.