Bug 38201: Restore dropdown buttons to vendor show
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
5677734c09
commit
da4dc4a66d
|
|
@ -7,11 +7,11 @@
|
|||
><i class="fa fa-plus"></i> {{ title }}</a
|
||||
>
|
||||
<ul class="dropdown-menu">
|
||||
<li v-for="(item, index) in items" :key="index">
|
||||
<li v-for="(button, index) in dropdownButtons" :key="index">
|
||||
<ToolbarButton
|
||||
:to="item.to"
|
||||
:title="$__(item.title)"
|
||||
:callback="item.callback"
|
||||
:to="button.to"
|
||||
:title="$__(button.title)"
|
||||
:callback="button.callback"
|
||||
:cssClass="'dropdown-item'"
|
||||
/>
|
||||
</li>
|
||||
|
|
@ -24,7 +24,7 @@ import ToolbarButton from "./ToolbarButton.vue";
|
|||
|
||||
export default {
|
||||
components: { ToolbarButton },
|
||||
props: ["items", "title"],
|
||||
props: ["dropdownButtons", "title"],
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ export default {
|
|||
: redirectParams
|
||||
);
|
||||
};
|
||||
return { redirect };
|
||||
return { redirect, handleQuery, formatUrl };
|
||||
},
|
||||
emits: ["go-to-add-resource", "delete-resource", "go-to-edit-resource"],
|
||||
name: "Link",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,11 @@
|
|||
componentPropData
|
||||
)"
|
||||
>
|
||||
<ToolbarButton v-bind="{ ...button }" />
|
||||
<DropdownButtons
|
||||
v-if="button.dropdownButtons"
|
||||
v-bind="{ ...button }"
|
||||
/>
|
||||
<ToolbarButton v-else v-bind="{ ...button }" />
|
||||
</template>
|
||||
</template>
|
||||
<slot></slot>
|
||||
|
|
@ -23,6 +27,7 @@
|
|||
<script>
|
||||
import { computed, useTemplateRef, watch } from "vue";
|
||||
import ToolbarButton from "./ToolbarButton.vue";
|
||||
import DropdownButtons from "./DropdownButtons.vue";
|
||||
export default {
|
||||
props: {
|
||||
toolbarButtons: Function,
|
||||
|
|
@ -34,7 +39,7 @@ export default {
|
|||
default: false,
|
||||
},
|
||||
},
|
||||
components: { ToolbarButton },
|
||||
components: { ToolbarButton, DropdownButtons },
|
||||
name: "Toolbar",
|
||||
setup(props) {
|
||||
const toolbar = computed(() => {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export default {
|
|||
|
||||
const additionalToolbarButtons = (resource, componentData) => {
|
||||
const { instancedResource } = componentData;
|
||||
return {
|
||||
const buttons = {
|
||||
form: [
|
||||
{
|
||||
title: $__("Save"),
|
||||
|
|
@ -46,6 +46,86 @@ export default {
|
|||
cssClass: "btn btn-link",
|
||||
},
|
||||
],
|
||||
show: [
|
||||
{
|
||||
dropdownButtons: [
|
||||
{
|
||||
to: {
|
||||
path: "/cgi-bin/koha/acqui/basketheader.pl",
|
||||
query: {
|
||||
booksellerid: resource.id,
|
||||
op: "add_form",
|
||||
},
|
||||
},
|
||||
title: "Basket",
|
||||
callback: toolbarComponent => {
|
||||
const url = toolbarComponent.handleQuery(
|
||||
toolbarComponent.to
|
||||
);
|
||||
toolbarComponent.redirect(url);
|
||||
},
|
||||
},
|
||||
{
|
||||
to: {
|
||||
path: "/cgi-bin/koha/admin/aqcontract.pl",
|
||||
query: {
|
||||
booksellerid: resource.id,
|
||||
op: "add_form",
|
||||
},
|
||||
},
|
||||
title: "Contract",
|
||||
callback: toolbarComponent => {
|
||||
const url = toolbarComponent.handleQuery(
|
||||
toolbarComponent.to
|
||||
);
|
||||
toolbarComponent.redirect(url);
|
||||
},
|
||||
},
|
||||
{
|
||||
to: { name: "VendorFormAdd" },
|
||||
title: "Vendor",
|
||||
},
|
||||
],
|
||||
title: $__("New"),
|
||||
index: -1,
|
||||
},
|
||||
],
|
||||
};
|
||||
if (
|
||||
resource.active &&
|
||||
resource.baskets_count > 0 &&
|
||||
instancedResource.isUserPermitted(
|
||||
"CAN_user_acquisition_order_receive"
|
||||
)
|
||||
) {
|
||||
buttons.show.push({
|
||||
to: {
|
||||
path: "/cgi-bin/koha/acqui/parcels.pl",
|
||||
query: { booksellerid: resource.id },
|
||||
},
|
||||
title: $__("Receive shipments"),
|
||||
callback: toolbarComponent => {
|
||||
const url = toolbarComponent.handleQuery(
|
||||
toolbarComponent.to
|
||||
);
|
||||
toolbarComponent.redirect(url);
|
||||
},
|
||||
icon: "inbox",
|
||||
});
|
||||
}
|
||||
return buttons;
|
||||
};
|
||||
const defaultToolbarButtons = (defaultButtons, resource) => {
|
||||
return {
|
||||
list: defaultButtons.list,
|
||||
show: defaultButtons.show.filter(
|
||||
button =>
|
||||
button.action === "edit" ||
|
||||
(resource.baskets_count === 0 &&
|
||||
resource.subscriptions_count === 0 &&
|
||||
resource.invoices_count === 0 &&
|
||||
button.action === "delete")
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -74,6 +154,7 @@ export default {
|
|||
moduleStore: "vendorStore",
|
||||
formGroupsDisplayMode: "accordion",
|
||||
additionalToolbarButtons,
|
||||
defaultToolbarButtons,
|
||||
stickyToolbar: ["Form"],
|
||||
resourceAttrs: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -516,16 +516,20 @@ export function useBaseResource(instancedResource) {
|
|||
*/
|
||||
const toolbarButtons = computed(() => {
|
||||
return (resource, component, componentData) => {
|
||||
const defaultButtons = instancedResource.hasOwnProperty(
|
||||
let defaultButtons = defaultToolbarButtons(resource);
|
||||
defaultButtons = instancedResource.hasOwnProperty(
|
||||
"defaultToolbarButtons"
|
||||
)
|
||||
? instancedResource.defaultToolbarButtons(resource)
|
||||
: defaultToolbarButtons(resource);
|
||||
? instancedResource.defaultToolbarButtons(
|
||||
defaultButtons,
|
||||
resource || {}
|
||||
)
|
||||
: defaultButtons;
|
||||
const additionalButtons = instancedResource.hasOwnProperty(
|
||||
"additionalToolbarButtons"
|
||||
)
|
||||
? instancedResource.additionalToolbarButtons(
|
||||
resource,
|
||||
resource || {},
|
||||
componentData
|
||||
)
|
||||
: additionalToolbarButtons(resource, componentData);
|
||||
|
|
|
|||
Loading…
Reference in New Issue