Bug 37893: SIP2 System preference overrides

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2025-02-10 10:59:53 +00:00 committed by Lucas Gass
parent 443d4a069b
commit fa527ac8ff
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
14 changed files with 950 additions and 6 deletions

View File

@ -0,0 +1,189 @@
package Koha::REST::V1::SIP2::SystemPreferenceOverrides;
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Mojo::Base 'Mojolicious::Controller';
use Koha::SIP2::SystemPreferenceOverride;
use Koha::SIP2::SystemPreferenceOverrides;
use Try::Tiny qw( catch try );
=head1 API
=head2 Methods
=head3 list
=cut
sub list {
my $c = shift->openapi->valid_input or return;
return try {
my $syspref_overrides = $c->objects->search( Koha::SIP2::SystemPreferenceOverrides->new );
return $c->render( status => 200, openapi => $syspref_overrides );
} catch {
$c->unhandled_exception($_);
};
}
=head3 get
Controller function that handles retrieving a single Koha::SIP2::SystemPreferenceOverride object
=cut
sub get {
my $c = shift->openapi->valid_input or return;
return try {
my $syspref_override = $c->objects->find(
Koha::SIP2::SystemPreferenceOverrides->search,
$c->param('sip_system_preference_override_id')
);
return $c->render_resource_not_found("System preference override")
unless $syspref_override;
return $c->render(
status => 200,
openapi => $syspref_override
);
} catch {
$c->unhandled_exception($_);
};
}
=head3 add
Controller function that handles adding a new Koha::SIP2::SystemPreferenceOverride object
=cut
sub add {
my $c = shift->openapi->valid_input or return;
return try {
Koha::Database->new->schema->txn_do(
sub {
my $body = $c->req->json;
my $syspref_override = Koha::SIP2::SystemPreferenceOverride->new_from_api($body)->store;
$c->res->headers->location(
$c->req->url->to_string . '/' . $syspref_override->sip_system_preference_override_id );
return $c->render(
status => 201,
openapi => $c->objects->to_api($syspref_override),
);
}
);
} catch {
my $to_api_mapping = Koha::SIP2::SystemPreferenceOverride->new->to_api_mapping;
if ( blessed $_ ) {
if ( $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
return $c->render(
status => 409,
openapi => { error => $_->error, conflict => $_->duplicate_id }
);
} elsif ( $_->isa('Koha::Exceptions::BadParameter') ) {
return $c->render(
status => 400,
openapi => { error => "Given " . $to_api_mapping->{ $_->parameter } . " does not exist" }
);
}
}
$c->unhandled_exception($_);
};
}
=head3 update
Controller function that handles updating a Koha::SIP2::SystemPreferenceOverride object
=cut
sub update {
my $c = shift->openapi->valid_input or return;
my $syspref_override =
Koha::SIP2::SystemPreferenceOverrides->find( $c->param('sip_system_preference_override_id') );
return $c->render_resource_not_found("System preference override")
unless $syspref_override;
return try {
Koha::Database->new->schema->txn_do(
sub {
my $body = $c->req->json;
$syspref_override->set_from_api($body)->store;
$c->res->headers->location(
$c->req->url->to_string . '/' . $syspref_override->sip_system_preference_override_id );
return $c->render(
status => 200,
openapi => $c->objects->to_api($syspref_override),
);
}
);
} catch {
my $to_api_mapping = Koha::SIP2::SystemPreferenceOverride->new->to_api_mapping;
if ( blessed $_ ) {
if ( $_->isa('Koha::Exceptions::BadParameter') ) {
return $c->render(
status => 400,
openapi => { error => "Given " . $to_api_mapping->{ $_->parameter } . " does not exist" }
);
}
}
$c->unhandled_exception($_);
};
}
=head3 delete
=cut
sub delete {
my $c = shift->openapi->valid_input or return;
my $syspref_override =
Koha::SIP2::SystemPreferenceOverrides->find( $c->param('sip_system_preference_override_id') );
return $c->render_resource_not_found("System preference override")
unless $syspref_override;
return try {
$syspref_override->delete;
return $c->render_resource_deleted;
} catch {
$c->unhandled_exception($_);
};
}
1;

