Skip to content

Commit 8048184

Browse files
committed
Create Workspace
1 parent 989dcb9 commit 8048184

File tree

12 files changed

+295
-134
lines changed

12 files changed

+295
-134
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
},
1616
"dependencies": {
1717
"axios": "^0.16.1",
18+
"cors": "^2.8.3",
1819
"vue": "^2.2.6",
20+
"vue-resource": "^1.3.4",
1921
"vue-router": "^2.3.1"
2022
},
2123
"devDependencies": {

src/components/Comments.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</div>
1818
<div class="commentText"><strong>{{comment.CommenterUserId}}</strong>
1919
<span class="date sub-text">on {{new Date(comment.createdDateTime).toDateString()}}</span>
20-
<p class="">{{comment.content}}.</p>
20+
<p class="">{{comment.content}}</p>
2121

2222
</div>
2323
</li>

src/components/CreateProject.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export default {
5757
description,
5858
});
5959
//console.log("add-todo event emitted");
60-
this.newTodoText = '';
6160
this.nameText='';
6261
this.description='';
6362
}

src/components/CreateTodo.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export default {
5656
status: 'pending',
5757
});
5858
//console.log("add-todo event emitted");
59-
this.newTodoText = '';
6059
this.titleText='';
6160
this.description='';
6261
}

src/components/CreateWorkspace.vue

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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>Workspace Name</label>
11+
<input v-model="nameText" type='text' ref='title' defaultValue="">
12+
</div>
13+
<div class='field'>
14+
<label>Description</label>
15+
<input v-model="description" type='text' ref='project' defaultValue="">
16+
</div>
17+
<div class='ui two button attached buttons'>
18+
<button class='ui basic blue button' v-on:click="sendForm">
19+
Create
20+
</button>
21+
<button class='ui basic red button' v-on:click="closeForm">
22+
Cancel
23+
</button>
24+
</div>
25+
</div>
26+
</div>
27+
</div>
28+
</div>
29+
</template>
30+
31+
<script>
32+
export default {
33+
name: 'CreateWorkspace',
34+
35+
data() {
36+
return {
37+
nameText: '',
38+
description: '',
39+
isCreating: false,
40+
};
41+
},
42+
methods: {
43+
openForm() {
44+
//console.log("open form");
45+
this.isCreating = true;
46+
},
47+
closeForm() {
48+
this.isCreating = false;
49+
},
50+
sendForm() {
51+
//console.log("send form " + this.nameText.length);
52+
if (this.nameText.length > 0 && this.description.length > 0) {
53+
const name = this.nameText;
54+
const description = this.description;
55+
this.$emit('add-workspace', {
56+
name,
57+
description,
58+
});
59+
//console.log("add-todo event emitted");
60+
this.nameText='';
61+
this.description='';
62+
}
63+
this.isCreating = false;
64+
},
65+
},
66+
};
67+
</script>

src/components/Dashboard.vue

Lines changed: 25 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<!--<router-view></router-view>-->
55

66
<!-- Top Navbar -->
7-
<Navbar v-bind:username="user.username" v-bind:selectedWsName="selectedWsName"></Navbar>
7+
<Navbar v-bind:username="user.username" v-bind:selectedWs="selectedWs" v-bind:enrolledWorkspaces="enrolledWorkspaces"
8+
v-on:select-ws="selectWorkspace"></Navbar>
89

910
<!-- Projects in Sidebar -->
1011
<Sidebar v-bind:selectedWs="selectedWs" v-on:select-proj="selectProj"></Sidebar>
@@ -18,7 +19,7 @@
1819
<!-- Panel 1 -->
1920
<div class="col-md-6">
2021
<Tasks v-bind:tasks="tasks" v-bind:selectedWsId="selectedWs._id" v-bind:selectedProj="selectedProj"
21-
v-bind:username="user.username" v-on:select-task="selectTask">
22+
v-bind:username="user.username" v-on:select-task="selectTask">
2223
</Tasks>
2324
</div>
2425

