Merge pull request #9972 from colinux/upgrade-administrate

Tech: update administrate from 0.18.0 to 0.20.1 (manager)
This commit is contained in:
Colin Darie 2024-02-08 10:26:52 +00:00 committed by GitHub
commit 8361938511
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 390 additions and 383 deletions

View file

@ -2,6 +2,7 @@ exclude:
- 'app/assets/stylesheets/reset.scss' - 'app/assets/stylesheets/reset.scss'
- 'app/assets/stylesheets/direct_uploads.scss' - 'app/assets/stylesheets/direct_uploads.scss'
- 'app/assets/stylesheets/dsfr_override.scss' - 'app/assets/stylesheets/dsfr_override.scss'
- 'app/assets/stylesheets/manager.scss'
linters: linters:
BangFormat: BangFormat:

View file

@ -97,12 +97,12 @@ GEM
tzinfo (~> 2.0) tzinfo (~> 2.0)
addressable (2.8.6) addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0) public_suffix (>= 2.0.2, < 6.0)
administrate (0.18.0) administrate (0.20.1)
actionpack (>= 5.0) actionpack (>= 6.0, < 8.0)
actionview (>= 5.0) actionview (>= 6.0, < 8.0)
activerecord (>= 5.0) activerecord (>= 6.0, < 8.0)
jquery-rails (>= 4.0) jquery-rails (~> 4.6.0)
kaminari (>= 1.0) kaminari (~> 1.2.2)
sassc-rails (~> 2.1) sassc-rails (~> 2.1)
selectize-rails (~> 0.6) selectize-rails (~> 0.6)
administrate-field-enum (0.0.9) administrate-field-enum (0.0.9)
@ -357,7 +357,7 @@ GEM
reline (>= 0.3.8) reline (>= 0.3.8)
job-iteration (1.4.1) job-iteration (1.4.1)
activejob (>= 5.2) activejob (>= 5.2)
jquery-rails (4.5.1) jquery-rails (4.6.0)
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0) railties (>= 4.2.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
@ -724,7 +724,7 @@ GEM
spring (4.1.1) spring (4.1.1)
spring-commands-rspec (1.0.4) spring-commands-rspec (1.0.4)
spring (>= 0.9.1) spring (>= 0.9.1)
sprockets (4.2.0) sprockets (4.2.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4) rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2) sprockets-rails (3.4.2)
@ -745,7 +745,7 @@ GEM
unicode-display_width (>= 1.1.1, < 3) unicode-display_width (>= 1.1.1, < 3)
thor (1.3.0) thor (1.3.0)
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (2.0.11) tilt (2.3.0)
timecop (0.9.4) timecop (0.9.4)
timeout (0.4.1) timeout (0.4.1)
ttfunk (1.7.0) ttfunk (1.7.0)

View file

@ -55,3 +55,19 @@
color: #A10005; color: #A10005;
font-size: 18px; font-size: 18px;
} }
.main-content {
&__header {
.button_to {
display: inline;
}
.buttons {
text-align: right;
}
.button {
margin-bottom: 4px;
}
}
}

View file

@ -48,6 +48,11 @@ class ZoneDashboard < Administrate::BaseDashboard
# across all pages of the admin dashboard. # across all pages of the admin dashboard.
# #
def display_resource(zone) def display_resource(zone)
case zone
when NullZone
"Aucune zone"
else
"Zone #{zone.current_label}" "Zone #{zone.current_label}"
end end
end end
end

View file

@ -1,6 +1,6 @@
- if resources.singleton_class.included_modules.include?(Kaminari::PaginatableWithoutCount) - if resources.singleton_class.included_modules.include?(Kaminari::PaginatableWithoutCount)
%nav.pagination %nav.pagination
= link_to_prev_page resources, t("views.pagination.previous"), param_name: "_page" = link_to_prev_page resources, t("views.pagination.previous").html_safe, param_name: "_page"
= link_to_next_page resources, t("views.pagination.next"), param_name: "_page" = link_to_next_page resources, t("views.pagination.next").html_safe, param_name: "_page"
- else - else
= paginate resources, param_name: "_page", views_prefix: 'shared' = paginate resources, param_name: local_assigns.fetch(:param_name) { "_page" }

View file

@ -1,9 +1,13 @@
<% content_for(:title) { "Confirmation d'ajout d'un administrateur" } %> <% content_for(:title) { "Confirmation d'ajout d'un administrateur" } %>
<header class="main-content__header" role="banner"> <header class="main-content__header">
<h1 class="main-content__page-title"> <h1 class="main-content__page-title">
<%= content_for(:title) %> <%= content_for(:title) %>
</h1> </h1>
<div>
<%= link_to t("administrate.actions.back"), :back, class: "button" %>
</div>
</header> </header>
<section class="main-content__body"> <section class="main-content__body">

View file