View File

@ -0,0 +1,44 @@
package Koha::SIP2::SystemPreferenceOverride;
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Koha::Database;
use base qw(Koha::SIP2::Object Koha::Object);
=head1 NAME
Koha::SIP2::SystemPreferenceOverride - Koha SIP2 System Preference Override Object class
=head1 API
=head2 Class Methods
=cut
=head2 Internal methods
=head3 _type
=cut
sub _type {
return 'SipSystemPreferenceOverride';
}
1;

View File

@ -0,0 +1,70 @@
package Koha::SIP2::SystemPreferenceOverrides;
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Koha::Database;
use Koha::SIP2::SystemPreferenceOverride;
use base qw(Koha::Objects);
=head1 NAME
Koha::SIP2::SystemPreferenceOverrides - Koha SIP2 System Preference Overrid Object set class
=head1 API
=head2 Class Methods
=cut
=head3 get_for_config
Returns the server params hashref as expected by C4/SIP/Sip/Configuration->new;
=cut
sub get_for_config {
my ($self) = @_;
my $sys_pref_overrides = $self->search();
my $return_hash;
while ( my $sys_pref_override = $sys_pref_overrides->next() ) {
$return_hash->{ $sys_pref_override->variable } = $sys_pref_override->value;
}
return $return_hash;
}
=head3 type
=cut
sub _type {
return 'SipSystemPreferenceOverride';
}
=head3 object_class
=cut
sub object_class {
return 'Koha::SIP2::SystemPreferenceOverride';
}
1;

View File

@ -0,0 +1,84 @@
use utf8;
package Koha::Schema::Result::SipSystemPreferenceOverride;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Koha::Schema::Result::SipSystemPreferenceOverride
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 TABLE: C<sip_system_preference_overrides>
=cut
__PACKAGE__->table("sip_system_preference_overrides");
=head1 ACCESSORS
=head2 sip_system_preference_override_id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 variable
data_type: 'varchar'
is_nullable: 0
size: 80
System preference name
=head2 value
data_type: 'varchar'
is_nullable: 0
size: 80
System preference value
=cut
__PACKAGE__->add_columns(
"sip_system_preference_override_id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"variable",
{ data_type => "varchar", is_nullable => 0, size => 80 },
"value",
{ data_type => "varchar", is_nullable => 0, size => 80 },
);
=head1 PRIMARY KEY
=over 4
=item * L</sip_system_preference_override_id>
=back
=cut
__PACKAGE__->set_primary_key("sip_system_preference_override_id");
# Created by DBIx::Class::Schema::Loader v0.07051 @ 2025-02-10 10:27:51
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:szyNGurH+wJBItdnYfAoRA
sub koha_objects_class {
'Koha::SIP2::SystemPreferenceOverrides';
}
sub koha_object_class {
'Koha::SIP2::SystemPreferenceOverride';
}
1;

View File

@ -2876,6 +2876,16 @@ modules:
-
columnname: protocol
system_preference_overrides:
system_preference_overrides:
columns:
-
columnname: sip_system_preference_override_id
-
columnname: variable
-
columnname: value
pos:
pay:
invoices:

View File

@ -0,0 +1,19 @@
---
type: object
properties:
sip_system_preference_override_id:
type: integer
description: unique identifier
readOnly: true
variable:
description: variable
type: string
value:
description: value
type: string
additionalProperties: false
required:
- sip_system_preference_override_id
- variable
- value

View File

