Bugzilla – Attachment 154010 Details for
Bug 32607
Add record sources CRUD
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32607: (follow-up) Apply changes suggested
Bug-32607-follow-up-Apply-changes-suggested.patch (text/plain), 79.55 KB, created by
Agustín Moyano
on 2023-07-27 23:24:03 UTC
(
hide
)
Description:
Bug 32607: (follow-up) Apply changes suggested
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2023-07-27 23:24:03 UTC
Size:
79.55 KB
patch
obsolete
>From ba91fb67d397b39582510980d3dbf3b807a3c54f Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Thu, 27 Jul 2023 23:20:44 +0000 >Subject: [PATCH] Bug 32607: (follow-up) Apply changes suggested > >--- > .../V1/{ImportSources.pm => RecordSources.pm} | 75 +++---- > Koha/{ImportSource.pm => RecordSource.pm} | 12 +- > Koha/{ImportSources.pm => RecordSources.pm} | 12 +- > .../{import-sources.pl => record-sources.pl} | 4 +- > ...{import_source.yaml => record_source.yaml} | 6 +- > ...mport_sources.yaml => record_sources.yaml} | 77 ++++--- > api/v1/swagger/swagger.yaml | 24 +-- > debian/templates/apache-shared-intranet.conf | 2 + > .../data/mysql/atomicupdate/bug_32607.pl | 31 +-- > installer/data/mysql/kohastructure.sql | 12 +- > .../data/mysql/mandatory/userpermissions.sql | 2 +- > .../prog/en/modules/admin/admin-home.tt | 6 +- > .../{import-sources.tt => record-sources.tt} | 6 +- > .../prog/js/vue/components/Form.vue | 144 ------------- > .../prog/js/vue/components/Page.vue | 4 +- > .../vue/components/import-sources/ISEdit.vue | 80 ------- > .../vue/components/import-sources/ISList.vue | 100 --------- > .../js/vue/components/record-sources/Edit.vue | 154 ++++++++++++++ > .../js/vue/components/record-sources/List.vue | 120 +++++++++++ > .../ISMain.vue => record-sources/Main.vue} | 3 +- > .../prog/js/vue/fetch/import-sources.js | 40 ---- > .../prog/js/vue/fetch/patron-api-client.js | 4 - > .../prog/js/vue/fetch/record-sources.js | 48 +++++ > .../intranet-tmpl/prog/js/vue/i18n/index.js | 2 +- > .../prog/js/vue/import-source/router.js | 12 -- > .../prog/js/vue/inputs/autocomplete.js | 199 ------------------ > .../intranet-tmpl/prog/js/vue/inputs/index.js | 5 - > .../prog/js/vue/models/import-sources.js | 85 -------- > .../{import-sources.ts => record-sources.ts} | 30 +-- > .../prog/js/vue/routes/import-sources.js | 31 --- > .../prog/js/vue/routes/record-sources.js | 34 +++ > .../intranet-tmpl/prog/js/vue/stores/model.js | 51 ----- > .../Koha/{ImportSources.t => RecordSources.t} | 8 +- > .../v1/{import_sources.t => record_sources.t} | 64 +++--- > webpack.config.js | 2 +- > 35 files changed, 547 insertions(+), 942 deletions(-) > rename Koha/REST/V1/{ImportSources.pm => RecordSources.pm} (53%) > rename Koha/{ImportSource.pm => RecordSource.pm} (83%) > rename Koha/{ImportSources.pm => RecordSources.pm} (83%) > rename admin/{import-sources.pl => record-sources.pl} (90%) > rename api/v1/swagger/definitions/{import_source.yaml => record_source.yaml} (58%) > rename api/v1/swagger/paths/{import_sources.yaml => record_sources.yaml} (79%) > rename koha-tmpl/intranet-tmpl/prog/en/modules/admin/{import-sources.tt => record-sources.tt} (83%) > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/Form.vue > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/import-sources/ISEdit.vue > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/import-sources/ISList.vue > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/record-sources/Edit.vue > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/record-sources/List.vue > rename koha-tmpl/intranet-tmpl/prog/js/vue/components/{import-sources/ISMain.vue => record-sources/Main.vue} (88%) > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/fetch/import-sources.js > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/fetch/record-sources.js > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/import-source/router.js > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/inputs/autocomplete.js > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/inputs/index.js > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/models/import-sources.js > rename koha-tmpl/intranet-tmpl/prog/js/vue/modules/{import-sources.ts => record-sources.ts} (65%) > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/routes/import-sources.js > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/routes/record-sources.js > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/stores/model.js > rename t/db_dependent/Koha/{ImportSources.t => RecordSources.t} (85%) > rename t/db_dependent/api/v1/{import_sources.t => record_sources.t} (78%) > >diff --git a/Koha/REST/V1/ImportSources.pm b/Koha/REST/V1/RecordSources.pm >similarity index 53% >rename from Koha/REST/V1/ImportSources.pm >rename to Koha/REST/V1/RecordSources.pm >index b77e2cadca..3816c9b37e 100644 >--- a/Koha/REST/V1/ImportSources.pm >+++ b/Koha/REST/V1/RecordSources.pm >@@ -1,4 +1,4 @@ >-package Koha::REST::V1::ImportSources; >+package Koha::REST::V1::RecordSources; > > # Copyright 2023 Theke Solutions > # >@@ -21,7 +21,7 @@ use Modern::Perl; > > use Mojo::Base 'Mojolicious::Controller'; > >-use Koha::ImportSources; >+use Koha::RecordSources; > > use Try::Tiny qw( catch try ); > >@@ -37,11 +37,10 @@ sub list { > my $c = shift->openapi->valid_input or return; > > return try { >- my $import_sources_set = Koha::ImportSources->new; >- my $import_sources = $c->objects->search( $import_sources_set ); >- return $c->render( status => 200, openapi => $import_sources ); >- } >- catch { >+ my $record_sources_set = Koha::RecordSources->new; >+ my $record_sources = $c->objects->search($record_sources_set); >+ return $c->render( status => 200, openapi => $record_sources ); >+ } catch { > $c->unhandled_exception($_); > }; > } >@@ -54,16 +53,17 @@ sub get { > my $c = shift->openapi->valid_input or return; > > return try { >- my $import_sources_set = Koha::ImportSources->new; >- my $import_source = $c->objects->find( $import_sources_set, $c->validation->param('import_source_id') ); >- unless ($import_source) { >- return $c->render( status => 404, >- openapi => { error => "Import source not found" } ); >+ my $record_sources_set = Koha::RecordSources->new; >+ my $record_source = $c->objects->find( $record_sources_set, $c->validation->param('record_source_id') ); >+ unless ($record_source) { >+ return $c->render( >+ status => 404, >+ openapi => { error => "Record source not found" } >+ ); > } > >- return $c->render( status => 200, openapi => $import_source ); >- } >- catch { >+ return $c->render( status => 200, openapi => $record_source ); >+ } catch { > $c->unhandled_exception($_); > }; > } >@@ -76,15 +76,14 @@ sub add { > my $c = shift->openapi->valid_input or return; > > return try { >- my $import_source = Koha::ImportSource->new_from_api( $c->validation->param('body') ); >- $import_source->store; >- $c->res->headers->location( $c->req->url->to_string . '/' . $import_source->import_source_id ); >+ my $record_source = Koha::RecordSource->new_from_api( $c->validation->param('body') ); >+ $record_source->store; >+ $c->res->headers->location( $c->req->url->to_string . '/' . $record_source->record_source_id ); > return $c->render( > status => 201, >- openapi => $import_source->to_api >+ openapi => $record_source->to_api > ); >- } >- catch { >+ } catch { > $c->unhandled_exception($_); > }; > } >@@ -96,19 +95,20 @@ sub add { > sub update { > my $c = shift->openapi->valid_input or return; > >- my $import_source = Koha::ImportSources->find( $c->validation->param('import_source_id') ); >+ my $record_source = Koha::RecordSources->find( $c->validation->param('record_source_id') ); > >- if ( not defined $import_source ) { >- return $c->render( status => 404, >- openapi => { error => "Object not found" } ); >+ if ( not defined $record_source ) { >+ return $c->render( >+ status => 404, >+ openapi => { error => "Object not found" } >+ ); > } > > return try { >- $import_source->set_from_api( $c->validation->param('body') ); >- $import_source->store(); >- return $c->render( status => 200, openapi => $import_source->to_api ); >- } >- catch { >+ $record_source->set_from_api( $c->validation->param('body') ); >+ $record_source->store(); >+ return $c->render( status => 200, openapi => $record_source->to_api ); >+ } catch { > $c->unhandled_exception($_); > }; > } >@@ -120,20 +120,21 @@ sub update { > sub delete { > my $c = shift->openapi->valid_input or return; > >- my $import_source = Koha::ImportSources->find( $c->validation->param('import_source_id') ); >- if ( not defined $import_source ) { >- return $c->render( status => 404, >- openapi => { error => "Object not found" } ); >+ my $record_source = Koha::RecordSources->find( $c->validation->param('record_source_id') ); >+ if ( not defined $record_source ) { >+ return $c->render( >+ status => 404, >+ openapi => { error => "Object not found" } >+ ); > } > > return try { >- $import_source->delete; >+ $record_source->delete; > return $c->render( > status => 204, > openapi => q{} > ); >- } >- catch { >+ } catch { > $c->unhandled_exception($_); > }; > } >diff --git a/Koha/ImportSource.pm b/Koha/RecordSource.pm >similarity index 83% >rename from Koha/ImportSource.pm >rename to Koha/RecordSource.pm >index b23fc95422..29a817e77c 100644 >--- a/Koha/ImportSource.pm >+++ b/Koha/RecordSource.pm >@@ -1,4 +1,4 @@ >-package Koha::ImportSource; >+package Koha::RecordSource; > > # This file is part of Koha. > # >@@ -24,7 +24,7 @@ use base qw(Koha::Object); > > =head1 NAME > >-Koha::ImportSource - Koha ImportSource Object class >+Koha::RecordSource - Koha RecordSource Object class > > =head1 API > >@@ -32,9 +32,9 @@ Koha::ImportSource - Koha ImportSource Object class > > =head3 patron > >-my $patron = $import_source->patron >+my $patron = $record_source->patron > >-Return the patron for this import source >+Return the patron for this record source > > =cut > >@@ -50,7 +50,7 @@ sub patron { > =cut > > sub _type { >- return 'ImportSource'; >+ return 'RecordSource'; > } > >-1; >\ No newline at end of file >+1; >diff --git a/Koha/ImportSources.pm b/Koha/RecordSources.pm >similarity index 83% >rename from Koha/ImportSources.pm >rename to Koha/RecordSources.pm >index 1cdca37b1b..987aec76b9 100644 >--- a/Koha/ImportSources.pm >+++ b/Koha/RecordSources.pm >@@ -1,4 +1,4 @@ >-package Koha::ImportSources; >+package Koha::RecordSources; > > # This file is part of Koha. > # >@@ -22,11 +22,11 @@ use Modern::Perl; > > use base qw(Koha::Objects); > >-use Koha::ImportSource; >+use Koha::RecordSource; > > =head1 NAME > >-Koha::ImportSources - Koha ImportSources Object class >+Koha::RecordSources - Koha RecordSources Object class > > =head1 API > >@@ -37,7 +37,7 @@ Koha::ImportSources - Koha ImportSources Object class > =cut > > sub _type { >- return 'ImportSource'; >+ return 'RecordSource'; > } > > =head3 object_class >@@ -45,7 +45,7 @@ sub _type { > =cut > > sub object_class { >- return 'Koha::ImportSource'; >+ return 'Koha::RecordSource'; > } > >-1; >\ No newline at end of file >+1; >diff --git a/admin/import-sources.pl b/admin/record-sources.pl >similarity index 90% >rename from admin/import-sources.pl >rename to admin/record-sources.pl >index c23c53270a..1ccb3d42a9 100755 >--- a/admin/import-sources.pl >+++ b/admin/record-sources.pl >@@ -28,10 +28,10 @@ my $query = CGI->new; > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { >- template_name => "admin/import-sources.tt", >+ template_name => "admin/record-sources.tt", > query => $query, > type => "intranet", >- flagsrequired => { parameters => 'manage_import_sources' }, >+ flagsrequired => { parameters => 'manage_record_sources' }, > } > ); > >diff --git a/api/v1/swagger/definitions/import_source.yaml b/api/v1/swagger/definitions/record_source.yaml >similarity index 58% >rename from api/v1/swagger/definitions/import_source.yaml >rename to api/v1/swagger/definitions/record_source.yaml >index b7d3555d1d..2a0ae6d91b 100644 >--- a/api/v1/swagger/definitions/import_source.yaml >+++ b/api/v1/swagger/definitions/record_source.yaml >@@ -1,12 +1,12 @@ > --- > type: object > properties: >- import_source_id: >+ record_source_id: > type: integer >- description: internally assigned import source identifier >+ description: internally assigned record source identifier > readOnly: true > name: >- description: import source name >+ description: record source name > type: string > patron_id: > description: linked patron identifier >diff --git a/api/v1/swagger/paths/import_sources.yaml b/api/v1/swagger/paths/record_sources.yaml >similarity index 79% >rename from api/v1/swagger/paths/import_sources.yaml >rename to api/v1/swagger/paths/record_sources.yaml >index 63c8b50214..7161973267 100644 >--- a/api/v1/swagger/paths/import_sources.yaml >+++ b/api/v1/swagger/paths/record_sources.yaml >@@ -1,10 +1,10 @@ >-/import_sources: >+/record_sources: > get: >- x-mojo-to: ImportSources#list >- operationId: listImportSources >- summary: List import sources >+ x-mojo-to: RecordSources#list >+ operationId: listRecordSources >+ summary: List record sources > tags: >- - import_sources >+ - record_sources > parameters: > - $ref: "../swagger.yaml#/parameters/match" > - $ref: "../swagger.yaml#/parameters/order_by" >@@ -12,7 +12,6 @@ > - $ref: "../swagger.yaml#/parameters/per_page" > - $ref: "../swagger.yaml#/parameters/q_param" > - $ref: "../swagger.yaml#/parameters/q_body" >- - $ref: "../swagger.yaml#/parameters/q_header" > - $ref: "../swagger.yaml#/parameters/request_id_header" > - name: x-koha-embed > in: header >@@ -30,7 +29,7 @@ > - application/json > responses: > "200": >- description: A list of import sources >+ description: A list of record sources > "400": > description: Missing or wrong parameters > schema: >@@ -56,27 +55,27 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- parameters: manage_import_sources >+ parameters: manage_record_sources > post: >- x-mojo-to: ImportSources#add >- operationId: addImportSources >- summary: Add an import source >+ x-mojo-to: RecordSources#add >+ operationId: addRecordSources >+ summary: Add a record source > tags: >- - import_sources >+ - record_sources > parameters: > - name: body > in: body >- description: A JSON object containing informations about the new import source >+ description: A JSON object containing informations about the new record source > required: true > schema: >- $ref: "../swagger.yaml#/definitions/import_source" >+ $ref: "../swagger.yaml#/definitions/record_source" > consumes: > - application/json > produces: > - application/json > responses: > "201": >- description: An import source >+ description: A record source > "400": > description: Missing or wrong parameters > schema: >@@ -102,23 +101,23 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- parameters: manage_import_sources >-"/import_sources/{import_source_id}": >+ parameters: manage_record_sources >+"/record_sources/{record_source_id}": > get: >- x-mojo-to: ImportSources#get >- operationId: getImportSources >- summary: Get an import source >+ x-mojo-to: RecordSources#get >+ operationId: getRecordSources >+ summary: Get a record source > tags: >- - import_sources >+ - record_sources > parameters: >- - $ref: "../swagger.yaml#/parameters/import_source_id_pp" >+ - $ref: "../swagger.yaml#/parameters/record_source_id_pp" > consumes: > - application/json > produces: > - application/json > responses: > "200": >- description: An import source >+ description: A record source > "400": > description: Missing or wrong parameters > schema: >@@ -148,28 +147,28 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- parameters: manage_import_sources >+ parameters: manage_record_sources > put: >- x-mojo-to: ImportSources#update >- operationId: updateImportSources >- summary: Update an import source >+ x-mojo-to: RecordSources#update >+ operationId: updateRecordSources >+ summary: Update a record source > tags: >- - import_sources >+ - record_sources > parameters: >- - $ref: "../swagger.yaml#/parameters/import_source_id_pp" >+ - $ref: "../swagger.yaml#/parameters/record_source_id_pp" > - name: body > in: body >- description: A JSON object containing informations about the new import source >+ description: A JSON object containing informations about the new record source > required: true > schema: >- $ref: "../swagger.yaml#/definitions/import_source" >+ $ref: "../swagger.yaml#/definitions/record_source" > consumes: > - application/json > produces: > - application/json > responses: > "200": >- description: An import source >+ description: A record source > "400": > description: Missing or wrong parameters > schema: >@@ -199,15 +198,15 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- parameters: manage_import_sources >+ parameters: manage_record_sources > delete: >- x-mojo-to: ImportSources#delete >- operationId: deleteImportSources >- summary: Delete an import source >+ x-mojo-to: RecordSources#delete >+ operationId: deleteRecordSources >+ summary: Delete a record source > tags: >- - import_sources >+ - record_sources > parameters: >- - $ref: "../swagger.yaml#/parameters/import_source_id_pp" >+ - $ref: "../swagger.yaml#/parameters/record_source_id_pp" > consumes: > - application/json > produces: >@@ -244,4 +243,4 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- parameters: manage_import_sources >+ parameters: manage_record_sources >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index cafc1d68fd..14037945b7 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -70,8 +70,8 @@ definitions: > $ref: ./definitions/import_batch_profiles.yaml > import_record_match: > $ref: ./definitions/import_record_match.yaml >- import_source: >- $ref: ./definitions/import_source.yaml >+ record_source: >+ $ref: ./definitions/record_source.yaml > invoice: > $ref: ./definitions/invoice.yaml > item: >@@ -277,10 +277,10 @@ paths: > $ref: ./paths/import_batch_profiles.yaml#/~1import_batch_profiles > "/import_batch_profiles/{import_batch_profile_id}": > $ref: "./paths/import_batch_profiles.yaml#/~1import_batch_profiles~1{import_batch_profile_id}" >- /import_sources: >- $ref: ./paths/import_sources.yaml#/~1import_sources >- "/import_sources/{import_source_id}": >- $ref: ./paths/import_sources.yaml#/~1import_sources~1{import_source_id} >+ /record_sources: >+ $ref: ./paths/record_sources.yaml#/~1record_sources >+ "/record_sources/{record_source_id}": >+ $ref: ./paths/record_sources.yaml#/~1record_sources~1{record_source_id} > /items: > $ref: ./paths/items.yaml#/~1items > "/items/{item_id}": >@@ -539,10 +539,10 @@ parameters: > name: import_record_id > required: true > type: integer >- import_source_id_pp: >- description: Internal import source identifier >+ record_source_id_pp: >+ description: Internal record source identifier > in: path >- name: import_source_id >+ name: record_source_id > required: true > type: integer > item_id_pp: >@@ -842,9 +842,9 @@ tags: > - description: "Manage item groups\n" > name: item_groups > x-displayName: Item groups >- - description: "Manage import sources\n" >- name: import_sources >- x-displayName: Import source >+ - description: "Manage record sources\n" >+ name: record_sources >+ x-displayName: Record source > - description: "Manage items\n" > name: items > x-displayName: Items >diff --git a/debian/templates/apache-shared-intranet.conf b/debian/templates/apache-shared-intranet.conf >index dbeaf0dca5..85a9549839 100644 >--- a/debian/templates/apache-shared-intranet.conf >+++ b/debian/templates/apache-shared-intranet.conf >@@ -13,6 +13,7 @@ ScriptAlias /search "/usr/share/koha/intranet/cgi-bin/catalogue/search.pl" > > # Protect dev package install > RewriteEngine on >+ > RewriteRule ^/cgi-bin/koha/(C4|debian|etc|installer/data|install_misc|Koha|misc|selenium|t|test|tmp|xt)/|\.PL$ /notfound [PT] > > RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/catalogue/detail.pl?biblionumber=$1 [PT] >@@ -21,6 +22,7 @@ RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT] > RewriteRule ^(.*)_[0-9]{2}\.[0-9]{7}\.(js|css)$ $1.$2 [L] > > RewriteRule ^/cgi-bin/koha/erm/.*$ /cgi-bin/koha/erm/erm.pl [PT] >+RewriteRule ^/cgi-bin/koha/admin/record-sources(.*)?$ /cgi-bin/koha/admin/record-sources.pl$1 [PT] > > Alias "/api" "/usr/share/koha/api" > <Directory "/usr/share/koha/api"> >diff --git a/installer/data/mysql/atomicupdate/bug_32607.pl b/installer/data/mysql/atomicupdate/bug_32607.pl >index 252361d122..9106eb41ab 100755 >--- a/installer/data/mysql/atomicupdate/bug_32607.pl >+++ b/installer/data/mysql/atomicupdate/bug_32607.pl >@@ -2,31 +2,38 @@ use Modern::Perl; > > return { > bug_number => "32607", >- description => "Add import_source table", >+ description => "Add record_sources table", > up => sub { > my ($args) = @_; > my ($dbh, $out) = @$args{qw(dbh out)}; > # Do you stuffs here >- if(!TableExists('import_source')) { >+ if(!TableExists('record_sources')) { > $dbh->do(q{ >- CREATE TABLE `import_source` ( >- `import_source_id` int(11) NOT NULL AUTO_INCREMENT, >- `name` text NOT NULL, >- `patron_id` int(11) NOT NULL, >- PRIMARY KEY (`import_source_id`), >- CONSTRAINT `import_source_fk_1` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE >- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci >+ -- >+ -- Table structure for table `record_sources` >+ -- >+ >+ DROP TABLE IF EXISTS `record_sources`; >+ /*!40101 SET @saved_cs_client = @@character_set_client */; >+ /*!40101 SET character_set_client = utf8 */; >+ CREATE TABLE `record_sources` ( >+ `record_source_id` int(11) NOT NULL AUTO_INCREMENT, >+ `name` text NOT NULL, >+ `patron_id` int(11) NOT NULL, >+ PRIMARY KEY (`record_source_id`), >+ CONSTRAINT `record_source_fk_1` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > }); > } > >- say $out "Added new import_source table"; >+ say $out "Added new record_sources table"; > > $dbh->do(q{ > INSERT IGNORE INTO permissions (module_bit, code, description) VALUES >- ( 3, 'manage_import_sources', 'Manage import sources') >+ ( 3, 'manage_record_sources', 'Manage record sources') > }); > >- say $out "Added new manage_import_sources permission"; >+ say $out "Added new manage_record_sources permission"; > > }, > }; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index d0aac05749..1f773da1ce 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3468,18 +3468,18 @@ CREATE TABLE `import_items` ( > /*!40101 SET character_set_client = @saved_cs_client */; > > -- >--- Table structure for table `import_source` >+-- Table structure for table `record_sources` > -- > >-DROP TABLE IF EXISTS `import_source`; >+DROP TABLE IF EXISTS `record_sources`; > /*!40101 SET @saved_cs_client = @@character_set_client */; > /*!40101 SET character_set_client = utf8 */; >-CREATE TABLE `import_source` ( >- `import_source_id` int(11) NOT NULL AUTO_INCREMENT, >+CREATE TABLE `record_sources` ( >+ `record_source_id` int(11) NOT NULL AUTO_INCREMENT, > `name` text NOT NULL, > `patron_id` int(11) NOT NULL, >- PRIMARY KEY (`import_source_id`), >- CONSTRAINT `import_source_fk_1` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE >+ PRIMARY KEY (`record_source_id`), >+ CONSTRAINT `record_source_fk_1` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE > ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > -- > -- Table structure for table `import_record_matches` >diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql >index 0fed4c6d50..068c4b1a3f 100644 >--- a/installer/data/mysql/mandatory/userpermissions.sql >+++ b/installer/data/mysql/mandatory/userpermissions.sql >@@ -42,7 +42,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > ( 3, 'manage_curbside_pickups', 'Manage curbside pickups'), > ( 3, 'manage_search_filters', 'Manage custom search filters'), > ( 3, 'manage_identity_providers', 'Manage identity providers'), >- ( 3, 'manage_import_sources', 'Manage import sources'), >+ ( 3, 'manage_record_sources', 'Manage record sources'), > ( 4, 'delete_borrowers', 'Delete patrons'), > ( 4, 'edit_borrowers', 'Add, modify and view patron information'), > ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >index 9bf4480968..1e4c64b3ca 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >@@ -206,8 +206,10 @@ > <dt><a href="/cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl">Search engine configuration (Elasticsearch)</a></dt> > <dd>Manage indexes, facets, and their mappings to MARC fields and subfields</dd> > [% END %] >- <dt><a href="/cgi-bin/koha/admin/import-sources.pl">Import sources</a></dt> >- <dd>Define sources to import from</dd> >+ [% IF ( CAN_user_parameters_manage_record_sources ) %] >+ <dt><a href="/cgi-bin/koha/admin/record-sources">Record sources</a></dt> >+ <dd>Define record sources to import from</dd> >+ [% END %] > </dl> > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/import-sources.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/record-sources.tt >similarity index 83% >rename from koha-tmpl/intranet-tmpl/prog/en/modules/admin/import-sources.tt >rename to koha-tmpl/intranet-tmpl/prog/en/modules/admin/record-sources.tt >index 63fd41f541..e472c69019 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/import-sources.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/record-sources.tt >@@ -8,7 +8,7 @@ > [% PROCESS 'i18n.inc' %] > [% INCLUDE 'doc-head-open.inc' %] > <title> >- Import sources › Koha >+ Record sources › Koha > </title> > [% INCLUDE 'doc-head-close.inc' %] > </head> >@@ -18,7 +18,7 @@ > [% INCLUDE 'erm-search.inc' %] > [% END %] > >-<div id="import-source"> <!-- this is closed in intranet-bottom.inc --> >+<div id="record-source"> <!-- this is closed in intranet-bottom.inc --> > > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'calendar.inc' %] >@@ -31,7 +31,7 @@ > const RESTOAuth2ClientCredentials = [% IF Koha.Preference('RESTOAuth2ClientCredentials') %]true[% ELSE %]false[% END %]; > </script> > >- [% Asset.js("js/vue/dist/import-source.js") | $raw %] >+ [% Asset.js("js/vue/dist/record-source.js") | $raw %] > > [% END %] > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Form.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Form.vue >deleted file mode 100644 >index fcdfa5a773..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Form.vue >+++ /dev/null >@@ -1,144 +0,0 @@ >-<template> >- <FormKit >- v-if="!loading" >- ref="form" >- @submit="doSubmit" >- type="form" >- :actions="false" >- :value="data" >- > >- <FormKitSchema :schema="formSchema" :data="schemaData"></FormKitSchema> >- </FormKit> >- <div v-else>Loading...</div> >-</template> >-<script> >-import { FormKitSchema } from "@formkit/vue" >-import { $__ } from "../i18n" >- >-export default { >- name: "Form", >- data() { >- return { >- schemaData: { >- doCancel: () => { >- this.$emit("cancel") >- }, >- }, >- formSchema: [ >- { >- $el: "fieldset", >- attrs: { >- class: "rows", >- }, >- children: this.schema, >- }, >- { >- $el: "fieldset", >- attrs: { >- class: "action", >- }, >- children: [ >- { >- $el: "input", >- attrs: { >- type: "submit", >- class: "btn btn-primary", >- }, >- ignore: false, >- children: this.submitMessage, >- }, >- { >- $el: "a", >- attrs: { >- class: "cancel", >- onClick: "$doCancel", >- }, >- children: this.cancelMessage, >- }, >- ], >- }, >- ], >- } >- }, >- methods: { >- async doSubmit(event) { >- this.$emit("submit", event) >- }, >- }, >- components: { >- FormKitSchema, >- }, >- emits: ["submit", "cancel"], >- props: { >- schema: Object, >- loading: { >- type: Boolean, >- default: false, >- }, >- data: { >- type: Object, >- default: {}, >- }, >- submitMessage: { >- type: String, >- default: $__("Submit"), >- }, >- cancelMessage: { >- type: String, >- default: $__("Cancel"), >- }, >- }, >-} >-</script> >- >-<style> >-.formkit-value { >- align-items: center; >- background-color: #f5f5f5; >- border-radius: 0.25em; >- box-sizing: border-box; >- color: black; >- display: flex; >- justify-content: space-between; >- padding: 0.55em 0.5em; >- text-decoration: none; >- width: 100%; >-} >- >-a.formkit-value:hover { >- text-decoration: none; >-} >- >-.formkit-value::after { >- content: "\00D7"; >- margin-left: 0.5em; >- font-size: 1.1em; >-} >- >-.formkit-dropdown { >- position: absolute; >- top: 100%; >- left: 0; >- min-width: 15em; >- background-color: white; >- box-shadow: 0 0 0.5em rgb(0 0 0 / 10%); >- margin: 0; >- padding: 0; >- list-style-type: none; >- overflow: hidden; >- border-radius: 0.25em; >-} >- >-.formkit-dropdown-item[data-selected="true"] { >- background-color: #cfe8fc; >-} >- >-.formkit-dropdown-item { >- padding: 0.5em; >- border-bottom: 1px solid #e4e4e4; >-} >- >-a.cancel { >- cursor: pointer; >-} >-</style> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Page.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Page.vue >index bb98c147e7..c0c607b1cc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Page.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Page.vue >@@ -16,7 +16,9 @@ > </div> > </template> > <template v-else> >- <div class="col-sm-12"> >+ <div >+ class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2" >+ > > <Dialog></Dialog> > <slot></slot> > </div> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/import-sources/ISEdit.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/import-sources/ISEdit.vue >deleted file mode 100644 >index 167d36d90e..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/import-sources/ISEdit.vue >+++ /dev/null >@@ -1,80 +0,0 @@ >-<template> >- <h1>{{ title }}</h1> >- <Form >- :schema="schema" >- :data="data" >- @submit="processSubmit" >- @cancel="doCancel" >- :loading="loading" >- ></Form> >-</template> >- >-<script> >-import Form from "../Form.vue" >-import { inject } from "vue" >-import { ImportSourcesClient } from "../../fetch/import-sources" >- >-export default { >- name: "ISEdit", >- setup() { >- const { getFormSchema } = inject("modelStore") >- const api = new ImportSourcesClient() >- const { setMessage } = inject("mainStore") >- const schema = getFormSchema() >- return { >- schema, >- setMessage, >- api, >- } >- }, >- data() { >- return { >- data: null, >- loading: true, >- } >- }, >- methods: { >- async processSubmit(data) { >- let response >- let responseMessage >- if (data.import_source_id) { >- const { import_source_id: id, ...row } = data >- response = await this.api.update({ id, row }) >- responseMessage = this.$__("Import source updated!") >- } else { >- response = await this.api.add({ row: data }) >- responseMessage = this.$__("Import source created!") >- } >- if (response) { >- this.setMessage(responseMessage) >- return this.$router.push({ path: "../import-sources.pl" }) >- } >- }, >- doCancel() { >- this.$router.push({ path: "../import-sources.pl" }) >- }, >- }, >- async created() { >- const { id } = this.$route.params >- if (id !== undefined) { >- const response = await this.api.getOne({ >- id, >- }) >- this.data = response >- } >- this.loading = false >- }, >- computed: { >- title() { >- if (!this.data) return this.$__("Add import source") >- return this.$__("Edit %s").format(this.data.name) >- }, >- }, >- beforeMount() { >- this.$root.setTitle(this.title) >- }, >- components: { >- Form, >- }, >-} >-</script> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/import-sources/ISList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/import-sources/ISList.vue >deleted file mode 100644 >index f649af949b..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/import-sources/ISList.vue >+++ /dev/null >@@ -1,100 +0,0 @@ >-<template> >- <div id="toolbar" class="btn-toolbar"> >- <div class="btn-group"> >- <button class="btn btn-default" @click="newImportSource"> >- <i class="fa fa-plus"></i> New import source >- </button> >- </div> >- </div> >- <h1>{{ title }}</h1> >- <KohaTable >- v-bind="tableOptions" >- @edit="doEdit" >- @delete="doRemove" >- ></KohaTable> >-</template> >- >-<script> >-import { useRouter } from "vue-router" >-import { inject } from "vue" >-import { ImportSourcesClient } from "../../fetch/import-sources" >-import KohaTable from "../KohaTable.vue" >-export default { >- name: "ISList", >- data() { >- return { >- title: this.$__("Import Sources"), >- tableOptions: { >- columns: this.columns, >- options: { >- embed: "patron", >- }, >- actions: { >- "-1": ["edit", "delete"], >- }, >- url: "/api/v1/import_sources", >- }, >- } >- }, >- setup() { >- const { getTableColumns } = inject("modelStore") >- const { setWarning, setMessage, setError, setConfirmationDialog } = >- inject("mainStore") >- const api = new ImportSourcesClient() >- const columns = getTableColumns() >- return { >- columns, >- setWarning, >- setMessage, >- setError, >- setConfirmationDialog, >- api, >- } >- }, >- beforeMount() { >- this.$root.setTitle(this.title) >- }, >- methods: { >- newImportSource() { >- this.$router.push({ path: "import-sources.pl/add" }) >- }, >- doEdit(data) { >- this.$router.push({ >- path: `import-sources.pl/${data.import_source_id}`, >- props: { >- data, >- }, >- }) >- }, >- async doRemove(data, dt) { >- this.setConfirmationDialog( >- { >- title: this.$__( >- "Are you sure you want to remove this import source?" >- ), >- message: data.name, >- accept_label: this.$__("Yes, remove"), >- cancel_label: this.$__("No, do not remove"), >- }, >- async () => { >- const response = await this.api.remove({ >- id: data.import_source_id, >- }) >- if (response) { >- this.setMessage( >- this.$__("Import source %s removed").format( >- data.name >- ), >- true >- ) >- dt.draw() >- } >- } >- ) >- }, >- }, >- components: { >- KohaTable, >- }, >-} >-</script> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/record-sources/Edit.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/record-sources/Edit.vue >new file mode 100644 >index 0000000000..0868555f37 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/record-sources/Edit.vue >@@ -0,0 +1,154 @@ >+<template> >+ <h1>{{ title }}</h1> >+ <form @submit="processSubmit"> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <label class="required" for="name"> >+ {{ $__("Name") }}: >+ </label> >+ <input >+ id="name" >+ v-model="row.name" >+ :placeholder="$__('Name')" >+ required >+ /> >+ <span class="required">{{ $__("Required") }}</span> >+ </li> >+ <li> >+ <label :for="`user_id`" class="required" >+ >{{ $__("User") }}:</label >+ > >+ <span class="user"> >+ {{ patron_str }} >+ </span> >+ (<a >+ href="#" >+ @click="selectUser()" >+ class="btn btn-default" >+ >{{ $__("Select user") }}</a >+ >) >+ <span class="required">{{ $__("Required") }}</span> >+ </li> >+ <input >+ type="hidden" >+ name="selected_patron_id" >+ id="selected_patron_id" >+ /> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <input type="submit" :value="$__('Submit')" /> >+ <a @click="doCancel($event)" class="router-link-active cancel">{{ >+ $__("Cancel") >+ }}</a> >+ </fieldset> >+ </form> >+</template> >+ >+<script> >+import { inject } from "vue" >+import { RecordSourcesClient } from "../../fetch/record-sources" >+import { APIClient } from "../../fetch/api-client.js" >+let { >+ patron: { patrons }, >+} = APIClient >+ >+export default { >+ name: "Edit", >+ setup() { >+ const { record_source } = new RecordSourcesClient() >+ const { setMessage } = inject("mainStore") >+ return { >+ setMessage, >+ api: record_source, >+ } >+ }, >+ data() { >+ return { >+ row: { >+ name: "", >+ }, >+ loading: true, >+ patron_str: "", >+ } >+ }, >+ methods: { >+ processSubmit(event) { >+ event.preventDefault() >+ let response >+ if (this.row.record_source_id) { >+ const { record_source_id: id, ...row } = this.row >+ response = this.api >+ .update({ id, row }) >+ .then(() => this.$__("Record source updated!")) >+ } else { >+ response = this.api >+ .create({ row: this.row }) >+ .then(() => this.$__("Record source created!")) >+ } >+ return response.then(responseMessage => { >+ this.setMessage(responseMessage) >+ return this.$router.push({ path: "../record-sources" }) >+ }) >+ }, >+ selectUser() { >+ let select_user_window = window.open( >+ "/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=select", >+ "PatronPopup", >+ "width=740,height=450,location=yes,toolbar=no," + >+ "scrollbars=yes,resize=yes" >+ ) >+ // This is a bit dirty, the "select user" window should be rewritten and be a Vue component >+ // but that's not for now... >+ select_user_window.addEventListener( >+ "beforeunload", >+ this.newUserSelected, >+ false >+ ) >+ }, >+ newUserSelected() { >+ this.row.patron_id = >+ document.getElementById("selected_patron_id").value >+ this.getUserData() >+ }, >+ getUserData() { >+ patrons.get(this.row.patron_id).then(patron => { >+ this.patron_str = $patron_to_html(patron) >+ }) >+ }, >+ doCancel(event) { >+ event.preventDefault() >+ this.$router.push({ path: "../record-sources" }) >+ }, >+ }, >+ created() { >+ const { id } = this.$route.params >+ if (id !== undefined) { >+ this.api >+ .get({ >+ id, >+ }) >+ .then(response => { >+ Object.keys(response).forEach(key => { >+ this.row[key] = response[key] >+ }) >+ this.getUserData() >+ this.loading = false >+ }) >+ } else { >+ this.loading = false >+ } >+ }, >+ computed: { >+ title() { >+ if (!this.row || !this.row.record_source_id) >+ return this.$__("Add record source") >+ return this.$__("Edit %s").format(this.row.name) >+ }, >+ }, >+ beforeMount() { >+ this.$root.setTitle(this.title) >+ }, >+} >+</script> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/record-sources/List.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/record-sources/List.vue >new file mode 100644 >index 0000000000..251c9b5899 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/record-sources/List.vue >@@ -0,0 +1,120 @@ >+<template> >+ <div id="toolbar" class="btn-toolbar"> >+ <div class="btn-group"> >+ <button class="btn btn-default" @click="newRecordSource"> >+ <i class="fa fa-plus"></i> New record source >+ </button> >+ </div> >+ </div> >+ <h1>{{ title }}</h1> >+ <div class="page-section"> >+ <KohaTable >+ v-bind="tableOptions" >+ @edit="doEdit" >+ @delete="doRemove" >+ ></KohaTable> >+ </div> >+</template> >+ >+<script> >+import { useRouter } from "vue-router" >+import { inject } from "vue" >+import { RecordSourcesClient } from "../../fetch/record-sources" >+import KohaTable from "../KohaTable.vue" >+export default { >+ name: "List", >+ data() { >+ return { >+ title: this.$__("Record Sources"), >+ tableOptions: { >+ columns: [ >+ { >+ title: this.$__("Source name"), >+ data: "name", >+ searchable: true, >+ }, >+ { >+ title: this.$__("Patron"), >+ searchable: true, >+ data: "patron.firstname:patron.surname:patron.middle_name", >+ render: (data, type, row) => { >+ const { firstname, surname, middle_name } = >+ row.patron >+ return [firstname, middle_name, surname] >+ .filter(part => (part || "").trim()) >+ .join(" ") >+ }, >+ }, >+ ], >+ options: { >+ embed: "patron", >+ }, >+ actions: { >+ "-1": ["edit", "delete"], >+ }, >+ url: "/api/v1/record_sources", >+ }, >+ } >+ }, >+ setup() { >+ const { setWarning, setMessage, setError, setConfirmationDialog } = >+ inject("mainStore") >+ const { record_source } = new RecordSourcesClient() >+ return { >+ setWarning, >+ setMessage, >+ setError, >+ setConfirmationDialog, >+ api: record_source, >+ } >+ }, >+ beforeMount() { >+ this.$root.setTitle(this.title) >+ }, >+ methods: { >+ newRecordSource() { >+ this.$router.push({ path: "record-sources/add" }) >+ }, >+ doEdit(data) { >+ this.$router.push({ >+ path: `record-sources/${data.record_source_id}`, >+ props: { >+ data, >+ }, >+ }) >+ }, >+ doRemove(data, dt) { >+ this.setConfirmationDialog( >+ { >+ title: this.$__( >+ "Are you sure you want to remove this record source?" >+ ), >+ message: data.name, >+ accept_label: this.$__("Yes, remove"), >+ cancel_label: this.$__("No, do not remove"), >+ }, >+ () => { >+ this.api >+ .delete({ >+ id: data.record_source_id, >+ }) >+ .then(response => { >+ if (response) { >+ this.setMessage( >+ this.$__("Record source %s removed").format( >+ data.name >+ ), >+ true >+ ) >+ dt.draw() >+ } >+ }) >+ } >+ ) >+ }, >+ }, >+ components: { >+ KohaTable, >+ }, >+} >+</script> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/import-sources/ISMain.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/record-sources/Main.vue >similarity index 88% >rename from koha-tmpl/intranet-tmpl/prog/js/vue/components/import-sources/ISMain.vue >rename to koha-tmpl/intranet-tmpl/prog/js/vue/components/record-sources/Main.vue >index 51800b8772..bf691c1a62 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/import-sources/ISMain.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/record-sources/Main.vue >@@ -6,9 +6,8 @@ > > <script> > import Page from "../Page.vue" >-// import { inject } from "vue" > export default { >- name: "ISMain", >+ name: "Main", > data() { > return { > title: "", >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/import-sources.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/import-sources.js >deleted file mode 100644 >index b5f0df93aa..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/import-sources.js >+++ /dev/null >@@ -1,40 +0,0 @@ >-import HttpClient from "./http-client"; >- >-export class ImportSourcesClient extends HttpClient { >- constructor() { >- super({ >- baseURL: '/api/v1/import_sources', >- }); >- } >- async add({row, headers={}}) { >- const requestHeaders = {...headers, 'Content-Type': 'application/json'} >- return this.post({ >- endpoint: '', >- headers: requestHeaders, >- body: JSON.stringify(row) >- }) >- } >- >- async remove({id, headers={}}) { >- return this.delete({ >- endpoint: '/'+id, >- headers, >- }) >- } >- >- async update({id, headers={}, row}) { >- const requestHeaders = {...headers, 'Content-Type': 'application/json'} >- return this.put({ >- endpoint: '/'+id, >- headers: requestHeaders, >- body: JSON.stringify(row) >- }) >- } >- >- async getOne({id, headers={}}) { >- return this.get({ >- endpoint: '/'+id, >- headers, >- }) >- } >-} >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/patron-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/patron-api-client.js >index 4f30a8e2e8..4c39e977fd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/patron-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/patron-api-client.js >@@ -13,10 +13,6 @@ export class PatronAPIClient extends HttpClient { > this.get({ > endpoint: "patrons/" + id, > }), >- list: (query) => >- this.get({ >- endpoint: "patrons" + (query ? '?'+query:''), >- }) > }; > } > } >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/record-sources.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/record-sources.js >new file mode 100644 >index 0000000000..c5dd38c985 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/record-sources.js >@@ -0,0 +1,48 @@ >+import HttpClient from "./http-client"; >+ >+export class RecordSourcesClient extends HttpClient { >+ constructor() { >+ super({ >+ baseURL: "/api/v1/record_sources", >+ }); >+ } >+ >+ get record_source() { >+ return { >+ create: ({ row, headers = {} }) => { >+ const requestHeaders = { >+ ...headers, >+ "Content-Type": "application/json", >+ }; >+ return this.post({ >+ endpoint: "", >+ headers: requestHeaders, >+ body: JSON.stringify(row), >+ }); >+ }, >+ delete: ({ id, headers = {} }) => { >+ return this.delete({ >+ endpoint: "/" + id, >+ headers, >+ }); >+ }, >+ update: ({ id, headers = {}, row }) => { >+ const requestHeaders = { >+ ...headers, >+ "Content-Type": "application/json", >+ }; >+ return this.put({ >+ endpoint: "/" + id, >+ headers: requestHeaders, >+ body: JSON.stringify(row), >+ }); >+ }, >+ get: ({ id, headers = {} }) => { >+ return this.get({ >+ endpoint: "/" + id, >+ headers, >+ }); >+ }, >+ }; >+ } >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/i18n/index.js b/koha-tmpl/intranet-tmpl/prog/js/vue/i18n/index.js >index 359bc69377..27c8e75f8c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/i18n/index.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/i18n/index.js >@@ -6,4 +6,4 @@ export default { > install: (app, options) => { > app.config.globalProperties.$__ = $__; > }, >-}; >\ No newline at end of file >+}; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/import-source/router.js b/koha-tmpl/intranet-tmpl/prog/js/vue/import-source/router.js >deleted file mode 100644 >index 8fd05b5ce5..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/import-source/router.js >+++ /dev/null >@@ -1,12 +0,0 @@ >-import { createWebHistory, createRouter } from "vue-router"; >- >-export default (menuStore) => { >- >- const { routes } = menuStore >- const router = createRouter({ >- history: createWebHistory(), >- linkExactActiveClass: "current", >- routes, >- }) >- return router >-} >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/inputs/autocomplete.js b/koha-tmpl/intranet-tmpl/prog/js/vue/inputs/autocomplete.js >deleted file mode 100644 >index 5333b6e73b..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/inputs/autocomplete.js >+++ /dev/null >@@ -1,199 +0,0 @@ >-import { createInput } from '@formkit/vue' >- >-/** >- * This is an input "feature" â a function that accepts a node and exposes >- * some additional functionality to an input. When using schemas, this can >- * take the place of a traditional "script" block in a Vue component. In this >- * example, we expose: >- * >- * - An input handler `search`. >- * - An input handler `selections`. >- * - Commit middleware to place filtered options into the `matches` prop. >- * >- * Once written, input features are added via the input declaration. >- */ >-const searchFeature = (node) => { >- >- const _transform_options = (options) => { >- if(!Array.isArray(options)) { >- return Object.keys(options).map((key) => ({label: options[key], value: key})) >- } >- return options.map((option) => { >- if(typeof option === 'string') return {label: option, value: option} >- return option >- }) >- } >- >- // We wait for our node to be fully "created" before we start to add our >- // handlers to ensure the core Vue plugin has added its context object: >- node.on('created', async () => { >- // Ensure our matches prop starts as an array. >- node.props.matches = [] >- node.props.selection = '' >- >- if(node.value !== undefined && node.props.attrs && typeof node.props.attrs.optionLoader === 'function') { >- node.props.selection = await node.props.attrs.optionLoader(node.value) >- } >- >- const clearValue = async (e) => { >- if (e && typeof e.preventDefault === 'function') e.preventDefault() >- node.input('') >- node.props.matches = [] >- node.props.selection = '' >- node.props.searchValue = '' >- setTimeout(() => { >- if (document.querySelector('input#' + node.props.id)) { >- document.querySelector('input#' + node.props.id).focus() >- } >- }, 50) >- } >- // When we actually have an value to set: >- const setValue = async (e) => { >- if (e && typeof e.preventDefault === 'function') e.preventDefault() >- node.input(node.props.selection.value) >- node.props.display = node.props.selection.label >- node.props.searchValue = '' >- await new Promise((r) => setTimeout(r, 50)) // "next tick" >- } >- >- // Perform a soft selection, this is shown as a highlight in the dropdown >- const select = (delta) => { >- const available = node.props.matches >- let idx = available.indexOf(node.props.selection) + delta >- if (idx >= available.length) { >- idx = 0 >- } else if (idx < 0) { >- idx = available.length - 1 >- } >- node.props.selection = available[idx] >- } >- >- // Add some new "handlers" for our autocomplete. The handlers object is >- // just a conventionally good place to put event handlers. Auto complete >- // inputs always have to deal with lots of keyboard events, so that logic >- // is registered here. >- Object.assign(node.context.handlers, { >- setValue, >- clearValue, >- selection: (e) => { >- // This handler is called when entering data into the search input. >- switch (e.key) { >- case 'Enter': >- return setValue() >- case 'ArrowDown': >- e.preventDefault() >- return select(1) >- case 'ArrowUp': >- e.preventDefault() >- return select(-1) >- case 'Escape': >- return node.props.matches = [] >- } >- }, >- blur: (e) => { >- if(!node.props.hovering) node.props.matches = [] >- }, >- search(e) { >- node.props.searchValue = e.target.value >- }, >- hover: (e) => { >- node.props.hovering = true >- node.props.selection = node.props.matches.find(match => String(match.value) === e.target.attributes.value.value) >- console.log(node.props.selection) >- }, >- unhover: (e) => { >- if (node.props.matches.find(match => String(match.value) === e.target.attributes.value.value) === node.props.selection) { >- node.props.selection = '' >- node.props.hovering = false >- } >- }, >- }) >- }) >- >- // Perform filtering when the search value changes >- node.on('prop:searchValue', async ({ payload: value }) => { >- let results >- if(typeof node.props.options === 'function') { >- results = _transform_options(await node.props.options(value)) >- } else { >- results = _transform_options(node.props.options).filter((option) => >- option.label.toLowerCase().split(/\W/).find((part).startsWith(value.toLowerCase())) >- ) >- } >- //if (!results.length) results.push('No matches') >- node.props.matches = results >- }) >-} >- >-/** >- * This is our input schema responsible for rendering the inner âinputâ >- * section. In our example, we render an text input which will be used >- * to filter search results, and an unordered list that shows all remaining >- * matches. >- */ >-const schema = { >- if: '$value', >- then: [ >- { >- $el: 'a', >- attrs: { >- id: '$id', >- href: '#', >- class: '$classes.value', >- onClick: '$handlers.clearValue', >- }, >- children: '$selection.label' >- } >- ], >- else: [ >- { >- $el: 'input', >- bind: '$attrs', >- attrs: { >- id: '$id', >- class: '$classes.input', >- onKeydown: '$handlers.selection', >- onInput: '$handlers.search', >- onBlur: '$handlers.blur', >- value: '$searchValue', >- }, >- }, >- { >- $el: 'ul', >- if: '$matches.length', >- attrs: { >- class: '$classes.dropdown', >- }, >- children: [ >- { >- $el: 'li', >- for: ['match', '$matches'], >- attrs: { >- 'data-selected': { >- if: '$selection === $match', >- then: 'true', >- else: 'false', >- }, >- value: '$match.value', >- class: '$classes.dropdownItem', >- onClick: '$handlers.setValue', >- onMouseenter: '$handlers.hover', >- onMouseleave: '$handlers.unhover', >- }, >- children: '$match.label', >- }, >- ], >- }, >- ], >-} >- >-/** >- * Finally we create our actual input declaration by using `createInput` this >- * places our schema into a "standard" FormKit schema feature set with slots, >- * labels, help, messages etc. The return value of this function is a proper >- * input declaration. >- */ >-export default createInput(schema, { >- props: ['options', 'matches', 'selection', 'searchValue', 'value'], >- features: [searchFeature], >-}) >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/inputs/index.js b/koha-tmpl/intranet-tmpl/prog/js/vue/inputs/index.js >deleted file mode 100644 >index fb70888a28..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/inputs/index.js >+++ /dev/null >@@ -1,5 +0,0 @@ >-import autocomplete from './autocomplete' >- >-export default { >- autocomplete >-} >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/models/import-sources.js b/koha-tmpl/intranet-tmpl/prog/js/vue/models/import-sources.js >deleted file mode 100644 >index 53d05c409b..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/models/import-sources.js >+++ /dev/null >@@ -1,85 +0,0 @@ >- >-import PatronAPIClient from "../fetch/patron-api-client"; >-import { $__ } from "../i18n"; >- >-const api = new PatronAPIClient() >- >-export default [ >- { >- name: 'import_source_id', >- table: { >- data: 'import_source_id', >- visible: false >- }, >- form: { >- type: 'hidden' >- } >- }, >- { >- name: 'name', >- title: $__('Source name'), >- table: { >- data: 'name', >- searchable: true >- }, >- form: { >- type: 'text', >- label: { >- $ref: 'title' >- }, >- validation: 'required' >- } >- }, >- { >- name: 'patron_id', >- title: $__('Patron'), >- table: { >- searchable: true, >- data: "patron.firstname:patron.surname:patron.middle_name", >- render: (data, type, row) => { >- const {firstname, surname, middle_name} = row.patron >- return [firstname, middle_name, surname].filter(part => (part||'').trim()).join(' '); >- } >- }, >- form: { >- type: 'autocomplete', >- label: 'Choose a patron', >- validation: 'required', >- optionLoader: async (id) => { >- const {firstname, surname, middle_name, patron_id} = ( await api.patrons.get(id) || {} ); >- return {value: patron_id, label: [firstname, middle_name, surname].filter(part => (part||'').trim()).join(' ')} >- }, >- options: async (value) => { >- let query = ''; >- if(value !== undefined) { >- query = new URLSearchParams({ >- q: JSON.stringify([ >- { >- firstname: { >- like: '%'+value+'%' >- } >- }, >- { >- middle_name: { >- like: '%'+value+'%' >- } >- }, >- { >- surname: { >- like: '%'+value+'%' >- } >- } >- ]) >- }) >- } >- >- const response = await api.patrons.list(query) >- if(!response) return [] >- return response.map(row => { >- const {firstname, surname, middle_name, patron_id} = row >- return {value: patron_id, label: [firstname, middle_name, surname].filter(part => (part||'').trim()).join(' ')} >- }) >- } >- } >- } >-] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/import-sources.ts b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/record-sources.ts >similarity index 65% >rename from koha-tmpl/intranet-tmpl/prog/js/vue/modules/import-sources.ts >rename to koha-tmpl/intranet-tmpl/prog/js/vue/modules/record-sources.ts >index 2ed204e77f..af8cb7df35 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/import-sources.ts >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/record-sources.ts >@@ -1,8 +1,6 @@ > import { createApp } from "vue"; > import { createPinia } from "pinia"; >-import { plugin as formkit, defaultConfig } from '@formkit/vue' > import { createWebHistory, createRouter } from "vue-router"; >-import '@formkit/themes/genesis' > > import { library } from "@fortawesome/fontawesome-svg-core"; > import { >@@ -14,31 +12,26 @@ import { > } from "@fortawesome/free-solid-svg-icons"; > import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; > import vSelect from "vue-select"; >-import { useNavigationStore } from '../stores/navigation'; >-import { useMainStore } from '../stores/main'; >-import { useModelStore } from '../stores/model'; >-import routesDef from '../routes/import-sources'; >-import model from '../models/import-sources'; >+import { useNavigationStore } from "../stores/navigation"; >+import { useMainStore } from "../stores/main"; >+import routesDef from "../routes/record-sources"; > > library.add(faPlus, faMinus, faPencil, faTrash, faSpinner); > > const pinia = createPinia(); > const navigationStore = useNavigationStore(pinia); > const mainStore = useMainStore(pinia); >-const modelStore = useModelStore(pinia); > const { removeMessages } = mainStore; > const { setRoutes } = navigationStore; >-const { setModel } = modelStore; > const routes = setRoutes(routesDef); >-setModel(model); > > const router = createRouter({ > history: createWebHistory(), > linkExactActiveClass: "current", > routes, >-}) >+}); > >-import App from "../components/import-sources/ISMain.vue"; >+import App from "../components/record-sources/Main.vue"; > > // import { routes } from "./routes"; > >@@ -50,27 +43,22 @@ import App from "../components/import-sources/ISMain.vue"; > > // import { useAVStore } from "../stores/authorised_values"; > >-import i18n from "../i18n" >-import inputs from "../inputs" >+import i18n from "../i18n"; > const app = createApp(App); > > const rootComponent = app > .use(i18n) > .use(pinia) > .use(router) >- .use(formkit, defaultConfig({ >- inputs >- })) > .component("font-awesome-icon", FontAwesomeIcon) > .component("v-select", vSelect); > > app.config.unwrapInjectedRef = true; > app.provide("mainStore", mainStore); > app.provide("navigationStore", navigationStore); >-app.provide("modelStore", modelStore); >-app.mount("#import-source"); >+app.mount("#record-source"); > >-router.beforeEach((to, from) => { >- navigationStore.$patch({current: to.meta.self}); >+router.beforeEach(to => { >+ navigationStore.$patch({ current: to.matched, params: to.params || {} }); > removeMessages(); // This will actually flag the messages as displayed already > }); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/import-sources.js b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/import-sources.js >deleted file mode 100644 >index 471dc59472..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/import-sources.js >+++ /dev/null >@@ -1,31 +0,0 @@ >-import ISEdit from '../components/import-sources/ISEdit.vue' >-import ISList from '../components/import-sources/ISList.vue' >- >-export default { >- title: 'Administration', >- href: '/cgi-bin/koha/admin/admin-home.pl', >- children: [ >- { >- title: 'Import sources', >- path: '/cgi-bin/koha/admin/import-sources.pl', >- component: {template: '<router-view></router-view>', name: 'ISBase'}, >- children: [ >- { >- title: 'List', >- path: '', >- component: ISList >- }, >- { >- title: 'Add import source', >- path: 'add', >- component: ISEdit >- }, >- { >- title: 'Edit import source', >- path: ':id', >- component: ISEdit >- } >- ] >- } >- ] >-} >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/record-sources.js b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/record-sources.js >new file mode 100644 >index 0000000000..7c75e396fe >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/record-sources.js >@@ -0,0 +1,34 @@ >+import Edit from "../components/record-sources/Edit.vue"; >+import List from "../components/record-sources/List.vue"; >+ >+export default { >+ title: "Administration", >+ href: "/cgi-bin/koha/admin/admin-home.pl", >+ children: [ >+ { >+ title: "Record sources", >+ path: "/cgi-bin/koha/admin/record-sources", >+ component: { >+ template: "<router-view></router-view>", >+ name: "Base", >+ }, >+ children: [ >+ { >+ title: "List", >+ path: "", >+ component: List, >+ }, >+ { >+ title: "Add record source", >+ path: "add", >+ component: Edit, >+ }, >+ { >+ title: "Edit record source", >+ path: ":id", >+ component: Edit, >+ }, >+ ], >+ }, >+ ], >+}; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/model.js b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/model.js >deleted file mode 100644 >index f0ccd58acd..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/model.js >+++ /dev/null >@@ -1,51 +0,0 @@ >-import { defineStore } from "pinia"; >- >-export const useModelStore = defineStore("model", { >- state: () => ({ >- model: [] >- }), >- actions: { >- setModel(model) { >- this.model = model >- }, >- getFormSchema() { >- return this.model.map(row => { >- const {table, form = {}, ...common} = row >- Object.keys(form).forEach(key => { >- if (key === 'type') { >- form.$formkit = form[key] >- key = '$formkit' >- delete form.type; >- } >- if(form[key].$ref) { >- const path = form[key].$ref.split('.') >- form[key] = path.reduce((obj, key, idx) => { >- if(obj === undefined || obj[key] === undefined) return undefined >- const value = obj[key] >- if(idx === path.lenght - 1) delete obj[key] >- return value >- }, common) >- } >- }) >- return {...common, ...form} >- }) >- }, >- getTableColumns() { >- return this.model.map(row => { >- const {table = {}, form, ...common} = row >- Object.keys(table).forEach(key => { >- if(table[key].$ref) { >- const path = table[key].$ref.split('.') >- table[key] = path.reduce((obj, key, idx) => { >- if(obj === undefined || obj[key] === undefined) return undefined >- const value = obj[key] >- if(idx === path.lenght - 1) delete obj[key] >- return value >- }, common) >- } >- }) >- return {...common, ...table} >- }) >- } >- }, >-}); >diff --git a/t/db_dependent/Koha/ImportSources.t b/t/db_dependent/Koha/RecordSources.t >similarity index 85% >rename from t/db_dependent/Koha/ImportSources.t >rename to t/db_dependent/Koha/RecordSources.t >index 6788dab4ee..e956745a4b 100755 >--- a/t/db_dependent/Koha/ImportSources.t >+++ b/t/db_dependent/Koha/RecordSources.t >@@ -21,7 +21,7 @@ use Modern::Perl; > > use Test::More tests => 1; > >-use Koha::ImportSources; >+use Koha::RecordSources; > > use t::lib::TestBuilder; > my $schema = Koha::Database->new->schema; >@@ -34,11 +34,11 @@ subtest 'patron' => sub { > > my $patron = $builder->build_object({class => 'Koha::Patrons', value => {firstname => 'Afirstname'}}); > >- my $import_source = $builder->build_object({class => 'Koha::ImportSources', value => {name => 'import_source', patron_id => $patron->borrowernumber}}); >+ my $record_source = $builder->build_object({class => 'Koha::RecordSources', value => {name => 'record_source', patron_id => $patron->borrowernumber}}); > >- my $fetched_patron = $import_source->patron; >+ my $fetched_patron = $record_source->patron; > > is($fetched_patron->firstname, 'Afirstname', 'Patron matches'); > > $schema->storage->txn_rollback; >-}; >\ No newline at end of file >+}; >diff --git a/t/db_dependent/api/v1/import_sources.t b/t/db_dependent/api/v1/record_sources.t >similarity index 78% >rename from t/db_dependent/api/v1/import_sources.t >rename to t/db_dependent/api/v1/record_sources.t >index 2175a20754..7712548045 100755 >--- a/t/db_dependent/api/v1/import_sources.t >+++ b/t/db_dependent/api/v1/record_sources.t >@@ -27,7 +27,7 @@ use t::lib::TestBuilder; > use t::lib::Mocks; > > use C4::Auth; >-use Koha::ImportSources; >+use Koha::RecordSources; > use Koha::Database; > > my $schema = Koha::Database->new->schema; >@@ -45,7 +45,7 @@ subtest 'list() tests' => sub { > > my $source = $builder->build_object( > { >- class => 'Koha::ImportSources' >+ class => 'Koha::RecordSources' > } > ); > my $patron = $builder->build_object( >@@ -58,7 +58,7 @@ subtest 'list() tests' => sub { > for ( 1..10 ) { > $builder->build_object( > { >- class => 'Koha::ImportSources' >+ class => 'Koha::RecordSources' > } > ); > } >@@ -76,7 +76,7 @@ subtest 'list() tests' => sub { > { password => $password, skip_validation => 1 } ); > my $userid = $nonprivilegedpatron->userid; > >- $t->get_ok( "//$userid:$password@/api/v1/import_sources" ) >+ $t->get_ok( "//$userid:$password@/api/v1/record_sources" ) > ->status_is(403) > ->json_is( > '/error' => 'Authorization failure. Missing required permission(s).' ); >@@ -84,21 +84,21 @@ subtest 'list() tests' => sub { > $patron->set_password( { password => $password, skip_validation => 1 } ); > $userid = $patron->userid; > >- $t->get_ok( "//$userid:$password@/api/v1/import_sources?_per_page=10" ) >+ $t->get_ok( "//$userid:$password@/api/v1/record_sources?_per_page=10" ) > ->status_is( 200, 'SWAGGER3.2.2' ); > > my $response_count = scalar @{ $t->tx->res->json }; > > is( $response_count, 10, 'The API returns 10 sources' ); > >- my $id = $source->import_source_id; >- $t->get_ok( "//$userid:$password@/api/v1/import_sources?q={\"import_source_id\": $id}" ) >+ my $id = $source->record_source_id; >+ $t->get_ok( "//$userid:$password@/api/v1/record_sources?q={\"record_source_id\": $id}" ) > ->status_is(200) > ->json_is( '' => [ $source->to_api ], 'SWAGGER3.3.2'); > > $source->delete; > >- $t->get_ok( "//$userid:$password@/api/v1/import_sources?q={\"import_source_id\": $id}" ) >+ $t->get_ok( "//$userid:$password@/api/v1/record_sources?q={\"record_source_id\": $id}" ) > ->status_is(200) > ->json_is( '' => [] ); > >@@ -114,7 +114,7 @@ subtest 'get() tests' => sub { > > my $source = $builder->build_object( > { >- class => 'Koha::ImportSources' >+ class => 'Koha::RecordSources' > } > ); > my $patron = $builder->build_object( >@@ -137,9 +137,9 @@ subtest 'get() tests' => sub { > { password => $password, skip_validation => 1 } ); > my $userid = $nonprivilegedpatron->userid; > >- my $id = $source->import_source_id; >+ my $id = $source->record_source_id; > >- $t->get_ok( "//$userid:$password@/api/v1/import_sources/$id" ) >+ $t->get_ok( "//$userid:$password@/api/v1/record_sources/$id" ) > ->status_is(403) > ->json_is( > '/error' => 'Authorization failure. Missing required permission(s).' ); >@@ -147,15 +147,15 @@ subtest 'get() tests' => sub { > $patron->set_password( { password => $password, skip_validation => 1 } ); > $userid = $patron->userid; > >- $t->get_ok( "//$userid:$password@/api/v1/import_sources/$id" ) >+ $t->get_ok( "//$userid:$password@/api/v1/record_sources/$id" ) > ->status_is( 200, 'SWAGGER3.2.2' ) > ->json_is( '' => $source->to_api, 'SWAGGER3.3.2' ); > > $source->delete; > >- $t->get_ok( "//$userid:$password@/api/v1/import_sources/$id" ) >+ $t->get_ok( "//$userid:$password@/api/v1/record_sources/$id" ) > ->status_is(404) >- ->json_is( '/error' => 'Import source not found' ); >+ ->json_is( '/error' => 'Record source not found' ); > > $schema->storage->txn_rollback; > >@@ -169,7 +169,7 @@ subtest 'delete() tests' => sub { > > my $source = $builder->build_object( > { >- class => 'Koha::ImportSources' >+ class => 'Koha::RecordSources' > } > ); > my $patron = $builder->build_object( >@@ -192,9 +192,9 @@ subtest 'delete() tests' => sub { > { password => $password, skip_validation => 1 } ); > my $userid = $nonprivilegedpatron->userid; > >- my $id = $source->import_source_id; >+ my $id = $source->record_source_id; > >- $t->delete_ok( "//$userid:$password@/api/v1/import_sources/$id" ) >+ $t->delete_ok( "//$userid:$password@/api/v1/record_sources/$id" ) > ->status_is(403) > ->json_is( > '/error' => 'Authorization failure. Missing required permission(s).' ); >@@ -202,12 +202,12 @@ subtest 'delete() tests' => sub { > $patron->set_password( { password => $password, skip_validation => 1 } ); > $userid = $patron->userid; > >- $t->delete_ok( "//$userid:$password@/api/v1/import_sources/$id" ) >+ $t->delete_ok( "//$userid:$password@/api/v1/record_sources/$id" ) > ->status_is( 204, 'SWAGGER3.2.2' ); > >- my $deleted_source = Koha::ImportSources->search({import_source_id => $id}); >+ my $deleted_source = Koha::RecordSources->search({record_source_id => $id}); > >- is($deleted_source->count, 0, 'No import source found'); >+ is($deleted_source->count, 0, 'No record source found'); > > $schema->storage->txn_rollback; > >@@ -219,7 +219,7 @@ subtest 'add() tests' => sub { > > $schema->storage->txn_begin; > >- Koha::ImportSources->delete; >+ Koha::RecordSources->delete; > > my $patron = $builder->build_object( > { >@@ -242,7 +242,7 @@ subtest 'add() tests' => sub { > my $userid = $nonprivilegedpatron->userid; > my $patron_id = $nonprivilegedpatron->borrowernumber; > >- $t->post_ok( "//$userid:$password@/api/v1/import_sources" => json => { name => 'test1', patron_id => $patron_id }) >+ $t->post_ok( "//$userid:$password@/api/v1/record_sources" => json => { name => 'test1', patron_id => $patron_id }) > ->status_is(403) > ->json_is( > '/error' => 'Authorization failure. Missing required permission(s).' ); >@@ -250,14 +250,14 @@ subtest 'add() tests' => sub { > $patron->set_password( { password => $password, skip_validation => 1 } ); > $userid = $patron->userid; > >- $t->post_ok( "//$userid:$password@/api/v1/import_sources" => json => { name => 'test1', patron_id => $patron_id }) >+ $t->post_ok( "//$userid:$password@/api/v1/record_sources" => json => { name => 'test1', patron_id => $patron_id }) > ->status_is( 201, 'SWAGGER3.2.2' ) > ->json_is('/name', 'test1') > ->json_is('/patron_id', $patron_id); > >- my $created_source = Koha::ImportSources->search->next; >+ my $created_source = Koha::RecordSources->search->next; > >- is($created_source->name, 'test1', 'Import source found'); >+ is($created_source->name, 'test1', 'Record source found'); > > $schema->storage->txn_rollback; > >@@ -271,7 +271,7 @@ subtest 'update() tests' => sub { > > my $source = $builder->build_object( > { >- class => 'Koha::ImportSources', >+ class => 'Koha::RecordSources', > value => { name => 'Oldname' } > } > ); >@@ -295,9 +295,9 @@ subtest 'update() tests' => sub { > { password => $password, skip_validation => 1 } ); > my $userid = $nonprivilegedpatron->userid; > >- my $id = $source->import_source_id; >+ my $id = $source->record_source_id; > >- $t->put_ok( "//$userid:$password@/api/v1/import_sources/$id" => json => { name => 'Newname', patron_id => $source->patron_id } ) >+ $t->put_ok( "//$userid:$password@/api/v1/record_sources/$id" => json => { name => 'Newname', patron_id => $source->patron_id } ) > ->status_is(403) > ->json_is( > '/error' => 'Authorization failure. Missing required permission(s).' ); >@@ -305,14 +305,14 @@ subtest 'update() tests' => sub { > $patron->set_password( { password => $password, skip_validation => 1 } ); > $userid = $patron->userid; > >- $t->put_ok( "//$userid:$password@/api/v1/import_sources/$id" => json => { name => 'Newname', patron_id => $source->patron_id } ) >+ $t->put_ok( "//$userid:$password@/api/v1/record_sources/$id" => json => { name => 'Newname', patron_id => $source->patron_id } ) > ->status_is( 200, 'SWAGGER3.2.2' ) > ->json_is('/name', 'Newname'); > >- my $updated_source = Koha::ImportSources->find($id); >+ my $updated_source = Koha::RecordSources->find($id); > >- is($updated_source->name, 'Newname', 'Import source updated'); >+ is($updated_source->name, 'Newname', 'Record source updated'); > > $schema->storage->txn_rollback; > >-}; >\ No newline at end of file >+}; >diff --git a/webpack.config.js b/webpack.config.js >index 5a6cff9fd7..5275a818af 100644 >--- a/webpack.config.js >+++ b/webpack.config.js >@@ -6,7 +6,7 @@ const webpack = require('webpack'); > module.exports = { > entry: { > erm: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts", >- "import-source": "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/import-sources.ts" >+ "record-source": "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/record-sources.ts" > }, > output: { > filename: "[name].js", >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32607
:
146410
|
146411
|
146412
|
149777
|
149827
|
149828
|
149829
|
154006
|
154007
|
154008
|
154009
|
154010
|
154438
|
155682
|
155683
|
155684
|
155685
|
155686
|
155958
|
157756
|
157757
|
157758
|
157759
|
157760
|
157761
|
157762
|
161362
|
161363
|
161364
|
161365
|
161366
|
161367
|
161435
|
161436
|
161437
|
161438
|
161439
|
161440
|
161441
|
161474