@ -0,0 +1,44 @@
<%= form_for([namespace, Administrateur.new(user: User.new)], html: { class: "form" }) do |f| %>
<% if page.resource.errors.any? %>
<div id="error_explanation">
<h2>
<%= t(
"administrate.form.errors",
pluralized_errors: pluralize(page.resource.errors.count, t("administrate.form.error")),
resource_name: display_resource_name(page.resource_name, singular: true)
) %>
</h2>
<ul>
<% page.resource.errors.full_messages.each do |message| %>
<li class="flash-error"><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<% page.attributes(controller.action_name).each do |title, attributes| -%>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{f.object_name}.#{title}", default: title %></legend>
<% end %>
<% attributes.each do |attribute| %>
<div class="field-unit field-unit--<%= attribute.html_class %> field-unit--<%= requireness(attribute) %>">
<%= render_field attribute, f: f %>
<% hint_key = "administrate.field_hints.#{page.resource_name}.#{attribute.name}" %>
<% if I18n.exists?(hint_key) -%>
<div class="field-unit__hint">
<%= I18n.t(hint_key) %>
</div>
<% end -%>
</div>
<% end %>
</fieldset>
<% end -%>
<div class="form-actions">
<%= f.submit %>
</div>
<% end %>

View file

@ -1,13 +0,0 @@
= form_for([namespace, Administrateur.new(user: User.new)], html: { class: "form" }) do |f|
- if page.resource.errors.any?
#error_explanation
%h2
= t("administrate.form.errors", pluralized_errors: pluralize(page.resource.errors.count, t("administrate.form.error")), resource_name: display_resource_name(page.resource_name))
%ul
- page.resource.errors.full_messages.each do |message|
%li.flash-error= message
- page.attributes.each do |attribute|
%div{ :class => "field-unit field-unit--#{attribute.html_class}" }
= render_field attribute, f: f
.form-actions
= f.submit

View file

@ -19,7 +19,7 @@ as well as a link to its edit page.
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %> <% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
<% procedure = page.resource %> <% procedure = page.resource %>
<header class="main-content__header" role="banner"> <header class="main-content__header">
<h1 class="main-content__page-title"> <h1 class="main-content__page-title">
<%= content_for(:title) %> <%= content_for(:title) %>
</h1> </h1>
@ -29,31 +29,38 @@ as well as a link to its edit page.
t("administrate.actions.edit_resource", name: page.page_title), t("administrate.actions.edit_resource", name: page.page_title),
[:edit, namespace, page.resource], [:edit, namespace, page.resource],
class: "button", class: "button",
) if valid_action? :edit %> ) if accessible_action?(page.resource, :edit) %>
</div> </div>
<div> <div>
<% if page.resource.invitation_expired? %> <% if page.resource.invitation_expired? %>
<%= link_to "renvoyer l'invitation", reinvite_manager_administrateur_path(page.resource), method: :post, class: "button" %> <%= link_to "renvoyer l'invitation", reinvite_manager_administrateur_path(page.resource), method: :post, class: "button" %>
<% end %> <% end %>
<%= button_to "supprimer", delete_manager_administrateur_path(page.resource), method: :delete, disabled: !page.resource.can_be_deleted?, class: "button", data: { turbo_confirm: "Confirmez-vous la suppression de l'administrateur ?" }, title: page.resource.can_be_deleted? ? "Supprimer" : "Cet administrateur a des démarches dont il est le seul admin et ne peut être supprimé" %> <%= button_to t("administrate.actions.destroy"), delete_manager_administrateur_path(page.resource), method: :delete, disabled: !page.resource.can_be_deleted?, class: "button button--danger", data: { turbo_confirm: "Confirmez-vous la suppression de l'administrateur ?" }, title: page.resource.can_be_deleted? ? "Supprimer" : "Cet administrateur a des démarches dont il est le seul admin et ne peut être supprimé" %>
</div> </div>
</header> </header>
<section class="main-content__body"> <section class="main-content__body">
<%= render partial: 'manager/application/user_meta', locals: { user: page.resource&.user } %> <%= render partial: 'manager/application/user_meta', locals: { user: page.resource&.user } %>
<dl> <dl>
<% page.attributes.each do |attribute| %> <% page.attributes.each do |title, attributes| %>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{page.resource_name}.#{title}", default: title %></legend>
<% end %>
<% attributes.each do |attribute| %>
<dt class="attribute-label" id="<%= attribute.name %>"> <dt class="attribute-label" id="<%= attribute.name %>">
<%= t( <%= t(
"helpers.label.#{resource_name}.#{attribute.name}", "helpers.label.#{resource_name}.#{attribute.name}",
default: attribute.name.titleize, default: page.resource.class.human_attribute_name(attribute.name),
) %> ) %>
</dt> </dt>
<dd class="attribute-data attribute-data--<%=attribute.html_class%>" <dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute, page: page %></dd> ><%= render_field attribute, page: page %></dd>
<% end %> <% end %>
</fieldset>
<% end %>
</dl> </dl>
</section> </section>

View file

@ -1,15 +0,0 @@
- content_for(:title) { page.page_title }
%header.header
%h1.header__heading= content_for(:title)
.header__actions
- if page.resource.invitation_expired?
= link_to "renvoyer l'invitation", reinvite_manager_administrateur_path(page.resource), method: :post, class: "button"
%dl
- page.attributes.each do |attribute|
%dt.attribute-label
= t("helpers.label.#{resource_name}.#{attribute.name}", default: attribute.name.titleize)
%dd.attribute-data{ class: "attribute-data--#{attribute.html_class}" }
= render_field attribute

View file

