Bug 38201: [PoC] DRY ToolbarButton
This is only a PoC applied to Agreements for discussion. This is a continuation of bug 37274. Bug 37274 applied the ToolbarButton to missing components but it was mostly replacing WET for WET. This is DRYer: - All mark-up related to toolbar buttons is now written once (css class, icons, elements) - All labels are now written once (except 'Add' for translatability) 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
a3299492f9
commit
013a588f71
|
|
@ -3,8 +3,8 @@
|
|||
<div v-else id="agreements_list">
|
||||
<Toolbar v-if="!embedded">
|
||||
<ToolbarButton
|
||||
:to="{ name: 'AgreementsFormAdd' }"
|
||||
icon="plus"
|
||||
type="add"
|
||||
@add-clicked="add_agreement"
|
||||
:title="$__('New agreement')"
|
||||
/>
|
||||
</Toolbar>
|
||||
|
|
@ -222,6 +222,11 @@ export default {
|
|||
});
|
||||
});
|
||||
},
|
||||
add_agreement: function () {
|
||||
this.$router.push({
|
||||
name: "AgreementsFormAdd",
|
||||
});
|
||||
},
|
||||
doShow: function ({ agreement_id }, dt, event) {
|
||||
event.preventDefault();
|
||||
this.$router.push({
|
||||
|
|
|
|||
|
|
@ -2,21 +2,8 @@
|
|||
<div v-if="!initialized">{{ $__("Loading") }}</div>
|
||||
<div v-else id="agreements_show">
|
||||
<Toolbar>
|
||||
<ToolbarButton
|
||||
:to="{
|
||||
name: 'AgreementsFormAddEdit',
|
||||
params: { agreement_id: agreement.agreement_id },
|
||||
}"
|
||||
icon="pencil"
|
||||
:title="$__('Edit')"
|
||||
/>
|
||||
<a
|
||||
@click="
|
||||
delete_agreement(agreement.agreement_id, agreement.name)
|
||||
"
|
||||
class="btn btn-default"
|
||||
><font-awesome-icon icon="trash" /> {{ $__("Delete") }}</a
|
||||
>
|
||||
<ToolbarButton type="edit" @edit-clicked="edit_agreement" />
|
||||
<ToolbarButton type="delete" @delete-clicked="delete_agreement" />
|
||||
</Toolbar>
|
||||
|
||||
<h2>
|
||||
|
|
@ -406,7 +393,16 @@ export default {
|
|||
error => {}
|
||||
);
|
||||
},
|
||||
delete_agreement: function (agreement_id, agreement_name) {
|
||||
edit_agreement: function () {
|
||||
this.$router.push({
|
||||
name: "AgreementsFormAddEdit",
|
||||
params: { agreement_id: this.agreement.agreement_id },
|
||||
});
|
||||
},
|
||||
delete_agreement: function () {
|
||||
let agreement_id = this.agreement.agreement_id;
|
||||
let agreement_name = this.agreement.name;
|
||||
|
||||
this.setConfirmationDialog(
|
||||
{
|
||||
title: this.$__(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,13 @@
|
|||
<template>
|
||||
<a v-if="type === 'add'" @click="click_add" class="btn btn-default"
|
||||
><font-awesome-icon icon="plus" /> {{ title }}</a
|
||||
>
|
||||
<a v-if="type === 'delete'" @click="click_delete" class="btn btn-default"
|
||||
><font-awesome-icon icon="trash" /> {{ $__("Delete") }}</a
|
||||
>
|
||||
<a v-if="type === 'edit'" @click="click_edit" class="btn btn-default"
|
||||
><font-awesome-icon icon="pencil" /> {{ $__("Edit") }}</a
|
||||
>
|
||||
<a
|
||||
v-if="callback"
|
||||
@click="typeof callback === 'string' ? redirect() : callback(this)"
|
||||
|
|
@ -15,6 +24,10 @@
|
|||
<script>
|
||||
export default {
|
||||
props: {
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
to: {
|
||||
type: [String, Object],
|
||||
},
|
||||
|
|
@ -64,7 +77,17 @@ export default {
|
|||
}
|
||||
return url;
|
||||
},
|
||||
click_add() {
|
||||
this.$emit("add-clicked");
|
||||
},
|
||||
click_delete() {
|
||||
this.$emit("delete-clicked");
|
||||
},
|
||||
click_edit() {
|
||||
this.$emit("edit-clicked");
|
||||
},
|
||||
},
|
||||
emits: ["add-clicked", "delete-clicked", "edit-clicked"],
|
||||
name: "Link",
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ import Link from "./Link.vue";
|
|||
export default {
|
||||
components: { Link },
|
||||
props: {
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
to: {
|
||||
type: [String, Object],
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue