mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 12:18:45 -05:00
meal plan sort order
This commit is contained in:
@@ -72,9 +72,20 @@ const newPlanDialogDefaultItem = ref({} as MealPlan)
|
|||||||
const planItems = computed(() => {
|
const planItems = computed(() => {
|
||||||
let items = [] as IMealPlanCalendarItem[]
|
let items = [] as IMealPlanCalendarItem[]
|
||||||
useMealPlanStore().planList.forEach(mp => {
|
useMealPlanStore().planList.forEach(mp => {
|
||||||
|
let startDate = mp.fromDate
|
||||||
|
let endDate = mp.toDate ? mp.toDate : mp.fromDate
|
||||||
|
|
||||||
|
if (mp.mealType.time) {
|
||||||
|
let hour = parseInt(mp.mealType.time.split(':')[0])
|
||||||
|
let minutes = parseInt(mp.mealType.time.split(':')[1])
|
||||||
|
let seconds = parseInt(mp.mealType.time.split(':')[2])
|
||||||
|
startDate.setHours(hour, minutes, seconds)
|
||||||
|
endDate.setHours(hour, minutes, seconds)
|
||||||
|
}
|
||||||
|
console.log(startDate, endDate)
|
||||||
items.push({
|
items.push({
|
||||||
startDate: mp.fromDate,
|
startDate: startDate,
|
||||||
endDate: mp.toDate,
|
endDate: endDate,
|
||||||
id: mp.id,
|
id: mp.id,
|
||||||
mealPlan: mp,
|
mealPlan: mp,
|
||||||
} as IMealPlanCalendarItem)
|
} as IMealPlanCalendarItem)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
<span class="multiselect-clear-icon"></span>
|
<span class="multiselect-clear-icon"></span>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<template #afterlist>
|
<template v-if="hasMoreItems" #afterlist>
|
||||||
<span class="text-disabled font-italic text-caption ms-3">{{$t('ModelSelectResultsHelp')}}</span>
|
<span class="text-disabled font-italic text-caption ms-3">{{$t('ModelSelectResultsHelp')}}</span>
|
||||||
</template>
|
</template>
|
||||||
</Multiselect>
|
</Multiselect>
|
||||||
@@ -127,6 +127,7 @@ const itemLabel = computed(() => {
|
|||||||
const model = defineModel()
|
const model = defineModel()
|
||||||
const modelClass = ref({} as GenericModel)
|
const modelClass = ref({} as GenericModel)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
const hasMoreItems = ref(false)
|
||||||
|
|
||||||
const multiselect = useTemplateRef(`ref_${props.id}`)
|
const multiselect = useTemplateRef(`ref_${props.id}`)
|
||||||
|
|
||||||
@@ -145,8 +146,12 @@ function search(query: string) {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
return modelClass.value.list({query: query, page: 1, pageSize: props.limit}).then((r: any) => {
|
return modelClass.value.list({query: query, page: 1, pageSize: props.limit}).then((r: any) => {
|
||||||
if (modelClass.value.model.isPaginated) {
|
if (modelClass.value.model.isPaginated) {
|
||||||
|
if(r.next){
|
||||||
|
hasMoreItems.value = true
|
||||||
|
}
|
||||||
return r.results
|
return r.results
|
||||||
} else {
|
} else {
|
||||||
|
hasMoreItems.value = false
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
}).catch((err: any) => {
|
}).catch((err: any) => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {acceptHMRUpdate, defineStore} from "pinia"
|
|||||||
import {ApiApi, MealPlan} from "@/openapi";
|
import {ApiApi, MealPlan} from "@/openapi";
|
||||||
import {computed, ref} from "vue";
|
import {computed, ref} from "vue";
|
||||||
import {DateTime} from "luxon";
|
import {DateTime} from "luxon";
|
||||||
import {ErrorMessageType, MessageType, useMessageStore} from "@/stores/MessageStore";
|
import {ErrorMessageType, MessageType, PreparedMessage, useMessageStore} from "@/stores/MessageStore";
|
||||||
|
|
||||||
|
|
||||||
const _STORE_ID = "meal_plan_store"
|
const _STORE_ID = "meal_plan_store"
|
||||||
@@ -96,7 +96,7 @@ export const useMealPlanStore = defineStore(_STORE_ID, () => {
|
|||||||
const api = new ApiApi()
|
const api = new ApiApi()
|
||||||
loading.value = true
|
loading.value = true
|
||||||
return api.apiMealPlanCreate({mealPlan: object}).then((r) => {
|
return api.apiMealPlanCreate({mealPlan: object}).then((r) => {
|
||||||
useMessageStore().addMessage(MessageType.SUCCESS, 'Created successfully', 7000, object)
|
useMessageStore().addPreparedMessage(PreparedMessage.CREATE_SUCCESS)
|
||||||
plans.value.set(r.id!, r)
|
plans.value.set(r.id!, r)
|
||||||
return r
|
return r
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
@@ -109,7 +109,7 @@ export const useMealPlanStore = defineStore(_STORE_ID, () => {
|
|||||||
function updateObject(object: MealPlan) {
|
function updateObject(object: MealPlan) {
|
||||||
const api = new ApiApi()
|
const api = new ApiApi()
|
||||||
return api.apiMealPlanUpdate({id: object.id!, mealPlan: object}).then((r) => {
|
return api.apiMealPlanUpdate({id: object.id!, mealPlan: object}).then((r) => {
|
||||||
useMessageStore().addMessage(MessageType.SUCCESS, 'Updated successfully', 7000, object)
|
useMessageStore().addPreparedMessage(PreparedMessage.UPDATE_SUCCESS)
|
||||||
plans.value.set(r.id!, r)
|
plans.value.set(r.id!, r)
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
useMessageStore().addError(ErrorMessageType.UPDATE_ERROR, err)
|
useMessageStore().addError(ErrorMessageType.UPDATE_ERROR, err)
|
||||||
@@ -120,7 +120,7 @@ export const useMealPlanStore = defineStore(_STORE_ID, () => {
|
|||||||
const api = new ApiApi()
|
const api = new ApiApi()
|
||||||
loading.value = true
|
loading.value = true
|
||||||
return api.apiMealPlanDestroy({id: object.id!}).then((r) => {
|
return api.apiMealPlanDestroy({id: object.id!}).then((r) => {
|
||||||
useMessageStore().addMessage(MessageType.INFO, 'Deleted successfully', 7000, object)
|
useMessageStore().addPreparedMessage(PreparedMessage.DELETE_SUCCESS)
|
||||||
plans.value.delete(object.id!)
|
plans.value.delete(object.id!)
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
useMessageStore().addError(ErrorMessageType.DELETE_ERROR, err)
|
useMessageStore().addError(ErrorMessageType.DELETE_ERROR, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user