james0r
4/27/2018 - 10:47 PM

save func

save (userID) {
                if (this.techSelected == '') {
                    this.techRequired = true
                    return;
                }
                if (this.ratingSelected == 0) {
                    this.ratingRequired = true
                    return;
                }
               
                if (this.strongestSkill) {
                   firebase.database()
                   .ref('/profiles/' + userID + '/skills/')
                   .once('value',function(s){
                        var skills = s.val()
                        var newUsers = {}
                        for(var key in skills) {
                            firebase.database()
                            .ref('/profiles/' + userID + '/skills/' + key)
                            .once('value')
                            .update({strongestSkill: false})
                        }
                    })
                    .catch(error => {
                        console.log(error)
                    })
                }

                const skillData = {
                    id: this.makeid(),
                    name: this.techSelected,
                    stars: this.ratingSelected,
                    notes: this.skillNotes,
                    strongestSkill: this.strongestSkill,
                    icon: this.techIcons[this.techSelected]
                }
                //Firebase push call here
                console.log("right before pushing, the strongestSkill is " + this.strongestSkill)
                firebase.database().ref('/profiles/' + userID + '/skills/').push(skillData)

                this.clearValues()
                this.$store.dispatch('triggerFetch')
            },