Changeset 316ed83 in tailbone


Ignore:
Timestamp:
03/09/19 01:52:07 (6 weeks ago)
Author:
Lance Edgar <ledgar@…>
Branches:
master
Children:
5516a11
Parents:
75bddc8
Message:

Add view, edit links to vue.js users index

Location:
tailbone
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tailbone/api/users.py

    r75bddc8 r316ed83  
    4343    def normalize(self, user):
    4444        return {
     45            'uuid': user.uuid,
    4546            'username': user.username,
    4647            'person_display_name': (user.person.display_name or '') if user.person else '',
  • tailbone/templates/users/vue_index.mako

    r75bddc8 r316ed83  
    3737
    3838<div id="vue-app">
     39
    3940  ## TODO: need to make endpoint a bit more configurable somehow
    4041  <v-server-table name="users" url="/api/users" :columns="columns" :options="options">
    41     ## // TODO: why on earth doesn't it render bool as string by default?
     42
     43    ## TODO: make URLs more flexible / configurable... also perms?
     44    % if request.has_perm('users.view'):
     45        <span slot="username" slot-scope="props"><a :href="'/users/'+props.row.uuid">{{ props.row.username }}</a></span>
     46        <span slot="person_display_name" slot-scope="props"><a :href="'/users/'+props.row.uuid">{{ props.row.person_display_name }}</a></span>
     47    % endif
     48
     49    ## TODO: why on earth doesn't it render bool as string by default?
    4250    <span slot="active" slot-scope="props">{{ props.row.active }}</span>
     51
     52    ## TODO: make URLs more flexible / configurable... also perms?
     53    <span slot="actions" slot-scope="props">
     54      % if request.has_perm('users.view'):
     55          <a :href="'/users/'+props.row.uuid">View</a>
     56      % endif
     57      % if request.has_perm('users.edit'):
     58          | <a :href="'/users/'+props.row.uuid+'/edit'">Edit</a>
     59      % endif
     60    </span>
     61
    4362  </v-server-table>
    4463</div>
     
    8099}, true, 'bulma', 'default');
    81100
     101<%
     102   columns = [
     103       'username',
     104       'person_display_name',
     105       'active',
     106   ]
     107   if request.has_any_perm('users.view', 'users.edit'):
     108       columns.append('actions')
     109%>
     110
    82111var app = new Vue({
    83112    el: '#vue-app',
    84113    store: store,
    85114    data: {
    86         columns: [
    87             'username',
    88             'person_display_name',
    89             'active'
    90         ],
     115        columns: ${json.dumps(columns)|n},
    91116        options: {
    92117            columnsDropdown: true,
Note: See TracChangeset for help on using the changeset viewer.