Completed
Push — master ( 968494...b3d85d )
by Ajeh
21s
created

src/plugin/js/mixins/btn-mixin.js   A

Complexity

Total Complexity 10
Complexity/F 1.25

Size

Lines of Code 32
Function Count 8

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 10
c 1
b 0
f 0
nc 1
mnd 1
bc 8
fnc 8
dl 0
loc 32
rs 10
bpm 1
cpm 1.25
noi 0

8 Functions

Rating   Name   Duplication   Size   Complexity  
A ???.computed.cancelBtnDisabled 0 3 1
A ???.computed.leftBtnEnabled 0 3 1
A ???.computed.rightBtnEnabled 0 3 1
A ???.computed.rightBtnText 0 3 2
A ???.computed.rightBtnFocus 0 3 1
A ???.computed.leftBtnFocus 0 3 1
A ???.computed.okBtnDisabled 0 5 1
A ???.computed.leftBtnText 0 3 2
1
/**
2
 * Created by Emmy on 3/5/2018.
3
 */
4
5
import {DIALOG_TYPES, CONFIRM_TYPES} from '../constants'
6
7
export default {
8
    computed: {
9
        cancelBtnDisabled(){
10
            return (this.options.window === DIALOG_TYPES.ALERT)
11
        },
12
        okBtnDisabled(){
13
            return (this.options.window === DIALOG_TYPES.CONFIRM)
14
                && (this.options.type === CONFIRM_TYPES.HARD)
15
                && (this.input !== this.options.verification)
16
        },
17
        leftBtnEnabled(){
18
            return (this.cancelBtnDisabled === false) || (this.options.reverse === true)
19
        },
20
        rightBtnEnabled(){
21
            return (this.cancelBtnDisabled === false) || (this.options.reverse === false)
22
        },
23
        leftBtnFocus(){
24
            return !this.isHardConfirm && (this.options.reverse === true)
25
        },
26
        rightBtnFocus(){
27
            return !this.isHardConfirm && (this.options.reverse === false)
28
        },
29
        leftBtnText(){
30
            return this.options.reverse ? this.options.okText : this.options.cancelText
31
        },
32
        rightBtnText(){
33
            return this.options.reverse ? this.options.cancelText : this.options.okText
34
        }
35
    }
36
}