Skip to content

Commit 5d8a765

Browse files
committed
Nova 3.10.0 support
1 parent 7402184 commit 5d8a765

File tree

7 files changed

+87240
-1151
lines changed

7 files changed

+87240
-1151
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "saintsystems/nova-linkable-metrics",
3+
"version":"0.1.0",
34
"description": "Linkable metrics for Laravel Nova.",
45
"keywords": [
56
"laravel",
@@ -14,7 +15,7 @@
1415
"license": "MIT",
1516
"require": {
1617
"php": ">=7.1.0",
17-
"laravel/nova": "^2.1.0"
18+
"laravel/nova": "^3.10.0"
1819
},
1920
"repositories": [
2021
{

dist/js/card.js

Lines changed: 85800 additions & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
"chartist-plugin-tooltips": "^0.0.17",
1515
"cross-env": "^5.0.0",
1616
"laravel-mix": "^1.0",
17-
"laravel-nova": "^1.0.2",
18-
"lodash": "^4.17.11",
19-
"numbro": "^2.1.2"
17+
"laravel-nova": "^1.4.1",
18+
"lodash": "^4.17.0"
2019
},
2120
"dependencies": {
2221
"vue": "^2.5.0"

resources/js/components/Base/PartitionMetric.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@
1616
>
1717
</template>
1818
</h3>
19+
20+
<div v-if="helpText" class="absolute pin-r pin-b p-2">
21+
<tooltip trigger="hover">
22+
<icon
23+
type="help"
24+
viewBox="0 0 17 17"
25+
height="16"
26+
width="16"
27+
class="cursor-pointer text-60 -mb-1"
28+
/>
29+
30+
<tooltip-content
31+
slot="content"
32+
v-html="helpText"
33+
:max-width="helpWidth"
34+
/>
35+
</tooltip>
36+
</div>
37+
1938
<div class="overflow-hidden overflow-y-auto max-h-90px">
2039
<ul class="list-reset">
2140
<li v-for="item in formattedItems" class="text-xs text-80 leading-normal">
@@ -61,6 +80,8 @@ export default {
6180
props: {
6281
loading: Boolean,
6382
title: String,
83+
helpText: {},
84+
helpWidth: {},
6485
chartData: Array,
6586
url: '',
6687
},

resources/js/components/Base/TrendMetric.vue

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
<div class="flex mb-4">
44
<h3 class="mr-3 text-base text-80 font-bold">{{ title }}</h3>
55

6+
<div v-if="helpText" class="absolute pin-r pin-b p-2 z-25">
7+
<tooltip trigger="click">
8+
<icon
9+
type="help"
10+
viewBox="0 0 17 17"
11+
height="16"
12+
width="16"
13+
class="cursor-pointer text-60 -mb-1"
14+
/>
15+
16+
<tooltip-content
17+
slot="content"
18+
v-html="helpText"
19+
:max-width="helpWidth"
20+
/>
21+
</tooltip>
22+
</div>
23+
624
<select
725
v-if="ranges.length > 0"
826
@change="handleChange"
@@ -37,33 +55,25 @@
3755
</template>
3856

3957
<script>
40-
import numbro from 'numbro'
41-
import numbroLanguages from 'numbro/dist/languages.min'
42-
Object.values(numbroLanguages).forEach(l => numbro.registerLanguage(l))
4358
import _ from 'lodash'
4459
import Chartist from 'chartist'
4560
import 'chartist-plugin-tooltips'
4661
import 'chartist/dist/chartist.min.css'
4762
import { SingularOrPlural } from 'laravel-nova'
4863
import 'chartist-plugin-tooltips/dist/chartist-plugin-tooltip.css'
4964
50-
// const getLabelForValue = (value, vm) => {
51-
// const { labels, series } = vm.chartData
52-
53-
// return labels[_.findIndex(series[0], (item) => {
54-
// return item.value == value;
55-
// })]
56-
// }
57-
5865
export default {
5966
name: 'BaseTrendMetric',
6067
6168
props: {
6269
loading: Boolean,
6370
title: {},
71+
helpText: {},
72+
helpWidth: {},
6473
value: {},
6574
url: '',
6675
chartData: {},
76+
maxWidth: {},
6777
prefix: '',
6878
suffix: '',
6979
suffixInflection: true,
@@ -88,10 +98,6 @@ export default {
8898
},
8999
90100
mounted() {
91-
if (Nova.config.locale) {
92-
numbro.setLanguage(Nova.config.locale.replace('_', '-'))
93-
}
94-
95101
const low = Math.min(...this.chartData)
96102
const high = Math.max(...this.chartData)
97103
@@ -126,23 +132,28 @@ export default {
126132
},
127133
plugins: [
128134
Chartist.plugins.tooltip({
129-
anchorToPoint: true,
130-
transformTooltipTextFnc: value => {
131-
if (this.prefix) {
132-
return `${this.prefix}${value}`
133-
}
134-
135-
if (this.suffix) {
136-
const suffix = SingularOrPlural(value, this.suffix)
137-
138-
return `${value} ${suffix}`
139-
}
140-
141-
return `${value}`
142-
},
143-
}),
144-
],
145-
})
135+
anchorToPoint: true,
136+
transformTooltipTextFnc: value => {
137+
let formattedValue = Nova.formatNumber(
138+
new String(value),
139+
this.format
140+
)
141+
142+
if (this.prefix) {
143+
return `${this.prefix}${formattedValue}`
144+
}
145+
146+
if (this.suffix) {
147+
const suffix = SingularOrPlural(value, this.suffix)
148+
149+
return `${formattedValue} ${suffix}`
150+
}
151+
152+
return `${formattedValue}`
153+
},
154+
}),
155+
],
156+
})
146157
},
147158
148159
methods: {
@@ -167,7 +178,7 @@ export default {
167178
168179
formattedValue() {
169180
if (!this.isNullValue) {
170-
const value = numbro(new String(this.value)).format(this.format)
181+
const value = Nova.formatNumber(new String(this.value), this.format)
171182
172183
return `${this.prefix}${value}`
173184
}

resources/js/components/Base/ValueMetric.vue

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
<template>
2-
<loading-card :loading="loading" class="metric px-6 py-4 relative">
2+
<loading-card :loading="loading" class="px-6 py-4">
33
<div class="flex mb-4">
44
<h3 class="mr-3 text-base text-80 font-bold">{{ title }}</h3>
55

6+
<div v-if="helpText" class="absolute pin-r pin-b p-2 z-25">
7+
<tooltip trigger="click">
8+
<icon
9+
type="help"
10+
viewBox="0 0 17 17"
11+
height="16"
12+
width="16"
13+
class="cursor-pointer text-60 -mb-1"
14+
/>
15+
16+
<tooltip-content
17+
slot="content"
18+
v-html="helpText"
19+
:max-width="helpWidth"
20+
/>
21+
</tooltip>
22+
</div>
23+
624
<select
725
v-if="ranges.length > 0"
826
@change="handleChange"
@@ -64,30 +82,34 @@
6482
</span>
6583

6684
<span v-else>
67-
<span v-if="previous == '0' && value != '0'"> {{ __('No Prior Data') }} </span>
85+
<span v-if="previous == '0' && value != '0'">
86+
{{ __('No Prior Data') }}
87+
</span>
6888

6989
<span v-if="value == '0' && previous != '0'">
7090
{{ __('No Current Data') }}
7191
</span>
7292

73-
<span v-if="value == '0' && previous == '0'"> {{ __('No Data') }} </span>
93+
<span v-if="value == '0' && previous == '0'">
94+
{{ __('No Data') }}
95+
</span>
7496
</span>
7597
</p>
7698
</div>
7799
</loading-card>
78100
</template>
79101

80102
<script>
81-
import numbro from 'numbro'
82-
import numbroLanguages from 'numbro/dist/languages.min'
83-
Object.values(numbroLanguages).forEach(l => numbro.registerLanguage(l))
84103
import { SingularOrPlural } from 'laravel-nova'
85104
86105
export default {
87106
name: 'BaseValueMetric',
88107
props: {
89108
loading: { default: true },
90109
title: {},
110+
helpText: {},
111+
helpWidth: {},
112+
maxWidth: {},
91113
previous: {},
92114
value: {},
93115
url: '',
@@ -102,12 +124,9 @@ export default {
102124
type: String,
103125
default: '(0[.]00a)',
104126
},
105-
},
106-
107-
mounted() {
108-
if (Nova.config.locale) {
109-
numbro.setLanguage(Nova.config.locale.replace('_', '-'))
110-
}
127+
zeroResult: {
128+
default: false,
129+
},
111130
},
112131
113132
methods: {
@@ -160,7 +179,9 @@ export default {
160179
161180
formattedValue() {
162181
if (!this.isNullValue) {
163-
return this.prefix + numbro(new String(this.value)).format(this.format)
182+
return (
183+
this.prefix + Nova.formatNumber(new String(this.value), this.format)
184+
)
164185
}
165186
166187
return ''

0 commit comments

Comments
 (0)