Merge branch 'develop' into patch2
This commit is contained in:
commit
1fa9c806a6
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -21,7 +21,7 @@ from cookbook.helper.image_processing import handle_image
|
|||||||
from cookbook.helper.permission_helper import group_required, has_group_permission
|
from cookbook.helper.permission_helper import group_required, has_group_permission
|
||||||
from cookbook.helper.recipe_url_import import parse_cooktime
|
from cookbook.helper.recipe_url_import import parse_cooktime
|
||||||
from cookbook.models import (Comment, Food, Ingredient, Keyword, Recipe,
|
from cookbook.models import (Comment, Food, Ingredient, Keyword, Recipe,
|
||||||
RecipeImport, Step, Sync, Unit, UserPreference)
|
RecipeImport, Step, Sync, Unit, UserPreference, Automation)
|
||||||
from cookbook.tables import SyncTable
|
from cookbook.tables import SyncTable
|
||||||
|
|
||||||
|
|
||||||
@ -153,17 +153,20 @@ def import_url(request):
|
|||||||
recipe.keywords.add(k)
|
recipe.keywords.add(k)
|
||||||
|
|
||||||
for ing in data['recipeIngredient']:
|
for ing in data['recipeIngredient']:
|
||||||
ingredient = Ingredient(space=request.space,)
|
ingredient = Ingredient(space=request.space, )
|
||||||
|
|
||||||
if ing['ingredient']['text'] != '':
|
if food_text := ing['ingredient']['text'].strip() != '':
|
||||||
ingredient.food, f_created = Food.objects.get_or_create(
|
if automation := Automation.objects.filter(space=request.space, type=Automation.FOOD_ALIAS, param_1=food_text).first():
|
||||||
name=ing['ingredient']['text'].strip(), space=request.space
|
ingredient.food.id = automation.param_2
|
||||||
)
|
else:
|
||||||
|
ingredient.food, f_created = Food.objects.get_or_create(name=food_text, space=request.space)
|
||||||
|
|
||||||
if ing['unit'] and ing['unit']['text'] != '':
|
if ing['unit']:
|
||||||
ingredient.unit, u_created = Unit.objects.get_or_create(
|
if unit_text := ing['unit']['text'] != '':
|
||||||
name=ing['unit']['text'].strip(), space=request.space
|
if automation := Automation.objects.filter(space=request.space, type=Automation.UNIT_ALIAS, param_1=unit_text).first():
|
||||||
)
|
ingredient.unit.id = automation.param_2
|
||||||
|
else:
|
||||||
|
ingredient.unit, u_created = Unit.objects.get_or_create(name=unit_text, space=request.space)
|
||||||
|
|
||||||
# TODO properly handle no_amount recipes
|
# TODO properly handle no_amount recipes
|
||||||
if isinstance(ing['amount'], str):
|
if isinstance(ing['amount'], str):
|
||||||
|
@ -97,6 +97,7 @@ import GenericInfiniteCards from "@/components/GenericInfiniteCards";
|
|||||||
import GenericHorizontalCard from "@/components/GenericHorizontalCard";
|
import GenericHorizontalCard from "@/components/GenericHorizontalCard";
|
||||||
import GenericModalForm from "@/components/Modals/GenericModalForm";
|
import GenericModalForm from "@/components/Modals/GenericModalForm";
|
||||||
import ModelMenu from "@/components/ModelMenu";
|
import ModelMenu from "@/components/ModelMenu";
|
||||||
|
import {ApiApiFactory} from "@/utils/openapi/api";
|
||||||
|
|
||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
|
|
||||||
@ -179,9 +180,18 @@ export default {
|
|||||||
this.this_action = this.Actions.MERGE
|
this.this_action = this.Actions.MERGE
|
||||||
this.show_modal = true
|
this.show_modal = true
|
||||||
} else {
|
} else {
|
||||||
this.mergeThis(e.source.id, e.target.id)
|
this.mergeThis(e.source, e.target, false)
|
||||||
}
|
}
|
||||||
break;
|
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':
|
case 'get-children':
|
||||||
if (source.show_children) {
|
if (source.show_children) {
|
||||||
Vue.set(source, 'show_children', false)
|
Vue.set(source, 'show_children', false)
|
||||||
@ -219,7 +229,7 @@ export default {
|
|||||||
this.saveThis(update)
|
this.saveThis(update)
|
||||||
break;
|
break;
|
||||||
case this.Actions.MERGE:
|
case this.Actions.MERGE:
|
||||||
this.mergeThis(this.this_item.id, e.form_data.target.id)
|
this.mergeThis(this.this_item, e.form_data.target, false)
|
||||||
break;
|
break;
|
||||||
case this.Actions.MOVE:
|
case this.Actions.MOVE:
|
||||||
this.moveThis(this.this_item.id, e.form_data.target.id)
|
this.moveThis(this.this_item.id, e.form_data.target.id)
|
||||||
@ -305,7 +315,9 @@ export default {
|
|||||||
this.makeToast(this.$t('Error'), err.bodyText, 'danger')
|
this.makeToast(this.$t('Error'), err.bodyText, 'danger')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
mergeThis: function (source_id, target_id) {
|
mergeThis: function (source, target, automate) {
|
||||||
|
let source_id = source.id
|
||||||
|
let target_id = target.id
|
||||||
if (source_id === target_id) {
|
if (source_id === target_id) {
|
||||||
this.makeToast(this.$t('Error'), this.$t('Cannot merge item with itself'), 'danger')
|
this.makeToast(this.$t('Error'), this.$t('Cannot merge item with itself'), 'danger')
|
||||||
this.clearState()
|
this.clearState()
|
||||||
@ -331,6 +343,28 @@ export default {
|
|||||||
this.makeToast(this.$t('Error'), err.bodyText, 'danger')
|
this.makeToast(this.$t('Error'), err.bodyText, 'danger')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (automate){
|
||||||
|
let apiClient = new ApiApiFactory()
|
||||||
|
|
||||||
|
let automation = {
|
||||||
|
name: `Merge ${source.name} with ${target.name}`,
|
||||||
|
param_1: source.name,
|
||||||
|
param_2: target.id
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.this_model === this.Models.FOOD){
|
||||||
|
automation.type = 'FOOD_ALIAS'
|
||||||
|
}
|
||||||
|
if (this.this_model === this.Models.UNIT){
|
||||||
|
automation.type = 'UNIT_ALIAS'
|
||||||
|
}
|
||||||
|
if (this.this_model === this.Models.KEYWORD){
|
||||||
|
automation.type = 'KEYWORD_ALIAS'
|
||||||
|
}
|
||||||
|
|
||||||
|
apiClient.createAutomation(automation)
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
getChildren: function (col, item) {
|
getChildren: function (col, item) {
|
||||||
let parent = {}
|
let parent = {}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<span>
|
<span>
|
||||||
<b-dropdown variant="link" toggle-class="text-decoration-none" no-caret style="boundary:window">
|
<b-dropdown variant="link" toggle-class="text-decoration-none" right no-caret style="boundary:window">
|
||||||
<template #button-content>
|
<template #button-content>
|
||||||
<i class="fas fa-ellipsis-v" ></i>
|
<i class="fas fa-ellipsis-v" ></i>
|
||||||
</template>
|
</template>
|
||||||
@ -20,6 +20,10 @@
|
|||||||
<i class="fas fa-compress-arrows-alt fa-fw"></i> {{ $t('Merge') }}
|
<i class="fas fa-compress-arrows-alt fa-fw"></i> {{ $t('Merge') }}
|
||||||
</b-dropdown-item>
|
</b-dropdown-item>
|
||||||
|
|
||||||
|
<b-dropdown-item v-if="show_merge" v-on:click="$emit('item-action', 'merge-automate')">
|
||||||
|
<i class="fas fa-robot fa-fw"></i> {{$t('Merge')}} & {{$t('Automate')}}
|
||||||
|
</b-dropdown-item>
|
||||||
|
|
||||||
</b-dropdown>
|
</b-dropdown>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
@ -80,13 +80,16 @@
|
|||||||
<!-- this should be made a generic component, would also require mixin for functions that generate the popup and put in parent container-->
|
<!-- this should be made a generic component, would also require mixin for functions that generate the popup and put in parent container-->
|
||||||
<b-list-group ref="tooltip" variant="light" v-show="show_menu" v-on-clickaway="closeMenu" style="z-index:9999; cursor:pointer">
|
<b-list-group ref="tooltip" variant="light" v-show="show_menu" v-on-clickaway="closeMenu" style="z-index:9999; cursor:pointer">
|
||||||
<b-list-group-item v-if="useMove" action v-on:click="$emit('item-action',{'action': 'move', 'target': item, 'source': source}); closeMenu()">
|
<b-list-group-item v-if="useMove" action v-on:click="$emit('item-action',{'action': 'move', 'target': item, 'source': source}); closeMenu()">
|
||||||
<i class="fas fa-expand-arrows-alt fa-fw"></i> {{$t('Move')}}: {{$t('move_confirmation', {'child': source.name,'parent':item.name})}}
|
<i class="fas fa-expand-arrows-alt fa-fw"></i> <b>{{$t('Move')}}</b>: <span v-html="$t('move_confirmation', {'child': source.name,'parent':item.name})"></span>
|
||||||
</b-list-group-item>
|
</b-list-group-item>
|
||||||
<b-list-group-item v-if="useMerge" action v-on:click="$emit('item-action',{'action': 'merge', 'target': item, 'source': source}); closeMenu()">
|
<b-list-group-item v-if="useMerge" action v-on:click="$emit('item-action',{'action': 'merge', 'target': item, 'source': source}); closeMenu()">
|
||||||
<i class="fas fa-compress-arrows-alt fa-fw"></i> {{$t('Merge')}}: {{ $t('merge_confirmation', {'source': source.name,'target':item.name}) }}
|
<i class="fas fa-compress-arrows-alt fa-fw"></i> <b>{{$t('Merge')}}</b>: <span v-html="$t('merge_confirmation', {'source': source.name,'target':item.name})"></span>
|
||||||
|
</b-list-group-item>
|
||||||
|
<b-list-group-item v-if="useMerge" action v-on:click="$emit('item-action',{'action': 'merge-automate', 'target': item, 'source': source}); closeMenu()">
|
||||||
|
<i class="fas fa-robot fa-fw"></i> <b>{{$t('Merge')}} & {{$t('Automate')}}</b>: <span v-html="$t('merge_confirmation', {'source': source.name,'target':item.name})"></span> {{$t('create_rule')}}
|
||||||
</b-list-group-item>
|
</b-list-group-item>
|
||||||
<b-list-group-item action v-on:click="closeMenu()">
|
<b-list-group-item action v-on:click="closeMenu()">
|
||||||
{{$t('Cancel')}}
|
<i class="fas fa-times fa-fw"></i> <b>{{$t('Cancel')}}</b>
|
||||||
</b-list-group-item>
|
</b-list-group-item>
|
||||||
<!-- TODO add to shopping list -->
|
<!-- TODO add to shopping list -->
|
||||||
<!-- TODO add to and/or manage pantry -->
|
<!-- TODO add to and/or manage pantry -->
|
||||||
|
@ -86,7 +86,9 @@ export default {
|
|||||||
'new_value': function () {
|
'new_value': function () {
|
||||||
let x = this?.new_value
|
let x = this?.new_value
|
||||||
// pass the unflattened attributes that can be restored when ready to save/update
|
// pass the unflattened attributes that can be restored when ready to save/update
|
||||||
x['__override__'] = this.unflattenItem(this?.new_value)
|
if (this.form?.ordered) {
|
||||||
|
x['__override__'] = this.unflattenItem(this?.new_value)
|
||||||
|
}
|
||||||
this.$root.$emit('change', this.form.field, x)
|
this.$root.$emit('change', this.form.field, x)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
</b-dropdown-item>
|
</b-dropdown-item>
|
||||||
|
|
||||||
<b-dropdown-item :href="resolveDjangoUrl('list_automation')">
|
<b-dropdown-item :href="resolveDjangoUrl('list_automation')">
|
||||||
<i class="fas fa-cogs fa-fw"></i> {{ Models['AUTOMATION'].name }}
|
<i class="fas fa-robot fa-fw"></i> {{ Models['AUTOMATION'].name }}
|
||||||
</b-dropdown-item>
|
</b-dropdown-item>
|
||||||
|
|
||||||
</b-dropdown>
|
</b-dropdown>
|
||||||
|
@ -111,8 +111,9 @@
|
|||||||
"Merge": "Merge",
|
"Merge": "Merge",
|
||||||
"Parent": "Parent",
|
"Parent": "Parent",
|
||||||
"delete_confirmation": "Are you sure that you want to delete {source}?",
|
"delete_confirmation": "Are you sure that you want to delete {source}?",
|
||||||
"move_confirmation": "Move {child} to parent {parent}",
|
"move_confirmation": "Move <i>{child}</i> to parent <i>{parent}</i>",
|
||||||
"merge_confirmation": "Replace {source} with {target}",
|
"merge_confirmation": "Replace <i>{source}</i> with <i>{target}</i>",
|
||||||
|
"create_rule": "and create automation",
|
||||||
"move_selection": "Select a parent {type} to move {source} to.",
|
"move_selection": "Select a parent {type} to move {source} to.",
|
||||||
"merge_selection": "Replace all occurrences of {source} with the selected {type}.",
|
"merge_selection": "Replace all occurrences of {source} with the selected {type}.",
|
||||||
"Root": "Root",
|
"Root": "Root",
|
||||||
@ -152,6 +153,7 @@
|
|||||||
"and_up": "& Up",
|
"and_up": "& Up",
|
||||||
"Instructions": "Instructions",
|
"Instructions": "Instructions",
|
||||||
"Unrated": "Unrated",
|
"Unrated": "Unrated",
|
||||||
|
"Automate": "Automate",
|
||||||
"Key_Ctrl": "Ctrl",
|
"Key_Ctrl": "Ctrl",
|
||||||
"Key_Shift": "Shift",
|
"Key_Shift": "Shift",
|
||||||
"Time": "Time",
|
"Time": "Time",
|
||||||
|
@ -89,8 +89,8 @@
|
|||||||
"Move": "Déplacer",
|
"Move": "Déplacer",
|
||||||
"Merge": "Fusionner",
|
"Merge": "Fusionner",
|
||||||
"Parent": "Parent",
|
"Parent": "Parent",
|
||||||
"move_confirmation": "Déplacer {child} vers le parent {parent}",
|
"move_confirmation": "Déplacer <i>{child}</i> vers le parent <i>{parent}</i>",
|
||||||
"merge_confirmation": "Remplacer {source} par {target}",
|
"merge_confirmation": "Remplacer <i>{source}</i> par <i>{target}</i>",
|
||||||
"Root": "Racine",
|
"Root": "Racine",
|
||||||
"delete_confirmation": "Êtes-vous sûr de vouloir supprimer {source} ?",
|
"delete_confirmation": "Êtes-vous sûr de vouloir supprimer {source} ?",
|
||||||
"Shopping_Category": "Catégorie de courses",
|
"Shopping_Category": "Catégorie de courses",
|
||||||
|
@ -92,8 +92,8 @@
|
|||||||
"Merge": "Unisci",
|
"Merge": "Unisci",
|
||||||
"Parent": "Primario",
|
"Parent": "Primario",
|
||||||
"delete_confimation": "Sei sicuro di voler eliminare {kw} e tutti gli elementi dipendenti?",
|
"delete_confimation": "Sei sicuro di voler eliminare {kw} e tutti gli elementi dipendenti?",
|
||||||
"move_confirmation": "Sposta {child} al primario {parent}",
|
"move_confirmation": "Sposta <i>{child}</i> al primario <i>{parent}</i>",
|
||||||
"merge_confirmation": "Sostituisci {source} con {target}",
|
"merge_confirmation": "Sostituisci <i>{source}</i> con <i>{target}</i>",
|
||||||
"move_selection": "Scegli un primario {type} dove spostare {source}.",
|
"move_selection": "Scegli un primario {type} dove spostare {source}.",
|
||||||
"merge_selection": "Sostituisci tutte le voci di {source} con il {type} selezionato.",
|
"merge_selection": "Sostituisci tutte le voci di {source} con il {type} selezionato.",
|
||||||
"Root": "Radice",
|
"Root": "Radice",
|
||||||
|
@ -82,8 +82,8 @@
|
|||||||
"Recipes": "Recepten",
|
"Recipes": "Recepten",
|
||||||
"Move": "Verplaats",
|
"Move": "Verplaats",
|
||||||
"Parent": "Ouder",
|
"Parent": "Ouder",
|
||||||
"move_confirmation": "Verplaats {child} naar ouder {parent}",
|
"move_confirmation": "Verplaats <i>{child}</i> naar ouder <i>{parent}</i>",
|
||||||
"merge_confirmation": "Vervang {source} with {target}",
|
"merge_confirmation": "Vervang <i>{source}</i> with <i>{target}</i>",
|
||||||
"move_selection": "Selecteer een ouder {type} om {source} naar te verplaatsen.",
|
"move_selection": "Selecteer een ouder {type} om {source} naar te verplaatsen.",
|
||||||
"merge_selection": "Vervang alle voorvallen van {source} door het type {type}.",
|
"merge_selection": "Vervang alle voorvallen van {source} door het type {type}.",
|
||||||
"Root": "Bron",
|
"Root": "Bron",
|
||||||
|
@ -17,7 +17,7 @@ export function makeToast(title, message, variant = null) {
|
|||||||
toaster.$bvToast.toast(message, {
|
toaster.$bvToast.toast(message, {
|
||||||
title: title,
|
title: title,
|
||||||
variant: variant,
|
variant: variant,
|
||||||
toaster: 'b-toaster-top-center',
|
toaster: 'b-toaster-bottom-right',
|
||||||
solid: true
|
solid: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user