mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-21 07:26:15 +08:00
Update new repository row code so file columns work again
Also fix backend code a bit (so update & create of repository rows are more similar in their behavior), and fix line in JS: _initSelectPicker() was called a reduntant amount of times when editing repository row. Closes SCI-2436.
This commit is contained in:
parent
91673afbf3
commit
6135081a71
|
@ -426,7 +426,9 @@ var RepositoryDatatable = (function(global) {
|
|||
} else if ($(th).hasClass('repository-column') &&
|
||||
$(th).attr('data-type') === 'RepositoryAssetValue') {
|
||||
input = changeToInputFileField('repository_cell_file', th.attr('id'), '');
|
||||
tr.appendChild(createTdElement(input));
|
||||
td = createTdElement(input);
|
||||
tr.appendChild(td);
|
||||
_addSelectedFile($(th).attr('data-type'), '', $(td).find('input')[0]);
|
||||
} else {
|
||||
// Column we don't care for, just add empty td
|
||||
tr.appendChild(createTdElement(''));
|
||||
|
@ -657,9 +659,9 @@ var RepositoryDatatable = (function(global) {
|
|||
cell,
|
||||
list_columns));
|
||||
_addSelectedFile(type, cell, $(this).find('input')[0]);
|
||||
_initSelectPicker();
|
||||
}
|
||||
});
|
||||
_initSelectPicker();
|
||||
|
||||
// initialize smart annotation
|
||||
_.each($('[data-object="repository_cell"]'), function(el) {
|
||||
|
|
|
@ -198,9 +198,10 @@ class RepositoryRowsController < ApplicationController
|
|||
column = @repository.repository_columns.detect do |c|
|
||||
c.id == key.to_i
|
||||
end
|
||||
save_successful = false
|
||||
if column.data_type == 'RepositoryListValue'
|
||||
return if value == '-1'
|
||||
# check if item existx else revert the transaction
|
||||
# check if item exists else revert the transaction
|
||||
list_item = RepositoryListItem.where(repository_column: column)
|
||||
.find(value)
|
||||
cell_value = RepositoryListValue.new(
|
||||
|
@ -212,7 +213,9 @@ class RepositoryRowsController < ApplicationController
|
|||
repository_column: column
|
||||
}
|
||||
)
|
||||
save_successful = list_item && cell_value.save
|
||||
elsif column.data_type == 'RepositoryAssetValue'
|
||||
return if value.blank?
|
||||
asset = Asset.new(file: value,
|
||||
created_by: current_user,
|
||||
last_modified_by: current_user,
|
||||
|
@ -233,6 +236,7 @@ class RepositoryRowsController < ApplicationController
|
|||
repository_column: column
|
||||
}
|
||||
)
|
||||
save_successful = cell_value.save
|
||||
else
|
||||
cell_value = RepositoryTextValue.new(
|
||||
data: value,
|
||||
|
@ -243,11 +247,13 @@ class RepositoryRowsController < ApplicationController
|
|||
repository_column: column
|
||||
}
|
||||
)
|
||||
if (save_successful = cell_value.save)
|
||||
record_annotation_notification(record,
|
||||
cell_value.repository_cell)
|
||||
end
|
||||
end
|
||||
if cell_value.save
|
||||
record_annotation_notification(record,
|
||||
cell_value.repository_cell)
|
||||
else
|
||||
|
||||
unless save_successful
|
||||
errors[:repository_cells] << {
|
||||
"#{column.id}": cell_value.errors.messages
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue