| | |
| | | <template> |
| | | <h2>Add Resource</h2> |
| | | <base-dialog v-if="inputIsInvalid" title="Invalid Input" @close="confirmError"> |
| | | <template #default> |
| | | <p>Sfortunatamente un input รจ invalido</p> |
| | | <p>Controlla che tutti gli input contengano qualche carattere valido.</p> |
| | | </template> |
| | | <template #action> |
| | | <base-button @click="confirmError">Okay</base-button> |
| | | </template> |
| | | </base-dialog> |
| | | <base-card> |
| | | <form @submit.prevent="submitData"> |
| | | <div class="form-control"> |
| | |
| | | <script> |
| | | export default { |
| | | inject: ['addResource'], |
| | | data() { |
| | | return { |
| | | inputIsInvalid: false, |
| | | }; |
| | | }, |
| | | methods: { |
| | | submitData() { |
| | | const enteredTitle = this.$refs.titleInput.value; |
| | | const enteredDescription = this.$refs.descInput.value; |
| | | const enteredUrl = this.$refs.linkInput.value; |
| | | |
| | | if ( |
| | | enteredTitle.trim() === '' || |
| | | enteredDescription.trim() === '' || |
| | | enteredUrl.trim() === '' |
| | | ) { |
| | | this.inputIsInvalid = true; |
| | | return; |
| | | } |
| | | |
| | | this.addResource(enteredTitle, enteredDescription, enteredUrl); |
| | | }, |
| | | confirmError() { |
| | | this.inputIsInvalid = false; |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |