Lines 15-25
import DataTablesLib from "datatables.net"
Link Here
|
15 |
import "datatables.net-buttons" |
15 |
import "datatables.net-buttons" |
16 |
import "datatables.net-buttons/js/buttons.html5" |
16 |
import "datatables.net-buttons/js/buttons.html5" |
17 |
import "datatables.net-buttons/js/buttons.print" |
17 |
import "datatables.net-buttons/js/buttons.print" |
|
|
18 |
import "datatables.net-buttons/js/buttons.colVis" |
18 |
DataTable.use(DataTablesLib) |
19 |
DataTable.use(DataTablesLib) |
19 |
|
20 |
|
20 |
export default { |
21 |
export default { |
21 |
name: "KohaTable", |
22 |
name: "KohaTable", |
22 |
data() { |
23 |
data() { |
|
|
24 |
let hidden_ids, included_ids |
25 |
;[hidden_ids, included_ids] = _dt_visibility( |
26 |
this.table_settings, |
27 |
this.options |
28 |
) |
29 |
let buttons = _dt_buttons({ |
30 |
included_ids, |
31 |
table_settings: this.table_settings, |
32 |
}) |
23 |
return { |
33 |
return { |
24 |
data: [], |
34 |
data: [], |
25 |
tableColumns: this.columns, |
35 |
tableColumns: this.columns, |
Lines 34-42
export default {
Link Here
|
34 |
url: typeof this.url === "function" ? this.url() : this.url, |
44 |
url: typeof this.url === "function" ? this.url() : this.url, |
35 |
..._dt_default_ajax({ options: this.options }), |
45 |
..._dt_default_ajax({ options: this.options }), |
36 |
}, |
46 |
}, |
37 |
buttons: _dt_buttons({ table_settings: this.table_settings }), |
47 |
buttons, |
38 |
default_search: this.$route.query.q, |
48 |
default_search: this.$route.query.q, |
39 |
}, |
49 |
}, |
|
|
50 |
hidden_ids, |
51 |
included_ids, |
40 |
} |
52 |
} |
41 |
}, |
53 |
}, |
42 |
setup() { |
54 |
setup() { |
Lines 49-55
export default {
Link Here
|
49 |
}, |
61 |
}, |
50 |
beforeMount() { |
62 |
beforeMount() { |
51 |
if (this.actions.hasOwnProperty("-1")) { |
63 |
if (this.actions.hasOwnProperty("-1")) { |
52 |
let actions = this.actions["-1"] |
|
|
53 |
this.tableColumns = [ |
64 |
this.tableColumns = [ |
54 |
...this.tableColumns, |
65 |
...this.tableColumns, |
55 |
{ |
66 |
{ |
Lines 78-87
export default {
Link Here
|
78 |
}, |
89 |
}, |
79 |
] |
90 |
] |
80 |
} |
91 |
} |
|
|
92 |
|
93 |
$( |
94 |
".dt_button_clear_filter, .columns_controls, .export_controls, .dt_button_configure_table" |
95 |
).tooltip() |
96 |
|
97 |
if (this.add_filters) { |
98 |
this.options.orderCellsTop = true |
99 |
} |
100 |
|
101 |
if (this.table_settings) { |
102 |
if ( |
103 |
this.table_settings.hasOwnProperty("default_display_length") && |
104 |
this.table_settings.default_display_length != null |
105 |
) { |
106 |
this.options.pageLength = |
107 |
this.table_settings.default_display_length |
108 |
} |
109 |
if ( |
110 |
this.table_settings.hasOwnProperty("default_sort_order") && |
111 |
this.table_settings.default_sort_order != null |
112 |
) { |
113 |
this.options.order = [ |
114 |
[this.table_settings.default_sort_order, "asc"], |
115 |
] |
116 |
} |
117 |
} |
81 |
}, |
118 |
}, |
82 |
mounted() { |
119 |
mounted() { |
|
|
120 |
let dt = this.$refs.table.dt() |
121 |
let table_node = dt.table().node() |
122 |
if (this.add_filters) { |
123 |
_dt_add_filters(table_node, dt) |
124 |
} |
125 |
|
126 |
dt.on("column-visibility.dt", function () { |
127 |
_dt_on_visibility(this.add_filters, table_node, dt) |
128 |
}) |
129 |
.columns(this.hidden_ids) |
130 |
.visible(false) |
131 |
|
83 |
if (Object.keys(this.actions).length) { |
132 |
if (Object.keys(this.actions).length) { |
84 |
const dt = this.$refs.table.dt() |
|
|
85 |
const self = this |
133 |
const self = this |
86 |
dt.on("draw", () => { |
134 |
dt.on("draw", () => { |
87 |
const dataSet = dt.rows().data() |
135 |
const dataSet = dt.rows().data() |
Lines 137-142
export default {
Link Here
|
137 |
type: String, |
185 |
type: String, |
138 |
required: false, |
186 |
required: false, |
139 |
}, |
187 |
}, |
|
|
188 |
add_filters: { |
189 |
type: Boolean, |
190 |
required: false, |
191 |
}, |
140 |
}, |
192 |
}, |
141 |
} |
193 |
} |
142 |
</script> |
194 |
</script> |
143 |
- |
|
|