1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-19 13:19:41 +02:00
mealie/frontend/src/utils/index.js
sephrat 80f8806604
Localize more dates and texts (#341)
* Localize more dates and texts

* Adapt source language to 4-letter code for VS code

* Make page titles more reactive to language change

* Translate missing text + fix missed refactoring

* Fix missed page titles refactoring

* Translate nutrition view

* Translate Image upload vue

* Fix default text being defined twice in upload btn
2021-04-22 22:13:00 -08:00

51 lines
1.3 KiB
JavaScript

import { vueApp } from "../main";
// TODO: Migrate to Mixins
const notifyHelpers = {
baseCSS: "notify-base",
error: "notify-error-color",
warning: "notify-warning-color",
success: "notify-success-color",
info: "notify-info-color",
};
export default {
getImageURL(image) {
return `/api/recipes/${image}/image?image_type=small`;
},
generateUniqueKey(item, index) {
const uniqueKey = `${item}-${index}`;
return uniqueKey;
},
getDateAsPythonDate(dateObject) {
const month = dateObject.getUTCMonth() + 1;
const day = dateObject.getUTCDate();
const year = dateObject.getFullYear();
return `${year}-${month}-${day}`;
},
notify: {
show: function(text, type = "info", title = null) {
vueApp.flashMessage.show({
status: type,
title: title,
message: text,
time: 3000,
blockClass: `${notifyHelpers.baseCSS} ${notifyHelpers[type]}`,
contentClass: `${notifyHelpers.baseCSS} ${notifyHelpers[type]}`,
});
},
info: function(text, title = null) {
this.show(text, "info", title);
},
success: function(text, title = null) {
this.show(text, "success", title);
},
error: function(text, title = null) {
this.show(text, "error", title);
},
warning: function(text, title = null) {
this.show(text, "warning", title);
},
},
};