From e203a7d2298fe8da4d8c1cc2e4d939d74e9ae722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Wed, 13 Sep 2023 10:03:41 +0200 Subject: [PATCH] Refaktoring --- quasar.config.js | 1 + .../flights/form/FlightFormBasic.vue | 23 +- src/components/inputs/ComboboxInput.vue | 9 +- src/components/inputs/DatetimePicker.vue | 78 +++-- .../{flights => photos}/PhotoCarousel.vue | 0 src/components/photos/PhotoDetail.vue | 280 ++++++++++-------- src/components/photos/PhotosList.vue | 72 +++-- src/composables/datetimeUtils.js | 5 +- src/composables/photos/batchEdit.js | 44 +-- src/graphql/fragments/photo.js | 1 + src/pages/profile/flight/EditFlightPage.vue | 66 +++-- src/pages/profile/flight/FlightDetailPage.vue | 2 +- src/pages/public/FlightDetailPage.vue | 2 +- src/router/index.js | 6 +- 14 files changed, 347 insertions(+), 242 deletions(-) rename src/components/{flights => photos}/PhotoCarousel.vue (100%) diff --git a/quasar.config.js b/quasar.config.js index ad05f7d..e41d375 100644 --- a/quasar.config.js +++ b/quasar.config.js @@ -98,6 +98,7 @@ module.exports = configure(function (ctx) { // https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework framework: { config: {}, + cssAddon: true, iconSet: 'mdi-v6', // Quasar icon set // lang: 'cs-CZ', // Quasar language pack diff --git a/src/components/flights/form/FlightFormBasic.vue b/src/components/flights/form/FlightFormBasic.vue index d53348b..6fdf84a 100644 --- a/src/components/flights/form/FlightFormBasic.vue +++ b/src/components/flights/form/FlightFormBasic.vue @@ -24,6 +24,11 @@ const props = defineProps({ isRequestPending, }); +const airportName = (airport) => `${airport.icaoCode} (${airport.name})`; + +const airports = computed(() => props.airports.map(a => ({id: a.id, name: airportName(a)}))); +const aircrafts = computed(() => props.aircrafts.map(a => ({id: a.id, name: a.callSign}))); + const formData = reactive({ aircraft: null, takeoffAirport: null, @@ -43,19 +48,15 @@ const rules = { landingDatetime: [isRequired], landingAirport: [isRequired], }; + watch(() => props.flight, (newVal) => { if (newVal) { setDefaultData(formData, newVal); formData.aircraft = {id: newVal.aircraft.id, name: newVal.aircraft.callSign}; - formData.takeoffAirport = {id: newVal.takeoffAirport.id, name: newVal.takeoffAirport.name} - formData.landingAirport = {id: newVal.landingAirport.id, name: newVal.landingAirport.name} + formData.takeoffAirport = {id: newVal.takeoffAirport.id, name: airportName(newVal.takeoffAirport)} + formData.landingAirport = {id: newVal.landingAirport.id, name: airportName(newVal.landingAirport)} } }, {immediate: true}); - -const aircrafts = computed(() => { - return props.aircrafts.map(a => ({id: a.id, name: a.callSign})); -}); - watch(() => formData.takeoffDatetime, () => { if (!formData.landingDatetime) { formData.landingDatetime = structuredClone(formData.takeoffDatetime); @@ -73,7 +74,7 @@ watch(() => formData.takeoffAirport, () => {
- +
Vyber letadlo
@@ -92,7 +93,7 @@ watch(() => formData.takeoffAirport, () => {
- +
Vzlet
@@ -110,7 +111,6 @@ watch(() => formData.takeoffAirport, () => { v-model="formData.takeoffAirport" label="Letiště vzletu" v-bind="commonProps" - :enable-new-values="false" />
@@ -118,7 +118,7 @@ watch(() => formData.takeoffAirport, () => {
- +
Přistání
@@ -137,7 +137,6 @@ watch(() => formData.takeoffAirport, () => { label="Letiště přistání" v-bind="commonProps" :rules="rules.landingAirport" - :enable-new-values="false" />
diff --git a/src/components/inputs/ComboboxInput.vue b/src/components/inputs/ComboboxInput.vue index daa46f8..55caf4c 100644 --- a/src/components/inputs/ComboboxInput.vue +++ b/src/components/inputs/ComboboxInput.vue @@ -10,11 +10,6 @@ const props = defineProps({ required: false, default: () => [] }, - enableNewValues: { - type: Boolean, - required: false, - default: true, - }, options: { type: Array, required: true, @@ -101,11 +96,11 @@ const filterFn = (val, update, abort) => { :options="availableOptions" :option-label="optionLabel" :option-value="optionValue" - :new-value-mode="enableNewValues ? 'add' : 'toggle'" + new-value-mode="add" clear-icon="clear" :v-bind="$attrs" > -