% # frozen_string_literal: true %>
<%
object_assignment = UserAssignment.find_by(user_id: user.id, assignable: object)
item_id = dom_id(user, :assignment_member)
%>
<%= form_with(model: object_assignment, url: update_path, method: :put, remote: true, html: { class: 'row member-item', id: item_id, data: { action: 'replace-form autosave-form', object_type: :assignment_member } }) do |f| %>
<%= f.hidden_field :user_id, value: f.object.user.id %>
<%= image_tag avatar_path(user, :icon_small), title: current_assignee_name(user), class: 'img-circle pull-left' %>
<%= current_assignee_name(user) %>
<%= user_assignment_resource_role_name(user, object) %>
<% unless defined?(with_inherit) && current_user == user %>
<%= f.select :user_role_id, options_for_select(user_roles_collection(with_inherit: defined? with_inherit), selected: f.object.user_role.id), {}, class: 'form-control selectpicker', title: t('user_assignment.change_role'), data: { 'selected-text-format' => 'static' } %>
<% if defined? delete_path %>
<% unless object_assignment.last_assignable_owner? %>
<%= link_to delete_path, remote: true, method: :delete, class: 'btn btn-secondary', data: { action: 'remote-destroy', target: "##{item_id}" } do %>
<%= t 'general.remove' %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>