2020-08-21 12:51:20 +00:00
|
|
|
import Vue from 'vue'
|
2020-08-24 02:56:33 +00:00
|
|
|
import { mapActions } from 'vuex'
|
|
|
|
import FtLoader from '../../components/ft-loader/ft-loader.vue'
|
2020-08-21 12:51:20 +00:00
|
|
|
import FtCard from '../../components/ft-card/ft-card.vue'
|
|
|
|
import FtFlexBox from '../../components/ft-flex-box/ft-flex-box.vue'
|
2020-08-24 02:56:33 +00:00
|
|
|
import FtInput from '../../components/ft-input/ft-input.vue'
|
|
|
|
import FtButton from '../../components/ft-button/ft-button.vue'
|
2020-08-21 12:51:20 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
name: 'ProfileEdit',
|
|
|
|
components: {
|
2020-08-24 02:56:33 +00:00
|
|
|
'ft-loader': FtLoader,
|
2020-08-21 12:51:20 +00:00
|
|
|
'ft-card': FtCard,
|
|
|
|
'ft-flex-box': FtFlexBox,
|
2020-08-24 02:56:33 +00:00
|
|
|
'ft-input': FtInput,
|
|
|
|
'ft-button': FtButton
|
|
|
|
},
|
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
isLoading: false,
|
|
|
|
isNew: false,
|
|
|
|
profileId: '',
|
|
|
|
profileName: '',
|
|
|
|
profileBgColor: '',
|
|
|
|
profileTextColor: '',
|
|
|
|
profileSubscriptions: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
colorValues: function () {
|
|
|
|
return this.$store.getters.getColorValues
|
|
|
|
},
|
|
|
|
profileInitial: function () {
|
|
|
|
return this.profileName.slice(0, 1).toUpperCase()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
profileBgColor: async function (val) {
|
|
|
|
this.profileTextColor = await this.calculateColorLuminance(val)
|
|
|
|
}
|
2020-08-21 12:51:20 +00:00
|
|
|
},
|
|
|
|
mounted: function () {
|
2020-08-24 02:56:33 +00:00
|
|
|
this.isLoading = true
|
|
|
|
const profileType = this.$route.name
|
|
|
|
|
|
|
|
if (profileType === 'newProfile') {
|
|
|
|
this.isNew = true
|
|
|
|
} else {
|
|
|
|
this.isNew = false
|
|
|
|
this.profileId = this.$route.params.id
|
|
|
|
console.log(this.profileId)
|
|
|
|
console.log(this.$route.name)
|
|
|
|
|
|
|
|
this.grabProfileInfo(this.profileId).then((profile) => {
|
|
|
|
console.log(profile)
|
|
|
|
this.profileName = profile.name
|
|
|
|
this.profileBgColor = profile.bgColor
|
|
|
|
this.profileTextColor = profile.textColor
|
|
|
|
this.profileSubscriptions = profile.subscriptions
|
|
|
|
this.isLoading = false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
saveProfile: function () {
|
|
|
|
const profile = {
|
|
|
|
name: this.profileName,
|
|
|
|
bgColor: this.profileBgColor,
|
|
|
|
textColor: this.profileTextColor,
|
|
|
|
subscriptions: this.profileSubscriptions
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.isNew) {
|
|
|
|
profile._id = this.profileId
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(profile)
|
|
|
|
|
|
|
|
this.updateProfile(profile)
|
|
|
|
this.showToast({
|
|
|
|
message: 'Profile has been updated'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
...mapActions([
|
|
|
|
'showToast',
|
|
|
|
'grabProfileInfo',
|
|
|
|
'updateProfile',
|
|
|
|
'calculateColorLuminance'
|
|
|
|
])
|
2020-08-21 12:51:20 +00:00
|
|
|
}
|
|
|
|
})
|