From 25fa5347609ef65784f71eb344e9130913048896 Mon Sep 17 00:00:00 2001 From: Bilal Date: Mon, 7 Sep 2020 13:07:27 +0300 Subject: [PATCH] improve Download button for Talent releases --- app/views/talent_releases/index.html.erb | 3 ++- app/views/talent_releases/index.js.erb | 2 ++ spec/jobs/generate_contracts_zip_job_spec.rb | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/views/talent_releases/index.html.erb b/app/views/talent_releases/index.html.erb index 08a629d..b16edcb 100644 --- a/app/views/talent_releases/index.html.erb +++ b/app/views/talent_releases/index.html.erb @@ -1,5 +1,6 @@
+ />
<% if policy(TalentRelease).new? %> <%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :talent_release], class: "btn btn-primary mr-2 mb-2" %> @@ -10,7 +11,7 @@ <% end %> <% if @talent_releases.any? && policy(TalentRelease).download_multiple? %> - <%= link_to "Download All", [@project, :contract_downloads, release_type: @talent_releases.name], method: :post, remote: true, class: "btn btn-light border ml-auto mr-2 mb-2", data: { + <%= button_to "Download", [@project, :contract_downloads, release_type: @talent_releases.name], id: "download_releases", method: :post, remote: true, class: "btn btn-light border ml-auto mr-2 mb-2", data: { disable_with: "Please wait..." } %> <% end %> diff --git a/app/views/talent_releases/index.js.erb b/app/views/talent_releases/index.js.erb index e396385..76e549f 100644 --- a/app/views/talent_releases/index.js.erb +++ b/app/views/talent_releases/index.js.erb @@ -1,3 +1,5 @@ $("#talent_releases").html("<%= j render(@talent_releases) %>"); $("form input[type='search']").val("<%= params[:query] %>"); $("#talent_releases_pagination").html("<%= j will_paginate(@talent_releases) %>"); +$("#selected_releases_form").attr('data-releasable-ids', JSON.stringify([])); +$("#total_entries").val(<%= @talent_releases.total_entries %>); \ No newline at end of file diff --git a/spec/jobs/generate_contracts_zip_job_spec.rb b/spec/jobs/generate_contracts_zip_job_spec.rb index aefe5b2..74d1e80 100644 --- a/spec/jobs/generate_contracts_zip_job_spec.rb +++ b/spec/jobs/generate_contracts_zip_job_spec.rb @@ -236,10 +236,13 @@ describe GenerateContractsZipJob do end context "generates ZIP for talent releases" do - let(:release) { create(:talent_release_with_contract_template, :native, project: project) } + let(:release) { create(:talent_release_with_contract_template, :native, project: project, person_name: "John Doe") } + let(:release2) { create(:talent_release_with_contract_template, :native, project: project, person_name: "Jane Doe") } + let(:release3) { create(:talent_release_with_contract_template, :native, project: project, person_name: "Brad Doe") } subject { 'TalentRelease' } it_behaves_like "generates ZIP containig CSV file with all releases data" + it_behaves_like "generates ZIP containig CSV file with specific releases data" end context "When there are errors" do