Bug 38010: (QA follow-up) Add a config endpoint for permissions
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
1393aa163c
commit
7d0b44d9dc
|
|
@ -169,4 +169,25 @@ sub delete {
|
|||
};
|
||||
}
|
||||
|
||||
=head3 config
|
||||
|
||||
Return the configuration options needed for the ERM Vue app
|
||||
|
||||
=cut
|
||||
|
||||
sub config {
|
||||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
my $patron = $c->stash('koha.user');
|
||||
my $userflags = C4::Auth::getuserflags( $patron->flags, $patron->id );
|
||||
my $permissions = Koha::Auth::Permissions->get_authz_from_flags( { flags => $userflags } );
|
||||
|
||||
return $c->render(
|
||||
status => 200,
|
||||
openapi => {
|
||||
permissions => $permissions,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
type: object
|
||||
properties:
|
||||
permissions:
|
||||
type: object
|
||||
description: List of permissions for the user
|
||||
additionalProperties: false
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
/acquisitions/vendors/config:
|
||||
get:
|
||||
x-mojo-to: Acquisitions::Vendors#config
|
||||
operationId: getVendorsconfig
|
||||
description: This resource returns a list of options needed for the Vendors Vue app
|
||||
summary: get the Vendors config
|
||||
tags:
|
||||
- vendors_config
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
200:
|
||||
description: The Vendors config
|
||||
schema:
|
||||
$ref: "../swagger.yaml#/definitions/vendors_config"
|
||||
400:
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: "../swagger.yaml#/definitions/error"
|
||||
403:
|
||||
description: Access forbidden
|
||||
schema:
|
||||
$ref: "../swagger.yaml#/definitions/error"
|
||||
500:
|
||||
description: |
|
||||
Internal server error. Possible `error_code` attribute values:
|
||||
|
||||
* `internal_server_error`
|
||||
schema:
|
||||
$ref: "../swagger.yaml#/definitions/error"
|
||||
503:
|
||||
description: Under maintenance
|
||||
schema:
|
||||
$ref: "../swagger.yaml#/definitions/error"
|
||||
x-koha-authorization:
|
||||
permissions:
|
||||
acquisition: 1
|
||||
|
|
@ -188,6 +188,8 @@ definitions:
|
|||
$ref: ./definitions/vendor.yaml
|
||||
vendor_issue:
|
||||
$ref: ./definitions/vendor_issue.yaml
|
||||
vendors_config:
|
||||
$ref: ./definitions/vendors_config.yaml
|
||||
paths:
|
||||
/acquisitions/baskets:
|
||||
$ref: ./paths/acquisitions_baskets.yaml#/~1acquisitions~1baskets
|
||||
|
|
@ -207,6 +209,8 @@ paths:
|
|||
$ref: "./paths/acquisitions_orders.yaml#/~1acquisitions~1orders~1{order_id}"
|
||||
/acquisitions/vendors:
|
||||
$ref: ./paths/acquisitions_vendors.yaml#/~1acquisitions~1vendors
|
||||
/acquisitions/vendors/config:
|
||||
$ref: ./paths/acquisitions_vendors_config.yaml#/~1acquisitions~1vendors~1config
|
||||
"/acquisitions/vendors/{vendor_id}":
|
||||
$ref: "./paths/acquisitions_vendors.yaml#/~1acquisitions~1vendors~1{vendor_id}"
|
||||
"/acquisitions/vendors/{vendor_id}/issues":
|
||||
|
|
|
|||
|
|
@ -5,6 +5,15 @@ export class AcquisitionAPIClient {
|
|||
});
|
||||
}
|
||||
|
||||
get config() {
|
||||
return {
|
||||
get: moduleEndpoint =>
|
||||
this.httpClient.get({
|
||||
endpoint: moduleEndpoint + "/config",
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
get vendors() {
|
||||
return {
|
||||
get: id =>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import LeftMenu from "../LeftMenu.vue";
|
|||
import Dialog from "../Dialog.vue";
|
||||
import "vue-select/dist/vue-select.css";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { APIClient } from "../../fetch/api-client.js";
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
|
|
@ -61,18 +62,22 @@ export default {
|
|||
|
||||
this.loadAuthorisedValues(this.authorisedValues, this.vendorStore).then(
|
||||
() => {
|
||||
this.userPermissions = userPermissions;
|
||||
this.config.settings.edifact = edifact;
|
||||
this.config.settings.marcOrderAutomation = marcOrderAutomation;
|
||||
this.vendorStore.currencies = currencies;
|
||||
this.vendorStore.gstValues = gstValues.map(gv => {
|
||||
return {
|
||||
label: `${Number(gv.option * 100).format_price()}%`,
|
||||
value: gv.option,
|
||||
};
|
||||
const client = APIClient.acquisition;
|
||||
client.config.get("vendors").then(config => {
|
||||
this.userPermissions = config.permissions;
|
||||
this.config.settings.edifact = edifact;
|
||||
this.config.settings.marcOrderAutomation =
|
||||
marcOrderAutomation;
|
||||
this.vendorStore.currencies = currencies;
|
||||
this.vendorStore.gstValues = gstValues.map(gv => {
|
||||
return {
|
||||
label: `${Number(gv.option * 100).format_price()}%`,
|
||||
value: gv.option,
|
||||
};
|
||||
});
|
||||
this.loaded();
|
||||
this.initialized = true;
|
||||
});
|
||||
this.loaded();
|
||||
this.initialized = true;
|
||||
}
|
||||
);
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue