From 8ce1f7b97a6b488af922958aa207c991cf795fb4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 5 May 2025 10:57:41 +0200 Subject: [PATCH] Bug 38010: Restore ordering on the contracts table --- .../components/Vendors/VendorContracts.vue | 131 ++++++++---------- 1 file changed, 59 insertions(+), 72 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorContracts.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorContracts.vue index 30ac8c1f94a..c3e4da91cbd 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorContracts.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorContracts.vue @@ -39,82 +39,69 @@ export default { $.fn.dataTable.ext.search = $.fn.dataTable.ext.search.filter( search => search.name != "apply_filter" ); - $("#" + table_id).dataTable( - $.extend(true, {}, dataTablesDefaults, { - data: contracts, - embed: [], - ordering: false, - dom: '<<"table_entries">>', - aLengthMenu: [ - [10, 20, 50, 100], - [10, 20, 50, 100], - ], - autoWidth: false, - columns: [ - { - title: __("Name"), - data: "contractname", - searchable: false, - orderable: false, - render: function (data, type, row, meta) { - return ( - `` + - escape_str(row.contractname) + - "" - ); - }, + $("#" + table_id).kohaTable({ + data: contracts, + embed: [], + dom: '<<"table_entries">>', + autoWidth: false, + columns: [ + { + title: __("Name"), + data: "contractname", + render: function (data, type, row, meta) { + return ( + `` + + escape_str(row.contractname) + + "" + ); }, - { - title: __("Description"), - data: "contractdescription", - searchable: false, - orderable: false, + }, + { + title: __("Description"), + data: "contractdescription", + }, + { + title: __("Start date"), + data: "contractstartdate", + render: function (data, type, row, meta) { + return type == "sort" + ? row.contractstartdate + : format_date(row.contractstartdate); }, - { - title: __("Start date"), - data: "contractstartdate", - searchable: false, - orderable: false, - render: function (data, type, row, meta) { - return format_date(row.contractstartdate); - }, + }, + { + title: __("End date"), + data: "contractenddate", + render: function (data, type, row, meta) { + return type == "sort" + ? row.contractenddate + : format_date(row.contractenddate); }, - { - title: __("End date"), - data: "contractenddate", - searchable: false, - orderable: false, - render: function (data, type, row, meta) { - return format_date(row.contractenddate); - }, - }, - ...(isUserPermitted( - "CAN_user_acquisition_contracts_manage" - ) - ? [ - { - title: __("Actions"), - data: "contractnumber", - searchable: false, - orderable: false, - render: function (data, type, row, meta) { - return ( - `` + - " " + - __("Edit") + - "" + - `` + - " " + - __("Delete") + - "" - ); - }, + }, + ...(isUserPermitted("CAN_user_acquisition_contracts_manage") + ? [ + { + title: __("Actions"), + data: "contractnumber", + searchable: false, + orderable: false, + render: function (data, type, row, meta) { + return ( + `` + + " " + + __("Edit") + + "" + + `` + + " " + + __("Delete") + + "" + ); }, - ] - : []), - ], - }) - ); + }, + ] + : []), + ], + }); }, }, mounted() { -- 2.34.1