Skip to content

Commit

Permalink
Improved: added spinner to be shown while fetching pickers (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais authored and ravilodhi committed Jul 9, 2024
1 parent 6d7d137 commit 6a76fa0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/components/EditPickersModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@

<ion-list>
<ion-list-header>{{ translate("Staff") }}</ion-list-header>
<div class="ion-padding" v-if="!pickers.length">

<div v-if="isLoading" class="empty-state">
<ion-spinner name="crescent" />
<ion-label>{{ translate("Fetching pickers") }}</ion-label>
</div>
<div class="empty-state" v-if="!pickers.length">
{{ 'No picker found' }}
</div>
<div v-else>
Expand Down Expand Up @@ -62,6 +67,7 @@ import {
IonListHeader,
IonRow,
IonSearchbar,
IonSpinner,
modalController,
alertController
} from "@ionic/vue";
Expand Down Expand Up @@ -93,13 +99,15 @@ export default defineComponent({
IonListHeader,
IonRow,
IonSearchbar,
IonSpinner
},
data () {
return {
selectedPickers: [] as any,
queryString: '',
pickers: [] as any,
editedPicklist: {} as any
editedPicklist: {} as any,
isLoading: false
}
},
async mounted() {
Expand All @@ -121,6 +129,8 @@ export default defineComponent({
}
},
async findPickers(pickerIds?: Array<any>) {
this.isLoading = true;
let inputFields = {}
this.pickers = []
Expand Down Expand Up @@ -183,6 +193,7 @@ export default defineComponent({
} catch (err) {
logger.error('Failed to fetch the pickers information or there are no pickers available', err)
}
this.isLoading = false;
},
async confirmSave() {
const message = translate("Replace current pickers with new selection?");
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"Failed to update variance type.": "Failed to update variance type.",
"Fetching time zones": "Fetching time zones",
"Fetching order information...": "Fetching order information...",
"Fetching pickers": "Fetching pickers",
"Field mapping name": "Field mapping name",
"File downloaded successfully": "File downloaded successfully",
"File uploaded successfully": "File uploaded successfully",
Expand Down
1 change: 1 addition & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"Failed to update tracking code settings.": "Failed to update tracking code settings.",
"Failed to update variance type.": "Failed to update variance type.",
"Fetching order information...": "Obteniendo información del pedido...",
"Fetching pickers": "Fetching pickers",
"Field mapping name": "Nombre del mapeo de campos",
"File downloaded successfully": "Archivo descargado con éxito",
"File uploaded successfully": "Archivo cargado con éxito",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"Failed to update variance type.": "変動タイプの更新に失敗しました。",
"Fetching time zones": "タイムゾーンの取得中",
"Fetching order information...": "注文情報の取得中...",
"Fetching pickers": "Fetching pickers",
"Field mapping name": "フィールドマッピング名",
"File downloaded successfully": "ファイルが正常にダウンロードされました",
"File uploaded successfully": "ファイルが正常にアップロードされました",
Expand Down
14 changes: 12 additions & 2 deletions src/views/AssignPickerModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
<!-- TODO: added click event on the item as when using the ionChange event then it's getting
called every time the v-for loop runs and then removes or adds the currently rendered picker
-->
<div class="ion-padding" v-if="!pickers.length">{{ 'No picker found' }}</div>
<div v-if="isLoading" class="empty-state">
<ion-spinner name="crescent" />
<ion-label>{{ translate("Fetching pickers") }}</ion-label>
</div>
<div class="empty-state" v-else-if="!pickers.length">{{ "No picker found" }}</div>
<div v-else>
<ion-item v-for="(picker, index) in pickers" :key="index" @click="selectPicker(picker.id)">
<ion-checkbox :checked="isPickerSelected(picker.id)">
Expand Down Expand Up @@ -61,6 +65,7 @@ import {
IonListHeader,
IonRow,
IonSearchbar,
IonSpinner,
IonTitle,
IonToolbar,
modalController } from "@ionic/vue";
Expand Down Expand Up @@ -93,6 +98,7 @@ export default defineComponent({
IonListHeader,
IonRow,
IonSearchbar,
IonSpinner,
IonTitle,
IonToolbar,
},
Expand All @@ -106,7 +112,8 @@ export default defineComponent({
return {
selectedPickers: [],
queryString: '',
pickers: []
pickers: [],
isLoading: false
}
},
props: ["order"], // if we have order in props then create picklist for this single order only
Expand Down Expand Up @@ -182,6 +189,8 @@ export default defineComponent({
emitter.emit("dismissLoader")
},
async findPickers() {
this.isLoading = true;
let inputFields = {}
this.pickers = []
Expand Down Expand Up @@ -238,6 +247,7 @@ export default defineComponent({
} catch (err) {
logger.error('Failed to fetch the pickers information or there are no pickers available', err)
}
this.isLoading = false
}
},
async mounted() {
Expand Down

0 comments on commit 6a76fa0

Please sign in to comment.