Bug 33484: Implement Vue KohaTable

Move up as beforeMount was called too late to init DT's options

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2024-10-03 11:59:08 +02:00 committed by Katrin Fischer
parent 4544f8833a
commit e5f172feb8
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 56 additions and 25 deletions

View File

@ -951,10 +951,8 @@ function _dt_get_saved_state( localstorage_config, columns_settings ){
columns_settings[ index ].is_hidden = stateSave_column_visibility[ index ];
}
});
return columns_settings;
} else {
return columns_settings;
}
return columns_settings;
}
(function($) {

View File

@ -31,6 +31,61 @@ export default {
included_ids,
table_settings: this.table_settings,
})
if (this.add_filters) {
this.options.orderCellsTop = true
}
if (this.table_settings) {
let columns_settings = this.table_settings["columns"]
let table_key = "DataTables_%s_%s_%s".format(
this.table_settings.module,
this.table_settings.page,
this.table_settings.table
)
let default_save_state = this.table_settings.default_save_state
let default_save_state_search =
this.table_settings.default_save_state_search
if (default_save_state) {
this.options.stateSave = true
this.options.stateSaveCallback = function (settings, data) {
if (!default_save_state_search) {
delete data.search
data.columns.forEach(c => delete c.search)
}
localStorage.setItem(table_key, JSON.stringify(data))
}
this.options.stateLoadCallback = function (settings) {
return JSON.parse(localStorage.getItem(table_key))
}
let local_settings = localStorage.getItem(table_key)
columns_settings = _dt_get_saved_state(
local_settings,
columns_settings
)
} else {
localStorage.removeItem(table_key)
}
if (
this.table_settings.hasOwnProperty("default_display_length") &&
this.table_settings.default_display_length != null
) {
this.options.pageLength =
this.table_settings.default_display_length
}
if (
this.table_settings.hasOwnProperty("default_sort_order") &&
this.table_settings.default_sort_order != null
) {
this.options.order = [
[this.table_settings.default_sort_order, "asc"],
]
}
}
return {
data: [],
tableColumns: this.columns,
@ -186,28 +241,6 @@ export default {
},
]
}
if (this.add_filters) {
this.options.orderCellsTop = true
}
if (this.table_settings) {
if (
this.table_settings.hasOwnProperty("default_display_length") &&
this.table_settings.default_display_length != null
) {
this.options.pageLength =
this.table_settings.default_display_length
}
if (
this.table_settings.hasOwnProperty("default_sort_order") &&
this.table_settings.default_sort_order != null
) {
this.options.order = [
[this.table_settings.default_sort_order, "asc"],
]
}
}
},
mounted() {
let dt = this.$refs.table.dt()