routie dev init since i didn't adhere to any proper guidance up until now
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
// Utilities
|
||||
import { watch } from 'vue';
|
||||
import { deepEqual, getCurrentInstance } from "../../../util/index.js"; // Types
|
||||
export function useOptions({
|
||||
page,
|
||||
itemsPerPage,
|
||||
sortBy,
|
||||
groupBy,
|
||||
search
|
||||
}) {
|
||||
const vm = getCurrentInstance('VDataTable');
|
||||
const options = () => ({
|
||||
page: page.value,
|
||||
itemsPerPage: itemsPerPage.value,
|
||||
sortBy: sortBy.value,
|
||||
groupBy: groupBy.value,
|
||||
search: search.value
|
||||
});
|
||||
let oldOptions = null;
|
||||
watch(options, value => {
|
||||
if (deepEqual(oldOptions, value)) return;
|
||||
|
||||
// Reset page when searching
|
||||
if (oldOptions && oldOptions.search !== value.search) {
|
||||
page.value = 1;
|
||||
}
|
||||
vm.emit('update:options', value);
|
||||
oldOptions = value;
|
||||
}, {
|
||||
deep: true,
|
||||
immediate: true
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=options.js.map
|
||||
Reference in New Issue
Block a user