1
1
<script >
2
+ import VdUsersTable from ' ./table.vue'
3
+ import VdUserForm from ' ./form.vue'
4
+ import bus from ' ../utils/events/bus'
2
5
export default {
3
- props: [' list' ],
4
- data () {
5
- return {
6
- details: [],
7
- }
8
- },
9
- computed: {
10
- users () {
11
- return JSON .parse (this .list )
12
- },
6
+ props: [' list' , ' token' , ' success' ],
7
+ components: {
8
+ VdUsersTable,
9
+ VdUserForm
13
10
},
14
11
methods: {
15
- toggle (id ) {
16
- if (id === undefined ) {
17
- this .toggleAll ()
18
- } else {
19
- this .toggleOne (id)
20
- }
21
- },
22
- toggleAll () {
23
- if (this .details .length > 0 ) {
24
- this .details = []
25
- } else {
26
- this .details = this .users .map (user => user .id )
27
- }
28
- },
29
- toggleOne (id ){
30
- if (this .details .includes (id)) {
31
- const index = this .details .indexOf (id)
32
- this .details .splice (index, 1 )
33
- } else {
34
- this .details .push (id)
35
- }
36
- },
12
+ form (){
13
+ bus .$emit (' open-form' )
14
+ }
37
15
}
38
16
}
39
17
</script >
40
18
41
19
<template >
42
20
<div >
43
- <h1 ><i class =" fa fa-w fa-users" aria-hidden =" true" ></i > Gerenciamento de Usuários</h1 >
44
- <div class =" well" >
45
- <table class =" table table-bordered table-striped" >
46
- <thead >
47
- <tr >
48
- <th class =" text-center" >
49
- <a href =" #" @click.prevent =" toggle()" >
50
- <i class =" fa fa-fw" :class =" {
51
- 'fa-plus-circle red' : details.length === 0,
52
- 'fa-minus-circle green' : details.length > 0
53
- }" aria-hidden =" true" ></i >
54
- </a >
55
- </th >
56
- <th >Nome</th >
57
- <th >E-mail</th >
58
- <th class =" text-center" >Data</th >
59
- <th class =" text-center" >Ações</th >
60
- </tr >
61
- </thead >
62
- <tbody v-for =" user in users" >
63
- <tr >
64
- <td class =" text-center" >
65
- <a href =" #" @click.prevent =" toggle(user.id)" >
66
- <i class =" fa fa-fw" :class =" {
67
- 'fa-plus-circle red' : !details.includes(user.id),
68
- 'fa-minus-circle green' : details.includes(user.id)
69
- }" aria-hidden =" true" ></i >
70
- </a >
71
- </td >
72
- <td >{{ user.name }}</td >
73
- <td >{{ user.email }}</td >
74
- <td class =" text-center" >{{ user.created_at }}</td >
75
- <td class =" text-center" >
76
- <a href =" #" ><i class =" fa fa-fw fa-pencil" aria-hidden =" true" ></i ></a >
77
- <a href =" #" ><i class =" fa fa-fw fa-trash-o" aria-hidden =" true" ></i ></a >
78
- </td >
79
- </tr >
80
- <tr v-show =" details.includes(user.id)" >
81
- <td colspan =" 5" >
82
- <i class =" fa fa-fw fa-map-marker" aria-hidden =" true" ></i >Placeholder para Endereço
83
- </td >
84
- </tr >
85
- </tbody >
86
- </table >
21
+ <h1 >
22
+ <i class =" fa fa-w fa-users" aria-hidden =" true" ></i > Gerenciamento de Usuários
23
+ <a href =" #" @click.prevent =" form" class =" btn btn-default" ><i class =" fa fa-fw fa-plus" aria-hidden =" true" ></i > Novo Usuário</a >
24
+ </h1 >
25
+ <div class =" alert alert-success" v-show =" success != ''" >
26
+ <button type =" button" class =" close" data-dismiss =" alert" aria-label =" Close" >
27
+ <span aria-hidden =" true" >× ; </span >
28
+ </button >
29
+ {{ success }}
87
30
</div >
31
+ <vd-user-form :token =" token" ></vd-user-form >
32
+ <vd-users-table :list =" list" ></vd-users-table >
88
33
</div >
89
34
</template >
90
-
91
- <style >
92
- .green {
93
- color : red ;
94
- }
95
- .red {
96
- color : green ;
97
- }
98
- </style >
0 commit comments