Add view, edit links to vue.js users index
This commit is contained in:
parent
75bddc8777
commit
316ed83047
|
@ -42,6 +42,7 @@ class UserView(APIMasterView):
|
||||||
|
|
||||||
def normalize(self, user):
|
def normalize(self, user):
|
||||||
return {
|
return {
|
||||||
|
'uuid': user.uuid,
|
||||||
'username': user.username,
|
'username': user.username,
|
||||||
'person_display_name': (user.person.display_name or '') if user.person else '',
|
'person_display_name': (user.person.display_name or '') if user.person else '',
|
||||||
'active': user.active,
|
'active': user.active,
|
||||||
|
|
|
@ -36,10 +36,29 @@
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<div id="vue-app">
|
<div id="vue-app">
|
||||||
|
|
||||||
## TODO: need to make endpoint a bit more configurable somehow
|
## TODO: need to make endpoint a bit more configurable somehow
|
||||||
<v-server-table name="users" url="/api/users" :columns="columns" :options="options">
|
<v-server-table name="users" url="/api/users" :columns="columns" :options="options">
|
||||||
## // TODO: why on earth doesn't it render bool as string by default?
|
|
||||||
|
## TODO: make URLs more flexible / configurable... also perms?
|
||||||
|
% if request.has_perm('users.view'):
|
||||||
|
<span slot="username" slot-scope="props"><a :href="'/users/'+props.row.uuid">{{ props.row.username }}</a></span>
|
||||||
|
<span slot="person_display_name" slot-scope="props"><a :href="'/users/'+props.row.uuid">{{ props.row.person_display_name }}</a></span>
|
||||||
|
% endif
|
||||||
|
|
||||||
|
## TODO: why on earth doesn't it render bool as string by default?
|
||||||
<span slot="active" slot-scope="props">{{ props.row.active }}</span>
|
<span slot="active" slot-scope="props">{{ props.row.active }}</span>
|
||||||
|
|
||||||
|
## TODO: make URLs more flexible / configurable... also perms?
|
||||||
|
<span slot="actions" slot-scope="props">
|
||||||
|
% if request.has_perm('users.view'):
|
||||||
|
<a :href="'/users/'+props.row.uuid">View</a>
|
||||||
|
% endif
|
||||||
|
% if request.has_perm('users.edit'):
|
||||||
|
| <a :href="'/users/'+props.row.uuid+'/edit'">Edit</a>
|
||||||
|
% endif
|
||||||
|
</span>
|
||||||
|
|
||||||
</v-server-table>
|
</v-server-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -79,15 +98,21 @@ Vue.use(VueTables.ServerTable, {
|
||||||
}
|
}
|
||||||
}, true, 'bulma', 'default');
|
}, true, 'bulma', 'default');
|
||||||
|
|
||||||
|
<%
|
||||||
|
columns = [
|
||||||
|
'username',
|
||||||
|
'person_display_name',
|
||||||
|
'active',
|
||||||
|
]
|
||||||
|
if request.has_any_perm('users.view', 'users.edit'):
|
||||||
|
columns.append('actions')
|
||||||
|
%>
|
||||||
|
|
||||||
var app = new Vue({
|
var app = new Vue({
|
||||||
el: '#vue-app',
|
el: '#vue-app',
|
||||||
store: store,
|
store: store,
|
||||||
data: {
|
data: {
|
||||||
columns: [
|
columns: ${json.dumps(columns)|n},
|
||||||
'username',
|
|
||||||
'person_display_name',
|
|
||||||
'active'
|
|
||||||
],
|
|
||||||
options: {
|
options: {
|
||||||
columnsDropdown: true,
|
columnsDropdown: true,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
|
|
Loading…
Reference in a new issue