<&| /Admin/Queues/Elements/SortableBox, prefix => $prefix, is_filter => 1, class_name => 'MemberOfRole' &>
<p><&|/l&>This filter selects eligible owners by their role membership. Only members of the following role, either on the queue or on the ticket itself, will be automatically assigned tickets.</&></p>

<div class="form-row">
  <div class="col-3 label">
    <&|/l&>Role</&>:
  </div>
  <div class="col-9 value">
    <select id="<% $prefix %>_role" name="<% $prefix %>_role" class="selectpicker form-control">
      <option value="">-</option>
%   for my $role (qw/AdminCc Cc Requestor/) {
      <option <% ($config->{role}||'') eq $role ? "selected" : "" %> value="<% $role %>"><% $role %></option>
%   }
% if ($custom_roles) {
%   while (my $role = $custom_roles->Next) {
      <option <% ($config->{role}||0) eq $role->Id ? "selected" : "" %> value="<% $role->Id %>"><% $role->Name %></option>
%   }
% }
    </select>
  </div>
</div>
</&>

<%INIT>
my $custom_roles;
if ( RT::Handle::cmp_version($RT::VERSION,'4.4.0') >= 0 ) {
    $custom_roles = RT::CustomRoles->new($session{CurrentUser});
    $custom_roles->LimitToObjectId($queue->Id);
    $custom_roles->ApplySortOrder;
}
</%INIT>
<%ARGS>
$prefix
$config
$queue
</%ARGS>
