Merge pull request #7848 from betagouv/perf_on_invite
perf: optimise la liste déroulante concernant les invités
This commit is contained in:
commit
183506810b
4 changed files with 14 additions and 5 deletions
|
@ -1,9 +1,10 @@
|
|||
- invites = dossier.invites.load
|
||||
.dropdown.invite-user-action{ data: { controller: 'menu-button', popover: 'true' } }
|
||||
%button.button.dropdown-button{ data: { menu_button_target: 'button' } }
|
||||
%span.icon.person
|
||||
- if dossier.invites.count > 0
|
||||
- if invites.size > 0
|
||||
= t('views.invites.dropdown.view_invited_people')
|
||||
%span.badge= dossier.invites.count
|
||||
%span.badge= invites.size
|
||||
- else
|
||||
- if dossier.read_only?
|
||||
= t('views.invites.dropdown.invite_to_view')
|
||||
|
@ -11,4 +12,4 @@
|
|||
= t('views.invites.dropdown.invite_to_edit')
|
||||
|
||||
#invite-content.dropdown-content.fade-in-down{ data: { menu_button_target: 'menu' } }
|
||||
= render partial: "invites/form", locals: { dossier: dossier }
|
||||
= render partial: "invites/form", locals: { dossier: dossier, invites: invites }
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#invites-form
|
||||
- if dossier.invites.present?
|
||||
- if invites.present?
|
||||
%h4= t('views.invites.form.invite_to_participate')
|
||||
%ul
|
||||
- dossier.invites.each do |invite|
|
||||
- invites.each do |invite|
|
||||
%li
|
||||
= invite.email
|
||||
%small{ 'data-turbo': 'true' }
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class AddIndexOnDossierIdToInvites < ActiveRecord::Migration[6.1]
|
||||
include Database::MigrationHelpers
|
||||
disable_ddl_transaction!
|
||||
def up
|
||||
add_concurrent_index :invites, [:dossier_id]
|
||||
end
|
||||
end
|
|
@ -562,6 +562,7 @@ ActiveRecord::Schema.define(version: 2022_10_05_145646) do
|
|||
t.text "message"
|
||||
t.datetime "updated_at"
|
||||
t.integer "user_id"
|
||||
t.index ["dossier_id"], name: "index_invites_on_dossier_id"
|
||||
t.index ["email", "dossier_id"], name: "index_invites_on_email_and_dossier_id", unique: true
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue