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

This commit is contained in:
Hosted Weblate 2021-07-03 18:23:39 +02:00
commit a9db1a24b7
No known key found for this signature in database
GPG key ID: A3FAAA06E6569B4C
4 changed files with 82 additions and 82 deletions

View file

@ -1,10 +1,10 @@
<template> <template>
<Page @loaded="pgLoad" actionBarHidden="true"> <Page @loaded="pageL" actionBarHidden="true">
<RGridLayout :rtl="RTL" rows="*, auto" columns="auto, *"> <RGridLayout :rtl="RTL" rows="*, auto" columns="auto, *">
<OptionsList title="db" :items="items" /> <OptionsList title="db" :items="items" />
<GridLayout <GridLayout
:hidden="toast || progress" :hidden="toast || progress"
@loaded="abLoad" @loaded="appbarL"
row="1" row="1"
class="appbar rtl" class="appbar rtl"
rows="*" rows="*"
@ -12,7 +12,7 @@
> >
<Button class="ico" :text="icon.back" @tap="$navigateBack()" /> <Button class="ico" :text="icon.back" @tap="$navigateBack()" />
</GridLayout> </GridLayout>
<Toast :onload="tbLoad" :toast="toast" :action="hideBar" /> <Toast :onload="toastL" :toast="toast" :action="hideBar" />
<RGridLayout <RGridLayout
:rtl="RTL" :rtl="RTL"
v-show="progress" v-show="progress"
@ -60,7 +60,7 @@ export default {
data() { data() {
return { return {
backupFolder: 0, backupFolder: 0,
progress: 0, progress: null,
toast: 0, toast: 0,
appbar: 0, appbar: 0,
toastbar: 0, toastbar: 0,
@ -117,7 +117,7 @@ export default {
"unLinkBIs", "unLinkBIs",
"clearIS", "clearIS",
]), ]),
pgLoad({ object }) { pageL({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
const ContentResolver = const ContentResolver =
Application.android.nativeApp.getContentResolver(); Application.android.nativeApp.getContentResolver();
@ -129,10 +129,10 @@ export default {
this.backupFolder = null; this.backupFolder = null;
} }
}, },
abLoad({ object }) { appbarL({ object }) {
this.appbar = object; this.appbar = object;
}, },
tbLoad({ object }) { toastL({ object }) {
this.toastbar = object; this.toastbar = object;
}, },
@ -180,7 +180,7 @@ export default {
this.progress = localize("expip"); this.progress = localize("expip");
this.hijackBackEvent(); this.hijackBackEvent();
let date = new Date(); let date = new Date();
let formattedDate = let intlDate =
date.getFullYear() + date.getFullYear() +
"-" + "-" +
("0" + (date.getMonth() + 1)).slice(-2) + ("0" + (date.getMonth() + 1)).slice(-2) +
@ -194,13 +194,13 @@ export default {
// Copy db file to EnRecipes folder // Copy db file to EnRecipes folder
utils.copyDBToExport(); utils.copyDBToExport();
let filename = `${localize("EnRecipes")}_${formattedDate}.zip`; let filename = `${localize("EnRecipes")}_${intlDate}.zip`;
let fromPath = path.join(knownFolders.documents().path, "EnRecipes"); let fromPath = path.join(knownFolders.documents().path, "EnRecipes");
utils.Zip.zip(fromPath, this.backupFolder, filename) utils.Zip.zip(fromPath, this.backupFolder, filename)
.then((res) => res && this.showExportSummary(filename)) .then((res) => res && this.showExportSummary(filename))
.catch((err) => { .catch((err) => {
console.log("Backup error: ", err); console.log("Backup error: ", err);
this.progress = null; this.progress = 0;
this.releaseBackEvent(); this.releaseBackEvent();
this.setBackupFolder(1); this.setBackupFolder(1);
}); });
@ -213,7 +213,7 @@ export default {
"EnRecipes.db" "EnRecipes.db"
) )
); );
this.progress = null; this.progress = 0;
this.releaseBackEvent(); this.releaseBackEvent();
let description = localize("buto", `"${filename}"`); let description = localize("buto", `"${filename}"`);
this.$showModal(Confirm, { this.$showModal(Confirm, {
@ -333,7 +333,7 @@ export default {
} else this.failedImport(localize("buEmp")); } else this.failedImport(localize("buEmp"));
}, },
failedImport(description) { failedImport(description) {
this.progress = null; this.progress = 0;
this.releaseBackEvent(); this.releaseBackEvent();
knownFolders.temp().clear(); knownFolders.temp().clear();
this.$showModal(Confirm, { this.$showModal(Confirm, {
@ -434,7 +434,7 @@ export default {
}); });
}, },
showImportSummary() { showImportSummary() {
this.progress = null; this.progress = 0;
this.releaseBackEvent(); this.releaseBackEvent();
let { found, imported, updated } = this.impSum; let { found, imported, updated } = this.impSum;
let exists = Math.abs(found - imported - updated) + updated; let exists = Math.abs(found - imported - updated) + updated;

View file

@ -386,8 +386,8 @@ export default new Vuex.Store({
}, },
], ],
shake: getNumber('shake', 1), // ShakeViewRandomRecipe shake: getNumber('shake', 1), // ShakeViewRandomRecipe
// ImportSummary
impSum: { impSum: {
// ImportSummary
found: 0, found: 0,
imported: 0, imported: 0,
updated: 0, updated: 0,
@ -575,24 +575,18 @@ export default new Vuex.Store({
f.match(/tags|ingredients|instructions|combinations|notes/) && f.match(/tags|ingredients|instructions|combinations|notes/) &&
(e[f] = JSON.parse(e[f])) (e[f] = JSON.parse(e[f]))
) )
if ( if (e.ingredients.length && !('type' in e.ingredients[0])) {
e.ingredients.length && e.ingredients = e.ingredients.map(({ quantity, unit, item }) => {
!e.ingredients[0].hasOwnProperty('type')
) {
e.ingredients = e.ingredients.map((e) => {
return { return {
id: utils.getRandomID(1), id: utils.getRandomID(1),
type: 1, type: 1,
quantity: e.quantity, quantity,
unit: e.unit, unit,
value: e.item, value: item,
} }
}) })
} }
if ( if (e.instructions.length && !('type' in e.instructions[0])) {
e.instructions.length &&
!e.instructions[0].hasOwnProperty('type')
) {
e.instructions = e.instructions.map((e) => { e.instructions = e.instructions.map((e) => {
return { return {
id: utils.getRandomID(1), id: utils.getRandomID(1),
@ -601,7 +595,7 @@ export default new Vuex.Store({
} }
}) })
} }
if (e.notes.length && !e.notes[0].hasOwnProperty('value')) { if (e.notes.length && !('value' in e.notes[0])) {
e.notes = e.notes.map((e) => { e.notes = e.notes.map((e) => {
return { return {
id: utils.getRandomID(1), id: utils.getRandomID(1),
@ -633,28 +627,25 @@ export default new Vuex.Store({
r.image = r.imageSrc.replace('enrecipes', 'EnRecipes') r.image = r.imageSrc.replace('enrecipes', 'EnRecipes')
delete r.imageSrc delete r.imageSrc
} }
if (!r.hasOwnProperty('cuisine')) r.cuisine = 'Undefined' if (!('cuisine' in r)) r.cuisine = 'Undefined'
if (!r.hasOwnProperty('tags')) r.tags = [] if (!('tags' in r)) r.tags = []
if (!r.hasOwnProperty('difficulty')) r.difficulty = 'Easy' if (!('difficulty' in r)) r.difficulty = 'Easy'
if (!r.hasOwnProperty('rating')) r.rating = 0 if (!('rating' in r)) r.rating = 0
if (!r.hasOwnProperty('created')) r.created = r.lastModified if (!('created' in r)) r.created = r.lastModified
r.yieldQuantity = r.yield.quantity r.yieldQuantity = r.yield.quantity
r.yieldUnit = r.yield.unit r.yieldUnit = r.yield.unit
delete r.yield delete r.yield
function getTime(d) { function getTime(d) {
return new Date(d).getTime() return new Date(d).getTime()
} }
if ( if (r.ingredients.length && !('type' in r.ingredients[0])) {
r.ingredients.length && r.ingredients = r.ingredients.map(({ quantity, unit, item }) => {
!r.ingredients[0].hasOwnProperty('type')
) {
r.ingredients = r.ingredients.map((e) => {
return { return {
id: utils.getRandomID(1), id: utils.getRandomID(1),
type: 1, type: 1,
quantity: e.quantity, quantity,
unit: e.unit, unit,
value: e.item, value: item,
} }
}) })
} }
@ -670,7 +661,7 @@ export default new Vuex.Store({
} }
}) })
} }
if (r.notes.length && !r.notes[0].hasOwnProperty('type')) { if (r.notes.length && !r.notes[0].hasOwnProperty('value')) {
r.notes = r.notes.map((e) => { r.notes = r.notes.map((e) => {
return { return {
id: utils.getRandomID(1), id: utils.getRandomID(1),
@ -774,9 +765,8 @@ export default new Vuex.Store({
) )
if (partition[0].length) createDocuments(partition[0]) if (partition[0].length) createDocuments(partition[0])
if (partition[1].length) updateDocuments(partition[1]) if (partition[1].length) updateDocuments(partition[1])
} else { } else createDocuments(ao)
createDocuments(ao)
}
state.impSum.found = ao.length state.impSum.found = ao.length
state.impSum.imported = imported state.impSum.imported = imported
state.impSum.updated = updated state.impSum.updated = updated
@ -786,47 +776,50 @@ export default new Vuex.Store({
let localRecipesIDs: string[], partition: any[] let localRecipesIDs: string[], partition: any[]
let imported = 0 let imported = 0
let updated = 0 let updated = 0
function getUpdatedData(data: any[]) { const getUpdatedData = (data) => {
return data.map((recipe) => { return data.map((recipe) => {
let r = Object.assign({}, recipe) let r = Object.assign({}, recipe)
if ( let ings = JSON.parse(r.ingredients)
r.ingredients.length && let inss = JSON.parse(r.instructions)
!r.ingredients[0].hasOwnProperty('type') let notes = JSON.parse(r.notes)
) { if (ings.length && !('type' in ings[0])) {
r.ingredients = r.ingredients.map((e) => { r.ingredients = JSON.stringify(
return { ings.map((e) => {
id: utils.getRandomID(1), return {
type: 1, id: utils.getRandomID(1),
quantity: e.quantity, type: 1,
unit: e.unit, quantity: e.quantity,
value: e.item, unit: e.unit,
} value: e.item,
}) }
})
)
} }
if ( if (inss.length && !inss[0].hasOwnProperty('type')) {
r.instructions.length && r.instructions = JSON.stringify(
!r.instructions[0].hasOwnProperty('type') inss.map((e) => {
) { return {
r.instructions = r.instructions.map((e) => { id: utils.getRandomID(1),
return { type: 1,
id: utils.getRandomID(1), value: e,
type: 1, }
value: e, })
} )
})
} }
if (r.notes.length && !r.notes[0].hasOwnProperty('value')) { if (notes.length && !notes[0].hasOwnProperty('value')) {
r.notes = r.notes.map((e) => { r.notes = JSON.stringify(
return { notes.map((e) => {
id: utils.getRandomID(1), return {
value: e, id: utils.getRandomID(1),
} value: e,
}) }
})
)
} }
return r return r
}) })
} }
function createDocuments(data: any[]) { const createDocuments = (data) => {
data = getUpdatedData(data) data = getUpdatedData(data)
data.forEach((r) => { data.forEach((r) => {
const cols = Object.keys(r).join(', ') const cols = Object.keys(r).join(', ')
@ -846,7 +839,7 @@ export default new Vuex.Store({
state.recipes.push(r) state.recipes.push(r)
}) })
} }
function updateDocuments(data: any[]) { const updateDocuments = (data) => {
data = getUpdatedData(data) data = getUpdatedData(data)
data.forEach((r) => { data.forEach((r) => {
let recipeIndex = state.recipes let recipeIndex = state.recipes
@ -889,6 +882,7 @@ export default new Vuex.Store({
if (partition[0].length) createDocuments(partition[0]) if (partition[0].length) createDocuments(partition[0])
if (partition[1].length) updateDocuments(partition[1]) if (partition[1].length) updateDocuments(partition[1])
} else createDocuments(ao) } else createDocuments(ao)
console.log(ao.length)
state.impSum.found = ao.length state.impSum.found = ao.length
state.impSum.imported = imported state.impSum.imported = imported
state.impSum.updated = updated state.impSum.updated = updated
@ -1038,7 +1032,7 @@ export default new Vuex.Store({
importMPsJSON(state, ao) { importMPsJSON(state, ao) {
let updatedMealPlans = [] let updatedMealPlans = []
let newMealPlans = ao.filter((e) => { let newMealPlans = ao.filter((e) => {
if (e.hasOwnProperty('eventColor')) { if ('eventColor' in e) {
return !state.mealPlans.some((f) => { return !state.mealPlans.some((f) => {
let d = new Date(e.startDate) let d = new Date(e.startDate)
let date = new Date( let date = new Date(
@ -1076,7 +1070,7 @@ export default new Vuex.Store({
p.recipeID = p.title p.recipeID = p.title
p.quantity = 1 p.quantity = 1
p.note = null p.note = null
if (p.hasOwnProperty('eventColor')) { if ('eventColor' in p) {
let d = new Date(p.startDate) let d = new Date(p.startDate)
p.date = new Date( p.date = new Date(
d.getFullYear(), d.getFullYear(),

View file

@ -327,5 +327,8 @@
"esgbInfo": "Disable this option if you have any navigation issues", "esgbInfo": "Disable this option if you have any navigation issues",
"sect": "Section %s", "sect": "Section %s",
"addSectBtn": "ADD SECTION", "addSectBtn": "ADD SECTION",
"sectRm": "Section removed" "sectRm": "Section removed",
} "mSystem": "Measuring system",
"mtrc": "Metric",
"imprl": "Imperial"
}

View file

@ -1,3 +1,6 @@
- Add sections to your recipe ingredients and instructions - Add sections to your recipe ingredients and instructions
- Adding or removing items in the recipe editor is even more easier - Adding or removing items in the recipe editor is even more easier
- Ingredient quantities are now shown in fractions
- Ingredient units are automatically converted during scaling
- Switch measuring system under interface setting
- Bug fixes and improvements - Bug fixes and improvements