mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-10 15:14:33 +08:00
Error is displayed and import is prevented in case repository name column is not mapped, when importing repository items from file. [SCI-1402]
This commit is contained in:
parent
d726c121bc
commit
f847b44067
4 changed files with 35 additions and 10 deletions
|
@ -47,6 +47,7 @@
|
||||||
|
|
||||||
// Populate the errors container
|
// Populate the errors container
|
||||||
$('#import-errors-container').html(data.responseJSON.html);
|
$('#import-errors-container').html(data.responseJSON.html);
|
||||||
|
animateSpinner(null, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,18 +226,33 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_records
|
def import_records
|
||||||
import_records = repostiory_import_actions
|
|
||||||
status = import_records.import!
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
if status[:status] == :ok
|
# Check if there exist mapping for repository record (it's mandatory)
|
||||||
flash[:success] = t('repositories.import_records.success_flash',
|
if params[:mappings].value?('-1')
|
||||||
number_of_rows: status[:nr_of_added])
|
import_records = repostiory_import_actions
|
||||||
render json: {}, status: :ok
|
status = import_records.import!
|
||||||
|
|
||||||
|
if status[:status] == :ok
|
||||||
|
flash[:success] = t('repositories.import_records.success_flash',
|
||||||
|
number_of_rows: status[:nr_of_added])
|
||||||
|
render json: {}, status: :ok
|
||||||
|
else
|
||||||
|
flash[:alert] = t('repositories.import_records.error_flash',
|
||||||
|
message: status[:errors])
|
||||||
|
render json: {}, status: :unprocessable_entity
|
||||||
|
end
|
||||||
else
|
else
|
||||||
flash[:alert] = t('repositories.import_records.error_flash',
|
render json: {
|
||||||
message: status[:errors])
|
html: render_to_string(
|
||||||
render json: {}, status: :unprocessable_entity
|
partial: 'shared/flash_errors.html.erb',
|
||||||
|
locals: { error_title: t('repositories.import_records'\
|
||||||
|
'.error_message.errors_list_title'),
|
||||||
|
error: t('repositories.import_records.error_message'\
|
||||||
|
'.no_repository_name') }
|
||||||
|
)
|
||||||
|
},
|
||||||
|
status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
7
app/views/shared/_flash_errors.html.erb
Normal file
7
app/views/shared/_flash_errors.html.erb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<% if error.present? %>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<div><%= error_title %></div>
|
||||||
|
<br>
|
||||||
|
<%= error %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -899,6 +899,8 @@ en:
|
||||||
no_data_to_parse: "There's nothing to be parsed."
|
no_data_to_parse: "There's nothing to be parsed."
|
||||||
no_column_name: "Name column is required!"
|
no_column_name: "Name column is required!"
|
||||||
duplicated_values: "Two or more columns have the same mapping."
|
duplicated_values: "Two or more columns have the same mapping."
|
||||||
|
errors_list_title: "Items were not imported because one or more errors were found:"
|
||||||
|
no_repository_name: "Item name is required!"
|
||||||
edit_record: "Edit"
|
edit_record: "Edit"
|
||||||
delete_record: "Delete"
|
delete_record: "Delete"
|
||||||
save_record: "Save"
|
save_record: "Save"
|
||||||
|
@ -1083,7 +1085,7 @@ en:
|
||||||
empty_file: "You've selected empty file. There's not much to import."
|
empty_file: "You've selected empty file. There's not much to import."
|
||||||
temp_file_failure: "We couldn't create temporary file. Please contact administrator."
|
temp_file_failure: "We couldn't create temporary file. Please contact administrator."
|
||||||
no_file_selected: "You didn't select any file."
|
no_file_selected: "You didn't select any file."
|
||||||
errors_list_title: "Samples were not imported because one or more errors was found:"
|
errors_list_title: "Samples were not imported because one or more errors were found:"
|
||||||
list_row: "Row %{row}"
|
list_row: "Row %{row}"
|
||||||
list_error: "%{key}: %{val}"
|
list_error: "%{key}: %{val}"
|
||||||
import_samples:
|
import_samples:
|
||||||
|
|
Loading…
Add table
Reference in a new issue