Skip to content
This repository was archived by the owner on Jun 10, 2021. It is now read-only.

Commit c8f568f

Browse files
committed
Added documentation to source code
1 parent abba7f7 commit c8f568f

File tree

3 files changed

+49
-21
lines changed

3 files changed

+49
-21
lines changed

src/Datasource.vue

+44-12
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@
2525
<table class="table table-striped Vue__table">
2626
<thead>
2727
<tr>
28+
<!--columns-->
2829
<th v-for="column in columns">{{ column.name }}</th>
30+
<!--/columns-->
2931
</tr>
3032
</thead>
3133
<tbody>
3234
<tr v-if="pagination.total == 0">
3335
<td :colspan="columns.length">{{ translation.table.records_not_found }}</td>
3436
</tr>
37+
<!--rows-->
3538
<tr v-else
3639
:class="{ 'success': (index == indexSelected) }"
3740
v-for="(row, index) in tableData"
@@ -40,16 +43,20 @@
4043
{{ fetchFromObject(row, k.key, k.render) }}
4144
</td>
4245
</tr>
46+
<!--/rows-->
4347
<tr>
48+
<!--info-table-->
4449
<td class="text-center" :colspan="columns.length">
4550
{{ tableInfo }}
4651
</td>
52+
<!--/info-table-->
4753
</tr>
4854
</tbody>
4955
</table>
5056
</div>
5157
<div class="panel-footer Vue__panel-footer">
5258
<div class="pull-left">
59+
<!--actions-buttons-->
5360
<div class="btn-group Vue__datasource_actions">
5461
<button class="btn btn-default" type="button"
5562
:class="btn.class"
@@ -59,12 +66,12 @@
5966
{{ btn.text }}
6067
</button>
6168
</div>
69+
<!--/actions-buttons-->
6270
</div>
6371
<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-->
6875
</div>
6976
<div class="clearfix"></div>
7077
</div>
@@ -81,18 +88,34 @@
8188
Pagination
8289
},
8390
props: {
91+
/**
92+
* The table information to display
93+
* @type {Array}
94+
*/
8495
tableData: {
8596
type: Array,
8697
required: true
8798
},
99+
/**
100+
* Defines the language with which the table will be displayed
101+
* @type {String}
102+
*/
88103
language: {
89104
type: String,
90105
default: 'es'
91106
},
107+
/**
108+
* Columns to display in table
109+
* @type {Array}
110+
*/
92111
columns: {
93112
type: Array,
94113
required: true
95114
},
115+
/**
116+
* Information about data collection to paginate
117+
* @type {Object}
118+
*/
96119
pagination: {
97120
type: Object,
98121
default() {
@@ -104,6 +127,10 @@
104127
}
105128
}
106129
},
130+
/**
131+
* Buttons to perform action on click event
132+
* @type {Array}
133+
*/
107134
actions: {
108135
type: Array,
109136
default() {
@@ -113,14 +140,18 @@
113140
},
114141
data() {
115142
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
121148
}
122149
},
123150
computed: {
151+
/**
152+
* Get the translation to display in the table
153+
* @return {Object}
154+
*/
124155
translation() {
125156
return Language.translations[this.language];
126157
},
@@ -136,6 +167,10 @@
136167
}
137168
},
138169
watch: {
170+
/**
171+
* Event when the record limit to be displayed is changed
172+
* @return {void}
173+
*/
139174
perpage() {
140175
this.selected = null;
141176
this.$emit('change', { perpage: this.perpage, page: 1 });
@@ -145,19 +180,16 @@
145180
</script>
146181
<style lang="sass" scoped>
147182
.vue-datasource {
148-
149183
.Vue__panel-body {
150184
padding: 0;
151185
.Vue__table {
152186
margin-bottom: 0;
153187
}
154188
}
155-
156189
.Vue__panel-footer {
157190
.Vue__datasource_actions {
158191
margin: 10px 0;
159192
}
160193
}
161-
162194
}
163195
</style>

src/utils/DatasourceLanguage.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export default {
22
translations: {
3+
// English translation
34
'en': {
45
'table': {
56
'label_limits': 'Show',
@@ -16,6 +17,7 @@ export default {
1617
'btn_last': 'Latest'
1718
}
1819
},
20+
// Spanish translation
1921
'es': {
2022
'table': {
2123
'label_limits': 'Mostrar',

src/utils/DatasourceUtils.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
export default {
22
/**
33
* Find the element value using Recursive Method and return the value rendered if it's defined
4-
*
5-
* @author Javier Diaz <[email protected]>
64
* @param obj
75
* @param column
86
* @param render
@@ -22,9 +20,8 @@ export default {
2220

2321
/**
2422
* Emit event to change page from pagination
25-
*
26-
* @author Javier Diaz <[email protected]>
2723
* @param page
24+
* @return {void}
2825
*/
2926
changePage(page) {
3027
this.selected = null;
@@ -33,10 +30,9 @@ export default {
3330

3431
/**
3532
* Effect toggle to selected row
36-
*
37-
* @author Javier Diaz <[email protected]>
3833
* @param row
3934
* @param index
35+
* @return {void}
4036
*/
4137
selectRow(row, index) {
4238
if(this.indexSelected == index) {
@@ -53,9 +49,7 @@ export default {
5349

5450
/**
5551
* Computed property: Building custom string information with translation
56-
*
57-
* @author Javier Diaz <[email protected]>
58-
* @returns {string}
52+
* @returns {String}
5953
*/
6054
tableInfo() {
6155
let label_show = this.translation.pagination.label_show;

0 commit comments

Comments
 (0)