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

Commit 00efd04

Browse files
authored
Merge pull request #52 from coderdiaz/fix/jsx-render-column
fix/jsx-render-column
2 parents 8c06e30 + 770acf3 commit 00efd04

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

src/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export default {
3232
{
3333
name: 'Last Name',
3434
key: 'last_name',
35-
render: function (value) {
36-
return `<strong>${value}</strong>`
35+
render: (value, row) => {
36+
return <strong><i>Epic</i> {value} <img src={row.avatar} width="20" /></strong>
3737
}
3838
}
3939
],

src/components/Pagination.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ export default {
88
<div class="vue-pagination">
99
<nav>
1010
<ul class="pagination">
11-
<li class={{ disabled: this.pages.current_page === 1 }}>
12-
<a href="#" on-click={ (e) => this.firstPage(e) }><span aria-hidden="true">&laquo;&laquo;</span></a>
11+
<li class={{disabled: this.pages.current_page === 1}}>
12+
<a href="#" on-click={(e) => this.firstPage(e)}><span aria-hidden="true">&laquo;&laquo;</span></a>
1313
</li>
1414
<li class={{ disabled: this.pages.current_page === 1 }}>
15-
<a href="#" on-click={ (e) => this.previous(e) }><span aria-hidden="true">&laquo;</span></a>
15+
<a href="#" on-click={(e) => this.previous(e)}><span aria-hidden="true">&laquo;</span></a>
1616
</li>
17-
{ this.paginationItems }
18-
<li class={{ disabled: this.pages.current_page === this.pages.last_page }}>
19-
<a href="#" on-click={ (e) => this.next(e) }><span aria-hidden="true">&raquo;</span></a>
17+
{this.paginationItems}
18+
<li class={{disabled: this.pages.current_page === this.pages.last_page}}>
19+
<a href="#" on-click={(e) => this.next(e)}><span aria-hidden="true">&raquo;</span></a>
2020
</li>
2121
<li class={{ disabled: this.pages.current_page === this.pages.last_page }}>
22-
<a href="#" on-click={ (e) => this.lastPage(e, this.pages.last_page) }><span aria-hidden="true">&raquo;&raquo;</span></a>
22+
<a href="#" on-click={(e) => this.lastPage(e, this.pages.last_page)}><span aria-hidden="true">&raquo;&raquo;</span></a>
2323
</li>
2424
</ul>
2525
</nav>
@@ -34,8 +34,8 @@ export default {
3434
items: DatasourceUtils.gettingItems,
3535
paginationItems () {
3636
return this.items.map((item, index) => {
37-
return <li class={{ active: (this.pages.current_page === item) }}>
38-
<a href="#" on-click={ (e) => this.change(e, item) }>{ item }</a>
37+
return <li class={{active: (this.pages.current_page === item)}}>
38+
<a href="#" on-click={(e) => this.change(e, item)}>{item}</a>
3939
</li>
4040
})
4141
}

src/components/ServerDatasource.vue

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script>
22
import DatasourceUtils from '../utils/DatasourceUtils'
33
import Pagination from './Pagination.vue'
4-
import { EventBus } from '../utils/EventBus'
4+
import {EventBus} from '../utils/EventBus'
55
export default {
66
name: 'ServerDatasource',
77
components: {Pagination},
@@ -12,13 +12,13 @@ export default {
1212
<div class="panel-heading">
1313
<div class="form-inline">
1414
<div class="form-group pull-left">
15-
<label class="control-label pr2">{ this.translation.limit }</label>
16-
<select on-change={ (e) => this.sync('perpage', parseInt(e.target.value)) } class="form-control" number>
17-
{ this.limitOptions }
15+
<label class="control-label pr2">{this.translation.limit}</label>
16+
<select on-change={(e) => this.sync('perpage', parseInt(e.target.value))} class="form-control" number>
17+
{this.limitOptions}
1818
</select>
1919
</div>
2020
<div class="form-group pull-right">
21-
<input class="form-control mr1" type="text" on-input={ (e) => this.searching(e) } placeholder={this.translation.placeholder_search} />
21+
<input class="form-control mr1" type="text" on-input={(e) => this.searching(e)} placeholder={this.translation.placeholder_search} />
2222
</div>
2323
<div class="clearfix"></div>
2424
</div>
@@ -27,23 +27,23 @@ export default {
2727
<table class="table table-striped">
2828
<thead>
2929
<tr>
30-
{ this.columnItems }
30+
{this.columnItems}
3131
</tr>
3232
</thead>
3333
<tbody>
34-
{ this.columnObjects }
34+
{this.columnObjects}
3535
<tr>
36-
<td class="text-center warning" colspan={ this.columns.length }>{ this.tableInfo }</td>
36+
<td class="text-center warning" colspan={this.columns.length}>{this.tableInfo}</td>
3737
</tr>
3838
</tbody>
3939
</table>
4040
</div>
4141
<div class="panel-footer">
4242
<div class="pull-left btn-group btn-group-actions">
43-
{ this.actionsObject }
43+
{this.actionsObject}
4444
</div>
4545
<div class="pull-right">
46-
<pagination pages={ this.pagination }></pagination>
46+
<pagination pages={this.pagination}></pagination>
4747
</div>
4848
<div class="clearfix"></div>
4949
</div>
@@ -131,35 +131,35 @@ export default {
131131
computed: {
132132
limitOptions () {
133133
return this.limits.map((limit, index) => {
134-
return <option value={ limit } selected={ parseInt(this.perpage) === parseInt(limit) }>{ limit }</option>
134+
return <option value={limit} selected={parseInt(this.perpage) === parseInt(limit)}>{limit}</option>
135135
})
136136
},
137137
columnItems () {
138138
return this.columns.map((column, index) => {
139-
return <th>{ column.name }</th>
139+
return <th>{column.name}</th>
140140
})
141141
},
142142
columnObjects () {
143143
if (this.source.length === 0) {
144144
return <tr class="text-center">
145-
<td colspan={ this.columns.length }>{ this.translation.records_not_found }</td>
145+
<td colspan={this.columns.length}>{this.translation.records_not_found}</td>
146146
</tr>
147147
} else {
148148
return this.source.map((row, index) => {
149149
let columns = this.columns.map((column, index) => {
150-
return <td domPropsInnerHTML={ this.fetchFromObject(row, column.key, column.render) }></td>
150+
return <td>{this.fetchFromObject(row, column.key, column.render)}</td>
151151
})
152-
return <tr class={{ success: index === this.indexSelected }} on-click={ (e) => this.selectRow(e, row, index) }>{ columns }</tr>
152+
return <tr class={{success: index === this.indexSelected}} on-click={(e) => this.selectRow(e, row, index)}>{columns}</tr>
153153
})
154154
}
155155
},
156156
actionsObject () {
157157
return this.actions.map((action, index) => {
158158
try {
159159
if (action.show(this.selected)) {
160-
return <button class={this.dynamicClass('btn', action.class)} type="button" on-click={ (e) => action.event(e, this.selected) }>
161-
<i class={ this.dynamicClass('pr1', action.icon) }></i>
162-
{ action.text }
160+
return <button class={this.dynamicClass('btn', action.class)} type="button" on-click={(e) => action.event(e, this.selected)}>
161+
<i class={this.dynamicClass('pr1', action.icon)}></i>
162+
{action.text}
163163
</button>
164164
}
165165
} catch (ex) {

src/utils/DatasourceUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313
return this.fetchFromObject(obj[column.substring(0, _index)], column.substr(_index + 1))
1414
}
1515
if (typeof render !== 'undefined') {
16-
return render(obj[column])
16+
return render(obj[column], obj)
1717
}
1818
return obj[column]
1919
},

0 commit comments

Comments
 (0)