View | Details | Raw Unified | Return to bug 40191
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ButtonSubmit.vue (-6 / +8 lines)
Lines 1-8 Link Here
1
<template>
1
<template>
2
    <button
2
    <button @click="callback && callback()" :class="cssClass">
3
        @click="form && form.value.requestSubmit()"
4
        class="btn btn-primary"
5
    >
6
        <font-awesome-icon v-if="icon" :icon="icon" />
3
        <font-awesome-icon v-if="icon" :icon="icon" />
7
        {{ title }}
4
        {{ title }}
8
    </button>
5
    </button>
Lines 22-29 export default { Link Here
22
            type: String,
19
            type: String,
23
            required: false,
20
            required: false,
24
        },
21
        },
25
        form: {
22
        cssClass: {
26
            type: Object,
23
            type: String,
24
            default: "btn btn-primary",
25
            required: false,
26
        },
27
        callback: {
28
            type: Function,
27
        },
29
        },
28
    },
30
    },
29
};
31
};
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/DropdownButtons.vue (-3 / +12 lines)
Lines 1-10 Link Here
1
<template>
1
<template>
2
    <div class="btn-group">
2
    <div class="btn-group">
3
        <slot />
3
        <a
4
        <a
4
            class="btn btn-default dropdown-toggle"
5
            :class="`btn ${cssClass} dropdown-toggle`"
5
            data-bs-toggle="dropdown"
6
            data-bs-toggle="dropdown"
6
            href="#"
7
            href="#"
7
            ><i class="fa fa-plus"></i> {{ title }}</a
8
            ><i v-if="title" class="fa fa-plus"></i> {{ title }}</a
8
        >
9
        >
9
        <ul class="dropdown-menu">
10
        <ul class="dropdown-menu">
10
            <li v-for="(button, index) in dropdownButtons" :key="index">
11
            <li v-for="(button, index) in dropdownButtons" :key="index">
Lines 13-18 Link Here
13
                    :title="$__(button.title)"
14
                    :title="$__(button.title)"
14
                    :callback="button.callback"
15
                    :callback="button.callback"
15
                    :cssClass="'dropdown-item'"
16
                    :cssClass="'dropdown-item'"
17
                    :action="button.action"
16
                />
18
                />
17
            </li>
19
            </li>
18
        </ul>
20
        </ul>
Lines 24-30 import ToolbarButton from "./ToolbarButton.vue"; Link Here
24
26
25
export default {
27
export default {
26
    components: { ToolbarButton },
28
    components: { ToolbarButton },
27
    props: ["dropdownButtons", "title"],
29
    props: {
30
        dropdownButtons: Array,
31
        title: String,
32
        cssClass: {
33
            type: String,
34
            default: "btn-default",
35
        },
36
    },
28
};
37
};
29
</script>
38
</script>
30
39
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ResourceFormSave.vue (-3 / +52 lines)
Lines 93-99 Link Here
93
                        !instancedResource.stickyToolbar.includes('Form'))
93
                        !instancedResource.stickyToolbar.includes('Form'))
94
                "
94
                "
95
            >
95
            >
96
                <ButtonSubmit />
96
                <DropdownButtons :dropdownButtons="dropdownButtons" :cssClass="'btn-primary'">
97
                    <ButtonSubmit :title="buttonTextLeader" />
98
                </DropdownButtons>
97
                <router-link
99
                <router-link
98
                    :to="{ name: instancedResource.components.list }"
100
                    :to="{ name: instancedResource.components.list }"
99
                    role="button"
101
                    role="button"
