add notice when matching is completed
This commit is contained in:
@@ -17,6 +17,7 @@ $(document).on "turbolinks:load", ->
|
|||||||
when "video_status_update" then @showVideoStatusUpdate(data.content)
|
when "video_status_update" then @showVideoStatusUpdate(data.content)
|
||||||
when "download_status_update" then @showDownloadStatusUpdate(data.content)
|
when "download_status_update" then @showDownloadStatusUpdate(data.content)
|
||||||
when "conference_recording_ready" then @showDownloadStatusUpdate(data.content)
|
when "conference_recording_ready" then @showDownloadStatusUpdate(data.content)
|
||||||
|
when "appearance_matching_flash_message" then @showMatchingStatusUpdate(data.content)
|
||||||
|
|
||||||
showVideoStatusUpdate: (content) ->
|
showVideoStatusUpdate: (content) ->
|
||||||
$("[data-ujs-target='video-analysis-msg']").replaceWith content
|
$("[data-ujs-target='video-analysis-msg']").replaceWith content
|
||||||
@@ -24,3 +25,6 @@ $(document).on "turbolinks:load", ->
|
|||||||
showDownloadStatusUpdate: (content) ->
|
showDownloadStatusUpdate: (content) ->
|
||||||
$(".flash-message").html content
|
$(".flash-message").html content
|
||||||
$(".toast").toast('show')
|
$(".toast").toast('show')
|
||||||
|
|
||||||
|
showMatchingStatusUpdate: (content) ->
|
||||||
|
$("#flash-message").replaceWith content
|
||||||
|
|||||||
@@ -33,4 +33,15 @@ class ProjectsChannel < ApplicationCable::Channel
|
|||||||
content = ApplicationController.render partial: 'application/flash', locals: { flash: flash }
|
content = ApplicationController.render partial: 'application/flash', locals: { flash: flash }
|
||||||
broadcast_to project, event: :conference_recording_ready, content: content
|
broadcast_to project, event: :conference_recording_ready, content: content
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.appearance_matching_flash_message(project, message, flash_type = :notice)
|
||||||
|
if (flash_type == :notice)
|
||||||
|
flash = OpenStruct.new notice: message
|
||||||
|
else
|
||||||
|
flash = OpenStruct.new alert: message
|
||||||
|
end
|
||||||
|
content = ApplicationController.render partial: 'application/flash', locals: { flash: flash }
|
||||||
|
|
||||||
|
broadcast_to project, event: :appearance_matching_flash_message, content: content
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ class MatchAppearanceReleasesJob < ApplicationJob
|
|||||||
def perform(project, attachments)
|
def perform(project, attachments)
|
||||||
filtered_attachments_object = filter_attachments attachments
|
filtered_attachments_object = filter_attachments attachments
|
||||||
|
|
||||||
return if filtered_attachments_object[:keys].blank?
|
if filtered_attachments_object[:keys].blank?
|
||||||
|
notification = I18n.t 'appearance_releases.create.matching_failed'
|
||||||
|
ProjectsChannel.appearance_matching_flash_message project, notification, :alert
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
matching_request = MatchingRequest.create project: project, attachments: filtered_attachments_object[:signed_ids]
|
matching_request = MatchingRequest.create project: project, attachments: filtered_attachments_object[:signed_ids]
|
||||||
|
|
||||||
@@ -17,6 +21,8 @@ class MatchAppearanceReleasesJob < ApplicationJob
|
|||||||
handle_matches matches, project, key_signed_id_hash
|
handle_matches matches, project, key_signed_id_hash
|
||||||
handle_unmatches matches, project, key_signed_id_hash
|
handle_unmatches matches, project, key_signed_id_hash
|
||||||
matching_request.destroy
|
matching_request.destroy
|
||||||
|
|
||||||
|
ProjectsChannel.appearance_matching_flash_message project, success_message
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -113,4 +119,8 @@ class MatchAppearanceReleasesJob < ApplicationJob
|
|||||||
signed_ids: filtered_attachments_signed_ids
|
signed_ids: filtered_attachments_signed_ids
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def success_message
|
||||||
|
I18n.t 'appearance_releases.create.matching_completed'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
<!-- Position toasts -->
|
<!-- Position toasts -->
|
||||||
<div class="position-absolute" style="top: 0.5rem; right: 0.5rem;">
|
<div class="position-absolute" style="top: 0.5rem; right: 0.5rem;">
|
||||||
<% if flash.alert.present? %>
|
<% if flash.alert.present? %>
|
||||||
<div class="toast fade show bg-black text-white toast-min-w-border-radius" data-autohide="false">
|
<div id="flash-message" class="toast fade show bg-black text-white toast-min-w-border-radius" data-autohide="false">
|
||||||
<div class="toast-body toast-border-left-danger">
|
<div class="toast-body toast-border-left-danger">
|
||||||
<button type="button" class="close text-white ml-2" data-dismiss="toast">×</button>
|
<button type="button" class="close text-white ml-2" data-dismiss="toast">×</button>
|
||||||
<p><%= flash.alert.html_safe %></p>
|
<p><%= flash.alert.html_safe %></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% elsif flash.notice.present? %>
|
<% elsif flash.notice.present? %>
|
||||||
<div class="toast fade show bg-black text-white toast-min-w-border-radius" data-autohide="false">
|
<div id="flash-message" class="toast fade show bg-black text-white toast-min-w-border-radius" data-autohide="false">
|
||||||
<div class="toast-body toast-border-left-primary">
|
<div class="toast-body toast-border-left-primary">
|
||||||
<button type="button" class="close text-white ml-2" data-dismiss="toast">×</button>
|
<button type="button" class="close text-white ml-2" data-dismiss="toast">×</button>
|
||||||
<p><%= flash.notice.html_safe %></p>
|
<p><%= flash.notice.html_safe %></p>
|
||||||
@@ -19,4 +19,3 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -151,6 +151,8 @@ en:
|
|||||||
failed_import: Failed to create appearance release for files listed below
|
failed_import: Failed to create appearance release for files listed below
|
||||||
matching_started: Matching started
|
matching_started: Matching started
|
||||||
no_attachments: Failed to import - no attachments
|
no_attachments: Failed to import - no attachments
|
||||||
|
matching_completed: Matching completed. Reload page to see new releases
|
||||||
|
matching_failed: Matching failed
|
||||||
edit:
|
edit:
|
||||||
heading: Edit Appearance Release
|
heading: Edit Appearance Release
|
||||||
form:
|
form:
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ es:
|
|||||||
failed_import: Failed to create appearance release for files listed below (ES)
|
failed_import: Failed to create appearance release for files listed below (ES)
|
||||||
matching_started: Matching started (ES)
|
matching_started: Matching started (ES)
|
||||||
no_attachments: Failed to import - no attachments (ES)
|
no_attachments: Failed to import - no attachments (ES)
|
||||||
|
matching_completed: Matching completed (ES)
|
||||||
|
matching_failed: Matching failed (ES)
|
||||||
form:
|
form:
|
||||||
guardian_2_info:
|
guardian_2_info:
|
||||||
heading: Second Guardian Information (if company requires) (ES)
|
heading: Second Guardian Information (if company requires) (ES)
|
||||||
|
|||||||
@@ -324,6 +324,18 @@ feature 'User managing appearance releases' do
|
|||||||
expect(page).to have_content no_appearance_releases
|
expect(page).to have_content no_appearance_releases
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario 'Message is shown when matching job is completed', js: true do
|
||||||
|
visit project_appearance_releases_path(project)
|
||||||
|
|
||||||
|
attach_file import_appearance_release_field, Rails.root.join(file_fixture('person_photo.png')), visible: false
|
||||||
|
allow(MatchAppearanceReleasesJob).to receive(:perform_later).with(project, anything)
|
||||||
|
click_button submit_create_button
|
||||||
|
expect(page).to have_content matching_started
|
||||||
|
expect(page).to have_content no_appearance_releases
|
||||||
|
expect(page).not_to have_content matching_started
|
||||||
|
expect(page).to have_content matching_completed
|
||||||
|
end
|
||||||
|
|
||||||
scenario 'user leaving the page is presented with the warning if file upload is in progress', js: true do
|
scenario 'user leaving the page is presented with the warning if file upload is in progress', js: true do
|
||||||
skip "Test is inconsistently failing in CI"
|
skip "Test is inconsistently failing in CI"
|
||||||
|
|
||||||
@@ -847,6 +859,10 @@ feature 'User managing appearance releases' do
|
|||||||
t 'appearance_releases.create.matching_started'
|
t 'appearance_releases.create.matching_started'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def matching_completed
|
||||||
|
t 'appearance_releases.create.matching_completed'
|
||||||
|
end
|
||||||
|
|
||||||
def filter_type_all
|
def filter_type_all
|
||||||
t 'appearance_releases.type_filter_actions.all_releases'
|
t 'appearance_releases.type_filter_actions.all_releases'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ describe MatchAppearanceReleasesJob do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe ".perform_now" do
|
describe ".perform_now" do
|
||||||
|
# before do
|
||||||
|
# allow(ProjectsChannel).to receive(:appearance_matching_flash_message).with(be_kind_of(Project), I18n.t("appearance_releases.create.matching_completed"))
|
||||||
|
# end
|
||||||
|
|
||||||
|
|
||||||
it "returns if no attachment is sent" do
|
it "returns if no attachment is sent" do
|
||||||
expect(MatchingRequest).not_to receive(:create)
|
expect(MatchingRequest).not_to receive(:create)
|
||||||
attachments = []
|
attachments = []
|
||||||
@@ -50,6 +55,8 @@ describe MatchAppearanceReleasesJob do
|
|||||||
|
|
||||||
expect(AppearanceRelease.last.contract).not_to be_attached
|
expect(AppearanceRelease.last.contract).not_to be_attached
|
||||||
expect(AppearanceRelease.last.person_photo).to be_attached
|
expect(AppearanceRelease.last.person_photo).to be_attached
|
||||||
|
|
||||||
|
# expect(ProjectsChannel).to receive(:appearance_matching_flash_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates a new incomplete appearance release for contracts which cannot be matched by BrayniacAI" do
|
it "creates a new incomplete appearance release for contracts which cannot be matched by BrayniacAI" do
|
||||||
|
|||||||
Reference in New Issue
Block a user