25
25
<table class =" table table-striped Vue__table" >
26
26
<thead >
27
27
<tr >
28
+ <!-- columns-->
28
29
<th v-for =" column in columns" >{{ column.name }}</th >
30
+ <!-- /columns-->
29
31
</tr >
30
32
</thead >
31
33
<tbody >
32
34
<tr v-if =" pagination.total == 0" >
33
35
<td :colspan =" columns.length" >{{ translation.table.records_not_found }}</td >
34
36
</tr >
37
+ <!-- rows-->
35
38
<tr v-else
36
39
:class =" { 'success': (index == indexSelected) }"
37
40
v-for =" (row, index) in tableData"
40
43
{{ fetchFromObject(row, k.key, k.render) }}
41
44
</td >
42
45
</tr >
46
+ <!-- /rows-->
43
47
<tr >
48
+ <!-- info-table-->
44
49
<td class =" text-center" :colspan =" columns.length" >
45
50
{{ tableInfo }}
46
51
</td >
52
+ <!-- /info-table-->
47
53
</tr >
48
54
</tbody >
49
55
</table >
50
56
</div >
51
57
<div class =" panel-footer Vue__panel-footer" >
52
58
<div class =" pull-left" >
59
+ <!-- actions-buttons-->
53
60
<div class =" btn-group Vue__datasource_actions" >
54
61
<button class =" btn btn-default" type =" button"
55
62
:class =" btn.class"
59
66
{{ btn.text }}
60
67
</button >
61
68
</div >
69
+ <!-- /actions-buttons-->
62
70
</div >
63
71
<div class =" pull-right" >
64
- <pagination
65
- :pages =" pagination"
66
- @change =" changePage"
67
- :translation =" translation.pagination" ></pagination >
72
+ <!-- pagination-->
73
+ <pagination :pages =" pagination" :translation =" translation.pagination" @change =" changePage" ></pagination >
74
+ <!-- /pagination-->
68
75
</div >
69
76
<div class =" clearfix" ></div >
70
77
</div >
81
88
Pagination
82
89
},
83
90
props: {
91
+ /**
92
+ * The table information to display
93
+ * @type {Array}
94
+ */
84
95
tableData: {
85
96
type: Array ,
86
97
required: true
87
98
},
99
+ /**
100
+ * Defines the language with which the table will be displayed
101
+ * @type {String}
102
+ */
88
103
language: {
89
104
type: String ,
90
105
default: ' es'
91
106
},
107
+ /**
108
+ * Columns to display in table
109
+ * @type {Array}
110
+ */
92
111
columns: {
93
112
type: Array ,
94
113
required: true
95
114
},
115
+ /**
116
+ * Information about data collection to paginate
117
+ * @type {Object}
118
+ */
96
119
pagination: {
97
120
type: Object ,
98
121
default () {
104
127
}
105
128
}
106
129
},
130
+ /**
131
+ * Buttons to perform action on click event
132
+ * @type {Array}
133
+ */
107
134
actions: {
108
135
type: Array ,
109
136
default () {
113
140
},
114
141
data () {
115
142
return {
116
- limits: [1 , 5 , 10 , 15 , 20 ],
117
- perpage: 15 ,
118
- selected: null ,
119
- indexSelected: - 1 ,
120
- search: ' '
143
+ limits: [1 , 5 , 10 , 15 , 20 ], // values that the user can select to display records
144
+ perpage: 15 , // default value to show records
145
+ selected: null , // row and Object selected on click event
146
+ indexSelected: - 1 , // index row selected on click event
147
+ search: ' ' // word to search in the table
121
148
}
122
149
},
123
150
computed: {
151
+ /**
152
+ * Get the translation to display in the table
153
+ * @return {Object}
154
+ */
124
155
translation () {
125
156
return Language .translations [this .language ];
126
157
},
136
167
}
137
168
},
138
169
watch: {
170
+ /**
171
+ * Event when the record limit to be displayed is changed
172
+ * @return {void}
173
+ */
139
174
perpage () {
140
175
this .selected = null ;
141
176
this .$emit (' change' , { perpage: this .perpage , page: 1 });
145
180
</script >
146
181
<style lang="sass" scoped>
147
182
.vue-datasource {
148
-
149
183
.Vue__panel-body {
150
184
padding : 0 ;
151
185
.Vue__table {
152
186
margin-bottom : 0 ;
153
187
}
154
188
}
155
-
156
189
.Vue__panel-footer {
157
190
.Vue__datasource_actions {
158
191
margin : 10px 0 ;
159
192
}
160
193
}
161
-
162
194
}
163
195
</style >
0 commit comments