mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-02 20:59:28 -05:00
recipe book context menu
This commit is contained in:
@@ -37,23 +37,6 @@ export function apiLogCooking(cook_log) {
|
||||
})
|
||||
}
|
||||
|
||||
export function apiLoadCookBooks(query) {
|
||||
return axios.get(resolveDjangoUrl('api:recipebook-list') + '?query=' + query).then((response) => {
|
||||
return response.data
|
||||
}).catch((err) => {
|
||||
//handleError(err, 'There was an error loading a resource!', 'danger')
|
||||
})
|
||||
}
|
||||
|
||||
export function apiAddRecipeBookEntry(entry) {
|
||||
return axios.post(resolveDjangoUrl('api:recipebookentry-list',), entry).then((response) => {
|
||||
makeToast('Saved', 'Recipe Book entry saved!', 'success')
|
||||
}).catch((err) => {
|
||||
handleError(err, 'There was an error creating a resource!', 'danger')
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function handleError(error, message) {
|
||||
if ('response' in error) {
|
||||
console.log(error.response)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Utility functions to call bootstrap toasts
|
||||
* */
|
||||
import {BToast} from 'bootstrap-vue'
|
||||
import i18n from "@/i18n";
|
||||
|
||||
export const ToastMixin = {
|
||||
methods: {
|
||||
@@ -21,6 +22,49 @@ export function makeToast(title, message, variant = null) {
|
||||
})
|
||||
}
|
||||
|
||||
export class StandardToasts {
|
||||
static SUCCESS_CREATE = 'SUCCESS_CREATE'
|
||||
static SUCCESS_FETCH = 'SUCCESS_FETCH'
|
||||
static SUCCESS_UPDATE = 'SUCCESS_UPDATE'
|
||||
static SUCCESS_DELETE = 'SUCCESS_DELETE'
|
||||
|
||||
static FAIL_CREATE = 'FAIL_CREATE'
|
||||
static FAIL_FETCH = 'FAIL_FETCH'
|
||||
static FAIL_UPDATE = 'FAIL_UPDATE'
|
||||
static FAIL_DELETE = 'FAIL_DELETE'
|
||||
|
||||
static makeStandardToast(toast) {
|
||||
switch (toast) {
|
||||
case StandardToasts.SUCCESS_CREATE:
|
||||
makeToast(i18n.tc('Success'), i18n.tc('success_creating_resource'), 'success')
|
||||
break;
|
||||
case StandardToasts.SUCCESS_FETCH:
|
||||
makeToast(i18n.tc('Success'), i18n.tc('success_fetching_resource'), 'success')
|
||||
break;
|
||||
case StandardToasts.SUCCESS_UPDATE:
|
||||
makeToast(i18n.tc('Success'), i18n.tc('success_updating_resource'), 'success')
|
||||
break;
|
||||
case StandardToasts.SUCCESS_DELETE:
|
||||
makeToast(i18n.tc('Success'), i18n.tc('success_deleting_resource'), 'success')
|
||||
break;
|
||||
case StandardToasts.FAIL_CREATE:
|
||||
makeToast(i18n.tc('Failure'), i18n.tc('success_creating_resource'), 'danger')
|
||||
break;
|
||||
case StandardToasts.FAIL_FETCH:
|
||||
makeToast(i18n.tc('Failure'), i18n.tc('err_fetching_resource'), 'danger')
|
||||
break;
|
||||
case StandardToasts.FAIL_UPDATE:
|
||||
makeToast(i18n.tc('Failure'), i18n.tc('err_updating_resource'), 'danger')
|
||||
break;
|
||||
case StandardToasts.FAIL_DELETE:
|
||||
makeToast(i18n.tc('Failure'), i18n.tc('err_deleting_resource'), 'danger')
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Utility functions to use djangos gettext
|
||||
* */
|
||||
|
||||
Reference in New Issue
Block a user