Skip to content

Commit

Permalink
fix: change frontend handling of data
Browse files Browse the repository at this point in the history
  • Loading branch information
sandro-imhof committed Dec 6, 2023
1 parent d289f29 commit a519a60
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions resources/js/components/GenerateButton.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
<template>
<div class="container">
<input type="text" id="altText" class="text-field" v-model="altText"/>
<div>
<button @click="sendData" id="generate_button" class="btn" type="button">Generate</button>
<input
class="text-field"
ref="input"
type="text"
id="altText"
:value="value"
:id="fieldId"
@input="inputUpdated"
@focus="$emit('focus')"
@blur="$emit('blur')"
/>
</div>
</template>

<script>
export default {
mixins: [Fieldtype],
props: {
Expand All @@ -16,11 +27,19 @@ export default {
data() {
return {
isLoading: false,
altText: '',
responseData: '',
};
},
methods: {
inputUpdated(value) {
if (! this.config.debounce) {
return this.update(value)
}
this.updateDebounced(value)
},
sendData() {
let jsonBody = JSON.stringify(
{
Expand All @@ -35,9 +54,9 @@ export default {
},
body: jsonBody,
})
.then(response => response.json())
.then(data => {
this.altText = data.altText;
.then(response => {
this.value = response.altText;
})
.catch(error => {
console.log(error)
Expand Down

0 comments on commit a519a60

Please sign in to comment.