@ -0,0 +1,276 @@
---
/sip2/system_preference_overrides:
get:
x-mojo-to: SIP2::SystemPreferenceOverrides#list
operationId: listSip2SystemPreferenceOverrides
tags:
- sip2_system_preference_overrides
summary: List system preference overrides
produces:
- application/json
parameters:
- description: Case insensitive search on system preference override sip_system_preference_override_id
in: query
name: sip_system_preference_override_id
required: false
type: string
collectionFormat: csv
- $ref: "../swagger.yaml#/parameters/match"
- $ref: "../swagger.yaml#/parameters/order_by"
- $ref: "../swagger.yaml#/parameters/page"
- $ref: "../swagger.yaml#/parameters/per_page"
- $ref: "../swagger.yaml#/parameters/q_param"
- $ref: "../swagger.yaml#/parameters/q_body"
responses:
200:
description: A list of SIP2 system preference overrides
schema:
items:
$ref: "../swagger.yaml#/definitions/sip2_system_preference_override"
type: array
"400":
description: |
Bad request. Possible `error_code` attribute values:
* `invalid_query`
schema:
$ref: "../swagger.yaml#/definitions/error"
403:
description: Access forbidden
schema:
$ref: "../swagger.yaml#/definitions/error"
500:
description: |-
Internal server error. Possible `error_code` attribute values:
* `internal_server_error`
schema:
$ref: "../swagger.yaml#/definitions/error"
503:
description: Under maintenance
schema:
$ref: "../swagger.yaml#/definitions/error"
x-koha-authorization:
permissions:
superlibrarian: 1 # TODO: Fix this, currently for superlibrarians only
post:
x-mojo-to: SIP2::SystemPreferenceOverrides#add
operationId: addSip2SystemPreferenceOverrides
tags:
- sip2_system_preference_overrides
summary: Add system preference overrides
consumes:
- application/json
produces:
- application/json
parameters:
- description: A JSON object containing information about the new system preference override
in: body
name: body
required: true
schema:
$ref: "../swagger.yaml#/definitions/sip2_system_preference_override"
responses:
201:
description: A successfully created system preference override
schema:
items:
$ref: "../swagger.yaml#/definitions/sip2_system_preference_override"
400:
description: Bad request
schema:
$ref: "../swagger.yaml#/definitions/error"
401:
description: Authentication required
schema:
$ref: "../swagger.yaml#/definitions/error"
403:
description: Access forbidden
schema:
$ref: "../swagger.yaml#/definitions/error"
404:
description: Ressource not found
schema:
$ref: "../swagger.yaml#/definitions/error"
409:
description: Conflict in creating resource
schema:
$ref: "../swagger.yaml#/definitions/error"
413:
description: Payload too large
schema:
$ref: "../swagger.yaml#/definitions/error"
500:
description: |-
Internal server error. Possible `error_code` attribute values:
* `internal_server_error`
schema:
$ref: "../swagger.yaml#/definitions/error"
503:
description: Under maintenance
schema:
$ref: "../swagger.yaml#/definitions/error"
x-koha-authorization:
permissions:
superlibrarian: 1 # TODO: Fix this, currently for superlibrarians only
"/sip2/system_preference_overrides/{sip_system_preference_override_id}":
get:
x-mojo-to: SIP2::SystemPreferenceOverrides#get
operationId: getSipSystemPreferenceOverrides
tags:
- sip2_system_preference_overrides
summary: Get SIP2 system preference overrides
produces:
- application/json
parameters:
- $ref: "../swagger.yaml#/parameters/sip_system_preference_override_id_pp"
- name: x-koha-embed
in: header
required: false
description: Embed list sent as a request header
type: array
items:
type: string
enum:
- custom_item_fields
- item_fields
- custom_patron_fields
- patron_attributes
collectionFormat: csv
responses:
200:
description: A SIP2 system preference override
schema:
items:
$ref: "../swagger.yaml#/definitions/sip2_system_preference_override"
400:
description: Bad request
schema:
$ref: "../swagger.yaml#/definitions/error"
401:
description: Authentication required
schema:
$ref: "../swagger.yaml#/definitions/error"
403:
description: Access forbidden
schema:
$ref: "../swagger.yaml#/definitions/error"
404:
description: Ressource not found
schema:
$ref: "../swagger.yaml#/definitions/error"
500:
description: |-
Internal server error. Possible `error_code` attribute values:
* `internal_server_error`
schema:
$ref: "../swagger.yaml#/definitions/error"
503:
description: Under maintenance
schema:
$ref: "../swagger.yaml#/definitions/error"
x-koha-authorization:
permissions:
superlibrarian: 1 # TODO: Fix this, currently for superlibrarians only
put:
x-mojo-to: SIP2::SystemPreferenceOverrides#update
operationId: updateSip2SystemPreferenceOverrides
tags:
- sip2_system_preference_overrides
summary: Update system preference override
consumes:
- application/json
produces:
- application/json
parameters:
- $ref: "../swagger.yaml#/parameters/sip_system_preference_override_id_pp"
- name: body
in: body
description: A JSON object containing new information about existing system preference override
required: true
schema:
$ref: "../swagger.yaml#/definitions/sip2_system_preference_override"
responses:
200:
description: A successfully updated system preference override
schema:
items:
$ref: "../swagger.yaml#/definitions/sip2_system_preference_override"
400:
description: Bad request
schema:
$ref: "../swagger.yaml#/definitions/error"
403:
description: Access forbidden
schema:
$ref: "../swagger.yaml#/definitions/error"
404:
description: Ressource not found
schema:
$ref: "../swagger.yaml#/definitions/error"
409:
description: Conflict in updating resource
schema:
$ref: "../swagger.yaml#/definitions/error"
413:
description: Payload too large
schema:
$ref: "../swagger.yaml#/definitions/error"
500:
description: |-
Internal server error. Possible `error_code` attribute values:
* `internal_server_error`
schema:
$ref: "../swagger.yaml#/definitions/error"
503:
description: Under maintenance
schema:
$ref: "../swagger.yaml#/definitions/error"
x-koha-authorization:
permissions:
superlibrarian: 1 # TODO: Fix this, currently for superlibrarians only
delete:
x-mojo-to: SIP2::SystemPreferenceOverrides#delete
operationId: deleteSip2SystemPreferenceOverrides
tags:
- sip2_system_preference_overrides
summary: Delete system preference override
produces:
- application/json
parameters:
- $ref: "../swagger.yaml#/parameters/sip_system_preference_override_id_pp"
responses:
204:
description: System preference override deleted
400:
description: Bad request
schema:
$ref: "../swagger.yaml#/definitions/error"
401:
description: Authentication required
schema:
$ref: "../swagger.yaml#/definitions/error"
403:
description: Access forbidden
schema:
$ref: "../swagger.yaml#/definitions/error"
404:
description: Resource not found
schema:
$ref: "../swagger.yaml#/definitions/error"
409:
description: Conflict in deleting resource
schema:
$ref: "../swagger.yaml#/definitions/error"
500:
description: |-
Internal server error. Possible `error_code` attribute values:
* `internal_server_error`
schema:
$ref: "../swagger.yaml#/definitions/error"
503:
description: Under maintenance
schema:
$ref: "../swagger.yaml#/definitions/error"
x-koha-authorization:
permissions:
superlibrarian: 1 # TODO: Fix this, currently for superlibrarians only

