Skip to content

Commit

Permalink
Trim titles/names before saving #1836
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico Hoffmann authored and bastianallgeier committed Aug 8, 2019
1 parent 0d7831b commit 540927a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions i18n/translations/en.json
Expand Up @@ -51,6 +51,7 @@

"error.field.converter.invalid": "Invalid converter \"{converter}\"",

"error.file.changeName.empty": "The name must not be empty",
"error.file.changeName.permission":
"You are not allowed to change the name of \"{filename}\"",
"error.file.duplicate": "A file with the name \"{filename}\" already exists",
Expand Down
8 changes: 8 additions & 0 deletions panel/src/components/Dialogs/FileRenameDialog.vue
Expand Up @@ -72,6 +72,14 @@ export default {
return slug(input, [this.slugs, this.system.ascii], ".");
},
submit() {
// prevent empty name with just spaces
this.file.name = this.file.name.trim();
if (this.file.name.length === 0) {
this.$refs.dialog.error(this.$t("error.file.changeName.empty"));
return;
}
this.$api.files
.rename(this.parent, this.file.filename, this.file.name)
.then(file => {
Expand Down
2 changes: 2 additions & 0 deletions panel/src/components/Dialogs/PageCreateDialog.vue
Expand Up @@ -107,6 +107,8 @@ export default {
},
submit() {
// prevent empty title with just spaces
this.page.title = this.page.title.trim();
if (this.page.title.length === 0) {
this.$refs.dialog.error('Please enter a title');
Expand Down
2 changes: 2 additions & 0 deletions panel/src/components/Dialogs/PageRenameDialog.vue
Expand Up @@ -53,6 +53,8 @@ export default {
});
},
submit() {
// prevent empty title with just spaces
this.page.title = this.page.title.trim();
if (this.page.title.length === 0) {
this.$refs.dialog.error(this.$t("error.page.changeTitle.empty"));
Expand Down
2 changes: 2 additions & 0 deletions panel/src/components/Dialogs/UserRenameDialog.vue
Expand Up @@ -52,6 +52,8 @@ export default {
});
},
submit() {
this.user.name = this.user.name.trim();
this.$api.users
.changeName(this.user.id, this.user.name)
.then(() => {
Expand Down

0 comments on commit 540927a

Please sign in to comment.