Disable app label submit button if value haven't changed

This commit is contained in:
Johannes Zellner
2025-07-16 13:39:40 +02:00
parent e632f07708
commit e35dbba57d
+7 -3
View File
@@ -1,6 +1,6 @@
<script setup>
import { ref, onMounted, useTemplateRef } from 'vue';
import { ref, onMounted, useTemplateRef, computed } from 'vue';
import { FormGroup, TextInput, Button, TagInput } from '@cloudron/pankow';
import ImagePicker from '../ImagePicker.vue';
import AppsModel from '../../models/AppsModel.js';
@@ -35,6 +35,10 @@ function getDataURLFromFile(file) {
});
}
const haveValuesChanged = computed(() => {
return (label.value !== props.app.label) || tags.value.join() !== props.app.tags.join();
});
async function onSubmit() {
busy.value = true;
labelError.value = '';
@@ -98,7 +102,7 @@ onMounted(() => {
<form @submit.prevent="onSubmit()" autocomplete="off">
<fieldset :disabled="busy">
<input type="submit" style="display: none;"/>
<input type="submit" style="display: none;" :disabled="busy || !haveValuesChanged"/>
<FormGroup>
<label for="labelInput">{{ $t('app.display.label') }}</label>
@@ -112,7 +116,7 @@ onMounted(() => {
<div class="text-error" v-if="tagsError">{{ tagsError }}</div>
</FormGroup>
<Button @click="onSubmit()" :loading="busy" :disabled="busy">{{ $t('app.display.saveAction') }}</Button>
<Button @click="onSubmit()" :loading="busy" :disabled="busy || !haveValuesChanged">{{ $t('app.display.saveAction') }}</Button>
</fieldset>
</form>
</div>