View File

@ -188,6 +188,8 @@ definitions:
$ref: ./definitions/sip2_listener.yaml
sip2_server_param:
$ref: ./definitions/sip2_server_param.yaml
sip2_system_preference_override:
$ref: ./definitions/sip2_system_preference_override.yaml
smtp_server:
$ref: ./definitions/smtp_server.yaml
file_transport:
@ -619,6 +621,10 @@ paths:
$ref: "./paths/sip2_listeners.yaml#/~1sip2~1listeners~1{sip_listener_id}"
/sip2/serverparams:
$ref: "./paths/sip2_server_params.yaml#/~1sip2~1server_params"
/sip2/system_preference_overrides:
$ref: ./paths/sip2_system_preference_overrides.yaml#/~1sip2~1system_preference_overrides
"/sip2/system_preference_overrides/{sip_system_preference_override_id}":
$ref: "./paths/sip2_system_preference_overrides.yaml#/~1sip2~1system_preference_overrides~1{sip_system_preference_override_id}"
/suggestions:
$ref: ./paths/suggestions.yaml#/~1suggestions
"/suggestions/{suggestion_id}":
@ -1023,6 +1029,12 @@ parameters:
name: sip_listener_id
required: true
type: integer
sip_system_preference_override_id_pp:
description: SIP2 system preference override internal identifier
in: path
name: sip_system_preference_override_id
required: true
type: integer
smtp_server_id_pp:
description: SMTP server internal identifier
in: path

View File

