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(() => {
|
||||
let items = [] as IMealPlanCalendarItem[]
|
||||
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({
|
||||
startDate: mp.fromDate,
|
||||
endDate: mp.toDate,
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
id: mp.id,
|
||||
mealPlan: mp,
|
||||
} as IMealPlanCalendarItem)
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<span class="multiselect-clear-icon"></span>
|
||||
</span>
|
||||
</template>
|
||||
<template #afterlist>
|
||||
<template v-if="hasMoreItems" #afterlist>
|
||||
<span class="text-disabled font-italic text-caption ms-3">{{$t('ModelSelectResultsHelp')}}</span>
|
||||
</template>
|
||||
</Multiselect>
|
||||
@@ -127,6 +127,7 @@ const itemLabel = computed(() => {
|
||||
const model = defineModel()
|
||||
const modelClass = ref({} as GenericModel)
|
||||
const loading = ref(false)
|
||||
const hasMoreItems = ref(false)
|
||||
|
||||
const multiselect = useTemplateRef(`ref_${props.id}`)
|
||||
|
||||
@@ -145,8 +146,12 @@ function search(query: string) {
|
||||
loading.value = true
|
||||
return modelClass.value.list({query: query, page: 1, pageSize: props.limit}).then((r: any) => {
|
||||
if (modelClass.value.model.isPaginated) {
|
||||
if(r.next){
|
||||
hasMoreItems.value = true
|
||||
}
|
||||
return r.results
|
||||
} else {
|
||||
hasMoreItems.value = false
|
||||
return r
|
||||
}
|
||||
}).catch((err: any) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import {acceptHMRUpdate, defineStore} from "pinia"
|
||||
import {ApiApi, MealPlan} from "@/openapi";
|
||||
import {computed, ref} from "vue";
|
||||
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"
|
||||
@@ -96,7 +96,7 @@ export const useMealPlanStore = defineStore(_STORE_ID, () => {
|
||||
const api = new ApiApi()
|
||||
loading.value = true
|
||||
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)
|
||||
return r
|
||||
}).catch((err) => {
|
||||
@@ -109,7 +109,7 @@ export const useMealPlanStore = defineStore(_STORE_ID, () => {
|
||||
function updateObject(object: MealPlan) {
|
||||
const api = new ApiApi()
|
||||
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)
|
||||
}).catch((err) => {
|
||||
useMessageStore().addError(ErrorMessageType.UPDATE_ERROR, err)
|
||||
@@ -120,7 +120,7 @@ export const useMealPlanStore = defineStore(_STORE_ID, () => {
|
||||
const api = new ApiApi()
|
||||
loading.value = true
|
||||
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!)
|
||||
}).catch((err) => {
|
||||
useMessageStore().addError(ErrorMessageType.DELETE_ERROR, err)
|
||||
|
||||
Reference in New Issue
Block a user