@@ -62,7 +63,6 @@ export default {
6263
user: api.user,
6364
enrolledWorkspaces: [],
6465
selectedWorkspaceIndex: -1,
65-
selectedWsName: '',
6666
selectedWs: {},
6767
selectedProj: {},
6868
tasks: {},
@@ -91,7 +91,6 @@ export default {
9191
});
9292
9393
Promise.all(promise1).then((results)=> {
94-
this.selectedWsName = this.enrolledWorkspaces[this.selectedWorkspaceIndex].name;
9594
this.selectedWs = this.enrolledWorkspaces[this.selectedWorkspaceIndex];
9695
var selectedProjIndex = this.enrolledWorkspaces[this.selectedWorkspaceIndex].projects.findIndex((proj)=>{
9796
return proj.selected;
@@ -118,13 +117,19 @@ export default {
118117
},
119118
selectProj(index){
120119
//console.log('selectProj called with index = ' + index);
121-
this.selectedProj = this.enrolledWorkspaces[this.selectedWorkspaceIndex].projects[index];
122-
api.getTasks(this.selectedWs._id,this.selectedProj._id, this.user.username)
123-
.then((resp)=>{
124-
//console.log('getTasks resp::- ' + JSON.stringify(resp.data));
125-
this.tasks = resp.data;
126-
this.taskComments = {};
127-
});
120+
this.selectedProj = this.selectedWs.projects[index];
121+
if(this.selectedProj){
122+
api.getTasks(this.selectedWs._id,this.selectedProj._id, this.user.username)
123+
.then((resp)=>{
124+
//console.log('getTasks resp::- ' + JSON.stringify(resp.data));
125+
this.tasks = resp.data;
126+
this.taskComments = {};
127+
});
128+
}
129+
else{
130+
this.tasks = {};
131+
this.taskComments = {};
132+
}
128133
},
129134
selectTask(task){
130135
console.log('showcom called' + JSON.stringify(task));
@@ -134,6 +139,12 @@ export default {
134139
console.log('getComments resp:- '+JSON.stringify(resp));
135140
this.taskComments = resp.data;
136141
});
142+
},
143+
144+
selectWorkspace(ws){
145+
console.log('selectWorkspace called in dashboard' + JSON.stringify(ws));
146+
this.selectedWs = ws;
147+
this.selectProj(0);
137148
}
138149
},
139150
@@ -142,22 +153,11 @@ export default {
142153

143154
<style>
144155
#wrapper {
145-
padding-left: 250px;
156+
padding-left: 170px;
146157
transition: all 0.4s ease 0s;
147158
}
148159
149-
#sidebar-wrapper {
150-
margin-left: -250px;
151-
top: 51px;
152-
left: 250px;
153-
width: 250px;
154-
background: #000;
155-
position: fixed;
156-
height: 100%;
157-
overflow-y: auto;
158-
z-index: 1000;
159-
transition: all 0.4s ease 0s;
160-
}
160+
161161
162162
#wrapper.active {
163163
padding-left: 0;
@@ -169,66 +169,11 @@ export default {
169169
170170
#page-content-wrapper {
171171
width: 100%;
172-
padding-top: 70px;
172+
padding-top: 10px;
173173
transition: all 0.4s ease 0s;
174174
}
175175
176-
.sidebar-nav {
177-
position: absolute;
178-
top: 0;
179-
width: 250px;
180-
list-style: none;
181-
margin: 0;
182-
padding: 0;
183-
}
184-
185-
.sidebar-nav li {
186-
line-height: 40px;
187-
text-indent: 20px;
188-
}
189-
190-
.sidebar-nav li a {
191-
color: #999999;
192-
display: block;
193-
text-decoration: none;
194-
padding-left: 60px;
195-
}
196-
197-
.sidebar-nav li a span:before {
198-
position: absolute;
199-
left: 0;
200-
color: #41484c;
201-
text-align: center;
202-
width: 20px;
203-
line-height: 18px;
204-
}
205-
206-
.sidebar-nav li a:hover,
207-
.sidebar-nav li.active {
208-
color: #fff;
209-
background: rgba(255,255,255,0.2);
210-
text-decoration: none;
211-
}
212-
213-
.sidebar-nav li a:active,
214-
.sidebar-nav li a:focus {
215-
text-decoration: none;
216-
}
217-
218-
.sidebar-nav > .sidebar-brand {
219-
height: 65px;
220-
line-height: 60px;
221-
font-size: 18px;
222-
}
223-
224-
.sidebar-nav > .sidebar-brand a {
225-
color: #999999;
226-
}
227176
228-
.sidebar-nav > .sidebar-brand a:hover {
229-
color: #fff;
230-
background: none;
231-
}
232177
233178
234179

src/components/Navbar.vue

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@
2323
<ul class="nav navbar-nav pull-right">
2424

2525
<li class="dropdown">
26-
<a href="#" id="nbAcctDD" class="dropdown-toggle" data-toggle="dropdown"><li v-if="selectedWsName">{{selectedWsName}}</li></a>
26+
<a href="#" id="nbAcctDD" class="dropdown-toggle" data-toggle="dropdown"><li v-if="selectedWs">{{selectedWs.name}}</li></a>
2727
<ul class="dropdown-menu pull-right">
28-
<li>Other workspaces</li>
28+
<li v-for="(ws,index) in enrolledWorkspaces" :key="index">
29+
<a href="#" v-on:click="selectWorkspace(ws)" v-if="ws._id!=selectedWs._id"> {{ws.name}} </a>
30+
</li>
31+
<li role="separator" class="divider"></li>
32+
<li><CreateWorkspace v-on:add-workspace='createWorkspace'></CreateWorkspace></li>
2933
</ul>
3034
</li>
3135
<li class="dropdown">
@@ -42,20 +46,26 @@
4246

4347
<script>
4448
import api from '../utils/api'
49+
import CreateWorkspace from './CreateWorkspace';
4550
4651
export default{
4752
name: 'Navbar',
48-
//props: ['user','enrolledWorkspaces','selectedWorkspaceIndex'],
53+
54+
components: {CreateWorkspace},
4955
5056
props: {
5157
username: {
5258
type: String,
5359
required: true,
5460
},
55-
selectedWsName: {
56-
type: String,
61+
selectedWs: {
62+
type: Object,
5763
required: true,
58-
}
64+
},
65+
enrolledWorkspaces:{
66+
type: Array,
67+
required: true,
68+
}
5969
},
6070
6171
data(){
@@ -67,17 +77,37 @@
6777
//console.log('zzzzzzzzzz:: ' + this.selectedWorkspaceIndex);
6878
},
6979
methods: {
70-
toggleMenu(e){
71-
e.preventDefault();
72-
$("#wrapper").toggleClass("active");
73-
},
74-
logout() {
75-
api.logout()
76-
.then((response)=>{
77-
this.$router.push('/login');
78-
});
79-
},
80-
},
80+
toggleMenu(e){
81+
e.preventDefault();
82+
$("#wrapper").toggleClass("active");
83+
},
84+
85+
logout() {
86+
api.logout()
87+
.then((response)=>{
88+
this.$router.push('/login');
89+
});
90+
},
91+
92+
createWorkspace(newworkspace){
93+
console.log('createWorkspace function called');
94+
var createWorkspaceInputs = {
95+
username: this.username,
96+
workspacename: newworkspace.name,
97+
//description: newworkspace.description
98+
};
99+
api.createWorkspace(createWorkspaceInputs)
100+
.then((resp)=>{
101+
console.log('createWorkspace resp-> ' + JSON.stringify(resp.data));
102+
//this.selectedWs.projects.push(resp.data);
103+
//this.selectProj(this.selectedWs.projects.findIndex((p)=>{return p._id == resp.data._id}));
104+
});
105+
},
106+
107+
selectWorkspace(ws){
108+
this.$emit('select-ws', ws);
109+
},
110+
},
81111
}
82112
</script>
83113

0 commit comments

Comments
 (0)