Skip to content

Commit

Permalink
refactor: rename dialog components (Location, Barcode)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Apr 10, 2024
1 parent ccb531e commit c9d4587
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 75 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
65 changes: 31 additions & 34 deletions src/views/AddPriceMultiple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
{{ getNominatimLocationTitle(location, true, true, true) }}
</v-chip>
<br v-if="recentLocations.length" />
<v-btn class="mb-2" size="small" prepend-icon="mdi-magnify" @click="showLocationSelector">{{ $t('AddPriceSingle.WhereWhen.Find') }}</v-btn>
<v-btn class="mb-2" size="small" prepend-icon="mdi-magnify" @click="showLocationSelectorDialog">{{ $t('AddPriceSingle.WhereWhen.Find') }}</v-btn>
<p v-if="!locationFormFilled" class="text-red mb-2"><i>{{ $t('AddPriceSingle.WhereWhen.SelectLocation') }}</i></p>

<h3 class="mt-4 mb-1">{{ $t('AddPriceSingle.WhereWhen.Date') }}</h3>
Expand Down Expand Up @@ -166,8 +166,8 @@
</v-item-group>
</h3>
<v-sheet v-if="productMode === 'barcode'">
<v-btn class="mb-2 mr-2" size="small" prepend-icon="mdi-barcode-scan" @click="showBarcodeScanner">{{ $t('AddPriceSingle.ProductInfo.ScanBarcode') }}</v-btn>
<a href="#" @click.prevent="showBarcodeManualInput">{{ $t('AddPriceSingle.ProductInfo.TypeBarcode') }}</a>
<v-btn class="mb-2 mr-2" size="small" prepend-icon="mdi-barcode-scan" @click="showBarcodeScannerDialog">{{ $t('AddPriceSingle.ProductInfo.ScanBarcode') }}</v-btn>
<a href="#" @click.prevent="showBarcodeManualInputDialog">{{ $t('AddPriceSingle.ProductInfo.TypeBarcode') }}</a>
<v-text-field
v-if="dev"
:prepend-inner-icon="productBarcodeFormFilled ? 'mdi-barcode' : 'mdi-barcode-scan'"
Expand All @@ -176,7 +176,7 @@
type="text"
hint="EAN"
hide-details="auto"
@click:prepend="showBarcodeScanner"
@click:prepend="showBarcodeScannerDialog"
></v-text-field>
<ProductCard v-if="product" class="mb-4" :product="product" :readonly="true" elevation="1"></ProductCard>
</v-sheet>
Expand Down Expand Up @@ -284,24 +284,24 @@
:timeout="2000"
>{{ $t('AddPriceMultiple.ProductPriceDetails.PriceUploaded') }}</v-snackbar>

<LocationSelector
v-if="locationSelector"
v-model="locationSelector"
<LocationSelectorDialog
v-if="locationSelectorDialog"
v-model="locationSelectorDialog"
@location="setLocationData($event)"
@close="closeLocationSelector($event)"
></LocationSelector>
<BarcodeScanner
v-if="barcodeScanner"
v-model="barcodeScanner"
@close="locationSelectorDialog = false"
></LocationSelectorDialog>
<BarcodeScannerDialog
v-if="barcodeScannerDialog"
v-model="barcodeScannerDialog"
@barcode="setProductCode($event)"
@close="barcodeScanner = false"
></BarcodeScanner>
<BarcodeManualInput
v-if="barcodeManualInput"
v-model="barcodeManualInput"
@close="barcodeScannerDialog = false"
></BarcodeScannerDialog>
<BarcodeManualInputDialog
v-if="barcodeManualInputDialog"
v-model="barcodeManualInputDialog"
@barcode="setProductCode($event)"
@close="barcodeManualInput = false"
></BarcodeManualInput>
@close="barcodeManualInputDialog = false"
></BarcodeManualInputDialog>
<UserRecentProofsDialog
v-if="userRecentProofsDialog"
v-model="userRecentProofsDialog"
Expand All @@ -328,12 +328,12 @@ Compressor.setDefaults({
export default {
components: {
'LocationSelector': defineAsyncComponent(() => import('../components/LocationSelector.vue')),
'LocationSelector': defineAsyncComponent(() => import('../components/LocationSelectorDialog.vue')),
'PriceInputRow': defineAsyncComponent(() => import('../components/PriceInputRow.vue')),
'PriceCard': defineAsyncComponent(() => import('../components/PriceCard.vue')),
'ProductCard': defineAsyncComponent(() => import('../components/ProductCard.vue')),
'BarcodeScanner': defineAsyncComponent(() => import('../components/BarcodeScanner.vue')),
'BarcodeManualInput': defineAsyncComponent(() => import('../components/BarcodeManualInput.vue')),
'BarcodeScanner': defineAsyncComponent(() => import('../components/BarcodeScannerDialog.vue')),
'BarcodeManualInputDialog': defineAsyncComponent(() => import('../components/BarcodeManualInputDialog.vue')),
'UserRecentProofsDialog': defineAsyncComponent(() => import('../components/UserRecentProofsDialog.vue')),
},
data() {
Expand All @@ -360,7 +360,7 @@ export default {
proofSelectedSuccessMessage: false,
proofisSelected: false,
// location data
locationSelector: false,
locationSelectorDialog: false,
locationSelectedDisplayName: '',
// product price data
productPriceUploadedList: [],
Expand All @@ -385,8 +385,8 @@ export default {
categoryTags: [], // list of category tags for autocomplete // see initPriceMultipleForm
originTags: [], // list of origins tags for autocomplete // see initPriceMultipleForm
labelsTags: LabelsTags,
barcodeScanner: false,
barcodeManualInput: false,
barcodeScannerDialog: false,
barcodeManualInputDialog: false,
categoryPricePerList: [
{key: 'KILOGRAM', value: this.$t('AddPriceSingle.CategoryPricePer.PerKg'), icon: 'mdi-weight-kilogram'},
{key: 'UNIT', value: this.$t('AddPriceSingle.CategoryPricePer.PerUnit'), icon: 'mdi-numeric-1-circle'}
Expand Down Expand Up @@ -535,11 +535,8 @@ export default {
this.proofImagePreview = null
this.addPriceMultipleForm.proof_id = null
},
showLocationSelector() {
this.locationSelector = true
},
closeLocationSelector(event) {
this.locationSelector = false
showLocationSelectorDialog() {
this.locationSelectorDialog = true
},
getNominatimLocationTitle(location, withName=true, withRoad=false, withCity=true) {
return utils.getLocationTitle(location, withName, withRoad, withCity)
Expand All @@ -553,11 +550,11 @@ export default {
isSelectedLocation(location) {
return this.locationSelectedDisplayName && this.locationSelectedDisplayName === location.display_name
},
showBarcodeScanner() {
this.barcodeScanner = true
showBarcodeScannerDialog() {
this.barcodeScannerDialog = true
},
showBarcodeManualInput() {
this.barcodeManualInput = true
showBarcodeManualInputDialog() {
this.barcodeManualInputDialog = true
},
setProductCode(code) {
this.productPriceForm.product_code = code
Expand Down
62 changes: 31 additions & 31 deletions src/views/AddPriceSingle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
</v-item-group>
</h3>
<v-sheet v-if="productMode === 'barcode'">
<v-btn class="mb-2 mr-2" size="small" prepend-icon="mdi-barcode-scan" @click="showBarcodeScanner">
<v-btn class="mb-2 mr-2" size="small" prepend-icon="mdi-barcode-scan" @click="showBarcodeScannerDialog">
<span class="d-sm-none">{{ $t('AddPriceSingle.ProductInfo.Scan') }}</span>
<span class="d-none d-sm-inline-flex">{{ $t('AddPriceSingle.ProductInfo.ScanBarcode') }}</span>
</v-btn>
<v-btn class="mb-2" size="small" prepend-icon="mdi-numeric" @click.prevent="showBarcodeManualInput">
<v-btn class="mb-2" size="small" prepend-icon="mdi-numeric" @click.prevent="showBarcodeManualInputDialog">
<span class="d-sm-none">{{ $t('AddPriceSingle.ProductInfo.Type') }}</span>
<span class="d-none d-sm-inline-flex">{{ $t('AddPriceSingle.ProductInfo.TypeBarcode') }}</span>
</v-btn>
Expand All @@ -45,7 +45,7 @@
type="text"
hint="EAN"
hide-details="auto"
@click:prepend-inner="showBarcodeScanner"
@click:prepend-inner="showBarcodeScannerDialog"
></v-text-field>
<ProductCard v-if="product" class="mb-4" :product="product" :readonly="true" elevation="1"></ProductCard>
</v-sheet>
Expand Down Expand Up @@ -185,7 +185,7 @@
{{ getNominatimLocationTitle(location, true, true, true) }}
</v-chip>
<br v-if="recentLocations.length" />
<v-btn class="mb-2" size="small" prepend-icon="mdi-magnify" @click="showLocationSelector">{{ $t('AddPriceSingle.WhereWhen.Find') }}</v-btn>
<v-btn class="mb-2" size="small" prepend-icon="mdi-magnify" @click="showLocationSelectorDialog">{{ $t('AddPriceSingle.WhereWhen.Find') }}</v-btn>
<p v-if="!locationFormFilled" class="text-red mb-2"><i>{{ $t('AddPriceSingle.WhereWhen.SelectLocation') }}</i></p>

<h3 class="mt-4 mb-1">{{ $t('AddPriceSingle.WhereWhen.Date') }}</h3>
Expand Down Expand Up @@ -231,24 +231,24 @@
:timeout="2000"
>{{ $t('AddPriceSingle.PriceDetails.ProofSelected') }}</v-snackbar>

<BarcodeScanner
v-if="barcodeScanner"
v-model="barcodeScanner"
<BarcodeScannerDialog
v-if="barcodeScannerDialog"
v-model="barcodeScannerDialog"
@barcode="setProductCode($event)"
@close="barcodeScanner = false"
></BarcodeScanner>
<BarcodeManualInput
v-if="barcodeManualInput"
v-model="barcodeManualInput"
@close="barcodeScannerDialog = false"
></BarcodeScannerDialog>
<BarcodeManualInputDialog
v-if="barcodeManualInputDialog"
v-model="barcodeManualInputDialog"
@barcode="setProductCode($event)"
@close="barcodeManualInput = false"
></BarcodeManualInput>
<LocationSelector
v-if="locationSelector"
v-model="locationSelector"
@close="barcodeManualInputDialog = false"
></BarcodeManualInputDialog>
<LocationSelectorDialog
v-if="locationSelectorDialog"
v-model="locationSelectorDialog"
@location="setLocationData($event)"
@close="locationSelector = false"
></LocationSelector>
@close="locationSelectorDialog = false"
></LocationSelectorDialog>
<UserRecentProofsDialog
v-if="userRecentProofsDialog"
v-model="userRecentProofsDialog"
Expand Down Expand Up @@ -279,9 +279,9 @@ export default {
components: {
'PriceInputRow': defineAsyncComponent(() => import('../components/PriceInputRow.vue')),
'ProductCard': defineAsyncComponent(() => import('../components/ProductCard.vue')),
'BarcodeScanner': defineAsyncComponent(() => import('../components/BarcodeScanner.vue')),
'BarcodeManualInput': defineAsyncComponent(() => import('../components/BarcodeManualInput.vue')),
'LocationSelector': defineAsyncComponent(() => import('../components/LocationSelector.vue')),
'BarcodeScannerDialog': defineAsyncComponent(() => import('../components/BarcodeScannerDialog.vue')),
'BarcodeManualInputDialog': defineAsyncComponent(() => import('../components/BarcodeManualInputDialog.vue')),
'LocationSelectorDialog': defineAsyncComponent(() => import('../components/LocationSelectorDialog.vue')),
'UserRecentProofsDialog': defineAsyncComponent(() => import('../components/UserRecentProofsDialog.vue')),
},
data() {
Expand Down Expand Up @@ -314,10 +314,10 @@ export default {
categoryTags: [], // list of category tags for autocomplete // see initPriceSingleForm
originTags: [], // list of origins tags for autocomplete // see initPriceSingleForm
labelsTags: LabelsTags,
barcodeScanner: false,
barcodeManualInput: false,
barcodeScannerDialog: false,
barcodeManualInputDialog: false,
// location data
locationSelector: false,
locationSelectorDialog: false,
locationSelectedDisplayName: '',
// proof data
userRecentProofsDialog: false,
Expand Down Expand Up @@ -475,11 +475,11 @@ export default {
this.proofImagePreview = null
this.addPriceSingleForm.proof_id = null
},
showBarcodeScanner() {
this.barcodeScanner = true
showBarcodeScannerDialog() {
this.barcodeScannerDialog = true
},
showBarcodeManualInput() {
this.barcodeManualInput = true
showBarcodeManualInputDialog() {
this.barcodeManualInputDialog = true
},
setProductCode(code) {
this.addPriceSingleForm.product_code = code
Expand All @@ -494,8 +494,8 @@ export default {
alert("Error: Open Prices server error")
})
},
showLocationSelector() {
this.locationSelector = true
showLocationSelectorDialog() {
this.locationSelectorDialog = true
},
getNominatimLocationTitle(location, withName=true, withRoad=false, withCity=true) {
return utils.getLocationTitle(location, withName, withRoad, withCity)
Expand Down
20 changes: 10 additions & 10 deletions src/views/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
inputmode="numeric"
:prepend-inner-icon="formFilled ? 'mdi-barcode' : 'mdi-barcode-scan'"
append-inner-icon="mdi-magnify"
@click:prepend-inner="showBarcodeScanner"
@click:prepend-inner="showBarcodeScannerDialog"
@click:append-inner="search"
:rules="[fieldRequired]"
:loading="loading"
Expand All @@ -34,12 +34,12 @@
</v-col>
</v-row>

<BarcodeScanner
v-if="barcodeScanner"
v-model="barcodeScanner"
<BarcodeScannerDialog
v-if="barcodeScannerDialog"
v-model="barcodeScannerDialog"
@barcode="setProductCode($event)"
@close="barcodeScanner = false"
></BarcodeScanner>
@close="barcodeScannerDialog = false"
></BarcodeScannerDialog>
</template>

<script>
Expand All @@ -49,7 +49,7 @@ import api from '../services/api'
export default {
components: {
'ProductCard': defineAsyncComponent(() => import('../components/ProductCard.vue')),
'BarcodeScanner': defineAsyncComponent(() => import('../components/BarcodeScanner.vue'))
'BarcodeScannerDialog': defineAsyncComponent(() => import('../components/BarcodeScannerDialog.vue'))
},
data() {
return {
Expand All @@ -60,7 +60,7 @@ export default {
productTotal: null,
loading: false,
// barcode scanner
barcodeScanner: false,
barcodeScannerDialog: false,
}
},
computed: {
Expand All @@ -72,8 +72,8 @@ export default {
fieldRequired(v) {
return !!v
},
showBarcodeScanner() {
this.barcodeScanner = true
showBarcodeScannerDialog() {
this.barcodeScannerDialog = true
},
setProductCode(code) {
this.productSearchForm.q = code
Expand Down

0 comments on commit c9d4587

Please sign in to comment.