@@ -334,12 +290,16 @@
v-model="newName"
:label="$t('Heightmap.Name')"
required
+ :rules="renameInputRules"
+ @update:error="isInvalidName = !isInvalidName"
@keyup.enter="renameProfile">
{{ $t('Heightmap.Abort') }}
- {{ $t('Heightmap.Rename') }}
+
+ {{ $t('Heightmap.Rename') }}
+
@@ -511,6 +471,12 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) {
}
private newName = ''
private oldName = ''
+ private isInvalidName = true
+ private renameInputRules = [
+ (value: string) => !!value || this.$t('Heightmap.InvalidNameEmpty'),
+ (value: string) => value !== 'default' || this.$t('Heightmap.InvalidNameReserved'),
+ (value: string) => !this.existsProfileName(value) || this.$t('Heightmap.InvalidNameAlreadyExists'),
+ ]
private heightmapScale = 0.5
private probedOpacity = 1
@@ -1078,6 +1044,10 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) {
}, 200)
}
+ existsProfileName(name: string) {
+ return this.profiles.findIndex((profile: { name: string }) => profile.name === name) >= 0
+ }
+
renameProfile(): void {
this.renameDialog = false
const gcodeNew = 'BED_MESH_PROFILE SAVE="' + this.newName + '"'
@@ -1169,3 +1139,47 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) {
}
}
+
+