Bugzilla – Attachment 149484 Details for
Bug 33103
Add vendor aliases
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33103: Add the ability to create vendor aliases
Bug-33103-Add-the-ability-to-create-vendor-aliases.patch (text/plain), 8.34 KB, created by
Katrin Fischer
on 2023-04-11 21:01:09 UTC
(
hide
)
Description:
Bug 33103: Add the ability to create vendor aliases
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2023-04-11 21:01:09 UTC
Size:
8.34 KB
patch
obsolete
>From 1c2447fdb2fde444da18098908875e8c785b498c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 1 Mar 2023 11:57:23 +0100 >Subject: [PATCH] Bug 33103: Add the ability to create vendor aliases > >This patchset is adding the ability to create aliases for vendors. It >will then be easier to search for vendors. > >* new DB table aqbookseller_aliases(id, vendor_id, alias) >* new pair of Koha classes Koha::Acquisition::Bookseller::Alias[es] >* new method to retrieve the aliases from the vendor >Koha::Acquisition::Bookseller->aliases >* The api spec changes to allow aliases to be embeded on >GET /acquisitions/vendors >* Add/Delete alias when editing a vendor >* Display the aliases on the vendor show view >* Search vendors by aliases >* Display the aliases in the dropdown list of the vendors in the ERM >module > >Test plan: >- Create a vendor, add it some aliases >- Edit the vendor, remove some aliases >=> Behaviour must be consistent >- Search the vendor in the acquisition module by its aliases >=> The vendor must be returned in the result >- Go to the ERM module, add a new agreement or license >=> Notice that the dropdown list of the vendors is displaying the >aliases, that make vendors searchable by their aliases > >Signed-off-by: Jonathan Field <jonathan.field@ptfs-europe.com> >--- > Koha/Acquisition/Bookseller.pm | 29 ++++++++++++ > acqui/supplier.pl | 2 + > acqui/updatesupplier.pl | 8 +++- > .../prog/en/modules/acqui/supplier.tt | 46 +++++++++++++++++++ > 4 files changed, 83 insertions(+), 2 deletions(-) > >diff --git a/Koha/Acquisition/Bookseller.pm b/Koha/Acquisition/Bookseller.pm >index 7cf76d6705..0ba30a3243 100644 >--- a/Koha/Acquisition/Bookseller.pm >+++ b/Koha/Acquisition/Bookseller.pm >@@ -17,6 +17,7 @@ package Koha::Acquisition::Bookseller; > > use Modern::Perl; > >+use Koha::Acquisition::Bookseller::Aliases; > use Koha::Acquisition::Bookseller::Contacts; > use Koha::Subscriptions; > >@@ -76,6 +77,34 @@ sub subscriptions { > return Koha::Subscriptions->search( { aqbooksellerid => $self->id } ); > } > >+=head3 aliases >+ >+ my $aliases = $vendor->aliases >+ >+ $vendor->aliases([{ alias => 'one alias'}]); >+ >+=cut >+ >+sub aliases { >+ my ($self, $aliases) = @_; >+ >+ if ($aliases) { >+ my $schema = $self->_result->result_source->schema; >+ $schema->txn_do( >+ sub { >+ $self->aliases->delete; >+ for my $alias (@$aliases) { >+ $self->_result->add_to_aqbookseller_aliases($alias); >+ } >+ } >+ ); >+ } >+ >+ my $rs = $self->_result->aqbookseller_aliases; >+ return Koha::Acquisition::Bookseller::Aliases->_new_from_dbic( $rs ); >+} >+ >+ > =head3 to_api_mapping > > This method returns the mapping for representing a Koha::Acquisition::Bookseller object >diff --git a/acqui/supplier.pl b/acqui/supplier.pl >index 0e3570780a..bd988551de 100755 >--- a/acqui/supplier.pl >+++ b/acqui/supplier.pl >@@ -85,6 +85,7 @@ if ( $op eq 'display' ) { > listprice => $supplier->listprice, > basketcount => $supplier->baskets->count, > subscriptioncount => $supplier->subscriptions->count, >+ vendor => $supplier, > contracts => $contracts, > ); > } elsif ( $op eq 'delete' ) { >@@ -106,6 +107,7 @@ if ( $op eq 'display' ) { > # set active ON by default for supplier add (id empty for add) > active => $supplier ? $supplier->active : 1, > tax_rate => $supplier ? $supplier->tax_rate + 0.0 : 0, >+ vendor => $supplier, > gst_values => \@gst_values, > currencies => Koha::Acquisition::Currencies->search, > enter => 1, >diff --git a/acqui/updatesupplier.pl b/acqui/updatesupplier.pl >index 75dca3c22b..ac0d50ba64 100755 >--- a/acqui/updatesupplier.pl >+++ b/acqui/updatesupplier.pl >@@ -93,6 +93,8 @@ $data{'tax_rate'} = $input->param('tax_rate'); > $data{'discount'} = $input->param('discount'); > $data{deliverytime} = $input->param('deliverytime'); > $data{'active'}=$input->param('status'); >+ >+my @aliases = $input->multi_param('alias'); > my @contacts; > my %contact_info; > >@@ -111,15 +113,16 @@ for my $cnt (0..scalar(@{$contact_info{'id'}})) { > } > > if($data{'name'}) { >+ my $bookseller; > if ( $data{id} ) { > # Update >- my $bookseller = Koha::Acquisition::Booksellers->find( $data{id} )->set(\%data)->store; >+ $bookseller = Koha::Acquisition::Booksellers->find( $data{id} )->set(\%data)->store; > # Delete existing contacts > $bookseller->contacts->delete; > } else { > # Insert > delete $data{id}; # Remove the key if exists >- my $bookseller = Koha::Acquisition::Bookseller->new( \%data )->store; >+ $bookseller = Koha::Acquisition::Bookseller->new( \%data )->store; > $data{id} = $bookseller->id; > } > # Insert contacts >@@ -127,6 +130,7 @@ if($data{'name'}) { > $contact->{booksellerid} = $data{id}; > Koha::Acquisition::Bookseller::Contact->new( $contact )->store > } >+ $bookseller->aliases([ map { { alias => $_ } } @aliases ]); > > #redirect to booksellers.pl > print $input->redirect("booksellers.pl?booksellerid=".$data{id}); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >index 9dd49954e9..ad73ec84bb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >@@ -1,4 +1,5 @@ > [% USE raw %] >+[% USE To %] > [% USE Asset %] > [% USE KohaDates %] > [% USE AuthorisedValues %] >@@ -181,6 +182,11 @@ > <label for="vendor_type">Vendor type: </label> > [% PROCESS 'av-build-dropbox.inc' name="vendor_type", category="VENDOR_TYPE", default=type, empty=1, size = 20 %] > </li> >+ <li> >+ <label for="aliases">Aliases: </label> >+ <div id="aliases" style="padding-left: 11rem;"></div> >+ </li> >+ > </ol> > </fieldset> > <fieldset class="rows"> >@@ -322,6 +328,16 @@ > [% IF ( accountnumber ) %] > <p><span class="label">Account number: </span>[% accountnumber | html %]</p> > [% END %] >+ [% IF vendor.aliases.count %] >+ <p> >+ <span class="label">Aliases: </span> >+ <ul> >+ [% FOR alias IN vendor.aliases %] >+ <li>[% alias.alias | html %]</li> >+ [% END %] >+ </ul> >+ </p> >+ [% END %] > </div> <!-- /#supplier-company-details --> > > <div id="supplier-ordering-information" class="page-section"> >@@ -452,6 +468,34 @@ > ev.preventDefault(); > } > >+ [% IF vendor %] >+ let aliases = [% To.json(vendor.aliases.unblessed) | $raw %]; >+ [% ELSE %] >+ let aliases = []; >+ [% END %] >+ function remove_alias(i){ >+ aliases.splice(i, 1); >+ refresh_aliases(); >+ } >+ function add_alias(){ >+ let alias = $("#new_alias").val(); >+ if ( !alias.length > 0 ) { return } >+ aliases.push({alias}); >+ refresh_aliases(); >+ } >+ function refresh_aliases(){ >+ let nodes = $("<div></div>"); >+ aliases.forEach((a, i) => { >+ let n = $("<div></div>").append(a.alias); >+ n.append(`<input type="hidden" name="alias" value="${a.alias}">`) >+ n.append(`<a onclick="remove_alias(${i});"><i class="fa fa-trash" aria-hidden="true"></i></a>`); >+ nodes.append(n); >+ }); >+ nodes.append("<input id='new_alias' type='text' />"); >+ nodes.append(`<a onclick="add_alias();"><i class="fa fa-plus" aria-hidden="true"></i></a>`); >+ $("#aliases").html(nodes.html()); >+ } >+ > var Sticky; > > $(document).ready(function() { >@@ -491,6 +535,8 @@ > $(this).next('.contact_claimissues_hidden').val($(this).is(':checked') ? '1' : '0'); > }); > >+ refresh_aliases(); >+ > Sticky = $("#toolbar"); > Sticky.hcSticky({ > stickTo: "main", >-- >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 33103
:
147621
|
147622
|
147623
|
147624
|
147625
|
147626
|
147627
|
147628
|
147629
|
147630
|
147645
|
147646
|
147647
|
147648
|
147649
|
147650
|
147651
|
147652
|
147653
|
147654
|
147827
|
148448
|
148449
|
148450
|
148451
|
148452
|
148453
|
148454
|
148455
|
148456
|
148457
|
148458
|
149414
|
149419
|
149479
|
149480
|
149481
|
149482
|
149483
| 149484 |
149485
|
149486
|
149487
|
149488
|
149489
|
149490
|
149491
|
149606
|
149607
|
149608
|
149609
|
149629
|
149630
|
149788