@ -40,7 +40,8 @@ It renders the `_table` partial to display details about the resources.
resources: resources, resources: resources,
table_title: "page-title" table_title: "page-title"
) %> ) %>
<%= render("pagination", resources: resources) %>
<%= render "pagination", resources: resources %>
</section> </section>
<%= render("index_footer") %> <%= render("index_footer") %><%# our footer %>

View file

@ -1,68 +0,0 @@
<%#
# Collection
This partial is used on the `index` and `show` pages
to display a collection of resources in an HTML table.
## Local variables:
- `collection_presenter`:
An instance of [Administrate::Page::Collection][1].
The table presenter uses `ResourceDashboard::COLLECTION_ATTRIBUTES` to determine
the columns displayed in the table
- `resources`:
An ActiveModel::Relation collection of resources to be displayed in the table.
By default, the number of resources is limited by pagination
or by a hard limit to prevent excessive page load times
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
%>
<table aria-labelledby="<%= table_title %>">
<thead>
<tr>
<% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
<th class="cell-label
cell-label--<%= attr_type.html_class %>
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>"
scope="col"
role="columnheader"
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
<%= link_to(sanitized_order_params(page, collection_field_name).merge(
collection_presenter.order_params_for(attr_name, key: collection_field_name)
)) do %>
<%= t(
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
default: attr_name.to_s,
).titleize %>
<% if collection_presenter.ordered_by?(attr_name) %>
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
<svg aria-hidden="true">
<use xlink:href="#icon-up-caret" />
</svg>
</span>
<% end %>
<% end %>
</th>
<% end %>
<% [valid_action?(:edit, collection_presenter.resource_name),
valid_action?(:destroy, collection_presenter.resource_name)].count(true).times do %>
<th scope="col"></th>
<% end %>
</tr>
</thead>
<tbody>
<% resources.each do |resource| %>
<tr class="js-table-row"
tabindex="0"
>
<% collection_presenter.attributes_for(resource).each do |attribute| %>
<td class="cell-data cell-data--<%= attribute.html_class %>">
<%= render_field attribute %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>

View file

@ -1,9 +1,13 @@
<% content_for(:title) { "Ajout d'un administrateur" } %> <% content_for(:title) { "Ajout d'un administrateur" } %>
<header class="main-content__header" role="banner"> <header class="main-content__header">
<h1 class="main-content__page-title"> <h1 class="main-content__page-title">
<%= content_for(:title) %> <%= content_for(:title) %>
</h1> </h1>
<div>
<%= link_to t("administrate.actions.back"), :back, class: "button" %>
</div>
</header> </header>
<section class="main-content__body"> <section class="main-content__body">

View file

@ -19,7 +19,7 @@ as well as a link to its edit page.
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %> <% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
<% dossier = page.resource %> <% dossier = page.resource %>
<header class="main-content__header" role="banner"> <header class="main-content__header">
<h1 class="main-content__page-title"> <h1 class="main-content__page-title">
<%= content_for(:title) %> <%= content_for(:title) %>
<% if dossier.hidden_for_administration? && !dossier.brouillon? %> <% if dossier.hidden_for_administration? && !dossier.brouillon? %>
@ -31,7 +31,7 @@ as well as a link to its edit page.
"Transférer le dossier", "Transférer le dossier",
[:transfer_edit, namespace, page.resource], [:transfer_edit, namespace, page.resource],
class: "button", class: "button",
) if valid_action? :transfer_edit %> ) if accessible_action?(page.resource, :transfer_edit) %>
</div> </div>
</header> </header>
@ -45,17 +45,26 @@ as well as a link to its edit page.
</p> </p>
<% end %> <% end %>
</div> </div>
<dl> <dl>
<% page.attributes.each do |attribute| %> <% page.attributes.each do |title, attributes| %>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{page.resource_name}.#{title}", default: title %></legend>
<% end %>
<% attributes.each do |attribute| %>
<dt class="attribute-label" id="<%= attribute.name %>"> <dt class="attribute-label" id="<%= attribute.name %>">
<%= t( <%= t(
"helpers.label.#{resource_name}.#{attribute.name}", "helpers.label.#{resource_name}.#{attribute.name}",
default: attribute.name.titleize, default: page.resource.class.human_attribute_name(attribute.name),
) %> ) %>
</dt> </dt>
<dd class="attribute-data attribute-data--<%=attribute.html_class%>" <dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute, page: page %></dd> ><%= render_field attribute, page: page %></dd>
<% end %> <% end %>
</fieldset>
<% end %>
</dl> </dl>
</section> </section>

View file

@ -1,6 +1,6 @@
<% content_for(:title) { "Transfert d'un dossier vers un autre utilisateur" } %> <% content_for(:title) { "Transfert d'un dossier vers un autre utilisateur" } %>
<header class="main-content__header" role="banner"> <header class="main-content__header">
<h1 class="main-content__page-title"> <h1 class="main-content__page-title">
<%= content_for(:title) %> <%= content_for(:title) %>
</h1> </h1>

View file

