@@ -, +, @@
Removed FormConfirmDelete component and routes
---
.../ERM/LicensesFormConfirmDelete.vue | 77 -------------------
.../js/vue/components/ERM/LicensesList.vue | 40 +++++++++-
.../js/vue/components/ERM/LicensesShow.vue | 37 ++++++++-
.../intranet-tmpl/prog/js/vue/routes/erm.js | 12 ---
4 files changed, 70 insertions(+), 96 deletions(-)
delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormConfirmDelete.vue
--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormConfirmDelete.vue
+++ a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormConfirmDelete.vue
@@ -1,77 +0,0 @@
-
- {{ $__("Loading") }}
-
-
{{ $__("Delete license") }}
-
-
-
-
-
--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue
+++ a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue
@@ -26,6 +26,8 @@ export default {
const AVStore = inject("AVStore")
const { get_lib_from_av, map_av_dt_filter } = AVStore
+ const { setConfirmationDialog, setMessage } = inject("mainStore")
+
const table_id = "license_list"
useDataTable(table_id)
@@ -34,6 +36,8 @@ export default {
get_lib_from_av,
map_av_dt_filter,
table_id,
+ setConfirmationDialog,
+ setMessage,
}
},
data: function () {
@@ -64,8 +68,34 @@ export default {
edit_license: function (license_id) {
this.$router.push("/cgi-bin/koha/erm/licenses/edit/" + license_id)
},
- delete_license: function (license_id) {
- this.$router.push("/cgi-bin/koha/erm/licenses/delete/" + license_id)
+ delete_license: function (license_id, license_name) {
+ this.setConfirmationDialog(
+ {
+ title: this.$__(
+ "Are you sure you want to remove this license?"
+ ),
+ message: license_name,
+ accept_label: this.$__("Yes, delete"),
+ cancel_label: this.$__("No, do not delete"),
+ },
+ () => {
+ const client = APIClient.erm
+ client.licenses.delete(license_id).then(
+ success => {
+ this.setMessage(
+ this.$__("License %s deleted").format(
+ license_name
+ )
+ )
+ $("#" + this.table_id)
+ .DataTable()
+ .ajax.url("/api/v1/erm/licenses")
+ .draw()
+ },
+ error => {}
+ )
+ }
+ )
},
build_datatable: function () {
let show_license = this.show_license
@@ -203,6 +233,7 @@ export default {
function (index, e) {
let tr = $(this).parent().parent()
let license_id = api.row(tr).data().license_id
+ let license_name = api.row(tr).data().name
let editButton = createVNode(
"a",
{
@@ -227,7 +258,10 @@ export default {
class: "btn btn-default btn-xs",
role: "button",
onClick: () => {
- delete_license(license_id)
+ delete_license(
+ license_id,
+ license_name
+ )
},
},
[
--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue
+++ a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue
@@ -9,11 +9,9 @@
:title="$__('Edit')"
>
-
+ >
@@ -152,6 +150,8 @@ export default {
const format_date = $date
const patron_to_html = $patron_to_html
+ const { setConfirmationDialog, setMessage } = inject("mainStore")
+
const AVStore = inject("AVStore")
const { get_lib_from_av } = AVStore
@@ -159,6 +159,8 @@ export default {
format_date,
patron_to_html,
get_lib_from_av,
+ setConfirmationDialog,
+ setMessage,
}
},
data() {
@@ -194,6 +196,32 @@ export default {
error => {}
)
},
+ delete_license: function (license_id, license_name) {
+ this.setConfirmationDialog(
+ {
+ title: this.$__(
+ "Are you sure you want to remove this license?"
+ ),
+ message: license_name,
+ accept_label: this.$__("Yes, delete"),
+ cancel_label: this.$__("No, do not delete"),
+ },
+ () => {
+ const client = APIClient.erm
+ client.licenses.delete(license_id).then(
+ success => {
+ this.setMessage(
+ this.$__("License %s deleted").format(
+ license_name
+ )
+ )
+ this.$router.push("/cgi-bin/koha/erm/licenses")
+ },
+ error => {}
+ )
+ }
+ )
+ },
},
components: {},
name: "LicensesShow",
@@ -203,6 +231,7 @@ export default {
.action_links a {
padding-left: 0.2em;
font-size: 11px;
+ cursor: pointer;
}
#license_documents ul {
padding-left: 0px;
--- a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/erm.js
+++ a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/erm.js
@@ -19,7 +19,6 @@ import EHoldingsEBSCOTitlesShow from "../components/ERM/EHoldingsEBSCOTitlesShow
import LicensesList from "../components/ERM/LicensesList.vue";
import LicensesShow from "../components/ERM/LicensesShow.vue";
import LicensesFormAdd from "../components/ERM/LicensesFormAdd.vue";
-import LicensesFormConfirmDelete from "../components/ERM/LicensesFormConfirmDelete.vue";
const breadcrumbs = {
home: {
@@ -470,17 +469,6 @@ export const routes = [
),
},
},
- {
- path: "delete/:license_id",
- component: LicensesFormConfirmDelete,
- meta: {
- breadcrumb: () =>
- build_breadcrumb(
- breadcrumb_paths.licenses,
- "Delete license" // $t("Delete license")
- ),
- },
- },
{
path: "add",
component: LicensesFormAdd,
--