Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
Hosted Weblate 2021-06-30 14:16:51 +02:00
commit c93c0db8a9
No known key found for this signature in database
GPG key ID: A3FAAA06E6569B4C
6 changed files with 127 additions and 96 deletions

View file

@ -1,12 +1,12 @@
## :warning: Important Notice :warning: #### :warning: IMPORTANT NOTICE for users with EnRecipes v1.3.2 or before:
To continue receiving updates, please update your EnRecipes to v2.0.0 To continue receiving updates, please update your EnRecipes to the latest version.
There are some significant changes in this version. So, in order to continue, you must do the following: There are some significant changes in this version. So, in order to continue, you must do the following:
1. Export a full backup. 1. Export a full backup.
2. Uninstall EnRecipes. 2. Uninstall EnRecipes.
3. Install v2.0.0 and Import your data. 3. Install this version and Import your data.
<p align="center"><a href="https://enrecipes.vercel.app"><img src="fastlane/metadata/android/en-US/images/featureGraphic.png" width="100%"></a></p> <p align="center"><a href="https://enrecipes.vercel.app"><img src="fastlane/metadata/android/en-US/images/featureGraphic.png" width="100%"></a></p>

View file

@ -155,7 +155,7 @@
col="2" col="2"
:text="`${recipe.ingredients[i].unit}` | L" :text="`${recipe.ingredients[i].unit}` | L"
editable="false" editable="false"
@focus="showUnits(1, i)" @focus="!modalOpen && showUnits(1, i)"
@tap="showUnits(0, i)" @tap="showUnits(0, i)"
/> />
<TextField <TextField
@ -714,6 +714,7 @@ export default {
}); });
}, },
showUnits(focus, i) { showUnits(focus, i) {
this.modalOpen = 1;
this.$showModal(Action, { this.$showModal(Action, {
props: { props: {
title: "Unit", title: "Unit",
@ -722,6 +723,7 @@ export default {
selected: this.recipe.ingredients[i].unit, selected: this.recipe.ingredients[i].unit,
}, },
}).then((action) => { }).then((action) => {
this.modalOpen = 0;
if (action == "aNBtn") { if (action == "aNBtn") {
this.$showModal(Prompt, { this.$showModal(Prompt, {
props: { props: {

View file

@ -608,6 +608,7 @@ export default {
}, },
pgUnload() { pgUnload() {
if (this.shake) stopAccelerometerUpdates(); if (this.shake) stopAccelerometerUpdates();
this.releaseBackEvent();
}, },
abLoad({ object }) { abLoad({ object }) {
this.appbar = object; this.appbar = object;

View file

@ -66,7 +66,7 @@
:class="{ r: RTL }" :class="{ r: RTL }"
> >
<RLabel class="sub" :text="'ts' | L" /> <RLabel class="sub" :text="'ts' | L" />
<RLabel class="v" :text="getTags(recipe.tags)" /> <RLabel class="v" :text="getTags" />
</StackLayout> </StackLayout>
<RGridLayout :rtl="RTL" rows="auto" columns="*, *"> <RGridLayout :rtl="RTL" rows="auto" columns="*, *">
<StackLayout class="attrT" :hidden="!hasTime(recipe.prepTime)"> <StackLayout class="attrT" :hidden="!hasTime(recipe.prepTime)">
@ -120,7 +120,7 @@
<RLabel <RLabel
class="v tw" class="v tw"
:class="{ 'tb t t3': !item.type }" :class="{ 'tb t t3': !item.type }"
:text="getIngredientItem(item)" :text="getIng(item)"
/> />
</RStackLayout> </RStackLayout>
</StackLayout> </StackLayout>
@ -234,7 +234,7 @@
col="2" col="2"
v-else v-else
class="ico" class="ico"
:text="icon.done" :text="recipeTried ? icon.try : icon.done"
@tap="toggle('tried', 1)" @tap="toggle('tried', 1)"
/> />
<Button <Button
@ -318,7 +318,6 @@ import * as utils from "~/shared/utils";
const Intl = require("nativescript-intl"); const Intl = require("nativescript-intl");
let barTimer; let barTimer;
declare const android: any; declare const android: any;
export default { export default {
components: { Toast }, components: { Toast },
props: ["filterTrylater", "recipeID", "yieldQuantity"], props: ["filterTrylater", "recipeID", "yieldQuantity"],
@ -348,6 +347,8 @@ export default {
view: null, view: null,
wv: null, wv: null,
showTools: 0, showTools: 0,
snackMsg: null,
recipeTried: 0,
}; };
}, },
computed: { computed: {
@ -378,6 +379,9 @@ export default {
hasPrinterSupport() { hasPrinterSupport() {
return utils.Printer.isSupported(); return utils.Printer.isSupported();
}, },
getTags() {
return this.recipe.tags.join(" · ");
},
}, },
methods: { methods: {
...mapActions(["toggleState", "setR"]), ...mapActions(["toggleState", "setR"]),
@ -392,6 +396,7 @@ export default {
}, },
onPageUnload() { onPageUnload() {
utils.keepScreenOn(0); utils.keepScreenOn(0);
if (this.recipeTried) this.markTried();
}, },
sbload({ object }) { sbload({ object }) {
this.sidebar = object; this.sidebar = object;
@ -401,7 +406,7 @@ export default {
}, },
tbLoad({ object }) { tbLoad({ object }) {
this.toastbar = object; this.toastbar = object;
this.recipe.tried && this.recipe.lastTried && this.showLastTried(); this.recipe.lastTried && this.showLastTried();
}, },
wvLoad({ object }) { wvLoad({ object }) {
this.wv = object; this.wv = object;
@ -527,7 +532,7 @@ export default {
let text = s && !unsel ? ` (${s}/${c})` : ` (${c})`; let text = s && !unsel ? ` (${s}/${c})` : ` (${c})`;
return localize(title) + text; return localize(title) + text;
}, },
getIngredientItem(o) { getIng(o) {
return `${ return `${
this.roundedQuantity(o.quantity) this.roundedQuantity(o.quantity)
? this.roundedQuantity(o.quantity) + " " ? this.roundedQuantity(o.quantity) + " "
@ -614,10 +619,6 @@ export default {
minute: "numeric", minute: "numeric",
}).format(new Date(date)); }).format(new Date(date));
}, },
isValidURL(string) {
let pattern = new RegExp("^https?|^www", "ig");
return pattern.test(string);
},
getCombinationTitle(id) { getCombinationTitle(id) {
return this.recipes.filter((e) => e.id === id)[0].title; return this.recipes.filter((e) => e.id === id)[0].title;
}, },
@ -692,6 +693,22 @@ export default {
}, },
// NavigationHandlers // NavigationHandlers
hijackBackEvent() {
Application.android.on(
AndroidApplication.activityBackPressedEvent,
this.backEvent
);
},
releaseBackEvent() {
Application.android.off(
AndroidApplication.activityBackPressedEvent,
this.backEvent
);
},
backEvent(args) {
args.cancel = true;
this.closePhoto();
},
editRecipe() { editRecipe() {
this.busyEdit = 1; this.busyEdit = 1;
this.$navigateTo(EditRecipe, { this.$navigateTo(EditRecipe, {
@ -714,7 +731,7 @@ export default {
this.syncCombinations(); this.syncCombinations();
this.createNotes(); this.createNotes();
this.yieldMultiplier = this.recipe.yieldQuantity; this.yieldMultiplier = this.recipe.yieldQuantity;
this.recipe.tried && this.recipe.lastTried && this.showLastTried(); this.recipe.lastTried && this.showLastTried();
}, },
// Tools // Tools
@ -767,60 +784,76 @@ export default {
} }
}, },
shareRecipe() { shareRecipe() {
let overview = `${this.recipe.title}\n\n`; let r = this.recipe;
if (this.recipe.rating) let overview = `${r.title}\n\n`;
overview += `${localize("stars")}: ${this.recipe.rating}\n`; if (r.rating) overview += `${localize("stars")}: ${r.rating}\n`;
overview += `${localize("cui")}: ${localize( overview += `${localize("cui")}: ${localize(r.cuisine)}\n${localize(
this.recipe.cuisine "cat"
)}\n${localize("cat")}: ${localize(this.recipe.category)}\n`; )}: ${localize(r.category)}\n`;
if (this.recipe.tags.length) if (r.tags.length)
overview += `${localize("ts")}: ${this.recipe.tags.join(", ")}\n`; overview += `${localize("ts")}: ${r.tags.join(", ")}\n`;
if (this.recipe.prepTime != "00:00") if (r.prepTime != "00:00")
overview += `${localize("prepT")}: ${this.formattedTime( overview += `${localize("prepT")}: ${this.formattedTime(r.prepTime)}\n`;
this.recipe.prepTime if (r.cookTime != "00:00")
)}\n`; overview += `${localize("cookT")}: ${this.formattedTime(r.cookTime)}\n`;
if (this.recipe.cookTime != "00:00")
overview += `${localize("cookT")}: ${this.formattedTime(
this.recipe.cookTime
)}\n`;
overview += `${localize("yld")}: ${this.tempYieldQuantity} ${localize( overview += `${localize("yld")}: ${this.tempYieldQuantity} ${localize(
this.recipe.yieldUnit r.yieldUnit
)}\n${localize("Difficulty level")}: ${localize( )}\n${localize("Difficulty level")}: ${localize(r.difficulty)}\n`;
this.recipe.difficulty
)}\n`;
let shareContent = overview; let shareContent = overview;
if (this.recipe.ingredients.length) { if (r.ingredients.length) {
let ingredients = `\n\n${localize("ings")}:\n\n`; let ingredients = `\n\n${localize("ings")}:\n\n`;
this.recipe.ingredients.forEach((e) => { r.ingredients.forEach((e) => {
ingredients += `- ${ if (e.type) {
e.quantity ingredients += `- ${
? this.roundedQuantity(e.quantity) + e.quantity
" " + ? this.roundedQuantity(e.quantity) +
this.$options.filters.L(e.unit) + " " +
" " localize(e.unit) +
: "" " "
}${e.value}\n`; : ""
}${e.value}\n`;
} else {
ingredients += `\n${
e.quantity
? this.roundedQuantity(e.quantity) +
" " +
localize(e.unit) +
" "
: ""
}${e.value}\n\n`;
}
}); });
shareContent += ingredients; shareContent += ingredients;
} }
if (this.recipe.instructions.length) { let ins = r.instructions;
if (ins.length) {
let a = 1;
let b = 1;
let group = ins.reduce((acc, e) => {
if (!e.type) {
a = 1;
acc.push(b++);
} else acc.push(a++);
return acc;
}, []);
let instructions = `\n\n${localize("inss")}:\n\n`; let instructions = `\n\n${localize("inss")}:\n\n`;
this.recipe.instructions.forEach((e, i) => { ins.forEach(
instructions += `${i + 1}. ${e.value}\n\n`; (e, i) =>
}); (instructions += (e.type ? group[i] + ". " : "") + `${e.value}\n\n`)
);
shareContent += instructions; shareContent += instructions;
} }
if (this.recipe.combinations.length) { if (r.combinations.length) {
let combinations = `\n${localize("cmbs")}:\n\n`; let combinations = `\n${localize("cmbs")}:\n\n`;
this.recipe.combinations.forEach((e, i) => { r.combinations.forEach((e, i) => {
combinations += `${i + 1}. ${this.getCombinationTitle(e)}\n\n`; combinations += `${i + 1}. ${this.getCombinationTitle(e)}\n\n`;
}); });
shareContent += combinations; shareContent += combinations;
} }
if (this.recipe.notes.length) { if (r.notes.length) {
let notes = `\n${localize("nos")}:\n\n`; let notes = `\n${localize("nos")}:\n\n`;
this.recipe.notes.forEach((e, i) => { r.notes.forEach((e, i) => {
notes += `${i + 1}. ${e.value}\n\n`; notes += `${i + 1}. ${e.value}\n\n`;
}); });
shareContent += notes; shareContent += notes;
@ -831,19 +864,25 @@ export default {
}, },
// DataHandlers // DataHandlers
toggle(key: string, setDate: boolean) { toggle(key: string, setDate: number) {
console.log(setDate);
if (setDate) {
this.recipeTried = !this.recipeTried;
} else
this.toggleState({
id: this.currentRecipeID,
key,
setDate,
});
},
markTried() {
this.toggleState({ this.toggleState({
id: this.currentRecipeID, id: this.currentRecipeID,
key, key: "tried",
setDate, setDate: 1,
}); });
if (setDate) this.$navigateBack();
}, },
touchRate({ object, action }, r) { rate(r) {
this.touchFade(object, action);
if (action == "up") this.setRating(r);
},
setRating(r) {
if (r !== this.recipe.rating || r === 1) { if (r !== this.recipe.rating || r === 1) {
if (this.recipe.rating == 1 && r == 1) r = 0; if (this.recipe.rating == 1 && r == 1) r = 0;
this.setR({ this.setR({
@ -853,8 +892,6 @@ export default {
} }
}, },
// ShoppingList
// Notes // Notes
createNote(note) { createNote(note) {
let regex = /(https?:\/\/[^\s]+)/g; let regex = /(https?:\/\/[^\s]+)/g;
@ -887,27 +924,12 @@ export default {
stack.addChild(this.createNote(note.value)) stack.addChild(this.createNote(note.value))
); );
}, },
getTags(tags) { isValidURL(s) {
return tags.join(" · "); let pattern = new RegExp("^https?|^www", "ig");
}, return pattern.test(s);
hijackBackEvent() {
Application.android.on(
AndroidApplication.activityBackPressedEvent,
this.backEvent
);
},
releaseBackEvent() {
Application.android.off(
AndroidApplication.activityBackPressedEvent,
this.backEvent
);
},
backEvent(args) {
if (this.photoOpen) {
args.cancel = true;
this.closePhoto();
} else this.$navigateBack();
}, },
// PhotoViewer
viewPhoto() { viewPhoto() {
this.hideBars(); this.hideBars();
this.photoOpen = 1; this.photoOpen = 1;
@ -978,7 +1000,7 @@ export default {
}); });
}, },
//DuplicateRecipe // Duplicate
duplicateRecipe() { duplicateRecipe() {
this.busyDup = 1; this.busyDup = 1;
let dupRecipe = Object.assign({}, this.recipe); let dupRecipe = Object.assign({}, this.recipe);
@ -1011,9 +1033,9 @@ export default {
i < ings.length - 1 ? "<ul>" : "" i < ings.length - 1 ? "<ul>" : ""
}`; }`;
else else
return `${i < 1 ? "<ul>" : ""}<li>${this.getIngredientItem( return `${i < 1 ? "<ul>" : ""}<li>${this.getIng(e)}</li>${
e i == ings.length - 1 ? "</ul>" : ""
)}</li>${i == ings.length - 1 ? "</ul>" : ""}`; }`;
}) })
.join(""); .join("");
}; };
@ -1069,7 +1091,7 @@ export default {
r.tags.length r.tags.length
? `<div class=attr><div style="grid-column:span 2"><p>${localize( ? `<div class=attr><div style="grid-column:span 2"><p>${localize(
"ts" "ts"
)}<p>${this.getTags(r.tags)}</div></div>` )}<p>${this.getTags}</div></div>`
: "" : ""
} ${ } ${
this.hasTime(r.prepTime) || this.hasTime(r.cookTime) this.hasTime(r.prepTime) || this.hasTime(r.cookTime)
@ -1123,6 +1145,10 @@ export default {
}, },
// Helpers // Helpers
touchRate({ object, action }, r) {
this.touchFade(object, action);
if (action == "up") this.rate(r);
},
touchYield({ object, action }) { touchYield({ object, action }) {
this.touchFade(object, action); this.touchFade(object, action);

View file

@ -1173,16 +1173,16 @@ export default new Vuex.Store({
} }
}, },
toggleState(state, { id, key, setDate }) { toggleState(state, { id, key, setDate }) {
let i = state.recipes.findIndex((e) => e.id == id) let res = state.recipes
state.recipes[i][key] = state.recipes[i][key] ? 0 : 1 let i = res.findIndex((e) => e.id == id)
state.recipes[i][key] = +!res[i][key]
db.execute( db.execute(
`UPDATE recipes SET ${key} = ${state.recipes[i][key]} WHERE id = '${id}'` `UPDATE recipes SET ${key} = ${res[i][key]} WHERE id = '${id}'`
) )
if (setDate) { if (setDate) {
state.recipes[i].lastTried = new Date().getTime() let time = new Date().getTime()
db.execute( state.recipes[i].lastTried = time
`UPDATE recipes SET lastTried = ${state.recipes[i].lastTried} WHERE id = '${id}'` db.execute(`UPDATE recipes SET lastTried = ${time} WHERE id = '${id}'`)
)
} }
}, },
// UnLinkCombinations // UnLinkCombinations

View file

@ -1,3 +1,5 @@
IMPORTANT NOTICE for users with EnRecipes v1.3.2 or before:
To continue receiving updates, please update your EnRecipes to this version. To continue receiving updates, please update your EnRecipes to this version.
There are some significant changes in this version. So, in order to continue, you must do the following: There are some significant changes in this version. So, in order to continue, you must do the following: