Skip to content

Commit

Permalink
Improved: naming and added checks when no data is returned from the m…
Browse files Browse the repository at this point in the history
…odal (hotwax#237)
  • Loading branch information
k2maan committed Aug 29, 2023
1 parent 7df72d1 commit 5df5c96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
15 changes: 6 additions & 9 deletions src/components/EditPickersModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<ion-row>
<ion-chip v-for="picker in selectedPickers" :key="picker.id">
<ion-label>{{ picker.name }}</ion-label>
<ion-icon :icon="closeCircle" @click="removePicker(picker.id)" />
<ion-icon :icon="closeCircle" @click="updateSelectedPickers(picker.id)" />
</ion-chip>
</ion-row>

Expand All @@ -25,7 +25,7 @@
{{ 'No picker found' }}
</div>
<div v-else>
<ion-item v-for="(picker, index) in pickers" :key="index" @click="selectPicker(picker.id)">
<ion-item v-for="(picker, index) in pickers" :key="index" @click="updateSelectedPickers(picker.id)">
<ion-label>
{{ picker.name }}
<p>{{ picker.externalId ? picker.externalId : picker.id }}</p>
Expand All @@ -35,7 +35,7 @@
</div>
</ion-list>
<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button :disabled="evaluateSelectedPickers()" @click="confirmSave()">
<ion-fab-button :disabled="arePickersSelected()" @click="confirmSave()">
<ion-icon :icon="saveOutline" />
</ion-fab-button>
</ion-fab>
Expand Down Expand Up @@ -109,18 +109,15 @@ export default defineComponent({
isPickerSelected(id: string) {
return this.selectedPickers.some((picker: any) => picker.id == id)
},
selectPicker(id: string) {
const picker = this.selectedPickers.some((picker: any) => picker.id == id)
updateSelectedPickers(id: string) {
const picker = this.isPickerSelected(id)
if (picker) {
// if picker is already selected then removing that picker from the list on click
this.selectedPickers = this.selectedPickers.filter((picker: any) => picker.id != id)
} else {
this.selectedPickers.push(this.pickers.find((picker: any) => picker.id == id))
}
},
removePicker(id: string) {
this.selectedPickers = this.selectedPickers.filter((picker: any) => picker.id != id)
},
async findPickers() {
let inputFields = {}
this.pickers = []
Expand Down Expand Up @@ -237,7 +234,7 @@ export default defineComponent({
logger.error('Something went wrong, could not edit picker(s)')
}
},
evaluateSelectedPickers() {
arePickersSelected() {
// disable the save button if only 'System Generate' entry is there
// or if no pickers are selected
return (this.selectedPickers.length === 1
Expand Down
4 changes: 2 additions & 2 deletions src/views/InProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
</div>
</ion-content>
<!-- only show footer buttons if 'All orders' is not selected -->
<ion-footer v-if="selectedPicklistId.length">
<ion-footer v-if="selectedPicklistId">
<ion-toolbar>
<ion-buttons slot="end">
<ion-button fill="outline" color="primary" @click="editPickers(getPicklist(selectedPicklistId))">
Expand Down Expand Up @@ -911,7 +911,7 @@ export default defineComponent({
editPickersModal.onDidDismiss().then((result) => {
// manually updating the picklist data as UI is not updated because same data
// is returned from solr on fetchPickersInformation API call
if (result.data?.editedPicklist) {
if (result.data?.editedPicklist && Object.keys(result.data?.editedPicklist).length) {
const editedPicklist = result.data.editedPicklist
this.picklists = JSON.parse(JSON.stringify(this.picklists.map((picklist: any) => picklist.id === editedPicklist.id ? picklist = editedPicklist : picklist)))
}
Expand Down

0 comments on commit 5df5c96

Please sign in to comment.