toggle-components-library 1.36.1 → 1.36.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/img/airship-feedback-hover.a207c947.svg +10 -0
- package/dist/img/airship-feedback.1f7c858c.svg +10 -0
- package/dist/toggle-components-library.common.js +39123 -13087
- package/dist/toggle-components-library.common.js.map +1 -1
- package/dist/toggle-components-library.css +1 -1
- package/dist/toggle-components-library.umd.js +39123 -13087
- package/dist/toggle-components-library.umd.js.map +1 -1
- package/dist/toggle-components-library.umd.min.js +285 -8
- package/dist/toggle-components-library.umd.min.js.map +1 -1
- package/package-lock.json +83 -89
- package/package.json +2 -1
- package/src/assets/icons/airship-feedback-hover.svg +10 -0
- package/src/assets/icons/airship-feedback.svg +10 -0
- package/src/components/buttons/ToggleMetricsButton.vue +22 -3
- package/src/components/cards/ToggleCommentCard.vue +55 -0
- package/src/components/carousel/ToggleCarousel.vue +29 -16
- package/src/components/carousel/ToggleCarouselSlide.vue +1 -1
- package/src/components/forms/ToggleDatePicker.vue +229 -138
- package/src/components/forms/ToggleInputSelect.vue +7 -13
- package/src/components/forms/ToggleInputText.vue +6 -15
- package/src/components/metrics/ToggleMetricSingleMetric.vue +12 -7
- package/src/components/metrics/ToggleMetricSparkLine.vue +7 -3
- package/src/components/mixins/mixins.js +2 -2
- package/src/components/tables/ToggleTable.vue +49 -114
- package/src/index.js +4 -4
- package/src/sass/includes/_as_buttons.scss +47 -4
- package/src/sass/includes/_as_cards.scss +33 -0
- package/src/sass/includes/_as_carousels.scss +12 -0
- package/src/sass/includes/_as_inputs.scss +832 -832
- package/src/sass/includes/_as_metrics.scss +5 -0
- package/src/sass/includes/_as_navs.scss +18 -2
- package/src/sass/includes/_as_table.scss +163 -163
- package/dist/img/contacts-greyblue.ef6f8a9a.svg +0 -1
- package/dist/img/contacts-white.95d07c7a.svg +0 -1
|
@@ -1,167 +1,258 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
|
|
3
|
-
<div class="toggle-date-container" :class="['datepicker-trigger',{'toggle-input-is-invalid':isInvalid }]">
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<label class="toggle-input-label">{{label}}</label>
|
|
7
|
-
|
|
8
|
-
<div class="toggle-date-input-container">
|
|
9
|
-
<div class="toggle-date-input-calendar-icon">
|
|
10
|
-
<input type="text" class="toggle-input" :name="name" ref="date-input" :id="'toggle-date-input'+_uid" :value="date" v-on:keypress="$event.preventDefault()">
|
|
11
|
-
</div>
|
|
12
|
-
<button type="button" class="toggle-clear" v-on:click="clearDate" v-if="displayValue"></button>
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
<AirbnbStyleDatepicker
|
|
16
|
-
:trigger-element-id="'toggle-date-input'+_uid"
|
|
17
|
-
:trigger="datePickerOpen"
|
|
18
|
-
:mode="'single'"
|
|
19
|
-
:date-one="displayValue"
|
|
20
|
-
@date-one-selected="val => { displayValue = val}"
|
|
21
|
-
@closed="toggleDatePickerState(false)"
|
|
22
|
-
@cancelled="toggleDatePickerState(false)"
|
|
23
|
-
:monthsToShow="1"
|
|
24
|
-
:showShortcutsMenuTrigger="false"
|
|
25
|
-
/>
|
|
26
|
-
<label
|
|
27
|
-
class="toggle-input-label-error"
|
|
28
|
-
v-if="isInvalid"
|
|
29
|
-
:for="name ? name : 'ToggleInputText' "
|
|
30
|
-
>
|
|
31
|
-
{{ errorMessage }}
|
|
32
|
-
</label>
|
|
3
|
+
<div class="toggle-date-container" :class="[{'visible': show}, 'datepicker-trigger',{'toggle-input-is-invalid':isInvalid }, { 'toggle-input-is-disabled': disabled }]">
|
|
33
4
|
|
|
5
|
+
<label class="toggle-input-label">{{label}}</label>
|
|
6
|
+
|
|
7
|
+
<div :class="['toggle-date-input-container', 'toggle-date-input-container-' + size, {'toggle-date-input-disabled': disabled} ]">
|
|
8
|
+
<date-picker v-model="inputVal" prefix-class="toggle-mxdatepicker" :formatter="momentFormat" :range="range" :type="type" :disabled="disabled">
|
|
9
|
+
</date-picker>
|
|
34
10
|
</div>
|
|
11
|
+
|
|
12
|
+
<label
|
|
13
|
+
class="toggle-input-label-error"
|
|
14
|
+
v-if="isInvalid"
|
|
15
|
+
:for="name ? name : 'ToggleInputText' "
|
|
16
|
+
>
|
|
17
|
+
{{ errorMessage }}
|
|
18
|
+
</label>
|
|
19
|
+
|
|
20
|
+
</div>
|
|
35
21
|
</template>
|
|
36
22
|
|
|
37
23
|
<script>
|
|
38
24
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
import AirbnbStyleDatepicker from 'vue-airbnb-style-datepicker';
|
|
43
|
-
import variables from '../../sass/includes/_as_variables.scss';
|
|
44
|
-
|
|
45
|
-
Vue.use(AirbnbStyleDatepicker, {
|
|
46
|
-
colors: {
|
|
47
|
-
selected : variables.toggleblue,
|
|
48
|
-
inRange : variables.togglelightblue,
|
|
49
|
-
selectedText : variables.togglewhite,
|
|
50
|
-
text : variables.toggleinputcolour,
|
|
51
|
-
inRangeBorder: variables.togglewhite,
|
|
52
|
-
disabled : variables.togglewhite,
|
|
53
|
-
},
|
|
54
|
-
texts: {
|
|
55
|
-
apply: 'Done'
|
|
56
|
-
},
|
|
57
|
-
});
|
|
25
|
+
import { mixins } from '../mixins/mixins'
|
|
26
|
+
import moment from 'moment';
|
|
27
|
+
import DatePicker from 'vue2-datepicker';
|
|
58
28
|
|
|
59
29
|
export default {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
name: {
|
|
68
|
-
type: String,
|
|
69
|
-
default: "ToggleInputText"
|
|
70
|
-
},
|
|
71
|
-
label: {
|
|
72
|
-
type: String,
|
|
73
|
-
required: false
|
|
74
|
-
},
|
|
75
|
-
placeholder: {
|
|
76
|
-
type: String,
|
|
77
|
-
required: false
|
|
78
|
-
},
|
|
79
|
-
autocomplete: {
|
|
80
|
-
type: Boolean,
|
|
81
|
-
default: true
|
|
82
|
-
},
|
|
83
|
-
size: {
|
|
84
|
-
type: String,
|
|
85
|
-
validator: function (value) {
|
|
86
|
-
return ['extra-small', 'small', 'medium', 'large', 'full'].indexOf(value) !== -1
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
required: {
|
|
90
|
-
type: Boolean,
|
|
91
|
-
default: false
|
|
92
|
-
},
|
|
93
|
-
isInvalid: {
|
|
94
|
-
type: Boolean,
|
|
95
|
-
default: false
|
|
96
|
-
},
|
|
97
|
-
errorMessage: {
|
|
98
|
-
type: String,
|
|
99
|
-
required: false
|
|
100
|
-
},
|
|
101
|
-
maxLength:{
|
|
102
|
-
type: Number,
|
|
103
|
-
required:false
|
|
104
|
-
}
|
|
30
|
+
mixins:[mixins],
|
|
31
|
+
components:{
|
|
32
|
+
DatePicker
|
|
33
|
+
},
|
|
34
|
+
props: {
|
|
35
|
+
set_value: {
|
|
36
|
+
type: [Boolean,Date,Object]
|
|
105
37
|
},
|
|
106
|
-
|
|
107
|
-
|
|
38
|
+
value: {},
|
|
39
|
+
// datepicker mode, see: https://www.npmjs.com/package/vue2-datepicker#props
|
|
40
|
+
type: {
|
|
41
|
+
type: String,
|
|
42
|
+
validator: function (value) {
|
|
43
|
+
return ['date', 'datetime', 'year', 'month', 'time', 'week'].indexOf(value) !== -1
|
|
44
|
+
},
|
|
45
|
+
default: "date"
|
|
108
46
|
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
47
|
+
// singular date or range between 2 dates
|
|
48
|
+
range: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false
|
|
113
51
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
let state = newVal ? 'open' : 'closed';
|
|
118
|
-
this.$emit('state', state);
|
|
119
|
-
}
|
|
120
|
-
|
|
52
|
+
name: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "ToggleInputText"
|
|
121
55
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
// plugin only accepts MM/DD/YYYY, so change this so that it excepts and outputs JS dates
|
|
128
|
-
displayValue: {
|
|
129
|
-
get: function() {
|
|
130
|
-
return this.formatDate(this.value)
|
|
131
|
-
},
|
|
132
|
-
set: function(modifiedValue) {
|
|
133
|
-
if(modifiedValue){
|
|
134
|
-
modifiedValue = new Date(new Date(modifiedValue+' 00:00:00').toISOString());
|
|
135
|
-
}
|
|
136
|
-
else modifiedValue = false;
|
|
137
|
-
this.$emit('input', modifiedValue);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
56
|
+
label: {
|
|
57
|
+
type: String,
|
|
58
|
+
required: false
|
|
140
59
|
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
60
|
+
placeholder: {
|
|
61
|
+
type: String,
|
|
62
|
+
required: false
|
|
63
|
+
},
|
|
64
|
+
autocomplete: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: true
|
|
67
|
+
},
|
|
68
|
+
size: {
|
|
69
|
+
type: String,
|
|
70
|
+
validator: function (value) {
|
|
71
|
+
return ['small', 'medium'].indexOf(value) !== -1
|
|
72
|
+
},
|
|
73
|
+
default: 'medium'
|
|
74
|
+
},
|
|
75
|
+
displayFormat: {
|
|
76
|
+
type: String,
|
|
77
|
+
default: 'DD/MM/Y'
|
|
78
|
+
},
|
|
79
|
+
required: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: false
|
|
82
|
+
},
|
|
83
|
+
isInvalid: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
default: false
|
|
86
|
+
},
|
|
87
|
+
errorMessage: {
|
|
88
|
+
type: String,
|
|
89
|
+
required: false
|
|
90
|
+
},
|
|
91
|
+
maxLength:{
|
|
92
|
+
type: Number,
|
|
93
|
+
required:false
|
|
94
|
+
},
|
|
95
|
+
disabled: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: false
|
|
98
|
+
},
|
|
99
|
+
// in toggle-table context, if search bar height expand transition has finished
|
|
100
|
+
searchIsOpen: {
|
|
101
|
+
type: Boolean,
|
|
102
|
+
required: false,
|
|
103
|
+
default: null
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
data : function(){
|
|
107
|
+
return {
|
|
108
|
+
show: false,
|
|
147
109
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
else this.datePickerOpen = !this.datePickerOpen;
|
|
153
|
-
});
|
|
110
|
+
momentFormat: {
|
|
111
|
+
//[optional] Date to String
|
|
112
|
+
stringify: (date) => {
|
|
113
|
+
return date ? moment(date).format(this.displayFormat) : ''
|
|
154
114
|
},
|
|
115
|
+
//[optional] String to Date
|
|
116
|
+
parse: (value) => {
|
|
117
|
+
return value ? moment(value, this.displayFormat).toDate() : null
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
created : function(){
|
|
123
|
+
// in table mode, has search bar expand transition finished?
|
|
124
|
+
if(this.searchIsOpen === null || this.searchIsOpen){
|
|
125
|
+
this.show = true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
},
|
|
129
|
+
watch :{
|
|
130
|
+
// search bar expand transition / if in table context
|
|
131
|
+
searchIsOpen(new_value){
|
|
132
|
+
if(new_value){
|
|
133
|
+
this.show = true;
|
|
134
|
+
}
|
|
155
135
|
}
|
|
136
|
+
},
|
|
137
|
+
computed: {
|
|
138
|
+
|
|
139
|
+
inputVal: {
|
|
140
|
+
get: function (){
|
|
141
|
+
return this.convertRangeObject(this.value);
|
|
142
|
+
},
|
|
143
|
+
set: function (value){
|
|
144
|
+
this.$emit('input', this.convertRangeObject(value));
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
},
|
|
149
|
+
methods: {
|
|
150
|
+
// convert singular date to range. Plugin uses array with 2 values / parents in Toggle dash expect object with start & end keys
|
|
151
|
+
convertRangeObject(input)
|
|
152
|
+
{
|
|
153
|
+
if(!this.range){
|
|
154
|
+
return input
|
|
155
|
+
}
|
|
156
|
+
return Array.isArray(input) ? {
|
|
157
|
+
start: input[0],
|
|
158
|
+
end: input[1]
|
|
159
|
+
} : [
|
|
160
|
+
input.start,
|
|
161
|
+
input.end
|
|
162
|
+
];
|
|
163
|
+
},
|
|
164
|
+
}
|
|
156
165
|
}
|
|
157
166
|
|
|
158
167
|
|
|
159
168
|
</script>
|
|
160
169
|
|
|
170
|
+
<style scoped>
|
|
171
|
+
.toggle-date-container {
|
|
172
|
+
display: none;
|
|
173
|
+
&.visible {
|
|
174
|
+
display: block;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
</style>
|
|
178
|
+
|
|
161
179
|
<style lang="scss">
|
|
180
|
+
$namespace: 'toggle-mxdatepicker';
|
|
181
|
+
|
|
182
|
+
@import '~vue2-datepicker/scss/index.scss';
|
|
162
183
|
|
|
163
|
-
|
|
164
184
|
|
|
185
|
+
.toggle-mxdatepicker-datepicker, .toggle-mxdatepicker-datepicker-range {
|
|
186
|
+
width: 100%;
|
|
187
|
+
}
|
|
188
|
+
.toggle-mxdatepicker-input {
|
|
189
|
+
padding: 0.5rem 3.5rem 0.5rem 1rem;
|
|
190
|
+
background-color: #F4F6F7 !important;
|
|
191
|
+
height: 2.8rem;
|
|
192
|
+
width: 100%;
|
|
193
|
+
box-shadow: none;
|
|
194
|
+
border: 0;
|
|
195
|
+
color: #354b64 !important;
|
|
196
|
+
font-weight: bold !important;
|
|
197
|
+
font-size: 1.2rem !important;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
i.toggle-mxdatepicker-icon-clear {
|
|
201
|
+
display: flex;
|
|
202
|
+
align-items: center;
|
|
203
|
+
justify-content: center;
|
|
204
|
+
width: 1.5rem;
|
|
205
|
+
height: 1.5rem;
|
|
206
|
+
&:after{
|
|
207
|
+
cursor: pointer;
|
|
208
|
+
content: url('../../assets/icons/delete.svg');
|
|
209
|
+
width: 1.5rem;
|
|
210
|
+
height: 1.5rem;
|
|
211
|
+
position: absolute;
|
|
212
|
+
pointer-events: none;
|
|
213
|
+
z-index: 2;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
i.toggle-mxdatepicker-icon-calendar {
|
|
218
|
+
display: flex;
|
|
219
|
+
align-items: center;
|
|
220
|
+
justify-content: center;
|
|
221
|
+
width: 1.5rem;
|
|
222
|
+
height: 1.5rem;
|
|
223
|
+
&:after{
|
|
224
|
+
cursor: pointer;
|
|
225
|
+
content: url("../../assets/icons/calendar.svg");
|
|
226
|
+
width: 1.5rem;
|
|
227
|
+
height: 1.5rem;
|
|
228
|
+
position: absolute;
|
|
229
|
+
pointer-events: none;
|
|
230
|
+
z-index: 2;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.toggle-date-input-container-small {
|
|
235
|
+
.toggle-mxdatepicker-input {
|
|
236
|
+
background-color: transparent;
|
|
237
|
+
margin-top: 11px;
|
|
238
|
+
padding: 1px 1.65rem 1px 3px;
|
|
239
|
+
font-size: 0.9rem !important;
|
|
240
|
+
height: 1.5rem;
|
|
241
|
+
}
|
|
242
|
+
i.toggle-mxdatepicker-icon-calendar, i.toggle-mxdatepicker-icon-clear {
|
|
243
|
+
margin-top: 6px;
|
|
244
|
+
width: 1em;
|
|
245
|
+
height: 1em;
|
|
246
|
+
&:after{
|
|
247
|
+
width: 1rem;
|
|
248
|
+
height: 1rem;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.toggle-mxdatepicker-calendar-content {
|
|
254
|
+
height: auto;
|
|
255
|
+
}
|
|
165
256
|
</style>
|
|
166
257
|
|
|
167
258
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
|
|
3
3
|
<div class="toggle-input-container" :class="{'toggle-input-is-invalid':isInvalid, 'toggle-input-is-disabled':disabled}" v-on:click="focusClosestInput">
|
|
4
|
-
<label
|
|
4
|
+
<label
|
|
5
5
|
v-if="label"
|
|
6
|
-
:for="name ? name : 'ToggleInputSelect' "
|
|
6
|
+
:for="name ? name : 'ToggleInputSelect' "
|
|
7
7
|
class="toggle-input-label"
|
|
8
|
-
> {{ label }}
|
|
8
|
+
> {{ label }}
|
|
9
9
|
</label>
|
|
10
10
|
|
|
11
11
|
<div class="toggle-input-select-container">
|
|
12
|
-
<select
|
|
13
|
-
:name="name ? name : 'ToggleInputSelect' "
|
|
12
|
+
<select
|
|
13
|
+
:name="name ? name : 'ToggleInputSelect' "
|
|
14
14
|
:class="[ 'toggle-input-select', size]"
|
|
15
|
-
v-model="inputVal"
|
|
15
|
+
v-model="inputVal"
|
|
16
16
|
:autocomplete="autocomplete ? 'on' : 'off' "
|
|
17
17
|
:required="required"
|
|
18
18
|
:disabled="disabled"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
</div>
|
|
25
25
|
|
|
26
26
|
<label
|
|
27
|
-
class="toggle-input-label-error"
|
|
27
|
+
class="toggle-input-label-error"
|
|
28
28
|
v-if="isInvalid"
|
|
29
29
|
:for="name ? name : 'ToggleInputText' "
|
|
30
30
|
>
|
|
@@ -39,11 +39,6 @@ import { mixins } from '../mixins/mixins'
|
|
|
39
39
|
|
|
40
40
|
export default {
|
|
41
41
|
mixins:[mixins],
|
|
42
|
-
data() {
|
|
43
|
-
return {
|
|
44
|
-
show: false
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
42
|
props: {
|
|
48
43
|
value: {},
|
|
49
44
|
name: {
|
|
@@ -92,7 +87,6 @@ export default {
|
|
|
92
87
|
},
|
|
93
88
|
|
|
94
89
|
created : function(){
|
|
95
|
-
|
|
96
90
|
},
|
|
97
91
|
computed: {
|
|
98
92
|
inputVal: {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
|
|
3
3
|
<div class="toggle-input-container" :class="{'toggle-input-is-invalid':isInvalid, 'toggle-input-is-disabled':disabled}" v-on:click="focusClosestInput">
|
|
4
|
-
<label
|
|
4
|
+
<label
|
|
5
5
|
v-if="label"
|
|
6
|
-
:for="name ? name : 'InputText' "
|
|
6
|
+
:for="name ? name : 'InputText' "
|
|
7
7
|
class="toggle-input-label"
|
|
8
|
-
> {{ label }}
|
|
8
|
+
> {{ label }}
|
|
9
9
|
</label>
|
|
10
10
|
<span class="toggle-input-counter" v-if="maxLength">{{messageLength(inputVal, maxLength)}}</span>
|
|
11
11
|
<input
|
|
12
12
|
:type="type"
|
|
13
|
-
:name="name ? name : 'ToggleInputText' "
|
|
13
|
+
:name="name ? name : 'ToggleInputText' "
|
|
14
14
|
:class="[ 'toggle-input', size]"
|
|
15
15
|
:placeholder="placeholder ? placeholder : '' "
|
|
16
16
|
:autocomplete="autocomplete ? 'on' : 'off' "
|
|
@@ -19,11 +19,9 @@
|
|
|
19
19
|
:maxlength="maxLength"
|
|
20
20
|
:disabled="disabled"
|
|
21
21
|
:readonly="readonly"
|
|
22
|
-
:ref="'input_ele'"
|
|
23
|
-
@keyup.esc="handleEscPress"
|
|
24
22
|
/>
|
|
25
23
|
<label
|
|
26
|
-
class="toggle-input-label-error"
|
|
24
|
+
class="toggle-input-label-error"
|
|
27
25
|
v-if="isInvalid"
|
|
28
26
|
:for="name ? name : 'ToggleInputText' "
|
|
29
27
|
>
|
|
@@ -105,9 +103,7 @@ export default {
|
|
|
105
103
|
}
|
|
106
104
|
},
|
|
107
105
|
|
|
108
|
-
created : function()
|
|
109
|
-
{
|
|
110
|
-
this.$nextTick(() => this.$refs['input_ele'].focus());
|
|
106
|
+
created : function(){
|
|
111
107
|
},
|
|
112
108
|
computed: {
|
|
113
109
|
inputVal: {
|
|
@@ -122,11 +118,6 @@ export default {
|
|
|
122
118
|
},
|
|
123
119
|
methods: {
|
|
124
120
|
|
|
125
|
-
handleEscPress()
|
|
126
|
-
{
|
|
127
|
-
this.$emit('bail');
|
|
128
|
-
},
|
|
129
|
-
|
|
130
121
|
/*
|
|
131
122
|
* Concat message for count characters
|
|
132
123
|
* @return string
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
<div>
|
|
3
3
|
<h3 class="toggle-metric metric-label">{{label}}</h3>
|
|
4
4
|
<div class="single-metric-icon" v-if="metricPending && label.length == 0"></div>
|
|
5
|
-
<h1 class="toggle-metric metric-value" v-else>{{metricValue}}
|
|
5
|
+
<h1 class="toggle-metric metric-value" v-else>{{metricValue}}
|
|
6
|
+
<span v-if="score && value.maxScore" class="toggle-metric-score-rating">/{{value.maxScore}}</span>
|
|
7
|
+
</h1>
|
|
6
8
|
</div>
|
|
7
9
|
</template>
|
|
8
10
|
|
|
@@ -21,20 +23,20 @@ export default {
|
|
|
21
23
|
type: String,
|
|
22
24
|
default: "ToggleMetricSingleMetric"
|
|
23
25
|
},
|
|
24
|
-
|
|
26
|
+
/**
|
|
25
27
|
* Type of the value, this will affect on the format shown
|
|
26
28
|
*/
|
|
27
29
|
type : {
|
|
28
30
|
type: String,
|
|
29
31
|
validator: function (value) {
|
|
30
|
-
return ['text', 'number', 'percentage', 'currency'].indexOf(value) !== -1
|
|
32
|
+
return ['text', 'number', 'percentage', 'currency', 'score'].indexOf(value) !== -1
|
|
31
33
|
}
|
|
32
34
|
},
|
|
33
35
|
/**
|
|
34
36
|
* Component's value
|
|
35
37
|
*/
|
|
36
38
|
value: {
|
|
37
|
-
type: [String, Number],
|
|
39
|
+
type: [String, Number, Object],
|
|
38
40
|
required: true
|
|
39
41
|
},
|
|
40
42
|
/**
|
|
@@ -87,14 +89,17 @@ export default {
|
|
|
87
89
|
case 'currency':
|
|
88
90
|
return (this.value/this.currencyDenomination).toLocaleString(this.currencyLocale, {style: 'currency', currency: this.currencyCode});
|
|
89
91
|
case'percentage':
|
|
90
|
-
return `${this.value}
|
|
92
|
+
return `${this.value} %`;
|
|
93
|
+
case 'score':
|
|
94
|
+
return this.value.score;
|
|
91
95
|
default:
|
|
92
96
|
return this.value.toLocaleString();
|
|
93
97
|
|
|
94
98
|
}
|
|
99
|
+
},
|
|
100
|
+
score() {
|
|
101
|
+
return this.type === 'score';
|
|
95
102
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
103
|
}
|
|
99
104
|
}
|
|
100
105
|
|
|
@@ -54,14 +54,14 @@ export default {
|
|
|
54
54
|
type : {
|
|
55
55
|
type: String,
|
|
56
56
|
validator: function (value) {
|
|
57
|
-
return ['text', 'number', 'percentage', 'currency'].indexOf(value) !== -1
|
|
57
|
+
return ['text', 'number', 'percentage', 'currency', 'score'].indexOf(value) !== -1
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
/**
|
|
61
61
|
* single metric component value
|
|
62
62
|
*/
|
|
63
63
|
singleMetricVal: {
|
|
64
|
-
type: [String, Number],
|
|
64
|
+
type: [String, Number, Object],
|
|
65
65
|
required: true
|
|
66
66
|
},
|
|
67
67
|
/**
|
|
@@ -112,6 +112,10 @@ export default {
|
|
|
112
112
|
inverse_trend_impact: {
|
|
113
113
|
type: Boolean,
|
|
114
114
|
default: false
|
|
115
|
+
},
|
|
116
|
+
showTrendForAllZeros: {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
default: false
|
|
115
119
|
}
|
|
116
120
|
},
|
|
117
121
|
|
|
@@ -195,7 +199,7 @@ export default {
|
|
|
195
199
|
|
|
196
200
|
const trendImpactVals = this.sparkLineVal[0].data[0].y || this.sparkLineVal[0].data[0].y === 0 ? this.sparkLineVal[0].data.map(data => data.y) : this.sparkLineVal[0].data;
|
|
197
201
|
|
|
198
|
-
let result = this.calcTrendImpact(trendImpactVals, this.trend_impact_base);
|
|
202
|
+
let result = this.calcTrendImpact(trendImpactVals, this.trend_impact_base, this.showTrendForAllZeros);
|
|
199
203
|
|
|
200
204
|
if (this.inverse_trend_impact === true && result != false)
|
|
201
205
|
return result *-1;
|
|
@@ -139,10 +139,10 @@ export const charts = {
|
|
|
139
139
|
*
|
|
140
140
|
* @return { {Integer} 1, 0,-1 }
|
|
141
141
|
*/
|
|
142
|
-
calcTrendImpact(values, trend_impact_base){
|
|
142
|
+
calcTrendImpact(values, trend_impact_base, show_trend_for_all_zeros){
|
|
143
143
|
|
|
144
144
|
// If all values in the values array are 0 return 0;
|
|
145
|
-
if (values.every((val) => val === 0)){
|
|
145
|
+
if (!show_trend_for_all_zeros && values.every((val) => val === 0)){
|
|
146
146
|
return false;
|
|
147
147
|
}
|
|
148
148
|
|