@@ -, +, @@ --- Koha/Preservation/Processing.pm | 25 +++++++++++++++++-- .../SettingsProcessingsFormAdd.vue | 20 +++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) --- a/Koha/Preservation/Processing.pm +++ a/Koha/Preservation/Processing.pm @@ -46,10 +46,31 @@ sub attributes { my $schema = $self->_result->result_source->schema; $schema->txn_do( sub { - $self->attributes->delete; + my @existing_ids = map { $_->{processing_attribute_id} || () } @$attributes; + if (@existing_ids || !@$attributes) { + $self->attributes->search( + { + ( + # If no attributes passed we delete all the existing ones + @$attributes + ? ( + processing_attribute_id => { + -not_in => \@existing_ids + } + ) + : () + ) + } + )->delete; + } for my $attribute (@$attributes) { - $self->_result->add_to_preservation_processing_attributes($attribute); + my $existing_attribute = $self->attributes->find( $attribute->{processing_attribute_id} ); + if ($existing_attribute) { + $existing_attribute->set($attribute)->store; + } else { + $self->_result ->add_to_preservation_processing_attributes( $attribute ); + } } } ); --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/SettingsProcessingsFormAdd.vue +++ a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/SettingsProcessingsFormAdd.vue @@ -25,6 +25,17 @@
{{ $__("Attributes") }} +
+ {{ + $__( + "Be careful removing attribute to this processing, the items using it will be impacted as well!" + ) + }} +
- keepAttrs + ({ processing_id, ...keepAttrs }) => keepAttrs ) const client = APIClient.preservation @@ -284,3 +294,9 @@ export default { name: "SettingsProcessingsFormAdd", } + + --