Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions admin_ui/src/components/AddRowForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

<form v-if="defaults" v-on:submit.prevent="submitForm($event)">
<RowForm v-bind:row="defaults" v-bind:schema="schema" />
<button data-uitest="create_button">{{ $t("Create") }}</button>
<button :disabled="!saveButtonEnabled" data-uitest="create_button">
{{ $t("Create") }}
</button>
</form>
</div>
</template>
Expand Down Expand Up @@ -38,7 +40,8 @@ export default defineComponent({
data() {
return {
defaults: {} as { [key: string]: any },
errors: [] as string[]
errors: [] as string[],
saveButtonEnabled: true
}
},
setup() {
Expand All @@ -48,6 +51,8 @@ export default defineComponent({
},
methods: {
async submitForm(event: Event) {
this.saveButtonEnabled = false

const form = new FormData(event.target as HTMLFormElement)

const json: { [key: string]: any } = {}
Expand All @@ -66,6 +71,17 @@ export default defineComponent({
tableName: this.tableName,
data: json
})

this.errors = []

var message: APIResponseMessage = {
contents: "Successfully added row",
type: "success"
}
this.$store.commit("updateApiResponseMessage", message)

this.$emit("addedRow")
this.$emit("close")
} catch (error) {
if (axios.isAxiosError(error) && error.response) {
this.errors = parseErrorResponse(
Expand All @@ -81,19 +97,9 @@ export default defineComponent({
type: "error"
}
this.$store.commit("updateApiResponseMessage", message)

return
}
this.errors = []

var message: APIResponseMessage = {
contents: "Successfully added row",
type: "success"
}
this.$store.commit("updateApiResponseMessage", message)

this.$emit("addedRow")
this.$emit("close")
this.saveButtonEnabled = true
}
},
async mounted() {
Expand Down
14 changes: 9 additions & 5 deletions admin_ui/src/components/EditRowForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
:row="selectedRow"
:schema="schema"
/>
<button data-uitest="save_button">{{ $t("Save") }}</button>
<button :disabled="!saveButtonEnabled" data-uitest="save_button">
{{ $t("Save") }}
</button>
</form>

<ReferencingTables :rowID="rowID" :tableName="tableName" />
Expand Down Expand Up @@ -79,7 +81,8 @@ export default defineComponent({
data: function () {
return {
errors: [] as string[],
showDropdown: false
showDropdown: false,
saveButtonEnabled: true
}
},
computed: {
Expand All @@ -99,6 +102,8 @@ export default defineComponent({
async submitForm(event: Event) {
console.log("Submitting...")

this.saveButtonEnabled = false

const form = new FormData(event.target as HTMLFormElement)

const json: { [key: string]: any } = {}
Expand All @@ -125,6 +130,7 @@ export default defineComponent({
type: "success"
}
this.$store.commit("updateApiResponseMessage", message)
this.errors = []
} catch (error) {
if (axios.isAxiosError(error) && error.response) {
this.errors = parseErrorResponse(
Expand All @@ -140,11 +146,9 @@ export default defineComponent({
type: "error"
}
this.$store.commit("updateApiResponseMessage", message)

return
}

this.errors = []
this.saveButtonEnabled = true
},
async deleteRow() {
if (window.confirm("Are you sure you want to delete this row?")) {
Expand Down
4 changes: 4 additions & 0 deletions admin_ui/src/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ button {
&:hover {
transition: background-color 0.5s;
}

&:disabled {
opacity: 0.8;
}
}

a {
Expand Down