prevent user to create noname flagcolls and force uniqness name by user scope

This commit is contained in:
Bachir Soussi Chiadmi 2021-09-01 00:31:15 +02:00
parent 4f34ab85a9
commit bc16158162
4 changed files with 24 additions and 11 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -57,7 +57,7 @@ export default {
return { return {
'mdi-plus-circle-outline': !this.is_creating_folder, 'mdi-plus-circle-outline': !this.is_creating_folder,
'mdi-loading': this.is_creating_folder, 'mdi-loading': this.is_creating_folder,
active: this.new_folder_name.length > 4 && !this.is_creating_folder, active: this.new_folder_name.length > 4 && this.checkFlagNameUniqness() && !this.is_creating_folder,
loading: this.is_creating_folder loading: this.is_creating_folder
} }
}, },
@ -76,15 +76,28 @@ export default {
openFlagColl: 'User/openFlagColl', openFlagColl: 'User/openFlagColl',
openCloseHamMenu: 'Common/openCloseHamMenu' openCloseHamMenu: 'Common/openCloseHamMenu'
}), }),
checkFlagNameUniqness () {
let uniq = true
const flagcolls_ids = Object.keys(this.flagcolls);
flagcolls_ids.forEach((id) => {
if(this.flagcolls[id].name === this.new_folder_name){
uniq = false
}
})
return uniq
},
onCreateFlagColl () { onCreateFlagColl () {
console.log("UserFlags onCreateFlagColl", this.new_folder_name) console.log("UserFlags onCreateFlagColl", this.new_folder_name)
this.is_creating_folder = true; if (this.new_folder_name.length > 4 && this.checkFlagNameUniqness()){
this.createFlagColl(this.new_folder_name) // create new flagcoll
.then(data => { this.is_creating_folder = true;
console.log("onCreateFlagColl then", data) this.createFlagColl(this.new_folder_name)
this.new_folder_name = ""; .then(data => {
this.is_creating_folder = false; console.log("onCreateFlagColl then", data)
}) this.new_folder_name = "";
this.is_creating_folder = false;
})
}
}, },
onDeleteFlagColl (e) { onDeleteFlagColl (e) {
const flagcollid = e.target.getAttribute('flagcollid'); const flagcollid = e.target.getAttribute('flagcollid');