Add multiple checkboxes to select domains for bulk renew

This commit is contained in:
Alex Sherman 2020-12-10 14:35:04 +05:00
parent 9c662471a7
commit 40b22cd433
3 changed files with 28 additions and 0 deletions

View file

@ -11,6 +11,8 @@ class Registrar
def bulk_renew def bulk_renew
authorize! :manage, :repp authorize! :manage, :repp
@expire_date = params[:expire_date].to_date @expire_date = params[:expire_date].to_date
# binding.pry
@domains = domains_by_date(@expire_date)
render file: 'registrar/bulk_change/new', locals: { active_tab: :bulk_renew } render file: 'registrar/bulk_change/new', locals: { active_tab: :bulk_renew }
end end
@ -23,5 +25,13 @@ class Registrar
def default_tab def default_tab
:technical_contact :technical_contact
end end
def domains_scope
current_registrar_user.registrar.domains
end
def domains_by_date(date)
domains_scope.where('valid_to <= ?', date)
end
end end
end end

View file

@ -12,6 +12,23 @@
</div> </div>
</div> </div>
<% if @domains.present? %>
<div class="form-group">
<div class="col-md-2 control-label">
<%= f.label :domain_ids, t('.domain_ids') %>
</div>
<div class="col-md-4">
<%= f.collection_check_boxes :domain_ids, @domains, :id, :name,
checked: @domains.map(&:id) do |b|%>
<div class="row">
<%= b.check_box %>
<%= b.label %>
</div>
<% end %>
</div>
</div>
<% end %>
<div class="form-group"> <div class="form-group">
<div class="col-md-4 col-md-offset-2 text-right"> <div class="col-md-4 col-md-offset-2 text-right">
<button class="btn btn-warning"> <button class="btn btn-warning">

View file

@ -34,3 +34,4 @@ en:
bulk_renew_form: bulk_renew_form:
filter_btn: Filter filter_btn: Filter
expire_date: Expire date until expire_date: Expire date until
domain_ids: Domains for bulk renewal