@ -24,16 +24,30 @@ to display a collection of resources in an HTML table.
<% collection_presenter.attribute_types.each do |attr_name, attr_type| %> <% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
<th class="cell-label <th class="cell-label
cell-label--<%= attr_type.html_class %> cell-label--<%= attr_type.html_class %>
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>" cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
cell-label--<%= "#{collection_presenter.resource_name}_#{attr_name}" %>"
scope="col" scope="col"
role="columnheader"
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>"> aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
<%= t( <%= t(
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}", "helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
default: resource_class.human_attribute_name(attr_name), default: resource_class.human_attribute_name(attr_name).titleize,
).titleize %> ) %>
<% if collection_presenter.ordered_by?(attr_name) %>
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
<svg aria-hidden="true">
<use xlink:href="#icon-up-caret" />
</svg>
</span>
<% end %>
</th> </th>
<% end %> <% end %>
<%= render(
"collection_header_actions",
collection_presenter: collection_presenter,
page: page,
resources: resources,
table_title: "page-title"
) %>
</tr> </tr>
</thead> </thead>

View file

@ -0,0 +1,17 @@
<% content_for(:title) do %>
<%= display_resource_name(page.resource_name) %>
<% end %>
<header class="main-content__header">
<h1 class="main-content__page-title" id="page-title">
<%= content_for(:title) %>
</h1>
<% if show_search_bar %>
<%= render(
"search",
search_term: search_term,
resource_name: display_resource_name(page.resource_name)
) %>
<% end %>
</header>

View file

