From 81b189950cba977afb32b4a6ac6f5b70cbfd5a1a Mon Sep 17 00:00:00 2001
From: Matt Blenkinsop
Date: Tue, 29 Oct 2024 16:53:18 +0000
Subject: [PATCH] Bug 38290: Add fields to the UI for CRUD
---
acqui/vendors.pl | 3 +-
admin/library_groups.pl | 4 +
api/v1/swagger/definitions/vendor.yaml | 8 +
.../swagger/paths/acquisitions_vendors.yaml | 1 +
.../prog/en/modules/acqui/vendors.tt | 3 +
.../prog/en/modules/admin/library_groups.tt | 25 +++-
.../prog/js/vue/components/Vendors/Main.vue | 24 ++-
.../vue/components/Vendors/VendorDetails.vue | 45 ++++++
.../vue/components/Vendors/VendorFormAdd.vue | 16 ++
.../js/vue/fetch/acquisition-api-client.js | 2 +-
.../prog/js/vue/stores/vendors.js | 140 ++++++++++++++++++
11 files changed, 263 insertions(+), 8 deletions(-)
diff --git a/acqui/vendors.pl b/acqui/vendors.pl
index b9d2628e805..a13936c8972 100755
--- a/acqui/vendors.pl
+++ b/acqui/vendors.pl
@@ -49,7 +49,8 @@ $template->param(
currencies => Koha::Acquisition::Currencies->search->unblessed,
gst_values => \@gst_values,
edifact => C4::Context->preference('EDIFACT'),
- erm_module => C4::Context->preference('ERMModule')
+ erm_module => C4::Context->preference('ERMModule'),
+ logged_in_branch => { branchcode => C4::Context::mybranch },
);
output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/admin/library_groups.pl b/admin/library_groups.pl
index 84dc309c667..23fc929b222 100755
--- a/admin/library_groups.pl
+++ b/admin/library_groups.pl
@@ -52,6 +52,7 @@ if ( $op eq 'cud-add' ) {
my $ft_search_groups_staff = $cgi->param('ft_search_groups_staff') || 0;
my $ft_local_hold_group = $cgi->param('ft_local_hold_group') || 0;
my $ft_local_float_group = $cgi->param('ft_local_float_group') || 0;
+ my $ft_acquisitions = $cgi->param('ft_acquisitions') || 0;
if ( !$branchcode && Koha::Library::Groups->search( { title => $title } )->count() ) {
$template->param( error_duplicate_title => $title );
@@ -69,6 +70,7 @@ if ( $op eq 'cud-add' ) {
ft_local_hold_group => $ft_local_hold_group,
ft_limit_item_editing => $ft_limit_item_editing,
ft_local_float_group => $ft_local_float_group,
+ ft_acquisitions => $ft_acquisitions,
branchcode => $branchcode,
}
)->store();
@@ -91,6 +93,7 @@ elsif ( $op eq 'cud-edit' ) {
my $ft_search_groups_staff = $cgi->param('ft_search_groups_staff') || 0;
my $ft_local_hold_group = $cgi->param('ft_local_hold_group') || 0;
my $ft_local_float_group = $cgi->param('ft_local_float_group') || 0;
+ my $ft_acquisitions = $cgi->param('ft_acquisitions') || 0;
if ($id) {
my $group = Koha::Library::Groups->find($id);
@@ -105,6 +108,7 @@ elsif ( $op eq 'cud-edit' ) {
ft_search_groups_staff => $ft_search_groups_staff,
ft_local_hold_group => $ft_local_hold_group,
ft_local_float_group => $ft_local_float_group,
+ ft_acquisitions => $ft_acquisitions,
}
)->store();
diff --git a/api/v1/swagger/definitions/vendor.yaml b/api/v1/swagger/definitions/vendor.yaml
index 5ab146b4a2a..c99bb48024e 100644
--- a/api/v1/swagger/definitions/vendor.yaml
+++ b/api/v1/swagger/definitions/vendor.yaml
@@ -124,6 +124,14 @@ properties:
- string
- "null"
description: Language
+ lib_group_visibility:
+ type:
+ - string
+ - "null"
+ description: Language
+ lib_group_limits:
+ type: array
+ description: Library groups this vendor belongs to
aliases:
type: array
description: List of aliases
diff --git a/api/v1/swagger/paths/acquisitions_vendors.yaml b/api/v1/swagger/paths/acquisitions_vendors.yaml
index 67ce39d8ad1..8932c450556 100644
--- a/api/v1/swagger/paths/acquisitions_vendors.yaml
+++ b/api/v1/swagger/paths/acquisitions_vendors.yaml
@@ -158,6 +158,7 @@
- contracts
- extended_attributes
- +strings
+ - lib_group_limits
collectionFormat: csv
produces:
- application/json
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendors.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendors.tt
index 17d350e1a97..aecf20a8a7e 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendors.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendors.tt
@@ -34,6 +34,9 @@
const gstValues = [% To.json(gst_values) | $raw %];
const edifact = [% To.json(edifact) | $raw %];
const ermModule = [% To.json(erm_module) | $raw %];
+ const loggedInUser = [% To.json(logged_in_user.unblessed) | $raw %];
+ const loggedInBranch = [% To.json(logged_in_branch) | $raw %];
+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt
index 8120dd647a2..7034f661e38 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt
@@ -166,6 +166,12 @@
Is local float group
+
+
+
@@ -244,6 +250,12 @@
Is local float group
+
+
+
@@ -330,7 +342,8 @@
var ft_search_groups_staff = $(this).data('groupFt_search_groups_staff');
var ft_local_hold_group = $(this).data('groupFt_local_hold_group');
var ft_local_float_group = $(this).data('groupFt_local_float_group');
- edit_group( id, parent_id, title, description, ft_hide_patron_info, ft_search_groups_opac, ft_search_groups_staff, ft_local_hold_group, ft_limit_item_editing, ft_local_float_group );
+ var ft_acquisitions = $(this).data('groupFt_acquisitions');
+ edit_group( id, parent_id, title, description, ft_hide_patron_info, ft_search_groups_opac, ft_search_groups_staff, ft_local_hold_group, ft_limit_item_editing, ft_local_float_group, ft_acquisitions );
});
$('.delete-group').on('click', function(e) {
@@ -368,6 +381,7 @@
$('#add-group-modal-ft_search_groups_staff').prop('checked', false);
$('#add-group-modal-ft_local_hold_group').prop('checked', false);
$('#add-group-modal-ft_local_float_group').prop('checked', false);
+ $('#add-group-modal-ft_acquisitions').prop('checked', false);
if ( parent_id ) {
$('#root-group-features-add').hide();
} else {
@@ -377,7 +391,7 @@
}
- function edit_group( id, parent_id, title, description, ft_hide_patron_info, ft_search_groups_opac, ft_search_groups_staff, ft_local_hold_group, ft_limit_item_editing, ft_local_float_group ) {
+ function edit_group( id, parent_id, title, description, ft_hide_patron_info, ft_search_groups_opac, ft_search_groups_staff, ft_local_hold_group, ft_limit_item_editing, ft_local_float_group, ft_acquisitions ) {
$('#edit-group-modal-id').val( id );
$('#edit-group-modal-title').val( title );
$('#edit-group-modal-description').val( description );
@@ -388,6 +402,7 @@
$('#edit-group-modal-ft_search_groups_staff').prop('checked', false);
$('#edit-group-modal-ft_local_hold_group').prop('checked', false);
$('#edit-group-modal-ft_local_float_group').prop('checked', false);
+ $('#edit-group-modal-ft_acquisitions').prop('checked', false);
$('#root-group-features-edit').hide();
} else {
$('#edit-group-modal-ft_hide_patron_info').prop('checked', ft_hide_patron_info ? true : false );
@@ -396,6 +411,7 @@
$('#edit-group-modal-ft_search_groups_staff').prop('checked', ft_search_groups_staff ? true : false );
$('#edit-group-modal-ft_local_hold_group').prop('checked', ft_local_hold_group ? true : false );
$('#edit-group-modal-ft_local_float_group').prop('checked', ft_local_float_group ? true : false );
+ $('#edit-group-modal-ft_acquisitions').prop('checked', ft_acquisitions ? true : false );
$('#root-group-features-edit').show();
}
@@ -457,6 +473,9 @@
[% IF group.ft_local_float_group %]
Is local float group
[% END %]
+ [% IF group.ft_acquisitions %]
+ Use in the acquisitions module
+ [% END %]
[% END %]
@@ -474,7 +493,7 @@
-
+
Edit
diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/Main.vue
index 323e0d8d4c8..ab81e7135a0 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/Main.vue
+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/Main.vue
@@ -37,7 +37,9 @@ import { APIClient } from "../../fetch/api-client"
export default {
setup() {
const vendorStore = inject("vendorStore")
- const { config } = storeToRefs(vendorStore)
+ const { config, user, currencies, libraryGroups, gstValues } =
+ storeToRefs(vendorStore)
+ const { setLibraryGroups } = vendorStore
const mainStore = inject("mainStore")
const { loading, loaded, setError } = mainStore
@@ -54,6 +56,11 @@ export default {
userPermissions,
AVStore,
config,
+ user,
+ currencies,
+ libraryGroups,
+ gstValues,
+ setLibraryGroups,
}
},
beforeCreate() {
@@ -62,6 +69,14 @@ export default {
const fetchConfig = () => {
let promises = []
+ const libraryClient = APIClient.libraries
+ libraryClient.libraryGroups.getAll().then(
+ libraryGroups => {
+ this.setLibraryGroups(libraryGroups)
+ },
+ error => {}
+ )
+
const av_client = APIClient.authorised_values
const authorised_values = {
av_vendor_types: "VENDOR_TYPE",
@@ -100,8 +115,11 @@ export default {
this.userPermissions = userPermissions
this.config.settings.edifact = edifact
this.config.settings.ermModule = ermModule
- this.vendorStore.currencies = currencies
- this.vendorStore.gstValues = gstValues.map(gv => {
+ this.currencies = currencies
+ // this.libraryGroups = libraryGroups
+ this.user.loggedInUser = loggedInUser
+ this.user.loggedInUser.loggedInBranch = loggedInBranch.branchcode
+ this.gstValues = gstValues.map(gv => {
return {
label: `${(gv.option * 100).toFixed(2)}%`,
value: gv.option,
diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorDetails.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorDetails.vue
index 69333c90250..c8ab8afbc4d 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorDetails.vue
+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorDetails.vue
@@ -66,6 +66,30 @@
{{ get_lib_from_av("av_lang", vendor.language) }}
+
+
+
+
+
+ {{ $__("ID") }} |
+ {{ $__("Title") }} |
+
+
+
+
+ {{ libGroup.id }} |
+ {{ libGroup.title }} |
+
+
+
+
+
+
+ {{ $__("All library groups") }}
+
+
+
+
+
+
@@ -189,6 +228,7 @@