Skip to content

Commit

Permalink
ACQUI-139: Use patron embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
mblenk committed Apr 11, 2024
1 parent 6a75df3 commit 4713ab4
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 39 deletions.
4 changes: 0 additions & 4 deletions Koha/Plugin/Acquire/Controllers/FundManagement/FiscalYears.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ sub get {
);
}

$fiscal_year = Koha::Plugin::Acquire::Controllers::ControllerUtils->add_patron_data(
{ data => $fiscal_year, field => 'owned_by', key => "owner" } );
$fiscal_year =
Koha::Plugin::Acquire::Controllers::ControllerUtils->add_lib_group_data( { data => $fiscal_year } );

Expand All @@ -100,7 +98,6 @@ sub add {
sub {

my $body = $c->req->json;
delete $body->{owned_by} if $body->{owned_by};
delete $body->{lib_groups} if $body->{lib_groups};

my $fiscal_year = Koha::Acquire::Funds::FiscalYear->new_from_api($body)->store;
Expand Down Expand Up @@ -141,7 +138,6 @@ sub update {

my $body = $c->req->json;

delete $body->{owned_by} if $body->{owned_by};
delete $body->{lib_groups} if $body->{lib_groups};
delete $body->{last_updated} if $body->{last_updated};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ sub get {
);
}

$fund_allocation = Koha::Plugin::Acquire::Controllers::ControllerUtils->add_patron_data(
{ data => $fund_allocation, field => 'owned_by', key => "owner" } );
$fund_allocation = Koha::Plugin::Acquire::Controllers::ControllerUtils->add_lib_group_data( { data => $fund_allocation } );

return $c->render(
Expand All @@ -110,7 +108,6 @@ sub add {
sub {

my $body = $c->req->json;
delete $body->{owned_by} if $body->{owned_by};
delete $body->{lib_groups} if $body->{lib_groups};

my $fund_allocation = Koha::Acquire::Funds::FundAllocation->new_from_api($body)->store;
Expand Down Expand Up @@ -151,7 +148,6 @@ sub update {

my $body = $c->req->json;

delete $body->{owned_by} if $body->{owned_by};
delete $body->{lib_groups} if $body->{lib_groups};
delete $body->{fiscal_year} if $body->{fiscal_year};
delete $body->{last_updated} if $body->{last_updated};
Expand Down
4 changes: 0 additions & 4 deletions Koha/Plugin/Acquire/Controllers/FundManagement/Funds.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ sub get {
);
}

$fund = Koha::Plugin::Acquire::Controllers::ControllerUtils->add_patron_data(
{ data => $fund, field => 'owned_by', key => "owner" } );
$fund =
Koha::Plugin::Acquire::Controllers::ControllerUtils->add_lib_group_data( { data => $fund } );
$fund =
Expand Down Expand Up @@ -104,7 +102,6 @@ sub add {
sub {

my $body = $c->req->json;
delete $body->{owned_by} if $body->{owned_by};
delete $body->{lib_groups} if $body->{lib_groups};

$body = _inherit_currency_and_owner($body);
Expand Down Expand Up @@ -147,7 +144,6 @@ sub update {

my $body = $c->req->json;

delete $body->{owned_by} if $body->{owned_by};
delete $body->{lib_groups} if $body->{lib_groups};
delete $body->{last_updated} if $body->{last_updated};

Expand Down
4 changes: 0 additions & 4 deletions Koha/Plugin/Acquire/Controllers/FundManagement/Ledgers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ sub get {
);
}

$ledger = Koha::Plugin::Acquire::Controllers::ControllerUtils->add_patron_data(
{ data => $ledger, field => 'owned_by', key => "owner" } );
$ledger =
Koha::Plugin::Acquire::Controllers::ControllerUtils->add_lib_group_data( { data => $ledger } );
$ledger =
Expand Down Expand Up @@ -102,7 +100,6 @@ sub add {
sub {

my $body = $c->req->json;
delete $body->{owned_by} if $body->{owned_by};
delete $body->{lib_groups} if $body->{lib_groups};

my $ledger = Koha::Acquire::Funds::Ledger->new_from_api($body)->store;
Expand Down Expand Up @@ -143,7 +140,6 @@ sub update {

my $body = $c->req->json;

delete $body->{owned_by} if $body->{owned_by};
delete $body->{lib_groups} if $body->{lib_groups};
delete $body->{fiscal_year} if $body->{fiscal_year};
delete $body->{last_updated} if $body->{last_updated};
Expand Down
4 changes: 0 additions & 4 deletions Koha/Plugin/Acquire/Controllers/FundManagement/SubFunds.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ sub get {
);
}

$sub_fund = Koha::Plugin::Acquire::Controllers::ControllerUtils->add_patron_data(
{ data => $sub_fund, field => 'owned_by', key => "owner" } );
$sub_fund = Koha::Plugin::Acquire::Controllers::ControllerUtils->add_lib_group_data( { data => $sub_fund } );
$sub_fund =
Koha::Plugin::Acquire::Controllers::ControllerUtils
Expand All @@ -102,7 +100,6 @@ sub add {
sub {

my $body = $c->req->json;
delete $body->{owned_by} if $body->{owned_by};
delete $body->{lib_groups} if $body->{lib_groups};

my $sub_fund = Koha::Acquire::Funds::SubFund->new_from_api($body)->store;
Expand Down Expand Up @@ -143,7 +140,6 @@ sub update {

my $body = $c->req->json;

delete $body->{owned_by} if $body->{owned_by};
delete $body->{lib_groups} if $body->{lib_groups};
delete $body->{last_updated} if $body->{last_updated};

Expand Down
36 changes: 24 additions & 12 deletions Koha/Plugin/Acquire/api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,8 @@
"type": "string",
"enum": [
"koha_plugin_acquire_ledgers",
"koha_plugin_acquire_funds"
"koha_plugin_acquire_funds",
"owner"
]
},
"collectionFormat": "csv"
Expand Down Expand Up @@ -846,7 +847,8 @@
"type": "string",
"enum": [
"koha_plugin_acquire_ledgers",
"koha_plugin_acquire_funds"
"koha_plugin_acquire_funds",
"owner"
]
},
"collectionFormat": "csv"
Expand Down Expand Up @@ -1187,7 +1189,8 @@
"enum": [
"fiscal_yr",
"koha_plugin_acquire_funds",
"koha_plugin_acquire_funds.koha_plugin_acquire_fund_allocations"
"koha_plugin_acquire_funds.koha_plugin_acquire_fund_allocations",
"owner"
]
},
"collectionFormat": "csv"
Expand Down Expand Up @@ -1344,7 +1347,8 @@
"enum": [
"fiscal_yr",
"koha_plugin_acquire_funds",
"koha_plugin_acquire_funds.koha_plugin_acquire_fund_allocations"
"koha_plugin_acquire_funds.koha_plugin_acquire_fund_allocations",
"owner"
]
},
"collectionFormat": "csv"
Expand Down Expand Up @@ -1686,7 +1690,8 @@
"fiscal_yr",
"ledger",
"koha_plugin_acquire_sub_funds",
"koha_plugin_acquire_fund_allocations"
"koha_plugin_acquire_fund_allocations",
"owner"
]
},
"collectionFormat": "csv"
Expand Down Expand Up @@ -1846,7 +1851,8 @@
"fund_group",
"koha_plugin_acquire_sub_funds",
"koha_plugin_acquire_sub_funds.koha_plugin_acquire_fund_allocations",
"koha_plugin_acquire_fund_allocations"
"koha_plugin_acquire_fund_allocations",
"owner"
]
},
"collectionFormat": "csv"
Expand Down Expand Up @@ -2188,7 +2194,8 @@
"fiscal_yr",
"ledger",
"fund",
"koha_plugin_acquire_fund_allocations"
"koha_plugin_acquire_fund_allocations",
"owner"
]
},
"collectionFormat": "csv"
Expand Down Expand Up @@ -2346,7 +2353,8 @@
"fiscal_yr",
"ledger",
"fund",
"koha_plugin_acquire_fund_allocations"
"koha_plugin_acquire_fund_allocations",
"owner"
]
},
"collectionFormat": "csv"
Expand Down Expand Up @@ -2687,7 +2695,8 @@
"enum": [
"fiscal_yr",
"ledger",
"fund"
"fund",
"owner"
]
},
"collectionFormat": "csv"
Expand Down Expand Up @@ -2891,7 +2900,8 @@
"enum": [
"fiscal_yr",
"ledger",
"fund"
"fund",
"owner"
]
},
"collectionFormat": "csv"
Expand Down Expand Up @@ -3231,7 +3241,8 @@
"type": "string",
"enum": [
"koha_plugin_acquire_funds",
"koha_plugin_acquire_funds.koha_plugin_acquire_fund_allocations"
"koha_plugin_acquire_funds.koha_plugin_acquire_fund_allocations",
"owner"
]
},
"collectionFormat": "csv"
Expand Down Expand Up @@ -3387,7 +3398,8 @@
"type": "string",
"enum": [
"koha_plugin_acquire_funds",
"koha_plugin_acquire_funds.koha_plugin_acquire_fund_allocations"
"koha_plugin_acquire_funds.koha_plugin_acquire_fund_allocations",
"owner"
]
},
"collectionFormat": "csv"
Expand Down
8 changes: 4 additions & 4 deletions Koha/Plugin/Acquire/installer/config/schemaToUI.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"owner": {
"label": "Owner",
"type": "patron"
"type": "owner"
},
"visible_to": {
"label": "Library groups covered",
Expand Down Expand Up @@ -110,7 +110,7 @@
},
"owner": {
"label": "Owner",
"type": "patron"
"type": "owner"
},
"visible_to": {
"label": "Library groups covered",
Expand Down Expand Up @@ -200,7 +200,7 @@
},
"owner": {
"label": "Owner",
"type": "patron"
"type": "owner"
},
"visible_to": {
"label": "Library groups covered",
Expand Down Expand Up @@ -285,7 +285,7 @@
},
"owner": {
"label": "Owner",
"type": "patron"
"type": "owner"
},
"visible_to": {
"label": "Library groups covered",
Expand Down
13 changes: 13 additions & 0 deletions Koha/Plugin/Acquire/lib/Koha/Acquire/Funds/FiscalYear.pm
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ sub koha_plugin_acquire_ledgers {
}


=head3 owner
Method to embed the owner to a given fiscal year
=cut

sub owner {
my ($self) = @_;
my $owner_rs = $self->_result->owner;
return Koha::Patron->_new_from_dbic($owner_rs);
}


=head2 Internal methods
=head3 _type
Expand Down
13 changes: 13 additions & 0 deletions Koha/Plugin/Acquire/lib/Koha/Acquire/Funds/Fund.pm
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ sub koha_plugin_acquire_fund_allocations {
return Koha::Acquire::Funds::FundAllocations->_new_from_dbic($fund_allocation_rs);
}


=head3 owner
Method to embed the owner to a given fund
=cut

sub owner {
my ($self) = @_;
my $owner_rs = $self->_result->owner;
return Koha::Patron->_new_from_dbic($owner_rs);
}

=head2 Internal methods
=head3 _type
Expand Down
14 changes: 14 additions & 0 deletions Koha/Plugin/Acquire/lib/Koha/Acquire/Funds/FundAllocation.pm
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ sub sub_fund {
return Koha::Acquire::Funds::SubFund->_new_from_dbic($sub_fund_rs);
}


=head3 owner
Method to embed the owner to a given fund allocation
=cut

sub owner {
my ($self) = @_;
my $owner_rs = $self->_result->owner;
return Koha::Patron->_new_from_dbic($owner_rs);
}


=head2 Internal methods
=head3 _type
Expand Down
12 changes: 12 additions & 0 deletions Koha/Plugin/Acquire/lib/Koha/Acquire/Funds/Ledger.pm
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ sub koha_plugin_acquire_funds {
}


=head3 owner
Method to embed the owner to a given ledger
=cut

sub owner {
my ($self) = @_;
my $owner_rs = $self->_result->owner;
return Koha::Patron->_new_from_dbic($owner_rs);
}


=head2 Internal methods
Expand Down
14 changes: 14 additions & 0 deletions Koha/Plugin/Acquire/lib/Koha/Acquire/Funds/SubFund.pm
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,20 @@ sub koha_plugin_acquire_fund_allocations {
return Koha::Acquire::Funds::FundAllocations->_new_from_dbic($fund_allocation_rs);
}


=head3 owner
Method to embed the owner to a given sub fund
=cut

sub owner {
my ($self) = @_;
my $owner_rs = $self->_result->owner;
return Koha::Patron->_new_from_dbic($owner_rs);
}


=head2 Internal methods
=head3 _type
Expand Down
2 changes: 1 addition & 1 deletion src/components/DataField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<li v-if="item.type === 'owner'">
<label>{{ item.label }}:</label>
<span>
{{ `${item.value.firstname} ${item.value.surname}` }}
{{ `${item.value.firstname || ''} ${item.value.surname || ''}` }}
</span>
</li>
<li v-if="item.type === 'creator'">
Expand Down
2 changes: 1 addition & 1 deletion src/components/DisplayDataFields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default {
const value = this.data[key]
fields[key].value = value
if(fields[key].type === 'owner') {
fields[key].value = this.data.owned_by
fields[key].value = this.data.owner
}
if(fields[key].type === 'link') {
const value = this.data[fields[key].dataType]
Expand Down
Loading

0 comments on commit 4713ab4

Please sign in to comment.