@ -18,7 +18,7 @@ as well as a link to its edit page.
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %> <% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
<header class="main-content__header" role="banner"> <header class="main-content__header">
<h1 class="main-content__page-title"> <h1 class="main-content__page-title">
<%= content_for(:title) %> <%= content_for(:title) %>
</h1> </h1>
@ -30,16 +30,28 @@ as well as a link to its edit page.
class: "button", class: "button",
) if accessible_action?(page.resource, :edit) %> ) if accessible_action?(page.resource, :edit) %>
</div> <%= button_to(
<div> t("administrate.actions.destroy"),
<%= button_to "Supprimer", delete_manager_gestionnaire_path(page.resource), method: :delete, disabled: !page.resource.can_be_deleted?, class: "button", data: { confirm: "Confirmez-vous la suppression du gestionnaire ?" }, title: page.resource.can_be_deleted? ? "Supprimer" : "Ce gestionnaire ne peut etre supprimé car il est le seul gestionnaire d'un groupe racine" %> [namespace, page.resource],
method: :delete,
disabled: !page.resource.can_be_deleted?,
class: "button button--danger",
data: { confirm: "Confirmez-vous la suppression du gestionnaire ?" },
title: page.resource.can_be_deleted? ? "Supprimer" : "Ce gestionnaire ne peut etre supprimé car il est le seul gestionnaire d'un groupe racine") %>
</div> </div>
</header> </header>
<section class="main-content__body"> <section class="main-content__body">
<%= render partial: 'manager/application/user_meta', locals: { user: page.resource&.user } %> <%= render partial: 'manager/application/user_meta', locals: { user: page.resource&.user } %>
<dl> <dl>
<% page.attributes.each do |attribute| %> <% page.attributes.each do |title, attributes| %>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{page.resource_name}.#{title}", default: title %></legend>
<% end %>
<% attributes.each do |attribute| %>
<dt class="attribute-label" id="<%= attribute.name %>"> <dt class="attribute-label" id="<%= attribute.name %>">
<%= t( <%= t(
"helpers.label.#{resource_name}.#{attribute.name}", "helpers.label.#{resource_name}.#{attribute.name}",
@ -50,5 +62,7 @@ as well as a link to its edit page.
<dd class="attribute-data attribute-data--<%=attribute.html_class%>" <dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute, page: page %></dd> ><%= render_field attribute, page: page %></dd>
<% end %> <% end %>
</fieldset>
<% end %>
</dl> </dl>
</section> </section>

View file

@ -18,7 +18,7 @@ as well as a link to its edit page.
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %> <% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
<header class="main-content__header" role="banner"> <header class="main-content__header">
<h1 class="main-content__page-title"> <h1 class="main-content__page-title">
<%= content_for(:title) %> <%= content_for(:title) %>
</h1> </h1>
@ -42,7 +42,13 @@ as well as a link to its edit page.
<section class="main-content__body"> <section class="main-content__body">
<dl> <dl>
<% page.attributes.each do |attribute| %> <% page.attributes.each do |title, attributes| %>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{page.resource_name}.#{title}", default: title %></legend>
<% end %>
<% attributes.each do |attribute| %>
<dt class="attribute-label" id="<%= attribute.name %>"> <dt class="attribute-label" id="<%= attribute.name %>">
<%= t( <%= t(
"helpers.label.#{resource_name}.#{attribute.name}", "helpers.label.#{resource_name}.#{attribute.name}",
@ -50,9 +56,8 @@ as well as a link to its edit page.
) %> ) %>
</dt> </dt>
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"> <dd class="attribute-data attribute-data--<%=attribute.html_class%>"
<% if attribute.name == 'gestionnaires' %> ><% if attribute.name == 'gestionnaires' %>
<%= render( <%= render(
"collection_gestionnaires", "collection_gestionnaires",
page: page, page: page,
@ -63,5 +68,7 @@ as well as a link to its edit page.
<% end %> <% end %>
</dd> </dd>
<% end %> <% end %>
</fieldset>
<% end %>
</dl> </dl>
</section> </section>

View file

@ -19,7 +19,7 @@ as well as a link to its edit page.
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %> <% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
<% instructeur = page.resource %> <% instructeur = page.resource %>
<header class="main-content__header" role="banner"> <header class="main-content__header">
<h1 class="main-content__page-title"> <h1 class="main-content__page-title">
<%= content_for(:title) %> <%= content_for(:title) %>
</h1> </h1>
@ -30,29 +30,41 @@ as well as a link to its edit page.
[:edit, namespace, page.resource], [:edit, namespace, page.resource],
class: "button", class: "button",
) if valid_action?(:edit) && show_action?(:edit, page.resource) %> ) if valid_action?(:edit) && show_action?(:edit, page.resource) %>
</div>
<div>
<%= link_to 'Réinviter', reinvite_manager_instructeur_path(instructeur), method: :post, class: 'button' %> <%= link_to 'Réinviter', reinvite_manager_instructeur_path(instructeur), method: :post, class: 'button' %>
</div>
<div> <%= button_to("Supprimer",
<%= button_to "Supprimer", delete_manager_instructeur_path(page.resource), method: :delete, disabled: !page.resource.can_be_deleted?, class: "button", data: { turbo_confirm: "Confirmez-vous la suppression de l'instructeur ?" }, title: page.resource.can_be_deleted? ? "Supprimer" : "Cet instructeur est administrateur ou a des démarches dont il est le seul instructeur et ne peut être supprimé" %> delete_manager_instructeur_path(page.resource),
method: :delete,
disabled: !page.resource.can_be_deleted?,
class: "button button--danger",
data: { turbo_confirm: "Confirmez-vous la suppression de l'instructeur ?" },
title: page.resource.can_be_deleted? ? "Supprimer" : "Cet instructeur est administrateur ou a des démarches dont il est le seul instructeur et ne peut être supprimé") %>
</div> </div>
</header> </header>
<section class="main-content__body"> <section class="main-content__body">
<%= render partial: 'manager/application/user_meta', locals: { user: page.resource&.user } %> <%= render partial: 'manager/application/user_meta', locals: { user: page.resource&.user } %>
<dl> <dl>
<% page.attributes.each do |attribute| %> <% page.attributes.each do |title, attributes| %>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{page.resource_name}.#{title}", default: title %></legend>
<% end %>
<% attributes.each do |attribute| %>
<dt class="attribute-label" id="<%= attribute.name %>"> <dt class="attribute-label" id="<%= attribute.name %>">
<%= t( <%= t(
"helpers.label.#{resource_name}.#{attribute.name}", "helpers.label.#{resource_name}.#{attribute.name}",
default: attribute.name.titleize, default: page.resource.class.human_attribute_name(attribute.name),
) %> ) %>
</dt> </dt>
<dd class="attribute-data attribute-data--<%=attribute.html_class%>" <dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute, page: page %></dd> ><%= render_field attribute, page: page %></dd>
<% end %> <% end %>
</fieldset>
<% end %>
</dl> </dl>
</section> </section>

View file

@ -18,14 +18,15 @@ to display a collection of resources in an HTML table.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection [1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
%> %>
<div class="bt-3"> <div style="padding: 1em">
<%= form_with(url: manager_outdated_procedures_path, method: :get) do |f| %> <%= form_with(url: manager_outdated_procedures_path, method: :get) do |f| %>
<h2>Nombre de démarches sans auto archivage des dossiers: <%= @records_per_page %></h2> <h2>Nombre de démarches sans auto archivage des dossiers: <%= @records_per_page %></h2>
<h2>Nombre de dossiers archivable parmis ces démarches: <%= resources.sum(&:dossiers_close_to_expiration) %> </h2> <h2>Nombre de dossiers archivable parmis ces démarches: <%= resources.sum(&:dossiers_close_to_expiration) %> </h2>
<%= f.select :records_per_page, options_for_select([["10", "10"], ["100", "100"], ["1000", "1000"]], @records_per_page) %> <%= f.select :records_per_page, options_for_select([["10", "10"], ["100", "100"], ["1000", "1000"]], @records_per_page), {}, style: "width: auto" %>
<%= f.submit "Mettre a jour le nombre de démarche a archiver", class: 'button button--nav' %> <%= f.submit "Mettre a jour le nombre de démarche a archiver", class: 'button button--nav' %>
<% end %> <% end %>
</div> </div>
<%= form_with(url: bulk_update_manager_outdated_procedures_path, method: :patch) do |f| %> <%= form_with(url: bulk_update_manager_outdated_procedures_path, method: :patch) do |f| %>
<table aria-labelledby="<%= table_title %>"> <table aria-labelledby="<%= table_title %>">
<thead data-controller="outdated" > <thead data-controller="outdated" >
@ -34,17 +35,17 @@ to display a collection of resources in an HTML table.
<% collection_presenter.attribute_types.each do |attr_name, attr_type| %> <% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
<th class="cell-label <th class="cell-label
cell-label--<%= attr_type.html_class %> cell-label--<%= attr_type.html_class %>
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>" cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
cell-label--<%= "#{collection_presenter.resource_name}_#{attr_name}" %>"
scope="col" scope="col"
role="columnheader"
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>"> aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
<%= link_to(sanitized_order_params(page, collection_field_name).merge( <%= link_to(sanitized_order_params(page, collection_field_name).merge(
collection_presenter.order_params_for(attr_name, key: collection_field_name) collection_presenter.order_params_for(attr_name, key: collection_field_name)
)) do %> )) do %>
<%= t( <%= t(
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}", "helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
default: resource_class.human_attribute_name(attr_name), default: resource_class.human_attribute_name(attr_name).titleize,
).titleize %> ) %>
<% if collection_presenter.ordered_by?(attr_name) %> <% if collection_presenter.ordered_by?(attr_name) %>
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>"> <span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
<svg aria-hidden="true"> <svg aria-hidden="true">
@ -55,23 +56,28 @@ to display a collection of resources in an HTML table.
<% end %> <% end %>
</th> </th>
<% end %> <% end %>
<% [valid_action?(:edit, collection_presenter.resource_name), <%= render(
valid_action?(:destroy, collection_presenter.resource_name)].count(true).times do %> "collection_header_actions",
<th scope="col"></th> collection_presenter: collection_presenter,
<% end %> page: page,
resources: resources,
table_title: "page-title"
) %>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% resources.each do |resource| %> <% resources.each do |resource| %>
<tr class="" <tr
<% if show_action? :show, resource %> <% if accessible_action?(resource, :show) %>
<%= %(tabindex=0 role=link data-url=#{polymorphic_path([namespace, resource])}) %> <%= %(tabindex=0 role=link data-url=#{polymorphic_path([namespace, resource])}) %>
<% end %> <% end %>
> >
<td><%= f.check_box "procedure[ids][#{resource.id}]", checked: false %></td> <td><%= f.check_box "procedure[ids][#{resource.id}]", checked: false %></td>
<% collection_presenter.attributes_for(resource).each do |attribute| %> <% collection_presenter.attributes_for(resource).each do |attribute| %>
<td class="js-table-row cell-data cell-data--<%= attribute.html_class %>"> <td class="cell-data cell-data--<%= attribute.html_class %>">
<% if show_action? :show, resource -%> <% if show_action? :show, resource -%>
<a href="<%= polymorphic_path([namespace, resource]) -%>" <a href="<%= polymorphic_path([namespace, resource]) -%>"
tabindex="-1" tabindex="-1"
@ -85,26 +91,18 @@ to display a collection of resources in an HTML table.
</td> </td>
<% end %> <% end %>
<% if valid_action? :edit, collection_presenter.resource_name %> <%= render(
<td><%= link_to( "collection_item_actions",
t("administrate.actions.edit"), collection_presenter: collection_presenter,
[:edit, namespace, resource], collection_field_name: collection_field_name,
class: "action-edit", page: page,
) if show_action? :edit, resource%></td> namespace: namespace,
<% end %> resource: resource,
table_title: "page-title"
<% if valid_action? :destroy, collection_presenter.resource_name %> ) %>
<td><%= link_to(
t("administrate.actions.destroy"),
[namespace, resource],
class: "text-color-red",
method: :delete,
data: { confirm: t("administrate.actions.confirm") }
) if show_action? :destroy, resource %></td>
<% end %>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
<%= f.submit "Activer l'archivage automatique des démarches sélectionnée" %> <%= f.submit "Activer l'archivage automatique des démarches sélectionnée", style: "margin: 1em"%>
<% end %> <% end %>

View file

@ -62,5 +62,5 @@ It renders the `_table` partial to display details about the resources.
table_title: "page-title" table_title: "page-title"
) %> ) %>
<%= paginate resources, param_name: '_page' %> <%= render "pagination", resources: resources %>
</section> </section>

View file

@ -18,7 +18,7 @@ as well as a link to its edit page.
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %> <% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
<% procedure = page.resource %> <% procedure = page.resource %>
<header class="main-content__header" role="banner"> <header class="main-content__header">
<h1 class="main-content__page-title"> <h1 class="main-content__page-title">
<%= content_for(:title) %> <%= content_for(:title) %>
<% if procedure.discarded? %> <% if procedure.discarded? %>
@ -26,39 +26,42 @@ as well as a link to its edit page.
<% end %> <% end %>
</h1> </h1>
<div> <div class="buttons">
<%= link_to( <%= link_to(
t("administrate.actions.edit_resource", name: page.page_title), t("administrate.actions.edit_resource", name: page.page_title),
[:edit, namespace, page.resource], [:edit, namespace, page.resource],
class: "button", class: "button",
) if valid_action? :edit %> ) if valid_action? :edit %>
</div>
<div> <%= link_to 'Aperçu', apercu_admin_procedure_path(procedure), class: 'button' %>
<%= link_to 'aperçu', apercu_admin_procedure_path(procedure), class: 'button' %>
<% if !procedure.whitelisted? %> <% if !procedure.whitelisted? %>
<%= link_to 'whitelister', whitelist_manager_procedure_path(procedure), method: :post, class: 'button' %> <%= link_to 'Whitelister', whitelist_manager_procedure_path(procedure), method: :post, class: 'button' %>
<% end %> <% end %>
<% if procedure.hidden_as_template? %> <% if procedure.hidden_as_template? %>
<%= link_to 'autoriser l\'affichage dans les modèles', unhide_as_template_manager_procedure_path(procedure), method: :post, class: 'button' %> <%= link_to 'Autoriser l\'affichage dans les modèles', unhide_as_template_manager_procedure_path(procedure), method: :post, class: 'button' %>
<% else %> <% else %>
<%= link_to 'masquer l\'affichage dans les modèles', hide_as_template_manager_procedure_path(procedure), method: :post, class: 'button' %> <%= link_to 'Masquer l\'affichage dans les modèles', hide_as_template_manager_procedure_path(procedure), method: :post, class: 'button' %>
<% end %> <% end %>
<% if procedure.can_be_deleted_by_manager? %> <% if procedure.can_be_deleted_by_manager? %>
<%= link_to 'Supprimer la démarche', discard_manager_procedure_path(procedure), method: :post, class: 'button', data: { confirm: "Confirmez-vous la suppression de la démarche ?" } %> <%= link_to 'Supprimer la démarche', discard_manager_procedure_path(procedure), method: :post, class: 'button button--danger', data: { confirm: "Confirmez-vous la suppression de la démarche ?" } %>
<% elsif procedure.discarded? %> <% elsif procedure.discarded? %>
<%= link_to 'Restaurer la démarche', restore_manager_procedure_path(procedure), method: :post, class: 'button', data: { confirm: "Confirmez-vous la restauration de la démarche ?" } %> <%= link_to 'Restaurer la démarche', restore_manager_procedure_path(procedure), method: :post, class: 'button', data: { confirm: "Confirmez-vous la restauration de la démarche ?" } %>
<% end %> <% end %>
<div> </div>
</header> </header>
<section class="main-content__body"> <section class="main-content__body">
<dl> <dl>
<% page.attributes.each do |attribute| %> <% page.attributes.each do |title, attributes| %>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{page.resource_name}.#{title}", default: title %></legend>
<% end %>
<% attributes.each do |attribute| %>
<dt class="attribute-label" id="<%= attribute.name %>"> <dt class="attribute-label" id="<%= attribute.name %>">
<%= t( <%= t(
"helpers.label.#{resource_name}.#{attribute.name}", "helpers.label.#{resource_name}.#{attribute.name}",
@ -66,8 +69,8 @@ as well as a link to its edit page.
) %> ) %>
</dt> </dt>
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"> <dd class="attribute-data attribute-data--<%=attribute.html_class%>"
<%= render_field attribute, page: page %> ><%= render_field attribute, page: page %>
<% if attribute.name == 'administrateurs' %> <% if attribute.name == 'administrateurs' %>
<%= form_tag(add_administrateur_with_confirmation_manager_procedure_path(procedure), style: 'margin-top: 1rem;') do %> <%= form_tag(add_administrateur_with_confirmation_manager_procedure_path(procedure), style: 'margin-top: 1rem;') do %>
<%= email_field_tag(:email, '', placeholder: 'Email', autocapitalize: 'off', autocorrect: 'off', spellcheck: 'false', style: 'margin-bottom: 1rem;width:24rem;') %> <%= email_field_tag(:email, '', placeholder: 'Email', autocapitalize: 'off', autocorrect: 'off', spellcheck: 'false', style: 'margin-bottom: 1rem;width:24rem;') %>
@ -87,9 +90,8 @@ as well as a link to its edit page.
<% end %> <% end %>
<% end %> <% end %>
<% end %>
<% if attribute.name == 'tags' %>
<% elsif attribute.name == 'tags' %>
<%= form_for procedure, url: add_tags_manager_procedure_path(procedure), html: { class: 'form procedure-form__column--form fr-background-alt--blue-france mt-1' } do %> <%= form_for procedure, url: add_tags_manager_procedure_path(procedure), html: { class: 'form procedure-form__column--form fr-background-alt--blue-france mt-1' } do %>
<%= hidden_field_tag 'procedure[tags]', nil %> <%= hidden_field_tag 'procedure[tags]', nil %>
<%= react_component("ComboMultiple", <%= react_component("ComboMultiple",
@ -103,8 +105,8 @@ as well as a link to its edit page.
acceptNewValues: true) %> acceptNewValues: true) %>
<button class="mt-1">Ajouter des tags</button> <button class="mt-1">Ajouter des tags</button>
<% end %> <% end %>
<% end %>
<% if attribute.name == 'template' %> <% elsif attribute.name == 'template' %>
<%= form_for procedure, url: update_template_status_manager_procedure_path(procedure), html: { method: :patch, class: 'procedure-form__column--form fr-background-alt--blue-france mt-1', id: 'template-form' } do |f| %> <%= form_for procedure, url: update_template_status_manager_procedure_path(procedure), html: { method: :patch, class: 'procedure-form__column--form fr-background-alt--blue-france mt-1', id: 'template-form' } do |f| %>
<%= f.label :template, 'Marquer comme modèle', for: 'template_checkbox' %> <%= f.label :template, 'Marquer comme modèle', for: 'template_checkbox' %>
<%= f.check_box :template, id: 'template_checkbox', onchange: 'this.form.submit();' %> <%= f.check_box :template, id: 'template_checkbox', onchange: 'this.form.submit();' %>
@ -112,8 +114,10 @@ as well as a link to its edit page.
<% end %> <% end %>
</dd> </dd>
<% end %> <% end %>
<dd class="attribute-data"> <dd class="attribute-data">
<a class="button" href="<%= export_mail_brouillons_manager_procedure_url(procedure) %>">Télécharger un export CSV contenant les emails des demandeurs ayant effectué une demandes en brouillon</a> <a class="button" href="<%= export_mail_brouillons_manager_procedure_url(procedure) %>">Télécharger un export CSV contenant les emails des demandeurs ayant effectué une demandes en brouillon</a></dd>
</dd> </fieldset>
<% end %>
</dl> </dl>
</section> </section>

View file

@ -19,19 +19,26 @@ as well as a link to its edit page.
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %> <% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
<% user = page.resource %> <% user = page.resource %>
<header class="main-content__header" role="banner"> <header class="main-content__header">
<h1 class="main-content__page-title" style="<%= "background-color: red;color: white;" if user.blocked_at %>"> <h1 class="main-content__page-title" style="<%= "background-color: red;color: white;" if user.blocked_at %>">
<%= content_for(:title) %> <%= content_for(:title) %>
<%= "Bloqué" if user.blocked_at %> <%= "Bloqué" if user.blocked_at %>
</h1> </h1>
<div> <div class="buttons">
<%= button_to "modifier", edit_manager_user_path(page.resource), method: :get, class: "button" %> <%= link_to(
</div> "Modifier",
<div> edit_manager_user_path(page.resource),
<%= button_to "supprimer", delete_manager_user_path(page.resource), method: :delete, disabled: !page.resource.can_be_deleted?, class: "button", data: { turbo_confirm: "Confirmez-vous la suppression de l'utilisateur ?" }, title: page.resource.can_be_deleted? ? "Supprimer" : "Cet utilisateur ne peut être supprimé. Il a des dossiers dont l'instruction a commencé ou il est administrateur ou instructeur" %> class: "button") %>
</div>
<div> <%= button_to(t("administrate.actions.destroy"),
delete_manager_user_path(page.resource),
method: :delete,
disabled: !page.resource.can_be_deleted?,
class: "button button--danger",
data: { turbo_confirm: "Confirmez-vous la suppression de l'utilisateur ?" },
title: page.resource.can_be_deleted? ? "Supprimer" : "Cet utilisateur ne peut être supprimé. Il a des dossiers dont l'instruction a commencé ou il est administrateur ou instructeur") %>
<% if !user.confirmed? %> <% if !user.confirmed? %>
<%= link_to('Renvoyer lemail de confirmation', [:resend_confirmation_instructions, namespace, page.resource], method: :post, class: 'button') %> <%= link_to('Renvoyer lemail de confirmation', [:resend_confirmation_instructions, namespace, page.resource], method: :post, class: 'button') %>
<% end %> <% end %>
@ -40,17 +47,26 @@ as well as a link to its edit page.
<section class="main-content__body"> <section class="main-content__body">
<%= render partial: 'manager/application/user_meta', locals: { user: user } %> <%= render partial: 'manager/application/user_meta', locals: { user: user } %>
<dl> <dl>
<% page.attributes.each do |attribute| %> <% page.attributes.each do |title, attributes| %>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{page.resource_name}.#{title}", default: title %></legend>
<% end %>
<% attributes.each do |attribute| %>
<dt class="attribute-label" id="<%= attribute.name %>"> <dt class="attribute-label" id="<%= attribute.name %>">
<%= t( <%= t(
"helpers.label.#{resource_name}.#{attribute.name}", "helpers.label.#{resource_name}.#{attribute.name}",
default: attribute.name.titleize, default: page.resource.class.human_attribute_name(attribute.name),
) %> ) %>
</dt> </dt>
<dd class="attribute-data attribute-data--<%=attribute.html_class%>" <dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute, page: page %></dd> ><%= render_field attribute, page: page %></dd>
<% end %> <% end %>
</fieldset>
<% end %>
</dl> </dl>
</section> </section>

View file

@ -1,70 +0,0 @@
<%#
# Index
This view is the template for the index page.
It is responsible for rendering the search bar, header and pagination.
It renders the `_table` partial to display details about the resources.
## Local variables:
- `page`:
An instance of [Administrate::Page::Collection][1].
Contains helper methods to help display a table,
and knows which attributes should be displayed in the resource's table.
- `resources`:
An instance of `ActiveRecord::Relation` containing the resources
that match the user's search criteria.
By default, these resources are passed to the table partial to be displayed.
- `search_term`:
A string containing the term the user has searched for, if any.
- `show_search_bar`:
A boolean that determines if the search bar should be shown.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
%>
<% content_for(:title) do %>
<%= display_resource_name(page.resource_name) %>
<% end %>
<header class="main-content__header" role="banner">
<h1 class="main-content__page-title" id="page-title">
<%= content_for(:title) %>
</h1>
<div>
<%= link_to "Procedures sans zone renseignée", manager_zone_path(id: 'nil') %>
</div>
<% if show_search_bar %>
<%= render(
"search",
search_term: search_term,
resource_name: display_resource_name(page.resource_name)
) %>
<% end %>
<div>
<%= link_to(
t(
"administrate.actions.new_resource",
name: display_resource_name(page.resource_name, singular: true).downcase
),
[:new, namespace, page.resource_path.to_sym],
class: "button",
) if valid_action?(:new) && show_action?(:new, new_resource) %>
</div>
</header>
<section class="main-content__body main-content__body--flush">
<%= render(
"collection",
collection_presenter: page,
collection_field_name: resource_name,
page: page,
resources: resources,
table_title: "page-title"
) %>
<%= paginate resources, param_name: '_page' %>
</section>