fix editing of inventory items of hidden columns

This commit is contained in:
mlorb 2018-08-07 11:47:26 +02:00
parent 29f0f2afeb
commit f52ccfd606
2 changed files with 13 additions and 12 deletions

View file

@ -125,14 +125,19 @@
} else {
var colId = element.replace('colId-', '');
var $el = $('#' + element);
// don't save anything if element is not visible
if($el.length == 0) {
return true;
}
if($el.attr('type') === 'file') {
// don't save anything if element is deleted
// handle deleting of element
if($el.attr('remove') === "true") {
return true;
formDataObj.append('repository_cells[' + colId + ']', 'remove');
} else {
formDataObj.append('repository_cells[' + colId + ']',
getFileValue($el));
}
formDataObj.append('repository_cells[' + colId + ']',
getFileValue($el));
} else if(value.length > 0) {
} else if(value.length >= 0) {
formDataObj.append('repository_cells[' + colId + ']', value);
}
}

View file

@ -134,7 +134,7 @@ class RepositoryRowsController < ApplicationController
existing.delete
end
elsif existing.value_type == 'RepositoryAssetValue'
next if value.blank?
existing.value.destroy && next if value == 'remove'
if existing.value.asset.update(file: value)
existing.value.asset.created_by = current_user
existing.value.asset.last_modified_by = current_user
@ -145,6 +145,7 @@ class RepositoryRowsController < ApplicationController
}
end
else
existing.value.destroy && next if value == ''
existing.value.data = value
if existing.value.save
record_annotation_notification(@record, existing)
@ -156,17 +157,12 @@ class RepositoryRowsController < ApplicationController
end
end
else
next if value == ''
# Looks like it is a new cell, so we need to create new value, cell
# will be created automatically
next if create_cell_value(@record, key, value, errors).nil?
end
end
# Clean up empty cells, not present in updated record
@record.repository_cells.each do |cell|
next if cell.value_type == 'RepositoryListValue'
cell.value.destroy unless cell_params
.key?(cell.repository_column_id.to_s)
end
else
@record.repository_cells.each { |c| c.value.destroy }
end