From a96854063508d39c6808525430622d1b33234c2c Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 14 Mar 2024 13:06:02 +0100 Subject: [PATCH] refactor: #6993 set default QTable pagination, created quasar.defaults for standards --- quasar.config.js | 2 +- src/boot/defaults/qTable.js | 5 +++++ src/boot/{setDefaults.js => defaults/setDefault.js} | 8 ++------ src/boot/quasar.defaults.js | 1 + 4 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 src/boot/defaults/qTable.js rename src/boot/{setDefaults.js => defaults/setDefault.js} (71%) create mode 100644 src/boot/quasar.defaults.js diff --git a/quasar.config.js b/quasar.config.js index aa42e19eb..c8bae3105 100644 --- a/quasar.config.js +++ b/quasar.config.js @@ -29,7 +29,7 @@ module.exports = configure(function (/* ctx */) { // app boot file (/src/boot) // --> boot files are part of "main.js" // https://v2.quasar.dev/quasar-cli/boot-files - boot: ['i18n', 'axios', 'vnDate', 'validations', 'setDefaults'], + boot: ['i18n', 'axios', 'vnDate', 'validations', 'quasar.defaults'], // https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css css: ['app.scss'], diff --git a/src/boot/defaults/qTable.js b/src/boot/defaults/qTable.js new file mode 100644 index 000000000..4adc5b1c3 --- /dev/null +++ b/src/boot/defaults/qTable.js @@ -0,0 +1,5 @@ +import { QTable } from 'quasar'; +import setDefault from './setDefault'; + +setDefault(QTable, 'pagination', { rowsPerPage: 25 }); +setDefault(QTable, 'hidePagination', true); diff --git a/src/boot/setDefaults.js b/src/boot/defaults/setDefault.js similarity index 71% rename from src/boot/setDefaults.js rename to src/boot/defaults/setDefault.js index a5e8c057d..7d56a1a3e 100644 --- a/src/boot/setDefaults.js +++ b/src/boot/defaults/setDefault.js @@ -1,6 +1,4 @@ -import { QTable } from 'quasar'; - -const setDefault = (component, key, value) => { +export default function (component, key, value) { const prop = component.props[key]; switch (typeof prop) { case 'object': @@ -17,6 +15,4 @@ const setDefault = (component, key, value) => { default: throw new Error('unhandled type: ' + typeof prop); } -}; -setDefault(QTable, 'pagination', { rowsPerPage: 25 }); -setDefault(QTable, 'hidePagination', true); +} diff --git a/src/boot/quasar.defaults.js b/src/boot/quasar.defaults.js new file mode 100644 index 000000000..c792100d7 --- /dev/null +++ b/src/boot/quasar.defaults.js @@ -0,0 +1 @@ +export * from './defaults/qTable';