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 >
0 commit comments