Skip to content

Commit

Permalink
style: disable add btn in emergency contact until all required fields…
Browse files Browse the repository at this point in the history
… are filled
  • Loading branch information
duchunter committed Sep 6, 2023
1 parent 5b6f570 commit 189e3ab
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/renderer/components/setting/EmergencyContact.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<div class="text-head-5 text-black-700 font-semibold truncate">
{{
emergency_access.id
? 'Edit emergency contact'
: 'Invite emergency contact'
? $t('data.emergency_access.edit_emergency_contact')
: $t('data.emergency_access.invite_emergency_contact')
}}
</div>
<!-- <div class="setting-description">
Expand Down Expand Up @@ -73,20 +73,21 @@
<div slot="footer" class="dialog-footer flex items-center text-left">
<div class="flex-grow" />
<div>
<button class="btn btn-default" @click="dialogVisible = false">
<el-button @click="dialogVisible = false">
{{ $t('common.cancel') }}
</button>
<button
class="btn btn-primary"
:disabled="loading"
</el-button>
<el-button
type="primary"
:loading="loading"
:disabled="loading || !isBtnActive"
@click="
emergency_access.id
? putEmergencyAccess(emergency_access)
: postEmergencyAccess(emergency_access)
"
>
{{ emergency_access.id ? $t('common.update') : $t('common.add') }}
</button>
</el-button>
</div>
</div>
</el-dialog>
Expand All @@ -95,10 +96,12 @@
<script>
import InputText from '../input/InputText'
import { Utils } from '../../core/misc/utils.ts'
export default {
components: {
InputText
},
data () {
return {
userAccessOptions: ['view', 'takeover'],
Expand All @@ -112,6 +115,7 @@ export default {
file: null
}
},
computed: {
waitTimeOptions () {
return [
Expand All @@ -122,8 +126,12 @@ export default {
{ label: this.$t('data.wait_time_days.thirtyDays'), value: 30 }
// { label: this.$t('data.wait_time_days.ninetyDays'), value: 90 }
]
},
isBtnActive () {
return this.emergency_access.wait_time_days && this.emergency_access.email
}
},
methods: {
async openDialog (emergencyAccess = {}) {
this.dialogVisible = true
Expand All @@ -137,9 +145,11 @@ export default {
}
}
},
closeDialog () {
this.dialogVisible = false
},
async postEmergencyAccess (emergencyAccess) {
try {
this.loading = true
Expand Down Expand Up @@ -170,6 +180,7 @@ export default {
this.loading = false
}
},
async putEmergencyAccess (emergencyAccess) {
try {
this.loading = true
Expand All @@ -195,6 +206,7 @@ export default {
this.loading = false
}
},
async deleteEmergencyAccess (emergencyAccess) {
this.$confirm(
this.$t('data.notifications.delete_emergency_contact'),
Expand Down Expand Up @@ -232,13 +244,15 @@ export default {
})
.catch(() => {})
},
async getPublicKey (email) {
const { public_key: publicKey } = await this.$axios.$post(
'cystack_platform/pm/sharing/public_key',
{ email }
)
return publicKey
},
async generateAccessKey (publicKey) {
const pk = Utils.fromB64ToArray(publicKey)
const encKey = await this.$cryptoService.getEncKey()
Expand Down

0 comments on commit 189e3ab

Please sign in to comment.