Correct namings etc.

- Rename all "link" contaning names from MySomeThingList.
- Remove comment from notificationsMiddleware.
- Create translations.
This commit is contained in:
Wolfgang Huß 2021-11-11 18:24:44 +01:00
parent 51eca9ac83
commit 7c43372423
6 changed files with 55 additions and 33 deletions

View File

@ -41,7 +41,6 @@ const publishNotifications = async (context, promises) => {
notifications.forEach((notificationAdded, index) => {
pubsub.publish(NOTIFICATION_ADDED, { notificationAdded })
if (notificationAdded.to.sendNotificationEmails) {
// Wolle await
sendMail(
notificationTemplate({
email: notificationsEmailAddresses[index].email,

View File

@ -106,7 +106,12 @@ describe('MySomethingList.vue', () => {
await Vue.nextTick()
const expectedItem = expect.objectContaining({ id: '' })
expect(propsData.callbacks.submit).toHaveBeenCalledTimes(1)
expect(propsData.callbacks.submit).toHaveBeenCalledWith(expect.any(Object), true, expectedItem, { dummy: '' })
expect(propsData.callbacks.submit).toHaveBeenCalledWith(
expect.any(Object),
true,
expectedItem,
{ dummy: '' },
)
})
it('call delete', async () => {

View File

@ -4,16 +4,15 @@
:schema="formSchema"
@input="handleInput"
@input-valid="handleInputValid"
@submit="handleSubmitSocialMedia"
@submit="handleSubmitItem"
>
<div v-if="isEditing">
<!-- Wolle translation -->
<ds-space margin="base">
<ds-heading tag="h3" class="undertitle">
{{
/* $t('settings.social-media.name') */ isCreation
? 'Add new'
: 'Edit "' + editingItem[namePropertyKey] + '"'
isCreation
? $t('settings.social-media.addNewTitle')
: $t('settings.social-media.editTitle', { name: editingItem[namePropertyKey] })
}}
</ds-heading>
</ds-space>
@ -25,7 +24,6 @@
<ds-space v-if="items" margin-top="base" margin="small">
<ds-list>
<ds-list-item v-for="item in items" :key="item.id" class="list-item--high">
<!-- Wolle remove template tag? -->
<template>
<slot name="list-item" :item="item" />
<span class="divider">|</span>
@ -33,7 +31,7 @@
icon="edit"
circle
ghost
@click="handleEditSocialMedia(item)"
@click="handleEditItem(item)"
:title="$t('actions.edit')"
data-test="edit-button"
/>
@ -41,7 +39,7 @@
icon="trash"
circle
ghost
@click="handleDeleteSocialMedia(item)"
@click="handleDeleteItem(item)"
:title="$t('actions.delete')"
data-test="delete-button"
/>
@ -55,7 +53,8 @@
<ds-space margin-top="base">
<base-button
filled
:disabled="!(!isEditing || (isEditing && !disabled))"
:disabled="loading || !(!isEditing || (isEditing && !disabled))"
:loading="loading"
type="submit"
data-test="add-save-button"
>
@ -95,7 +94,13 @@ export default {
},
callbacks: {
type: Object,
default: () => ({ edit: () => {}, submit: () => {}, delete: () => {} }),
default: () => ({
handleInput: () => {},
handleInputValid: () => {},
edit: () => {},
submit: () => {},
delete: () => {},
}),
},
},
data() {
@ -104,6 +109,7 @@ export default {
formSchema: this.useFormSchema,
items: this.useItems,
disabled: true,
loading: false,
editingItem: null,
}
},
@ -116,43 +122,42 @@ export default {
},
},
watch: {
// can change by a parents callback and again given trough by bind from there
// can change by a parents callback and again given trough by v-bind from there
useItems(newItems) {
this.items = newItems
},
},
methods: {
handleCancel() {
this.editingItem = null
this.disabled = true
},
handleEditSocialMedia(item) {
this.editingItem = item
this.callbacks.edit(this, item)
},
handleInput(data) {
this.callbacks.handleInput(this, data)
this.disabled = true
},
handleInputValid(data) {
if (data.socialMediaUrl.length < 1) {
this.disabled = true
} else {
this.disabled = false
}
this.callbacks.handleInputValid(this, data)
},
async handleDeleteSocialMedia(item) {
await this.callbacks.delete(this, item)
handleEditItem(item) {
this.editingItem = item
this.callbacks.edit(this, item)
},
async handleSubmitSocialMedia() {
async handleSubmitItem() {
if (!this.isEditing) {
this.handleEditSocialMedia({ ...this.defaultItem, id: '' })
this.handleEditItem({ ...this.defaultItem, id: '' })
} else {
this.loading = true
if (await this.callbacks.submit(this, this.isCreation, this.editingItem, this.formData)) {
this.disabled = true
this.editingItem = null
}
this.loading = false
}
},
handleCancel() {
this.editingItem = null
this.disabled = true
},
async handleDeleteItem(item) {
await this.callbacks.delete(this, item)
},
},
}
</script>

View File

@ -773,6 +773,8 @@
"name": "Sicherheit"
},
"social-media": {
"addNewTitle": "Neuen Link hinzufügen",
"editTitle": "Link \"{name}\" ändern",
"name": "Soziale Netzwerke",
"placeholder": "Deine Webadresse des Sozialen Netzwerkes",
"requireUnique": "Dieser Link existiert bereits",

View File

@ -773,6 +773,8 @@
"name": "Security"
},
"social-media": {
"addNewTitle": "Add new link",
"editTitle": "Edit link \"{name}\"",
"name": "Social media",
"placeholder": "Your social media url",
"requireUnique": "You added this url already",

View File

@ -8,6 +8,8 @@
:defaultItem="{ url: '' }"
:namePropertyKey="'url'"
:callbacks="{
handleInput: () => {},
handleInputValid,
edit: callbackEditSocialMedia,
submit: handleSubmitSocialMedia,
delete: callbackDeleteSocialMedia,
@ -80,6 +82,13 @@ export default {
...mapMutations({
setCurrentUser: 'auth/SET_USER',
}),
handleInputValid(thisList, data) {
if (data.socialMediaUrl.length < 1) {
thisList.disabled = true
} else {
thisList.disabled = false
}
},
callbackEditSocialMedia(thisList, link) {
thisList.formData.socialMediaUrl = link.url
// try to set focus on link edit field
@ -162,11 +171,11 @@ export default {
id: item.id,
},
update: (store, { data }) => {
const socialMedia = thisList.currentUser.socialMedia.filter(
const socialMedia = this.currentUser.socialMedia.filter(
(element) => element.id !== item.id,
)
thisList.setCurrentUser({
...thisList.currentUser,
this.setCurrentUser({
...this.currentUser,
socialMedia,
})
},