Only show notification text on errors

Fixes #377
This commit is contained in:
rijkvanzanten
2020-09-21 12:27:36 -04:00
parent b009fa86b1
commit adb786ed91
3 changed files with 10 additions and 33 deletions

View File

@@ -93,12 +93,6 @@ export function useItem(collection: Ref<string>, primaryKey: Ref<string | number
notify({
title: i18n.tc('item_create_success', isBatch.value ? 2 : 1),
text: i18n.tc('item_in', isBatch.value ? 2 : 1, {
collection: collection.value,
primaryKey: isBatch.value
? (primaryKey.value as string).split(',').join(', ')
: primaryKey.value,
}),
type: 'success',
});
} else {
@@ -106,12 +100,6 @@ export function useItem(collection: Ref<string>, primaryKey: Ref<string | number
notify({
title: i18n.tc('item_update_success', isBatch.value ? 2 : 1),
text: i18n.tc('item_in', isBatch.value ? 2 : 1, {
collection: collection.value,
primaryKey: isBatch.value
? (primaryKey.value as string).split(',').join(', ')
: primaryKey.value,
}),
type: 'success',
});
}
@@ -145,9 +133,11 @@ export function useItem(collection: Ref<string>, primaryKey: Ref<string | number
}
if (err?.response?.data?.errors) {
validationErrors.value = err.response.data.errors.filter((err: APIError) => err.extensions.code === 'FAILED_VALIDATION').map((err: APIError) => {
return err.extensions;
});
validationErrors.value = err.response.data.errors
.filter((err: APIError) => err.extensions.code === 'FAILED_VALIDATION')
.map((err: APIError) => {
return err.extensions;
});
} else {
throw err;
}
@@ -175,10 +165,6 @@ export function useItem(collection: Ref<string>, primaryKey: Ref<string | number
notify({
title: i18n.t('item_create_success'),
text: i18n.tc('item_in', isBatch.value ? 2 : 1, {
collection: collection.value,
primaryKey: isBatch.value ? (primaryKey.value as string).split(',').join(', ') : primaryKey.value,
}),
type: 'success',
});
@@ -194,9 +180,11 @@ export function useItem(collection: Ref<string>, primaryKey: Ref<string | number
});
if (err?.response?.data?.errors) {
validationErrors.value = err.response.data.errors.filter((err: APIError) => err.extensions.code === 'FAILED_VALIDATION').map((err: APIError) => {
return err.extensions;
});
validationErrors.value = err.response.data.errors
.filter((err: APIError) => err.extensions.code === 'FAILED_VALIDATION')
.map((err: APIError) => {
return err.extensions;
});
} else {
throw err;
}
@@ -237,10 +225,6 @@ export function useItem(collection: Ref<string>, primaryKey: Ref<string | number
notify({
title: i18n.tc('item_delete_success', isBatch.value ? 2 : 1),
text: i18n.tc('item_in', isBatch.value ? 2 : 1, {
collection: collection.value,
primaryKey: isBatch.value ? (primaryKey.value as string).split(',').join(', ') : primaryKey.value,
}),
type: 'success',
});
} catch (err) {
@@ -269,10 +253,6 @@ export function useItem(collection: Ref<string>, primaryKey: Ref<string | number
notify({
title: i18n.tc('item_delete_success', isBatch.value ? 2 : 1),
text: i18n.tc('item_in', isBatch.value ? 2 : 1, {
collection: collection.value,
primaryKey: isBatch.value ? (primaryKey.value as string).split(',').join(', ') : primaryKey.value,
}),
type: 'success',
});
} catch (err) {

View File

@@ -62,7 +62,6 @@ export const useCollectionsStore = createStore({
notify({
type: 'success',
title: i18n.t('update_collection_success'),
text: collection,
});
} catch (error) {
notify({
@@ -80,7 +79,6 @@ export const useCollectionsStore = createStore({
notify({
type: 'success',
title: i18n.t('delete_collection_success'),
text: collection,
});
} catch (error) {
notify({

View File

@@ -34,7 +34,6 @@ export const useSettingsStore = createStore({
notify({
title: i18n.t('settings_update_success'),
text: Object.keys(updates).join(', '),
type: 'success',
});
} catch (error) {