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:
parent
4544f8833a
commit
e5f172feb8
|
|
@ -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($) {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue