Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented: support to display searchbar and product store filters on the groups page and filter groups(#99) #100

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/components/RoutingHistoryModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<p>{{ groupName }}</p>
</ion-label>
<ion-label slot="end">
{{ currentEComStore.productStoreId }}
{{ productStoreName }}
</ion-label>
</ion-item>
<div class="empty-state" v-if="!routingHistory.length">
Expand Down Expand Up @@ -72,7 +72,10 @@ defineProps({
}
})

const currentEComStore = computed(() => store.getters["user/getCurrentEComStore"])
const userProfile = computed(() => store.getters["user/getUserProfile"])
const currentRoutingGroup: any = computed(() => store.getters["orderRouting/getCurrentRoutingGroup"])

const productStoreName = computed(() => userProfile.value.stores.find((store: any) => store.productStoreId === currentRoutingGroup.value.productStoreId)?.storeName || currentRoutingGroup.value.productStoreId)

function closeModal() {
modalController.dismiss();
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"Schedule": "Schedule",
"Schedule disabled": "Schedule disabled",
"Scheduler": "Scheduler",
"Search groups": "Search groups",
"Search time zones": "Search time zones",
"Select": "Select",
"Select filter to apply": "Select filter to apply",
Expand Down
2 changes: 1 addition & 1 deletion src/services/RoutingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fetchRoutingGroups = async (payload: any): Promise<any> => {
return api({
url: "groups",
method: "GET",
query: payload
params: payload
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/store/RootState.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import OrderRoutingState from "./modules/orderRouting/OrderRoutingState";
import UtilState from "./modules/util/UtilState";

export default interface RootState {
user: any;
util: UtilState;
orderRouting: OrderRoutingState;
}
5 changes: 4 additions & 1 deletion src/store/modules/orderRouting/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
import { DateTime } from "luxon"
import emitter from "@/event-bus"
import { translate } from "@/i18n"
import store from "@/store"

const actions: ActionTree<OrderRoutingState, RootState> = {
async fetchOrderRoutingGroups({ commit }) {
let routingGroups = [] as any;
// filter groups on the basis of productStoreId
const payload = {}
const payload = {
productStoreId: store.state.user.currentEComStore.productStoreId
}

try {
const resp = await OrderRoutingService.fetchRoutingGroups(payload);
Expand Down Expand Up @@ -200,7 +203,7 @@
commit(types.ORDER_ROUTING_HISTORY_UPDATED, routingHistory)
},

async deleteRoutingFilters({ dispatch }, payload) {

Check warning on line 206 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'dispatch' is defined but never used

Check warning on line 206 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'dispatch' is defined but never used
let hasAllFiltersDeletedSuccessfully = true;
try {
// As discussed, we can't make parallel api calls, hence using for loop to make api calls
Expand All @@ -220,7 +223,7 @@
return hasAllFiltersDeletedSuccessfully
},

async updateRouting({ dispatch }, payload) {

Check warning on line 226 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'dispatch' is defined but never used

Check warning on line 226 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'dispatch' is defined but never used
let orderRoutingId = ''
try {
const resp = await OrderRoutingService.updateRouting(payload)
Expand Down Expand Up @@ -267,7 +270,7 @@
return routingRuleId;
},

async deleteRuleConditions({ dispatch }, payload) {

Check warning on line 273 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'dispatch' is defined but never used

Check warning on line 273 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'dispatch' is defined but never used
// TODO: check if we can call request in parallel for delete operation
let hasAllConditionsDeletedSuccessfully = true;
try {
Expand All @@ -287,7 +290,7 @@
return hasAllConditionsDeletedSuccessfully
},

async deleteRuleActions({ dispatch }, payload) {

Check warning on line 293 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'dispatch' is defined but never used

Check warning on line 293 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'dispatch' is defined but never used
// TODO: check if we can call request in parallel for delete operation
let hasAllActionsDeletedSuccessfully = true;
try {
Expand Down Expand Up @@ -350,7 +353,7 @@
return JSON.parse(JSON.stringify(rulesInformation[routingRuleId]))
},

async updateRule({ dispatch }, payload) {

Check warning on line 356 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'dispatch' is defined but never used

Check warning on line 356 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'dispatch' is defined but never used
let routingRuleId = ''
try {
const resp = await OrderRoutingService.updateRule(payload)
Expand Down
2 changes: 2 additions & 0 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ const actions: ActionTree<UserState, RootState> = {
productStore = (state.current as any).stores.find((store: any) => store.productStoreId === payload.productStoreId);
}
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, productStore);
this.dispatch("util/updateShippingMethods", {})
this.dispatch("util/updateFacillityGroups", {})
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/store/modules/util/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ const actions: ActionTree<UtilState, RootState> = {
async fetchShippingMethods({ commit, state }) {
let shippingMethods = JSON.parse(JSON.stringify(state.shippingMethods))

// Do not fetch shipping methods if aleady available
// Do not fetch shipping methods if already available
if(Object.keys(shippingMethods).length) {
return;
}

// Fetching shipping methods for productStore of the currentGroup
const payload = {
productStoreId: store.state.user.currentEComStore.productStoreId
productStoreId: store.state.orderRouting.currentGroup.productStoreId
}

try {
Expand Down Expand Up @@ -101,7 +102,7 @@ const actions: ActionTree<UtilState, RootState> = {
}

const payload = {
productStoreId: store.state.user.currentEComStore.productStoreId,
productStoreId: store.state.orderRouting.currentGroup.productStoreId,
facilityGroupTypeId: "BROKERING_GROUP"
}

Expand Down Expand Up @@ -166,6 +167,14 @@ const actions: ActionTree<UtilState, RootState> = {

async clearUtilState({ commit }) {
commit(types.UTIL_CLEARED)
},

async updateShippingMethods({ commit }) {
commit(types.UTIL_SHIPPING_METHOD_UPDATED, {})
},

async updateFacillityGroups({ commit }) {
commit(types.UTIL_FACILITY_GROUP_UPDATED, {})
}
}

Expand Down
52 changes: 52 additions & 0 deletions src/theme/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,58 @@ http://ionicframework.com/docs/theming/ */
cursor: pointer;
}

.desktop-only {
display: none;
}

.mobile-only {
display: unset;
}

.find {
display: grid;
grid-template-areas: "search"
"main";
}

.find > .filters{
display: none;
}

.find > main {
grid-area: main;
}

.filters {
grid-area: filters;
}

.search {
grid-area: search;
}

@media (min-width: 991px) {
.find {
grid: "search main" min-content
"filters main" 1fr
/ 375px;
column-gap: var(--spacer-2xl);
margin: var(--spacer-lg);
}

.filters {
margin-top: var(--spacer-lg);
}

.filters {
margin-top: var(--spacer-lg);
}

.find > .filters{
display: unset;
}
}

@media (prefers-color-scheme: dark) {
ion-chip > ion-icon {
color: var(--ion-color-dark);
Expand Down
5 changes: 2 additions & 3 deletions src/views/BrokeringRoute.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ let orderRoutings = ref([]) as any
let groupHistory = ref([]) as any

const currentRoutingGroup: any = computed((): Group => store.getters["orderRouting/getCurrentRoutingGroup"])
const currentEComStore = computed(() => store.getters["user/getCurrentEComStore"])
const isOmsConnectionExist = computed(() => store.getters["util/isOmsConnectionExist"])
const getStatusDesc = computed(() => (id: string) => store.getters["util/getStatusDesc"](id))
const routingHistory = computed(() => store.getters["orderRouting/getRoutingHistory"])
Expand Down Expand Up @@ -447,7 +446,7 @@ function getArchivedOrderRoutings() {
async function updateGroupDescription() {
// Do not update description, if the desc is unchanged, and we do not have routingGroupId, and description is left empty
if(props.routingGroupId && currentRoutingGroup.value.description !== description.value) {
const routingGroupId = await updateRoutingGroup({ routingGroupId: props.routingGroupId, productStoreId: currentEComStore.value.productStoreId, description: description.value })
const routingGroupId = await updateRoutingGroup({ routingGroupId: props.routingGroupId, productStoreId: currentRoutingGroup.value.productStoreId, description: description.value })
if(routingGroupId) {
await store.dispatch("orderRouting/setCurrentGroup", { ...currentRoutingGroup.value, description: description.value })
}
Expand Down Expand Up @@ -576,7 +575,7 @@ async function saveRoutingGroup() {

const payload = {
routingGroupId: props.routingGroupId,
productStoreId: currentEComStore.value.productStoreId,
productStoreId: currentRoutingGroup.value.productStoreId,
routings
}

Expand Down
105 changes: 73 additions & 32 deletions src/views/BrokeringRuns.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,66 @@
</ion-header>

<ion-content>
<main v-if="isLoading">
<ion-item lines="none">
<ion-spinner name="crescent" slot="start" />
{{ translate("Fetching groups") }}
</ion-item>
</main>
<main v-else-if="groups.length">
<section>
<ion-card class="pointer" v-for="group in groups" :key="group.routingGroupId" @click="redirect(group)">
<ion-card-header>
<ion-card-title>
{{ group.groupName }}
</ion-card-title>
</ion-card-header>
<ion-item>
{{ group.description }}
</ion-item>
<ion-item>
<ion-label>{{ group.frequency ? group.frequency : "-" }}</ion-label>
<ion-label slot="end">{{ group.runTime ? group.runTime : "-" }}</ion-label>
</ion-item>
<ion-item>
{{ getDateAndTime(group.createdDate) }}
</ion-item>
<div class="find">
<section class="search">
<ion-searchbar :placeholder="translate('Search groups')" v-model="queryString" @keyup.enter="filterGroups()" />
</section>

<aside class="filters">
<ion-list-header>{{ "Product Stores" }}</ion-list-header>
<ion-list>
<ion-item lines="none">
{{ getDateAndTime(group.lastUpdatedStamp) }}
<ion-radio-group :value="currentEComStore.productStoreId" @ionChange="setEComStore($event)">
<ion-radio v-for="store in (userProfile ? userProfile.stores : [])" :key="store.productStoreId" :value="store.productStoreId">{{ store.storeName }}</ion-radio>
</ion-radio-group>
</ion-item>
</ion-card>
</section>
</main>
<main v-else>
{{ translate("No runs scheduled") }}
</main>
</ion-list>
</aside>

<main v-if="isLoading">
<ion-item lines="none">
<ion-spinner name="crescent" slot="start" />
{{ translate("Fetching groups") }}
</ion-item>
</main>
<main v-else-if="brokeringGroups.length">
<section>
<ion-card class="pointer" v-for="group in brokeringGroups" :key="group.routingGroupId" @click="redirect(group)">
<ion-card-header>
<ion-card-title>
{{ group.groupName }}
</ion-card-title>
</ion-card-header>
<ion-item>
{{ group.description }}
</ion-item>
<ion-item>
<ion-label>{{ group.frequency ? group.frequency : "-" }}</ion-label>
<ion-label slot="end">{{ group.runTime ? group.runTime : "-" }}</ion-label>
</ion-item>
<ion-item>
{{ getDateAndTime(group.createdDate) }}
</ion-item>
<ion-item lines="none">
{{ getDateAndTime(group.lastUpdatedStamp) }}
</ion-item>
</ion-card>
</section>
</main>
<main v-else>
{{ translate("No runs scheduled") }}
</main>
</div>
</ion-content>
</ion-page>
</template>

<script setup lang="ts">
import emitter from "@/event-bus";
import { translate } from "@/i18n";
import { Group } from "@/types";
import { getDateAndTime, showToast } from "@/utils";
import { IonButton, IonButtons, IonCard, IonCardHeader, IonCardTitle, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonPage, IonSpinner, IonTitle, IonToolbar, alertController, onIonViewWillEnter } from "@ionic/vue";
import { IonButton, IonButtons, IonCard, IonCardHeader, IonCardTitle, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonList, IonListHeader, IonPage, IonRadioGroup, IonRadio, IonSearchbar, IonSpinner, IonTitle, IonToolbar, alertController, onIonViewWillEnter } from "@ionic/vue";
import { addOutline } from "ionicons/icons"
import { computed, ref } from "vue";
import { useRouter } from "vue-router";
Expand All @@ -64,15 +82,27 @@ import { useStore } from "vuex";
const store = useStore()
const router = useRouter()
const groups = computed(() => store.getters["orderRouting/getRoutingGroups"])
const userProfile = computed(() => store.getters["user/getUserProfile"])
const currentEComStore = computed(() => store.getters["user/getCurrentEComStore"])

let isLoading = ref(false)
let queryString = ref("")
let brokeringGroups = ref([]) as any

onIonViewWillEnter(async () => {
isLoading.value = true
await store.dispatch("orderRouting/fetchOrderRoutingGroups");
isLoading.value = false
brokeringGroups.value = JSON.parse(JSON.stringify(groups.value))
store.dispatch("util/fetchEnums", { parentTypeId: "ORDER_ROUTING" })
})

function filterGroups() {
// Before filtering the groups, reassinging it with state, if we have searched for a specific character and then updates the search string then we need to again filter on all the groups and not on the previously searched results
brokeringGroups.value = JSON.parse(JSON.stringify(groups.value))
brokeringGroups.value = brokeringGroups.value.filter((group: any) => group.groupName.toLowerCase().includes(queryString.value.toLowerCase()))
}

async function addNewRun() {
const newRunAlert = await alertController.create({
header: translate("New Run"),
Expand Down Expand Up @@ -108,6 +138,17 @@ async function addNewRun() {
return newRunAlert.present();
}

async function setEComStore(event: CustomEvent) {
emitter.emit("presentLoader")
if(userProfile.value?.stores) {
await store.dispatch("user/setEcomStore", {
"productStoreId": event.detail.value
})
await store.dispatch("orderRouting/fetchOrderRoutingGroups");
}
emitter.emit("dismissLoader")
}

async function redirect(group: Group) {
router.push(`brokering/${group.routingGroupId}/routes`)
}
Expand Down
Loading