Lines 109-122 Link Here
109
import { computed, onBeforeMount, reactive, ref, useTemplateRef } from "vue";
111
import { computed, onBeforeMount, reactive, ref, useTemplateRef } from "vue";
110
import FormElement from "./FormElement.vue";
112
import FormElement from "./FormElement.vue";
111
import ButtonSubmit from "./ButtonSubmit.vue";
113
import ButtonSubmit from "./ButtonSubmit.vue";
114
import DropdownButtons from "./DropdownButtons.vue";
112
import TabsWrapper from "./TabsWrapper.vue";
115
import TabsWrapper from "./TabsWrapper.vue";
113
import AccordionWrapper from "./AccordionWrapper.vue";
116
import AccordionWrapper from "./AccordionWrapper.vue";
117
import { $__ } from "@koha-vue/i18n"
114
118
115
export default {
119
export default {
116
    inheritAttrs: false,
120
    inheritAttrs: false,
117
    setup(props) {
121
    setup(props) {
118
        const initialized = ref(false);
122
        const initialized = ref(false);
119
        const resource = ref(null);
123
        const resource = ref(null);
124
        const editMode = ref(false);
125
        const buttonTextLeader = computed(() => editMode.value ? $__("Save") : $__("Submit"))
120
126
121
        const resourceToSave = computed(() => {
127
        const resourceToSave = computed(() => {
122
            return (
128
            return (
Lines 139-144 export default { Link Here
139
                    props.instancedResource.idAttr
145
                    props.instancedResource.idAttr
140
                ]
146
                ]
141
            ) {
147
            ) {
148
                editMode.value = true
142
                props.instancedResource.getResource(
149
                props.instancedResource.getResource(
143
                    props.instancedResource.route.params[
150
                    props.instancedResource.route.params[
144
                        props.instancedResource.idAttr
151
                        props.instancedResource.idAttr
Lines 158-164 export default { Link Here
158
        const saveAndNavigate = ($event, resourceToSave) => {
165
        const saveAndNavigate = ($event, resourceToSave) => {
159
            const { components, navigationOnFormSave, onFormSave, router, idAttr } = props.instancedResource
166
            const { components, navigationOnFormSave, onFormSave, router, idAttr } = props.instancedResource
160
            // Default to show
167
            // Default to show
161
            const navigationAction = navigationOnFormSave || components.show
168
            const navigationAction = saveOptionSelected.value || navigationOnFormSave || components.show
162
            const idParamRequired = navigationAction === components.show || navigationAction === components.edit
169
            const idParamRequired = navigationAction === components.show || navigationAction === components.edit
163
            onFormSave($event, resourceToSave).then(resource => {
170
            onFormSave($event, resourceToSave).then(resource => {
164
                if(resource) {
171
                if(resource) {
Lines 173-184 export default { Link Here
173
                }
180
                }
174
            })
181
            })
175
        }
182
        }
183
184
        const saveOptionSelected = ref(props.instancedResource.navigationOnFormSave)
185
        const dropdownButtons = computed(() => {
186
            const { components, navigationOnFormSave } = props.instancedResource
187
188
            const buttonOptions = {
189
                list: {
190
                    title: $__("%s and return to list").format(buttonTextLeader.value),
191
                    action: "submit",
192
                    cssClass: "btn btn-default",
193
                    callback: () => {
194
                        saveOptionSelected.value = components.list
195
                    }
196
                },
197
                show: {
198
                    title: $__("%s and show").format(buttonTextLeader.value),
199
                    action: "submit",
200
                    cssClass: "btn btn-default",
201
                    callback: () => {
202
                        saveOptionSelected.value = components.show
203
                    }
204
                },
205
                edit: {
206
                    title: $__("%s and continue editing").format(buttonTextLeader.value),
207
                    action: "submit",
208
                    cssClass: "btn btn-default",
209
                    callback: () => {
210
                        saveOptionSelected.value = components.edit
211
                    }
212
                }
213
            }
214
            return Object.keys(buttonOptions).reduce((acc, key) => {
215
                if(key === "show" && !navigationOnFormSave) return acc
216
                if(components[key] === navigationOnFormSave) return acc
217
                return [buttonOptions[key], ...acc]
218
            },[])
219
        })
220
176
        return {
221
        return {
177
            initialized,
222
            initialized,
178
            resource,
223
            resource,
179
            resourceToSave,
224
            resourceToSave,
180
            resourceForm,
225
            resourceForm,
181
            saveAndNavigate
226
            saveAndNavigate,
227
            editMode,
228
            dropdownButtons,
229
            buttonTextLeader
182
        };
230
        };
183
    },
231
    },
184
    props: {
232
    props: {
Lines 189-194 export default { Link Here
189
        FormElement,
237
        FormElement,
190
        TabsWrapper,
238
        TabsWrapper,
191
        AccordionWrapper,
239
        AccordionWrapper,
240
        DropdownButtons
192
    },
241
    },
193
    name: "ResourceFormSave",
242
    name: "ResourceFormSave",
194
};
243
};
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue (-4 / +1 lines)
Lines 1-5 Link Here
1
<template>
1
<template>
2
    <ButtonSubmit v-if="form" v-bind="$props" />
2
    <ButtonSubmit v-if="action === 'submit'" v-bind="$props" />
3
    <Link v-else v-bind="$props" />
3
    <Link v-else v-bind="$props" />
4
</template>
4
</template>
5
5
Lines 35-43 export default { Link Here
35
            default: "btn btn-default",
35
            default: "btn btn-default",
36
            required: false,
36
            required: false,
37
        },
37
        },
38
        form: {
39
            type: Object,
40
        },
41
    },
38
    },
42
    name: "Toolbar",
39
    name: "Toolbar",
43
};
40
};
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorResource.vue (-2 / +4 lines)
Lines 37-43 export default { Link Here
37
                    {
37
                    {
38
                        title: $__("Save"),
38
                        title: $__("Save"),
39
                        icon: "save",
39
                        icon: "save",
40
                        form: componentData.resourceForm,
40
                        callback: () => {
41
                            componentData.resourceForm.value.requestSubmit()
42
                        },
43
                        cssClass: "btn btn-primary"
41
                    },
44
                    },
42
                    {
45
                    {
43
                        to: {
46
                        to: {
44
- 

Return to bug 40191