Changeset 6463df7 in tailbone


Ignore:
Timestamp:
06/22/20 14:59:17 (8 weeks ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
e5f0831
Parents:
dc81e5b
Message:

Add dropdown, autohide magic when editing Role permissions

only for Buefy theme though

Location:
tailbone
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tailbone/templates/deform/permissions.pt

    rdc81e5b r6463df7  
    11<div tal:define="oid oid|field.oid;
    2                  true_val true_val|field.widget.true_val;"
     2                 true_val true_val|field.widget.true_val;
     3                 use_buefy use_buefy|0;"
    34     tal:omit-tag="">
     5
     6  <div tal:condition="not use_buefy"
     7       tal:omit-tag="">
    48  ${field.start_mapping()}
    59
     
    3034
    3135  ${field.end_mapping()}
     36  </div>
     37
     38  <div tal:condition="use_buefy">
     39    ${field.start_mapping()}
     40
     41    <div class="level">
     42      <div class="level-left">
     43        <div class="level-item">
     44          showing group:
     45        </div>
     46        <div class="level-item">
     47          <!-- TODO: should make this v-model dynamic -->
     48          <b-select v-model="showingPermissionGroup">
     49            <option value="">(all)</option>
     50            <tal:loop tal:repeat="groupkey sorted(permissions, key=lambda k: permissions[k]['label'].lower())">
     51              <option tal:attributes="value groupkey">
     52                ${permissions[groupkey]['label']}
     53              </option>
     54            </tal:loop>
     55          </b-select>
     56        </div>
     57      </div>
     58    </div>
     59
     60    <tal:loop tal:repeat="groupkey sorted(permissions, key=lambda k: permissions[k]['label'].lower())">
     61      <div tal:define="perms permissions[groupkey]['perms'];"
     62           class="permissions-group">
     63        <!-- TODO: should use more dynamic v-model name -->
     64        <div class="card"
     65             tal:attributes="v-show string: !showingPermissionGroup || showingPermissionGroup == '${permissions[groupkey]['key']}';">
     66          <header class="card-header">
     67            <p class="card-header-title">${permissions[groupkey]['label']}</p>
     68          </header>
     69          <div class="card-content">
     70            <tal:loop tal:repeat="key sorted(perms, key=lambda p: perms[p]['label'].lower())">
     71              <div class="perm">
     72                <label>
     73                  <input type="checkbox"
     74                         name="${key}"
     75                         id="${oid}-${key}"
     76                         value="${true_val}"
     77                         tal:attributes="checked python:field.widget.get_checked_value(cstruct, key);" />
     78                  ${perms[key]['label']}
     79                </label>
     80              </div>
     81            </tal:loop>
     82          </div><!-- card-content -->
     83        </div><!-- card -->
     84      </div><!-- permissions-group -->
     85    </tal:loop>
     86
     87    ${field.end_mapping()}
     88  </div>
    3289</div>
  • tailbone/templates/roles/edit.mako

    rdc81e5b r6463df7  
    77</%def>
    88
     9<%def name="modify_this_page_vars()">
     10  ${parent.modify_this_page_vars()}
     11  <script type="text/javascript">
     12
     13    // TODO: this variable name should be more dynamic (?) since this is
     14    // connected to (and only here b/c of) the permissions field
     15    TailboneFormData.showingPermissionGroup = ''
     16
     17  </script>
     18</%def>
     19
    920${parent.body()}
  • tailbone/views/roles.py

    rdc81e5b r6463df7  
    138138        super(RolesView, self).configure_form(f)
    139139        role = f.model_instance
     140        use_buefy = self.get_use_buefy()
    140141
    141142        # name
     
    149150        f.set_renderer('permissions', PermissionsRenderer(permissions=self.tailbone_permissions))
    150151        f.set_node('permissions', colander.Set())
    151         f.set_widget('permissions', PermissionsWidget(permissions=self.tailbone_permissions))
     152        f.set_widget('permissions', PermissionsWidget(
     153            permissions=self.tailbone_permissions,
     154            use_buefy=use_buefy))
    152155        if self.editing:
    153156            granted = []
Note: See TracChangeset for help on using the changeset viewer.