Skip to content

Commit

Permalink
Fix users/groups overview batch navigation styling (#2455)
Browse files Browse the repository at this point in the history
* Added batching macro

* added margins around buttons

* Fixed styles

* Changelog updated

* Fixed icons for user group memebership listing

* Table fixtures

* Exclude group id from link

* Fixed groups membership form

* Apply a text center alignment to column headers (roles or groups)

---------

Co-authored-by: Jordi Puiggené <jp@naralabs.com>
  • Loading branch information
ramonski and xispa authored Dec 22, 2023
1 parent 22e4e8e commit e91e52c
Show file tree
Hide file tree
Showing 9 changed files with 701 additions and 561 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
2.5.0 (unreleased)
------------------

- #2455 Fix users/groups overview batch navigation styling
- #2454 Fix analyses not filtered by selected WST services
- #2453 Fix worksheets are not uncatalogued when deleted
- #2452 Fix reference definition range validation
Expand Down
Empty file.
14 changes: 14 additions & 0 deletions src/senaite/core/browser/batching/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">

<browser:page
name="batchnavigation"
for="*"
class="plone.batching.browser.PloneBatchView"
template="templates/batchnavigation.pt"
permission="zope.Public"
layer="senaite.core.interfaces.ISenaiteCore"
/>

</configure>
95 changes: 95 additions & 0 deletions src/senaite/core/browser/batching/templates/batchnavigation.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<!-- Navigation -->
<tal:batchnavigation
define="batch view/batch|nothing"
condition="batch"
metal:define-macro="navigation">

<nav i18n:domain="plone"
tal:condition="batch/multiple_pages">

<ul class="pagination pagination-sm p-0 m-0">

<tal:comment replace="nothing">
<!-- Previous page -->
</tal:comment>
<li class="page-item previous" tal:condition="batch/has_previous">
<a class="page-link" tal:attributes="href python:view.make_link(batch.previouspage)">
<span class="arrow"></span>
<span class="label" i18n:translate="batch_previous_x_items">
Previous <span i18n:name="number" tal:content="batch/pagesize" tal:omit-tag="">n</span> items
</span>
</a>
</li>

<tal:comment replace="nothing">
<!-- First page -->
</tal:comment>
<li class="page-item first" tal:condition="batch/show_link_to_first">
<a class="page-link" tal:attributes="href python:view.make_link(1)">1</a>
</li>

<tal:comment replace="nothing">
<!-- Ellipsis after first item -->
</tal:comment>
<li class="page-item disabled" tal:condition="batch/second_page_not_in_navlist">
<span class="page-link">...</span>
</li>

<tal:comment replace="nothing">
<!-- Pagelist with links to previous pages for quick navigation -->
</tal:comment>
<li class="page-item" tal:repeat="pagenumber batch/previous_pages">
<a class="page-link" tal:content="pagenumber"
tal:attributes="href python:view.make_link(pagenumber)" />
</li>

<tal:comment replace="nothing">
<!-- Active page -->
</tal:comment>
<li class="page-item active" tal:condition="batch/navlist">
<span class="page-link" tal:content="batch/pagenumber" />
</li>

<tal:comment replace="nothing">
<!-- Pagelist with links to next pages for quick navigation -->
</tal:comment>
<li class="page-item" tal:repeat="pagenumber batch/next_pages">
<a class="page-link"
tal:content="pagenumber"
tal:attributes="href python:view.make_link(pagenumber)" />
</li>

<tal:comment replace="nothing">
<!-- Ellipsis before last item -->
</tal:comment>
<li class="page-item disabled" tal:condition="batch/before_last_page_not_in_navlist">
<span class="page-link">...</span>
</li>

<tal:comment replace="nothing">
<!-- Last page -->
</tal:comment>
<li class="page-item last" tal:condition="batch/show_link_to_last">
<a class="page-link"
tal:attributes="href python:view.make_link(batch.lastpage)"
tal:content="batch/lastpage" />
</li>

<tal:comment replace="nothing">
<!-- Next page -->
</tal:comment>
<li class="page-item next" tal:condition="batch/has_next">
<a class="page-link" tal:attributes="href python:view.make_link(batch.nextpage)">
<span class="label" i18n:translate="batch_next_x_items">
Next
<span i18n:name="number" tal:omit-tag="" tal:content="batch/next_item_count">n</span>
items
</span>
<span class="arrow"></span>
</a>
</li>
</ul>

</nav>

</tal:batchnavigation>
1 change: 1 addition & 0 deletions src/senaite/core/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<!-- Package includes -->
<include package=".attachment"/>
<include package=".batching"/>
<include package=".bootstrap"/>
<include package=".contentmenu"/>
<include package=".contentrules"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,21 @@
<table class="table table-bordered table-hover table-sm"
summary="Group Members Listing"
tal:condition="view/groupMembers">
<colgroup>
<col style="width:36px;"/>
</colgroup>

<tr>
<th>
<input class="noborder"
type="checkbox"
src="select_all_icon.png"
name="selectButton"
title="Select all items"
onClick="toggleSelect(this, 'delete:list');"
tal:attributes="src string:$portal_url/select_all_icon.png"
alt="Select all items"
i18n:attributes="title label_select_all_items; alt label_select_all_items;"/>
<!-- <input class="noborder"
type="checkbox"
src="select_all_icon.png"
name="selectButton"
title="Select all items"
onClick="toggleSelect(this, 'delete:list');"
tal:attributes="src string:$portal_url/select_all_icon.png"
alt="Select all items"
i18n:attributes="title label_select_all_items; alt label_select_all_items;"/> -->
<!--Remove user from this group-->
</th>
<th i18n:translate="listingheader_user_name">User name</th>
Expand All @@ -126,24 +129,28 @@

<tal:block tal:condition="python: view.isGroup(this_user)">
<td>
<img src="group.png" alt="" />
<i class="fas fa-users text-primary mr-1"></i>
<a href="" tal:attributes="href python:'@@usergroup-groupdetails?' + view.makeQuery(groupname=this_user.getGroupName())" >
<span tal:replace="this_user/getGroupTitleOrName | default" />
(<span tal:replace="this_user/id" />)
</a>
<div class="small text-secondary">(<span tal:replace="this_user/id" />)</div>
</td>
</tal:block>

<tal:block tal:condition="python: not view.isGroup(this_user)">
<td>
<img src="user.png" alt="" />
<a href="" tal:attributes="href python:'@@user-information?' + view.makeQuery(userid=this_user.getId());
title this_user/getId">
<span tal:replace="python:this_user.getProperty('fullname')">Full Name</span>
<div class="text-nowrap">
<i class="fas fa-user text-primary mr-1"></i>
<a href="" tal:attributes="href python:'@@user-information?' + view.makeQuery(userid=this_user.getId());
title this_user/getId">
<span tal:replace="python:this_user.getProperty('fullname')">Full Name</span>
</a>
</div>
<div class="small text-secondary">
<tal:userid tal:condition="not:view/email_as_username">
(<span tal:replace="this_user/getUserName | default" />)
</tal:userid>
</a>
</div>
</td>
</tal:block>

Expand Down Expand Up @@ -182,6 +189,9 @@

<table class="table table-bordered table-hover table-sm"
summary="Groups">
<colgroup>
<col style="width:36px;">
</colgroup>
<tr>
<th colspan="3">
<div class="input-group input-group-sm">
Expand Down Expand Up @@ -218,15 +228,15 @@
</tr>
<tr tal:condition="batch">
<th>
<input class="noborder"
type="checkbox"
src="select_all_icon.png"
name="selectButton"
title="Select all items"
onClick="toggleSelect(this, 'add:list');"
tal:attributes="src string:$portal_url/select_all_icon.png"
alt="Select all items"
i18n:attributes="title label_select_all_items; alt label_select_all_items;"/>
<!-- <input class="noborder"
type="checkbox"
src="select_all_icon.png"
name="selectButton"
title="Select all items"
onClick="toggleSelect(this, 'add:list');"
tal:attributes="src string:$portal_url/select_all_icon.png"
alt="Select all items"
i18n:attributes="title label_select_all_items; alt label_select_all_items;"/> -->
</th>

<th i18n:translate="listingheader_group_user_name">Group/User name</th>
Expand All @@ -249,21 +259,25 @@

<td>
<tal:block tal:condition="python:not view.isGroup(this_user)">
<img src="user.png" alt="" />
<i class="fas fa-user text-primary mr-1"></i>
<a href="" tal:attributes="href python:'@@user-information?' + view.makeQuery(userid=this_user.getId());
title this_user/getId">
<span tal:replace="python:this_user.getProperty('fullname')">Full Name</span>
</a>
<div class="small text-secondary">
<tal:userid tal:condition="not:view/email_as_username">
(<span tal:replace="this_user/getUserName | default" />)
</tal:userid>
</a>
</div>
</tal:block>
<tal:block tal:condition="python: view.isGroup(this_user)">
<img src="group.png" alt="" />
<i class="fas fa-users text-primary mr-1"></i>
<a href="" tal:attributes="href python:'@@usergroup-groupdetails?' + view.makeQuery(groupname=this_user.getGroupName())">
<span tal:replace="this_user/getGroupTitleOrName | default" />
(<span tal:replace="this_user/id | default" />)
</a>
<div class="small text-secondary">
(<span tal:replace="this_user/id | default" />)
</div>
</tal:block>
</td>
<td tal:define="email python: this_user.getProperty('email')">
Expand Down Expand Up @@ -298,9 +312,7 @@
Enter a group or user name to search for or click 'Show All'.
</td>
</tal:block>

</tr>

</table>

<input type="hidden" value="b_start" name="b_start"
Expand All @@ -309,30 +321,30 @@
<input type="hidden" value="" name="showAll"
tal:attributes="value showAll"/>

<div class="d-flex">
<div class="form-inline form-group pb-3">
<div metal:use-macro="context/batch_macros/macros/navigation" />
</div>
<div class="showAllSearchResults ml-1"
tal:condition="python:batch.next or batch.previous"
tal:define="mq python:modules['ZTUtils'].make_query;
keys batchformkeys|nothing;
linkparams python:keys and dict([(key, request.form[key]) for key in keys if key in request]) or request.form;
url batch_base_url | string:${context/absolute_url}/${template_id}">
<a class="btn btn-sm btn-outline-secondary"
tal:attributes="href python: '%s?%s' % (url, mq( linkparams, {'showAll':'y'} ))"
i18n:translate="description_pas_show_all_search_results">
Show all search results
</a>
</div>

<input class="btn btn-sm btn-primary ml-1"
type="submit"
name="form.button.Add"
value="Add selected groups and users to this group"
tal:condition="batch"
i18n:attributes="value label_add_users_to_group;" />

<div class="showAllSearchResults"
tal:condition="python:batch.next or batch.previous"
tal:define="mq python:modules['ZTUtils'].make_query;
keys batchformkeys|nothing;
linkparams python:keys and dict([(key, request.form[key]) for key in keys if key in request]) or request.form;
url batch_base_url | string:${context/absolute_url}/${template_id}">
<a class="btn btn-sm btn-outline-secondary mr-2"
tal:attributes="href python: '%s?%s' % (url, mq( linkparams, {'showAll':'y'} ))"
i18n:translate="description_pas_show_all_search_results">
Show all search results
</a>
</div>

<input class="context btn btn-sm btn-primary"
type="submit"
name="form.button.Add"
value="Add selected groups and users to this group"
tal:condition="batch"
i18n:attributes="value label_add_users_to_group;" />

</tal:addusers>

<input tal:replace="structure context/@@authenticator/authenticator" />
Expand Down
Loading

0 comments on commit e91e52c

Please sign in to comment.