@ -310,9 +310,7 @@ return {
# Server params #
my @server_params_keys = keys %{ $SIPconfig->{'server-params'} };
foreach my $server_params_key (@server_params_keys) {
my $insert_listeners = $dbh->prepare(
q{INSERT IGNORE INTO sip_server_params (`key`, value) VALUES (?, ?) }
);
my $insert_listeners = $dbh->prepare(q{INSERT IGNORE INTO sip_server_params (`key`, value) VALUES (?, ?) });
$insert_listeners->execute(
$server_params_key,
@ -325,5 +323,31 @@ return {
my $timestamp = DateTime->now;
my $insert_config_timestamp = $dbh->prepare(q{INSERT INTO sip_server_params (`key`, value) VALUES (?, ?) });
$insert_config_timestamp->execute( 'config_timestamp', $timestamp->epoch );
# System preference overrides
my @system_preference_overrides =
ref $SIPconfig->{syspref_overrides} eq "ARRAY"
? @{ $SIPconfig->{syspref_overrides} }
: ( $SIPconfig->{syspref_overrides} );
my $insert_system_preference_overrides =
$dbh->prepare(q{INSERT IGNORE INTO sip_system_preference_overrides (variable, value) VALUES (?, ?)});
foreach my $system_preference_override (@system_preference_overrides) {
if ( ref $system_preference_override eq 'HASH' ) {
for my $key ( keys %{$system_preference_override} ) {
my $override_value = $system_preference_override->{$key};
if ( ref $system_preference_override->{$key} eq 'ARRAY' ) {
$override_value = $system_preference_override->{$key}->[0];
}
$insert_system_preference_overrides->execute(
$key,
$override_value
);
}
}
}
},
};

View File

@ -6318,6 +6318,20 @@ CREATE TABLE `sip_server_params` (
UNIQUE KEY `server_param_key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table `sip_system_preference_overrides`
--
DROP TABLE IF EXISTS `sip_system_preference_overrides`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sip_system_preference_overrides` (
`sip_system_preference_override_id` int(11) NOT NULL AUTO_INCREMENT,
`variable` varchar(80) NOT NULL COMMENT 'System preference name',
`value` varchar(80) NOT NULL COMMENT 'System preference value',
PRIMARY KEY (`sip_system_preference_override_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table `sms_providers`
--

View File

@ -23,6 +23,7 @@
const institutions_table_settings = [% TablesSettings.GetTableSettings( 'sip2', 'institutions', 'institutions', 'json' ) | $raw %];
const accounts_table_settings = [% TablesSettings.GetTableSettings( 'sip2', 'accounts', 'accounts', 'json' ) | $raw %];
const listeners_table_settings = [% TablesSettings.GetTableSettings( 'sip2', 'listeners', 'listeners', 'json' ) | $raw %];
const system_preference_overrides_table_settings = [% TablesSettings.GetTableSettings( 'sip2', 'system_preference_overrides', 'system_preference_overrides', 'json' ) | $raw %];
const logged_in_user = [% To.json(logged_in_user.unblessed) | $raw %];
</script>
[% Asset.js("js/vue/dist/sip2.js") | $raw %]

View File

@ -126,13 +126,50 @@ export class SIP2APIClient {
this.getAll({
endpoint: "serverparams",
}),
updateAll: (body) =>
updateAll: body =>
this.patch({
endpoint: "serverparams",
body: body,
}),
};
}
get system_preference_overrides() {
return {
get: id =>
this.get({
endpoint: "system_preference_overrides/" + id,
}),
getAll: params =>
this.getAll({
endpoint: "system_preference_overrides",
}),
delete: id =>
this.delete({
endpoint: "system_preference_overrides/" + id,
}),
create: system_preference_override =>
this.post({
endpoint: "system_preference_overrides",
body: system_preference_override,
}),
update: (system_preference_override, id) =>
this.put({
endpoint: "system_preference_overrides/" + id,
body: system_preference_override,
}),
count: (query = {}) =>
this.count({
endpoint:
"system_preference_overrides?" +
new URLSearchParams({
_page: 1,
_per_page: 1,
...(query && { q: JSON.stringify(query) }),
}),
}),
};
}
}
export default SIP2APIClient;

View File

@ -0,0 +1,132 @@
<script>
import BaseResource from "./../BaseResource.vue";
import { APIClient } from "../../fetch/api-client.js";
export default {
extends: BaseResource,
props: {
routeAction: String,
},
setup(props) {
return {
...BaseResource.setup({
resourceName: "system_preference_override",
nameAttr: "variable",
idAttr: "sip_system_preference_override_id",
showComponent: "SIP2SystemPreferenceOverridesShow",
listComponent: "SIP2SystemPreferenceOverridesList",
addComponent: "SIP2SystemPreferenceOverridesFormAdd",
editComponent: "SIP2SystemPreferenceOverridesFormAddEdit",
apiClient: APIClient.sip2.system_preference_overrides,
resourceTableUrl:
APIClient.sip2._baseURL + "system_preference_overrides",
i18n: {
displayName: __("System preference override"),
displayNameLowerCase: __("system preference override"),
displayNamePlural: __("system preference overrides"),
},
}),
};
},
data() {
return {
resourceAttrs: [
{
name: "variable",
required: true,
type: "text",
label: __("Variable"),
},
{
name: "value",
required: true,
type: "text",
label: __("Value"),
},
],
tableOptions: {
columns: this.getTableColumns(),
url: () => this.resourceTableUrl,
table_settings: this.system_preference_overrides_table_settings,
actions: {
0: ["show"],
"-1": this.embedded
? [
{
select: {
text: this.$__("Select"),
icon: "fa fa-check",
},
},
]
: ["edit", "delete"],
},
},
};
},
methods: {
getTableColumns: function () {
return [
{
title: __("Variable"),
data: "variable",
searchable: true,
orderable: true,
},
{
title: __("Value"),
data: "value",
searchable: true,
orderable: true,
},
];
},
onSubmit(e, systemPreferenceOverrideToSave) {
e.preventDefault();
let system_preference_override = JSON.parse(
JSON.stringify(systemPreferenceOverrideToSave)
); // copy
let sip_system_preference_override_id =
system_preference_override.sip_system_preference_override_id;
delete system_preference_override.sip_system_preference_override_id;
const client = APIClient.sip2;
if (sip_system_preference_override_id) {
client.system_preference_overrides
.update(
system_preference_override,
sip_system_preference_override_id
)
.then(
success => {
this.setMessage(
this.$__("System preference override updated")
);
this.$router.push({
name: "SIP2SystemPreferenceOverridesList",
});
},
error => {}
);
} else {
client.system_preference_overrides
.create(system_preference_override)
.then(
success => {
this.setMessage(
this.$__("System preference override created")
);
this.$router.push({
name: "SIP2SystemPreferenceOverridesList",
});
},
error => {}
);
}
},
},
name: "SIP2SystemPreferenceOverrideResource",
};
</script>

View File

@ -114,10 +114,42 @@ export const routes = [
},
],
},
{
path: "/cgi-bin/koha/sip2/system_preference_overrides",
title: $__("System preference overrides"),
icon: "fa fa-cog",
is_end_node: true,
resource: "SIP2/SIP2SystemPreferenceOverrideResource.vue",
children: [
{
path: "",
name: "SIP2SystemPreferenceOverridesList",
component: markRaw(ResourceWrapper),
},
{
path: ":sip_system_preference_override_id",
name: "SIP2SystemPreferenceOverridesShow",
component: markRaw(ResourceWrapper),
title: $__("Show system preference override"),
},
{
path: "add",
name: "SIP2SystemPreferenceOverridesFormAdd",
component: markRaw(ResourceWrapper),
title: $__("Add system preference override"),
},
{
path: "edit/:sip_system_preference_override_id",
name: "SIP2SystemPreferenceOverridesFormAddEdit",
component: markRaw(ResourceWrapper),
title: $__("Edit system preference override"),
},
],
},
{
path: "/cgi-bin/koha/sip2/serverparams",
title: $__("Server params"),
icon: "fa fa-cog",
icon: "fa fa-server",
is_end_node: true,
children: [
{
@ -125,7 +157,7 @@ export const routes = [
name: "SIP2ServerParams",
component: markRaw(ServerParams),
},
]
],
},
],
},