From 316ed83047e84ec12f6dc5f523aa2376fb24f26b Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 9 Mar 2019 01:52:07 -0600 Subject: [PATCH] Add view, edit links to vue.js users index --- tailbone/api/users.py | 1 + tailbone/templates/users/vue_index.mako | 37 +++++++++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/tailbone/api/users.py b/tailbone/api/users.py index 8ebfedf2..a21d3a2c 100644 --- a/tailbone/api/users.py +++ b/tailbone/api/users.py @@ -42,6 +42,7 @@ class UserView(APIMasterView): def normalize(self, user): return { + 'uuid': user.uuid, 'username': user.username, 'person_display_name': (user.person.display_name or '') if user.person else '', 'active': user.active, diff --git a/tailbone/templates/users/vue_index.mako b/tailbone/templates/users/vue_index.mako index 1b871343..e3a4675d 100644 --- a/tailbone/templates/users/vue_index.mako +++ b/tailbone/templates/users/vue_index.mako @@ -36,10 +36,29 @@
+ ## TODO: need to make endpoint a bit more configurable somehow - ## // 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'): + {{ props.row.username }} + {{ props.row.person_display_name }} + % endif + + ## TODO: why on earth doesn't it render bool as string by default? {{ props.row.active }} + + ## TODO: make URLs more flexible / configurable... also perms? + + % if request.has_perm('users.view'): + View + % endif + % if request.has_perm('users.edit'): + | Edit + % endif + +
@@ -79,15 +98,21 @@ Vue.use(VueTables.ServerTable, { } }, 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({ el: '#vue-app', store: store, data: { - columns: [ - 'username', - 'person_display_name', - 'active' - ], + columns: ${json.dumps(columns)|n}, options: { columnsDropdown: true, filterable: false,