Bug 38201: Convert 'action' to 'routeAction'

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:
Matt Blenkinsop 2025-01-29 14:43:54 +00:00 committed by Lucas Gass
parent be28447afd
commit 0b9f1ac8da
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
5 changed files with 31 additions and 52 deletions

View File

@ -1,6 +1,6 @@
<template>
<ResourceList
v-if="action === 'list'"
v-if="routeAction === 'list'"
v-bind="{
apiClient,
i18n,
@ -21,7 +21,7 @@
@select-resource="$emit('select-resource', $event)"
/>
<ResourceShow
v-if="action === 'show'"
v-if="routeAction === 'show'"
v-bind="{
idAttr,
apiClient,
@ -34,7 +34,7 @@
}"
/>
<ResourceFormAdd
v-if="['add', 'edit'].includes(action)"
v-if="['add', 'edit'].includes(routeAction)"
v-bind="{
idAttr,
apiClient,
@ -59,7 +59,7 @@ export default {
components: { ResourceShow, ResourceFormAdd, ResourceList },
extends: BaseResource,
props: {
action: String,
routeAction: String,
},
setup(props) {
return {
@ -191,16 +191,6 @@ export default {
},
async filterTable(filters, table, embedded = false) {},
},
computed: {
newResource() {
return this[this.resourceName];
},
hasAdditionalFields() {
return this.resourceAttrs.some(
attr => attr.name === "additional_fields"
);
},
},
created() {
//IMPROVEME: We need this for now to assign the correct av array from setup to the attr options in data
this.assignAVs(this.resourceAttrs);

View File

@ -3,6 +3,9 @@ import { inject } from "vue";
import { build_url } from "../composables/datatables";
export default {
props: {
routeAction: String,
},
setup(props) {
const { setConfirmationDialog, setMessage, setError, setWarning } =
inject("mainStore");
@ -119,7 +122,7 @@ export default {
if (typeof callback === "function") {
callback();
} else {
if (this.$props.action === "list") {
if (this.$props.routeAction === "list") {
callback.ajax.reload();
} else {
this.goToResourceList();
@ -190,6 +193,16 @@ export default {
return filterOptions;
},
},
computed: {
newResource() {
return this[this.resourceName];
},
hasAdditionalFields() {
return this.resourceAttrs.some(
attr => attr.name === "additional_fields"
);
},
},
name: "BaseResource",
props: {
resourceName: String,

View File

@ -1,11 +1,10 @@
<template>
<ResourceList
v-if="action === 'list'"
v-if="routeAction === 'list'"
v-bind="{
apiClient,
i18n,
tableOptions,
resourceName,
goToResourceShow,
goToResourceEdit,
doResourceDelete,
@ -22,7 +21,7 @@
@select-resource="$emit('select-resource', $event)"
/>
<ResourceShow
v-if="action === 'show'"
v-if="routeAction === 'show'"
v-bind="{
idAttr,
apiClient,
@ -35,7 +34,7 @@
}"
/>
<ResourceFormAdd
v-if="['add', 'edit'].includes(action)"
v-if="['add', 'edit'].includes(routeAction)"
v-bind="{
idAttr,
apiClient,
@ -62,7 +61,7 @@ export default {
components: { ResourceShow, ResourceFormAdd, ResourceList },
extends: BaseResource,
props: {
action: String,
routeAction: String,
embedded: { type: Boolean, default: false },
},
setup(props) {
@ -1056,16 +1055,6 @@ export default {
table.redraw(this.tableUrl(filters));
},
},
computed: {
newResource() {
return this[this.resourceName];
},
hasAdditionalFields() {
return this.resourceAttrs.some(
attr => attr.name === "additional_fields"
);
},
},
created() {
//IMPROVEME: We need this for now to assign the correct av array from setup to the attr options in data
this.assignAVs(this.resourceAttrs);

View File

@ -1,6 +1,6 @@
<template>
<ResourceList
v-if="action === 'list'"
v-if="routeAction === 'list'"
v-bind="{
apiClient,
i18n,
@ -21,7 +21,7 @@
@select-resource="$emit('select-resource', $event)"
/>
<ResourceShow
v-if="action === 'show'"
v-if="routeAction === 'show'"
v-bind="{
idAttr,
apiClient,
@ -34,7 +34,7 @@
}"
/>
<ResourceFormAdd
v-if="['add', 'edit'].includes(action)"
v-if="['add', 'edit'].includes(routeAction)"
v-bind="{
idAttr,
apiClient,
@ -61,7 +61,7 @@ export default {
components: { ResourceShow, ResourceFormAdd, ResourceList },
extends: BaseResource,
props: {
action: String,
routeAction: String,
},
setup(props) {
const AVStore = inject("AVStore");
@ -573,16 +573,6 @@ export default {
},
async filterTable(filters, table, embedded = false) {},
},
computed: {
newResource() {
return this[this.resourceName];
},
hasAdditionalFields() {
return this.resourceAttrs.some(
attr => attr.name === "additional_fields"
);
},
},
created() {
//IMPROVEME: We need this for now to assign the correct av array from setup to the attr options in data
this.assignAVs(this.resourceAttrs);

View File

@ -1,14 +1,11 @@
<template>
<component :is="getComponent()" v-bind="componentProps"> </component>
<component :is="getComponent()" v-bind="componentProps"></component>
</template>
<script>
import { defineAsyncComponent } from "vue";
import BaseResource from "./BaseResource.vue";
import ResourceShow from "./ResourceShow.vue";
export default {
components: { ResourceShow, BaseResource },
methods: {
getComponent() {
const routeResource = this.$route.meta.self.parent.resource;
@ -19,13 +16,13 @@ export default {
componentProps() {
const routeName = this.$route.meta.self.name;
if (routeName.includes("Show")) {
return { action: "show" };
return { routeAction: "show" };
} else if (routeName.includes("Edit")) {
return { action: "edit" };
return { routeAction: "edit" };
} else if (routeName.includes("Add")) {
return { action: "add" };
return { routeAction: "add" };
} else {
return { action: "list" };
return { routeAction: "list" };
}
},
},