mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-06 05:04:35 +08:00
Implement multiline editing in repositories [SCI-6982]
This commit is contained in:
parent
b6b1fed7e2
commit
98b3627219
8 changed files with 32 additions and 29 deletions
|
@ -38,7 +38,7 @@ var ChecklistColumnHelper = (function() {
|
|||
}
|
||||
|
||||
function initialChecklistEditMode(formId, columnId, cell, values) {
|
||||
var select = 'checklist-' + columnId;
|
||||
var select = `checklist-${columnId}-${cell.parent()[0].id}`;
|
||||
var checklistUrl = $('.repository-column#' + columnId).data('items-url');
|
||||
var $select = checklistSelect(select, checklistUrl, values);
|
||||
var $hiddenField = checklistHiddenField(formId, columnId, values);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
var ListColumnHelper = (function() {
|
||||
function listSelect(select, url, value) {
|
||||
var selectedOption = '';
|
||||
var selectObject = $(`<select id="${select}"
|
||||
var selectObject = $(`<select id="${select}"
|
||||
data-placeholder = "${I18n.t('repositories.table.list.select_item')}"
|
||||
data-ajax-url = "${url}" >${selectedOption}</select>`);
|
||||
|
||||
|
@ -26,7 +26,7 @@ var ListColumnHelper = (function() {
|
|||
}
|
||||
|
||||
function initialListEditMode(formId, columnId, cell, value = null) {
|
||||
var select = 'list-' + columnId;
|
||||
var select = `list-${columnId}-${cell.parent()[0].id}`;
|
||||
var listUrl = $('.repository-column#' + columnId).data('items-url');
|
||||
var $select = listSelect(select, listUrl, value);
|
||||
var $hiddenField = listHiddenField(formId, columnId, value);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
var StatusColumnHelper = (function() {
|
||||
function statusSelect(select, url, value) {
|
||||
var selectedOption = '';
|
||||
var selectObject = $(`<select id="${select}"
|
||||
var selectObject = $(`<select id="${select}"
|
||||
data-placeholder = "${I18n.t('repositories.table.status.set_status')}"
|
||||
data-ajax-url = "${url}" ></select>`);
|
||||
|
||||
|
@ -26,7 +26,7 @@ var StatusColumnHelper = (function() {
|
|||
}
|
||||
|
||||
function initialStatusEditMode(formId, columnId, cell, value = null) {
|
||||
var select = 'status-list-' + columnId;
|
||||
var select = `status-list-${columnId}-${cell.parent()[0].id}`;
|
||||
var listUrl = $('.repository-column#' + columnId).data('items-url');
|
||||
var $select = statusSelect(select, listUrl, value);
|
||||
var $hiddenField = statusHiddenField(formId, columnId, value);
|
||||
|
|
|
@ -71,11 +71,7 @@ var RepositoryDatatable = (function(global) {
|
|||
$('#editDeleteCopy').hide();
|
||||
$('#toolbarPrintLabel').hide();
|
||||
} else {
|
||||
if (rowsSelected.length === 1) {
|
||||
$('#editRepositoryRecord').prop('disabled', false);
|
||||
} else {
|
||||
$('#editRepositoryRecord').prop('disabled', true);
|
||||
}
|
||||
$('#editRepositoryRecord').prop('disabled', false);
|
||||
$('#exportRepositoriesButton').removeClass('disabled');
|
||||
$('#archiveRepositoryRecordsButton').prop('disabled', false);
|
||||
$('#copyRepositoryRecords').prop('disabled', false);
|
||||
|
@ -142,10 +138,8 @@ var RepositoryDatatable = (function(global) {
|
|||
|
||||
function changeToEditMode() {
|
||||
currentMode = 'editMode';
|
||||
// Table specific stuff
|
||||
TABLE.button(0).enable(false);
|
||||
|
||||
clearRowSelection();
|
||||
$(TABLE_WRAPPER_ID).find('tr:not(.editing)').addClass('blocked');
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
|
@ -262,9 +256,8 @@ var RepositoryDatatable = (function(global) {
|
|||
|
||||
checkAvailableColumns();
|
||||
|
||||
$(TABLE_ID).find('.repository-row-edit-icon').remove();
|
||||
|
||||
RepositoryDatatableRowEditor.switchRowToEditMode(row);
|
||||
|
||||
changeToEditMode();
|
||||
});
|
||||
}
|
||||
|
@ -542,6 +535,17 @@ var RepositoryDatatable = (function(global) {
|
|||
$('#repository-table_info').append('<span id="selected_info"></span>');
|
||||
$('#selected_info').html(' (' + rowsSelected.length + ' entries selected)');
|
||||
checkArchivedColumnsState();
|
||||
|
||||
// Hide edit button if not all selected rows are on the current page
|
||||
let visibleRowIds = $(
|
||||
`#repository-table-${$(TABLE_ID).data('repository-id')} tbody tr`
|
||||
).toArray().map((r) => parseInt(r.id, 10));
|
||||
|
||||
if (rowsSelected.every(r => visibleRowIds.includes(r))) {
|
||||
$('#editRepositoryRecord').show();
|
||||
} else {
|
||||
$('#editRepositoryRecord').hide();
|
||||
}
|
||||
},
|
||||
preDrawCallback: function() {
|
||||
var archived = $('.repository-show').hasClass('archived');
|
||||
|
@ -769,15 +773,12 @@ var RepositoryDatatable = (function(global) {
|
|||
.on('click', '#editRepositoryRecord', function() {
|
||||
checkAvailableColumns();
|
||||
|
||||
if (rowsSelected.length !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
let row = TABLE.row('#' + rowsSelected[0]);
|
||||
|
||||
$(TABLE_ID).find('.repository-row-edit-icon').remove();
|
||||
|
||||
RepositoryDatatableRowEditor.switchRowToEditMode(row);
|
||||
rowsSelected.forEach(function(rowNumber) {
|
||||
RepositoryDatatableRowEditor.switchRowToEditMode(TABLE.row('#' + rowNumber));
|
||||
});
|
||||
|
||||
changeToEditMode();
|
||||
adjustTableHeader();
|
||||
})
|
||||
|
|
|
@ -39,7 +39,6 @@ var SmartAnnotation = (function() {
|
|||
function generateFilterMenu() {
|
||||
var menu = '';
|
||||
$.ajax({
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
url: $(document.body).attr('data-atwho-repositories-url'),
|
||||
success: function(data) {
|
||||
|
|
|
@ -345,6 +345,13 @@
|
|||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
&.editing {
|
||||
.assigned-column .repository-row-edit-icon {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.editing {
|
||||
|
@ -363,10 +370,6 @@
|
|||
|
||||
tr:hover {
|
||||
.assigned-column {
|
||||
.repository-row-edit-icon {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.assign-counter-container {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<%if can_update_repository_rows?(@repository) %>
|
||||
<button type="button" title="<%= t('repositories.show.button_tooltip.edit') %>"
|
||||
class="btn btn-light editAdd auto-shrink-button"
|
||||
id="editRepositoryRecord" disabled data-view-mode="active">
|
||||
id="editRepositoryRecord" data-view-mode="active">
|
||||
<span class="fas fa-pencil-alt"></span>
|
||||
<span class="button-text"><%= t("repositories.edit_record") %></span>
|
||||
</button>
|
||||
|
|
|
@ -1699,7 +1699,7 @@ en:
|
|||
create:
|
||||
success_flash: "Successfully added item <strong>%{record}</strong> to inventory <strong>%{repository}</strong>"
|
||||
update:
|
||||
success_flash: "Successfully updated item <strong>%{record}</strong> in inventory <strong>%{repository}</strong>"
|
||||
success_flash: "Inventory items were successfully updated."
|
||||
destroy:
|
||||
success_flash: "%{records_number} item(s) successfully deleted."
|
||||
contains_other_records_flash: "%{records_number} item(s) successfully deleted. %{other_records_number} of the selected item(s) were created by other users and were not deleted."
|
||||
|
|
Loading…
Add table
Reference in a new issue