Fix after rebase
This commit is contained in:
parent
a24f09c419
commit
2b41fbc9f8
@ -428,8 +428,10 @@ class UserCreateForm(forms.Form):
|
|||||||
|
|
||||||
class SearchPreferenceForm(forms.ModelForm):
|
class SearchPreferenceForm(forms.ModelForm):
|
||||||
prefix = 'search'
|
prefix = 'search'
|
||||||
trigram_threshold = forms.DecimalField(min_value=0.01, max_value=1, decimal_places=2, widget=NumberInput(attrs={'class': "form-control-range", 'type': 'range'}),
|
trigram_threshold = forms.DecimalField(min_value=0.01, max_value=1, decimal_places=2,
|
||||||
help_text=_('Determines how fuzzy a search is if it uses trigram similarity matching (e.g. low values mean more typos are ignored).'))
|
widget=NumberInput(attrs={'class': "form-control-range", 'type': 'range'}),
|
||||||
|
help_text=_(
|
||||||
|
'Determines how fuzzy a search is if it uses trigram similarity matching (e.g. low values mean more typos are ignored).'))
|
||||||
preset = forms.CharField(widget=forms.HiddenInput(), required=False)
|
preset = forms.CharField(widget=forms.HiddenInput(), required=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -37,7 +37,8 @@ class ExtendedRecipeMixin(serializers.ModelSerializer):
|
|||||||
api_serializer = None
|
api_serializer = None
|
||||||
# extended values are computationally expensive and not needed in normal circumstances
|
# extended values are computationally expensive and not needed in normal circumstances
|
||||||
try:
|
try:
|
||||||
if bool(int(self.context['request'].query_params.get('extended', False))) and self.__class__ == api_serializer:
|
if bool(int(
|
||||||
|
self.context['request'].query_params.get('extended', False))) and self.__class__ == api_serializer:
|
||||||
return fields
|
return fields
|
||||||
except (AttributeError, KeyError) as e:
|
except (AttributeError, KeyError) as e:
|
||||||
pass
|
pass
|
||||||
|
@ -48,7 +48,8 @@ from cookbook.models import (Automation, BookmarkletImport, CookLog, Food, FoodI
|
|||||||
from cookbook.provider.dropbox import Dropbox
|
from cookbook.provider.dropbox import Dropbox
|
||||||
from cookbook.provider.local import Local
|
from cookbook.provider.local import Local
|
||||||
from cookbook.provider.nextcloud import Nextcloud
|
from cookbook.provider.nextcloud import Nextcloud
|
||||||
from cookbook.schemas import FilterSchema, QueryParam, QueryParamAutoSchema, TreeSchema
|
from cookbook.schemas import (FilterSchema, QueryOnlySchema, QueryParam, QueryParamAutoSchema,
|
||||||
|
RecipeSchema, TreeSchema)
|
||||||
from cookbook.serializer import (AutomationSerializer, BookmarkletImportSerializer,
|
from cookbook.serializer import (AutomationSerializer, BookmarkletImportSerializer,
|
||||||
CookLogSerializer, FoodInheritFieldSerializer, FoodSerializer,
|
CookLogSerializer, FoodInheritFieldSerializer, FoodSerializer,
|
||||||
FoodShoppingUpdateSerializer, ImportLogSerializer,
|
FoodShoppingUpdateSerializer, ImportLogSerializer,
|
||||||
@ -536,8 +537,7 @@ class StepViewSet(viewsets.ModelViewSet):
|
|||||||
permission_classes = [CustomIsUser]
|
permission_classes = [CustomIsUser]
|
||||||
pagination_class = DefaultPagination
|
pagination_class = DefaultPagination
|
||||||
query_params = [
|
query_params = [
|
||||||
QueryParam(name='recipe', description=_('ID of recipe a step is part of. For multiple repeat parameter.'),
|
QueryParam(name='recipe', description=_('ID of recipe a step is part of. For multiple repeat parameter.'), qtype='int'),
|
||||||
qtype='int'),
|
|
||||||
QueryParam(name='query', description=_('Query string matched (fuzzy) against object name.'), qtype='string'),
|
QueryParam(name='query', description=_('Query string matched (fuzzy) against object name.'), qtype='string'),
|
||||||
]
|
]
|
||||||
schema = QueryParamAutoSchema()
|
schema = QueryParamAutoSchema()
|
||||||
|
27502
vue/package-lock.json
generated
27502
vue/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -84,4 +84,14 @@
|
|||||||
"@vue/cli-plugin-pwa/workbox-webpack-plugin": "^5.1.3",
|
"@vue/cli-plugin-pwa/workbox-webpack-plugin": "^5.1.3",
|
||||||
"coa": "2.0.2"
|
"coa": "2.0.2"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"browserslist": [
|
||||||
|
"> 1%",
|
||||||
|
"last 2 versions",
|
||||||
|
"not dead"
|
||||||
|
],
|
||||||
|
"resolutions": {
|
||||||
|
"@vue/cli-plugin-pwa/workbox-webpack-plugin": "^5.1.3",
|
||||||
|
"coa": "2.0.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-md-12">
|
<div class="col col-md-12">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-12 col-lg-10 col-xl-8 mt-3 mb-3">
|
<div class="col-12 col-lg-10 mt-3 mb-3">
|
||||||
<b-input-group>
|
<b-input-group>
|
||||||
<b-input
|
<b-input
|
||||||
class="form-control form-control-lg form-control-borderless form-control-search"
|
class="form-control form-control-lg form-control-borderless form-control-search"
|
||||||
@ -26,12 +26,12 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<b-card class="d-flex flex-column" v-hover v-on:click="openBook(book.id)">
|
<b-card class="d-flex flex-column" v-hover v-on:click="openBook(book.id)">
|
||||||
<b-row no-gutters style="height:inherit;">
|
<b-row no-gutters style="height: inherit">
|
||||||
<b-col no-gutters md="2" style="height:inherit;">
|
<b-col no-gutters md="2" style="height: inherit">
|
||||||
<h3>{{ book.icon }}</h3>
|
<h3>{{ book.icon }}</h3>
|
||||||
</b-col>
|
</b-col>
|
||||||
<b-col no-gutters md="10" style="height:inherit;">
|
<b-col no-gutters md="10" style="height: inherit">
|
||||||
<b-card-body class="m-0 py-0" style="height:inherit;">
|
<b-card-body class="m-0 py-0" style="height: inherit">
|
||||||
<b-card-text class="h-100 my-0 d-flex flex-column" style="text-overflow: ellipsis">
|
<b-card-text class="h-100 my-0 d-flex flex-column" style="text-overflow: ellipsis">
|
||||||
<h5 class="m-0 mt-1 text-truncate">
|
<h5 class="m-0 mt-1 text-truncate">
|
||||||
{{ book.name }} <span class="float-right"><i class="fa fa-book"></i></span>
|
{{ book.name }} <span class="float-right"><i class="fa fa-book"></i></span>
|
||||||
@ -93,7 +93,11 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
createNew: function () {
|
||||||
|
let apiClient = new ApiApiFactory()
|
||||||
|
|
||||||
|
apiClient.createRecipeBook({name: this.$t('New_Cookbook'), description: '', icon: '', shared: []}).then(result => {
|
||||||
|
let new_book = result.data
|
||||||
this.refreshData()
|
this.refreshData()
|
||||||
this.$i18n.locale = window.CUSTOM_LOCALE
|
this.$i18n.locale = window.CUSTOM_LOCALE
|
||||||
},
|
},
|
||||||
@ -156,8 +160,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.slide-fade-enter, .slide-fade-leave-to
|
.slide-fade-enter, .slide-fade-leave-to
|
||||||
/* .slide-fade-leave-active below version 2.1.8 */
|
/* .slide-fade-leave-active below version 2.1.8 */ {
|
||||||
{
|
|
||||||
transform: translateX(10px);
|
transform: translateX(10px);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
@ -1,51 +1,99 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<b-tabs content-class="mt-3">
|
<b-tabs content-class="mt-3" v-model="current_tab">
|
||||||
<b-tab :title="$t('Planner')" active>
|
<b-tab :title="$t('Planner')" active>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 calender-parent">
|
<div class="col-12 calender-parent">
|
||||||
<calendar-view
|
<calendar-view
|
||||||
:show-date="showDate"
|
:show-date="showDate" :enable-date-selection="true" class="theme-default"
|
||||||
:enable-date-selection="true"
|
:items="plan_items"
|
||||||
class="theme-default"
|
:display-period-uom="settings.displayPeriodUom"
|
||||||
:items="plan_items"
|
:period-changed-callback="periodChangedCallback" :enable-drag-drop="true"
|
||||||
:display-period-uom="settings.displayPeriodUom"
|
:item-content-height="item_height"
|
||||||
:period-changed-callback="periodChangedCallback"
|
@click-date="createEntryClick" @drop-on-date="moveEntry"
|
||||||
:enable-drag-drop="true"
|
:display-period-count="settings.displayPeriodCount"
|
||||||
:item-content-height="item_height"
|
:starting-day-of-week="settings.startingDayOfWeek"
|
||||||
@click-date="createEntryClick"
|
:display-week-numbers="settings.displayWeekNumbers">
|
||||||
@drop-on-date="moveEntry"
|
<template #item="{ value, weekStartDate, top }">
|
||||||
:display-period-count="settings.displayPeriodCount"
|
<meal-plan-card :value="value" :week-start-date="weekStartDate" :top="top" :detailed="detailed_items"
|
||||||
:starting-day-of-week="settings.startingDayOfWeek"
|
:item_height="item_height" @dragstart="dragged_item = value" @click-item="entryClick"
|
||||||
:display-week-numbers="settings.displayWeekNumbers"
|
@open-context-menu="openContextMenu"/>
|
||||||
>
|
</template>
|
||||||
<template #item="{ value, weekStartDate, top }">
|
<template #header="{ headerProps }">
|
||||||
<meal-plan-card
|
<meal-plan-calender-header ref="header"
|
||||||
:value="value"
|
:header-props="headerProps"
|
||||||
:week-start-date="weekStartDate"
|
@input="setShowDate" @delete-dragged="deleteEntry(dragged_item)"
|
||||||
:top="top"
|
@create-new="createEntryClick(new Date())"
|
||||||
:detailed="detailed_items"
|
@set-starting-day-back="setStartingDay(-1)"
|
||||||
:item_height="item_height"
|
@set-starting-day-forward="setStartingDay(1)" :i-cal-url="iCalUrl"
|
||||||
@dragstart="dragged_item = value"
|
:options="options"
|
||||||
@click-item="entryClick"
|
:settings_prop="settings"/>
|
||||||
@open-context-menu="openContextMenu"
|
</template>
|
||||||
/>
|
</calendar-view>
|
||||||
</template>
|
</div>
|
||||||
<template #header="{ headerProps }">
|
</div>
|
||||||
<meal-plan-calender-header
|
</b-tab>
|
||||||
ref="header"
|
<b-tab :title="$t('Settings')">
|
||||||
:header-props="headerProps"
|
<div class="row mt-3">
|
||||||
@input="setShowDate"
|
<div class="col-12 col-md-3 calender-options">
|
||||||
@delete-dragged="deleteEntry(dragged_item)"
|
<h5>{{ $t('Planner_Settings') }}</h5>
|
||||||
@create-new="createEntryClick(new Date())"
|
<b-form>
|
||||||
@set-starting-day-back="setStartingDay(-1)"
|
<b-form-group id="UomInput"
|
||||||
@set-starting-day-forward="setStartingDay(1)"
|
:label="$t('Period')"
|
||||||
:i-cal-url="iCalUrl"
|
:description="$t('Plan_Period_To_Show')"
|
||||||
:options="options"
|
label-for="UomInput">
|
||||||
:settings_prop="settings"
|
<b-form-select
|
||||||
/>
|
id="UomInput"
|
||||||
</template>
|
v-model="settings.displayPeriodUom"
|
||||||
</calendar-view>
|
:options="options.displayPeriodUom"
|
||||||
|
></b-form-select>
|
||||||
|
</b-form-group>
|
||||||
|
<b-form-group id="PeriodInput"
|
||||||
|
:label="$t('Periods')"
|
||||||
|
:description="$t('Plan_Show_How_Many_Periods')"
|
||||||
|
label-for="PeriodInput">
|
||||||
|
<b-form-select
|
||||||
|
id="PeriodInput"
|
||||||
|
v-model="settings.displayPeriodCount"
|
||||||
|
:options="options.displayPeriodCount"
|
||||||
|
></b-form-select>
|
||||||
|
</b-form-group>
|
||||||
|
<b-form-group id="DaysInput"
|
||||||
|
:label="$t('Starting_Day')"
|
||||||
|
:description="$t('Starting_Day')"
|
||||||
|
label-for="DaysInput">
|
||||||
|
<b-form-select
|
||||||
|
id="DaysInput"
|
||||||
|
v-model="settings.startingDayOfWeek"
|
||||||
|
:options="dayNames"
|
||||||
|
></b-form-select>
|
||||||
|
</b-form-group>
|
||||||
|
<b-form-group id="WeekNumInput"
|
||||||
|
:label="$t('Week_Numbers')">
|
||||||
|
<b-form-checkbox v-model="settings.displayWeekNumbers" name="week_num">
|
||||||
|
{{ $t('Show_Week_Numbers') }}
|
||||||
|
</b-form-checkbox>
|
||||||
|
</b-form-group>
|
||||||
|
</b-form>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-md-9 col-lg-6">
|
||||||
|
<h5>{{ $t('Meal_Types') }}</h5>
|
||||||
|
<div>
|
||||||
|
<draggable :list="meal_types" group="meal_types"
|
||||||
|
:empty-insert-threshold="10" handle=".handle" @sort="sortMealTypes()">
|
||||||
|
<b-card no-body class="mt-1" v-for="(meal_type, index) in meal_types" v-hover :key="meal_type.id">
|
||||||
|
<b-card-header class="p-4">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2 handle">
|
||||||
|
<button type="button" class="btn btn-lg shadow-none"><i class="fas fa-arrows-alt-v "></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-10">
|
||||||
|
<h5>{{ meal_type.icon }} {{ meal_type.name }}<span class="float-right text-primary"><i
|
||||||
|
class="fa" v-bind:class="{ 'fa-pen': !meal_type.editing, 'fa-save': meal_type.editing }"
|
||||||
|
@click="editOrSaveMealType(index)"
|
||||||
|
aria-hidden="true"></i></span></h5>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</b-tab>
|
</b-tab>
|
||||||
@ -227,27 +275,57 @@
|
|||||||
{{ $t("Export_To_ICal") }}
|
{{ $t("Export_To_ICal") }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 col-6">
|
</div>
|
||||||
<button class="btn btn-block btn-primary shadow-none disabled" v-b-tooltip.focus.top :title="$t('Coming-Soon')">{{ $t("Auto-Planner") }}</button>
|
</b-sidebar>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 d-flex justify-content-center mt-2 d-block d-md-none">
|
</template>
|
||||||
<b-button-toolbar key-nav aria-label="Toolbar with button groups">
|
<transition name="slide-fade">
|
||||||
<b-button-group class="mx-1">
|
<div class="row fixed-bottom p-2 b-1 border-top text-center" style="background:rgba(255,255,255,0.6);"
|
||||||
<b-button v-html="'<<'" @click="setShowDate($refs.header.headerProps.previousPeriod)"></b-button>
|
v-if="current_tab === 0">
|
||||||
<b-button v-html="'<'" @click="setStartingDay(-1)"></b-button>
|
<div class="col-md-3 col-6">
|
||||||
</b-button-group>
|
<button class="btn btn-block btn-success shadow-none" @click="createEntryClick(new Date())"><i
|
||||||
<b-button-group class="mx-1">
|
class="fas fa-calendar-plus"></i> {{ $t('Create') }}
|
||||||
<b-button @click="setShowDate($refs.header.headerProps.currentPeriod)"><i class="fas fa-home"></i> </b-button>
|
</button>
|
||||||
<b-form-datepicker button-only button-variant="secondary"></b-form-datepicker>
|
|
||||||
</b-button-group>
|
|
||||||
<b-button-group class="mx-1">
|
|
||||||
<b-button v-html="'>'" @click="setStartingDay(1)"></b-button>
|
|
||||||
<b-button v-html="'>>'" @click="setShowDate($refs.header.headerProps.nextPeriod)"></b-button>
|
|
||||||
</b-button-group>
|
|
||||||
</b-button-toolbar>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-md-3 col-6">
|
||||||
|
<button class="btn btn-block btn-primary shadow-none" v-b-toggle.sidebar-shopping><i
|
||||||
|
class="fas fa-shopping-cart"></i> {{ $t('Shopping_list') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 col-6">
|
||||||
|
<a class="btn btn-block btn-primary shadow-none" :href="iCalUrl"><i class="fas fa-download"></i>
|
||||||
|
{{ $t('Export_To_ICal') }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 col-6">
|
||||||
|
<button class="btn btn-block btn-primary shadow-none disabled" v-b-tooltip.focus.top
|
||||||
|
:title="$t('Coming_Soon')">
|
||||||
|
{{ $t('Auto_Planner') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 d-flex justify-content-center mt-2 d-block d-md-none">
|
||||||
|
<b-button-toolbar key-nav aria-label="Toolbar with button groups">
|
||||||
|
<b-button-group class="mx-1">
|
||||||
|
<b-button v-html="'<<'" @click="setShowDate($refs.header.headerProps.previousPeriod)"></b-button>
|
||||||
|
<b-button v-html="'<'" @click="setStartingDay(-1)"></b-button>
|
||||||
|
</b-button-group>
|
||||||
|
<b-button-group class="mx-1">
|
||||||
|
<b-button @click="setShowDate($refs.header.headerProps.currentPeriod)"><i class="fas fa-home"></i>
|
||||||
|
</b-button>
|
||||||
|
<b-form-datepicker
|
||||||
|
button-only
|
||||||
|
button-variant="secondary"
|
||||||
|
></b-form-datepicker>
|
||||||
|
</b-button-group>
|
||||||
|
<b-button-group class="mx-1">
|
||||||
|
<b-button v-html="'>'" @click="setStartingDay(1)"></b-button>
|
||||||
|
<b-button v-html="'>>'" @click="setShowDate($refs.header.headerProps.nextPeriod)"></b-button>
|
||||||
|
</b-button-group>
|
||||||
|
</b-button-toolbar>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -279,61 +357,195 @@ Vue.use(VueCookies)
|
|||||||
let SETTINGS_COOKIE_NAME = "mealplan_settings"
|
let SETTINGS_COOKIE_NAME = "mealplan_settings"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MealPlanView",
|
name: "MealPlanView",
|
||||||
components: {
|
components: {
|
||||||
MealPlanEditModal,
|
MealPlanEditModal,
|
||||||
MealPlanCard,
|
MealPlanCard,
|
||||||
CalendarView,
|
CalendarView,
|
||||||
ContextMenu,
|
ContextMenu,
|
||||||
ContextMenuItem,
|
ContextMenuItem,
|
||||||
MealPlanCalenderHeader,
|
MealPlanCalenderHeader,
|
||||||
EmojiInput,
|
EmojiInput,
|
||||||
draggable,
|
draggable
|
||||||
},
|
},
|
||||||
mixins: [CalendarMathMixin, ApiMixin],
|
mixins: [CalendarMathMixin, ApiMixin],
|
||||||
data: function() {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
showDate: new Date(),
|
showDate: new Date(),
|
||||||
plan_entries: [],
|
plan_entries: [],
|
||||||
recipe_viewed: {},
|
recipe_viewed: {},
|
||||||
settings: {
|
settings: {
|
||||||
displayPeriodUom: "week",
|
displayPeriodUom: 'week',
|
||||||
displayPeriodCount: 2,
|
displayPeriodCount: 2,
|
||||||
startingDayOfWeek: 1,
|
startingDayOfWeek: 1,
|
||||||
displayWeekNumbers: true,
|
displayWeekNumbers: true
|
||||||
},
|
},
|
||||||
dragged_item: null,
|
dragged_item: null,
|
||||||
meal_types: [],
|
current_tab: 0,
|
||||||
current_context_menu_item: null,
|
meal_types: [],
|
||||||
options: {
|
current_context_menu_item: null,
|
||||||
displayPeriodUom: [
|
options: {
|
||||||
{ text: this.$t("Week"), value: "week" },
|
displayPeriodUom: [{text: this.$t('Week'), value: 'week'}, {
|
||||||
{
|
text: this.$t('Month'),
|
||||||
text: this.$t("Month"),
|
value: 'month'
|
||||||
value: "month",
|
}, {text: this.$t('Year'), value: 'year'}],
|
||||||
},
|
displayPeriodCount: [1, 2, 3],
|
||||||
{ text: this.$t("Year"), value: "year" },
|
entryEditing: {
|
||||||
],
|
date: null,
|
||||||
displayPeriodCount: [1, 2, 3],
|
id: -1,
|
||||||
entryEditing: {
|
meal_type: null,
|
||||||
date: null,
|
note: "",
|
||||||
id: -1,
|
note_markdown: "",
|
||||||
meal_type: null,
|
recipe: null,
|
||||||
note: "",
|
servings: 1,
|
||||||
note_markdown: "",
|
shared: [],
|
||||||
recipe: null,
|
title: '',
|
||||||
servings: 1,
|
title_placeholder: this.$t('Title')
|
||||||
shared: [],
|
|
||||||
title: "",
|
|
||||||
title_placeholder: this.$t("Title"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shopping_list: [],
|
|
||||||
current_period: null,
|
|
||||||
entryEditing: {},
|
|
||||||
edit_modal_show: false,
|
|
||||||
ical_url: window.ICAL_URL,
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
shopping_list: [],
|
||||||
|
current_period: null,
|
||||||
|
entryEditing: {},
|
||||||
|
edit_modal_show: false,
|
||||||
|
ical_url: window.ICAL_URL
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
modal_title: function () {
|
||||||
|
if (this.entryEditing.id === -1) {
|
||||||
|
return this.$t('Create_Meal_Plan_Entry')
|
||||||
|
} else {
|
||||||
|
return this.$t('Edit_Meal_Plan_Entry')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
entryEditing_initial_recipe: function () {
|
||||||
|
if (this.entryEditing.recipe != null) {
|
||||||
|
return [this.entryEditing.recipe]
|
||||||
|
} else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
entryEditing_initial_meal_type: function () {
|
||||||
|
if (this.entryEditing.meal_type != null) {
|
||||||
|
return [this.entryEditing.meal_type]
|
||||||
|
} else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plan_items: function () {
|
||||||
|
let items = []
|
||||||
|
this.plan_entries.forEach((entry) => {
|
||||||
|
items.push(this.buildItem(entry))
|
||||||
|
})
|
||||||
|
return items
|
||||||
|
},
|
||||||
|
detailed_items: function () {
|
||||||
|
return this.settings.displayPeriodUom === 'week';
|
||||||
|
},
|
||||||
|
dayNames: function () {
|
||||||
|
let options = []
|
||||||
|
this.getFormattedWeekdayNames(this.userLocale, "long", 0).forEach((day, index) => {
|
||||||
|
options.push({text: day, value: index})
|
||||||
|
})
|
||||||
|
return options
|
||||||
|
},
|
||||||
|
userLocale: function () {
|
||||||
|
return this.getDefaultBrowserLocale
|
||||||
|
},
|
||||||
|
item_height: function () {
|
||||||
|
if (this.settings.displayPeriodUom === 'week') {
|
||||||
|
return "10rem"
|
||||||
|
} else {
|
||||||
|
return "1.6rem"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
iCalUrl() {
|
||||||
|
if (this.current_period !== null) {
|
||||||
|
let start = moment(this.current_period.periodStart).format('YYYY-MM-DD')
|
||||||
|
let end = moment(this.current_period.periodEnd).format('YYYY-MM-DD')
|
||||||
|
return this.ical_url.replace(/12345/, start).replace(/6789/, end)
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$nextTick(function () {
|
||||||
|
if (this.$cookies.isKey(SETTINGS_COOKIE_NAME)) {
|
||||||
|
this.settings = Object.assign({}, this.settings, this.$cookies.get(SETTINGS_COOKIE_NAME))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.$root.$on('change', this.updateEmoji);
|
||||||
|
this.$i18n.locale = window.CUSTOM_LOCALE
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
settings: {
|
||||||
|
handler() {
|
||||||
|
this.$cookies.set(SETTINGS_COOKIE_NAME, this.settings, '360d')
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
addToShopping(entry) {
|
||||||
|
if (entry.originalItem.entry.recipe !== null) {
|
||||||
|
this.shopping_list.push(entry.originalItem.entry)
|
||||||
|
makeToast(this.$t("Success"), this.$t("Added_To_Shopping_List"), 'success')
|
||||||
|
} else {
|
||||||
|
makeToast(this.$t("Failure"), this.$t("Cannot_Add_Notes_To_Shopping"), 'danger')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
saveShoppingList() {
|
||||||
|
let url = window.SHOPPING_URL
|
||||||
|
let first = true
|
||||||
|
for (let se of this.shopping_list) {
|
||||||
|
if (first) {
|
||||||
|
url += `?r=[${se.recipe.id},${se.servings}]`
|
||||||
|
first = false
|
||||||
|
} else {
|
||||||
|
url += `&r=[${se.recipe.id},${se.servings}]`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.open(url)
|
||||||
|
},
|
||||||
|
setStartingDay(days) {
|
||||||
|
if (this.settings.startingDayOfWeek + days < 0) {
|
||||||
|
this.settings.startingDayOfWeek = 6
|
||||||
|
} else if (this.settings.startingDayOfWeek + days > 6) {
|
||||||
|
this.settings.startingDayOfWeek = 0
|
||||||
|
} else {
|
||||||
|
this.settings.startingDayOfWeek = this.settings.startingDayOfWeek + days
|
||||||
|
}
|
||||||
|
},
|
||||||
|
newMealType() {
|
||||||
|
let apiClient = new ApiApiFactory()
|
||||||
|
|
||||||
|
apiClient.createMealType({name: this.$t('Meal_Type')}).then(e => {
|
||||||
|
this.periodChangedCallback(this.current_period)
|
||||||
|
}).catch(error => {
|
||||||
|
StandardToasts.makeStandardToast(StandardToasts.FAIL_UPDATE)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.refreshMealTypes()
|
||||||
|
},
|
||||||
|
sortMealTypes() {
|
||||||
|
this.meal_types.forEach(function (element, index) {
|
||||||
|
element.order = index
|
||||||
|
});
|
||||||
|
let updated = 0
|
||||||
|
this.meal_types.forEach((meal_type) => {
|
||||||
|
let apiClient = new ApiApiFactory()
|
||||||
|
|
||||||
|
apiClient.updateMealType(meal_type.id, meal_type).then(e => {
|
||||||
|
if (updated === (this.meal_types.length - 1)) {
|
||||||
|
this.periodChangedCallback(this.current_period)
|
||||||
|
} else {
|
||||||
|
updated++
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
StandardToasts.makeStandardToast(StandardToasts.FAIL_UPDATE)
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
modal_title: function() {
|
modal_title: function() {
|
||||||
|
@ -54,6 +54,71 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-9" style="margin-top: 1vh">
|
||||||
|
<h3>
|
||||||
|
<!-- <span><b-button variant="link" size="sm" class="text-dark shadow-none"><i class="fas fa-chevron-down"></i></b-button></span> -->
|
||||||
|
<model-menu/>
|
||||||
|
<span>{{ this.this_model.name }}</span>
|
||||||
|
<span v-if="this_model.name !== 'Step'"><b-button variant="link" @click="startAction({'action':'new'})"><i
|
||||||
|
class="fas fa-plus-circle fa-2x"></i></b-button></span><!-- TODO add proper field to model config to determine if create should be available or not -->
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3" style="position: relative; margin-top: 1vh">
|
||||||
|
<b-form-checkbox v-model="show_split" name="check-button" v-if="paginated"
|
||||||
|
class="shadow-none"
|
||||||
|
style="position:relative;top: 50%; transform: translateY(-50%);" switch>
|
||||||
|
{{ $t('show_split_screen') }}
|
||||||
|
</b-form-checkbox>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col" :class="{'col-md-6' : show_split}">
|
||||||
|
<!-- model isn't paginated and loads in one API call -->
|
||||||
|
<div v-if="!paginated">
|
||||||
|
<generic-horizontal-card v-for="i in items_left" v-bind:key="i.id"
|
||||||
|
:item=i
|
||||||
|
:model="this_model"
|
||||||
|
@item-action="startAction($event, 'left')"
|
||||||
|
@finish-action="finishAction"/>
|
||||||
|
</div>
|
||||||
|
<!-- model is paginated and needs managed -->
|
||||||
|
<generic-infinite-cards v-if="paginated"
|
||||||
|
:card_counts="left_counts"
|
||||||
|
:scroll="show_split"
|
||||||
|
@search="getItems($event, 'left')"
|
||||||
|
@reset="resetList('left')">
|
||||||
|
<template v-slot:cards>
|
||||||
|
<generic-horizontal-card
|
||||||
|
v-for="i in items_left" v-bind:key="i.id"
|
||||||
|
:item=i
|
||||||
|
:model="this_model"
|
||||||
|
@item-action="startAction($event, 'left')"
|
||||||
|
@finish-action="finishAction"/>
|
||||||
|
</template>
|
||||||
|
</generic-infinite-cards>
|
||||||
|
</div>
|
||||||
|
<div class="col col-md-6" v-if="show_split">
|
||||||
|
<generic-infinite-cards v-if="this_model"
|
||||||
|
:card_counts="right_counts"
|
||||||
|
:scroll="show_split"
|
||||||
|
@search="getItems($event, 'right')"
|
||||||
|
@reset="resetList('right')">
|
||||||
|
<template v-slot:cards>
|
||||||
|
<generic-horizontal-card
|
||||||
|
v-for="i in items_right" v-bind:key="i.id"
|
||||||
|
:item=i
|
||||||
|
:model="this_model"
|
||||||
|
@item-action="startAction($event, 'right')"
|
||||||
|
@finish-action="finishAction"/>
|
||||||
|
</template>
|
||||||
|
</generic-infinite-cards>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -76,28 +141,149 @@ import { ApiApiFactory } from "@/utils/openapi/api"
|
|||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// TODO ApiGenerator doesn't capture and share error information - would be nice to share error details when available
|
// TODO ApiGenerator doesn't capture and share error information - would be nice to share error details when available
|
||||||
// or i'm capturing it incorrectly
|
// or i'm capturing it incorrectly
|
||||||
name: "ModelListView",
|
name: 'ModelListView',
|
||||||
mixins: [CardMixin, ApiMixin],
|
mixins: [CardMixin, ApiMixin, ToastMixin],
|
||||||
components: { GenericHorizontalCard, GenericModalForm, GenericInfiniteCards, ModelMenu },
|
components: {
|
||||||
data() {
|
GenericHorizontalCard, GenericModalForm, GenericInfiniteCards, ModelMenu,
|
||||||
return {
|
},
|
||||||
// this.Models and this.Actions inherited from ApiMixin
|
data() {
|
||||||
items_left: [],
|
return {
|
||||||
items_right: [],
|
// this.Models and this.Actions inherited from ApiMixin
|
||||||
right_counts: { max: 9999, current: 0 },
|
items_left: [],
|
||||||
left_counts: { max: 9999, current: 0 },
|
items_right: [],
|
||||||
this_model: undefined,
|
right_counts: {'max': 9999, 'current': 0},
|
||||||
model_menu: undefined,
|
left_counts: {'max': 9999, 'current': 0},
|
||||||
this_action: {},
|
this_model: undefined,
|
||||||
this_recipe_param: undefined,
|
model_menu: undefined,
|
||||||
this_item: {},
|
this_action: undefined,
|
||||||
this_target: {},
|
this_recipe_param: undefined,
|
||||||
show_modal: false,
|
this_item: {},
|
||||||
show_split: false,
|
this_target: {},
|
||||||
paginated: false,
|
show_modal: false,
|
||||||
header_component_name: undefined,
|
show_split: false,
|
||||||
|
paginated: false,
|
||||||
|
header_component_name: undefined,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
headerComponent() {
|
||||||
|
// TODO this leads webpack to create one .js file for each component in this folder because at runtime any one of them could be requested
|
||||||
|
// TODO this is not necessarily bad but maybe there are better options to do this
|
||||||
|
return () => import(/* webpackChunkName: "header-component" */ `@/components/${this.header_component_name}`)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// value is passed from lists.py
|
||||||
|
let model_config = JSON.parse(document.getElementById('model_config').textContent)
|
||||||
|
this.this_model = this.Models[model_config?.model]
|
||||||
|
this.this_recipe_param = model_config?.recipe_param
|
||||||
|
this.paginated = this.this_model?.paginated ?? false
|
||||||
|
this.header_component_name = this.this_model?.list?.header_component?.name ?? undefined
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (!this.paginated) {
|
||||||
|
this.getItems({page:1},'left')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.$i18n.locale = window.CUSTOM_LOCALE
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// this.genericAPI inherited from ApiMixin
|
||||||
|
resetList: function (e) {
|
||||||
|
this['items_' + e] = []
|
||||||
|
this[e + '_counts'].max = 9999 + Math.random()
|
||||||
|
this[e + '_counts'].current = 0
|
||||||
|
},
|
||||||
|
startAction: function (e, param) {
|
||||||
|
let source = e?.source ?? {}
|
||||||
|
let target = e?.target ?? undefined
|
||||||
|
this.this_item = source
|
||||||
|
this.this_target = target
|
||||||
|
|
||||||
|
switch (e.action) {
|
||||||
|
case 'delete':
|
||||||
|
this.this_action = this.Actions.DELETE
|
||||||
|
this.show_modal = true
|
||||||
|
break;
|
||||||
|
case 'new':
|
||||||
|
this.this_action = this.Actions.CREATE
|
||||||
|
this.show_modal = true
|
||||||
|
break;
|
||||||
|
case 'edit':
|
||||||
|
this.this_item = e.source
|
||||||
|
this.this_action = this.Actions.UPDATE
|
||||||
|
this.show_modal = true
|
||||||
|
break;
|
||||||
|
case 'move':
|
||||||
|
if (target == null) {
|
||||||
|
this.this_item = e.source
|
||||||
|
this.this_action = this.Actions.MOVE
|
||||||
|
this.show_modal = true
|
||||||
|
} else {
|
||||||
|
this.moveThis(source.id, target.id)
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'merge':
|
||||||
|
if (target == null) {
|
||||||
|
this.this_item = e.source
|
||||||
|
this.this_action = this.Actions.MERGE
|
||||||
|
this.show_modal = true
|
||||||
|
} else {
|
||||||
|
this.mergeThis(e.source, e.target, false)
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'merge-automate':
|
||||||
|
if (target == null) {
|
||||||
|
this.this_item = e.source
|
||||||
|
this.this_action = this.Actions.MERGE
|
||||||
|
this.show_modal = true
|
||||||
|
} else {
|
||||||
|
this.mergeThis(e.source, e.target, true)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'get-children':
|
||||||
|
if (source.show_children) {
|
||||||
|
Vue.set(source, 'show_children', false)
|
||||||
|
} else {
|
||||||
|
this.getChildren(param, source)
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'get-recipes':
|
||||||
|
if (source.show_recipes) {
|
||||||
|
Vue.set(source, 'show_recipes', false)
|
||||||
|
} else {
|
||||||
|
this.getRecipes(param, source)
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
finishAction: function (e) {
|
||||||
|
let update = undefined
|
||||||
|
switch (e?.action) {
|
||||||
|
case 'save':
|
||||||
|
this.saveThis(e.form_data)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (e !== 'cancel') {
|
||||||
|
switch (this.this_action) {
|
||||||
|
case this.Actions.DELETE:
|
||||||
|
this.deleteThis(this.this_item.id)
|
||||||
|
break;
|
||||||
|
case this.Actions.CREATE:
|
||||||
|
this.saveThis(e.form_data)
|
||||||
|
break;
|
||||||
|
case this.Actions.UPDATE:
|
||||||
|
update = e.form_data
|
||||||
|
update.id = this.this_item.id
|
||||||
|
this.saveThis(update)
|
||||||
|
break;
|
||||||
|
case this.Actions.MERGE:
|
||||||
|
this.mergeThis(this.this_item, e.form_data.target, false)
|
||||||
|
break;
|
||||||
|
case this.Actions.MOVE:
|
||||||
|
this.moveThis(this.this_item.id, e.form_data.target.id)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -226,7 +226,6 @@ export default {
|
|||||||
updateStartTime: function (e) {
|
updateStartTime: function (e) {
|
||||||
this.start_time = e
|
this.start_time = e
|
||||||
},
|
},
|
||||||
|
|
||||||
updateIngredientCheckedState: function (e) {
|
updateIngredientCheckedState: function (e) {
|
||||||
for (let step of this.recipe.steps) {
|
for (let step of this.recipe.steps) {
|
||||||
for (let ingredient of step.ingredients) {
|
for (let ingredient of step.ingredients) {
|
||||||
|
@ -264,5 +264,10 @@
|
|||||||
"SupermarketName": "Supermarket Name",
|
"SupermarketName": "Supermarket Name",
|
||||||
"CategoryInstruction": "Drag categories to change the order categories appear in shopping list.",
|
"CategoryInstruction": "Drag categories to change the order categories appear in shopping list.",
|
||||||
"shopping_recent_days_desc": "Days of recent shopping list entries to display.",
|
"shopping_recent_days_desc": "Days of recent shopping list entries to display.",
|
||||||
"shopping_recent_days": "Recent Days"
|
"shopping_recent_days": "Recent Days",
|
||||||
|
"Coming_Soon": "Coming-Soon",
|
||||||
|
"Auto_Planner": "Auto-Planner",
|
||||||
|
"New_Cookbook": "New cookbook",
|
||||||
|
"Hide_Keyword": "Hide keywords",
|
||||||
|
"Clear": "Clear"
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user