laravel-nova
Advanced tools
Comparing version 1.0.11 to 1.2.0
{ | ||
"name": "laravel-nova", | ||
"version": "1.0.11", | ||
"version": "1.2.0", | ||
"description": "Supporting modules for Laravel Nova", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -24,2 +24,5 @@ // Mixins | ||
// PropTypes | ||
import { mapProps } from './propTypes' | ||
export { | ||
@@ -47,2 +50,4 @@ // Mixins | ||
CardSizes, | ||
// PropTypes | ||
mapProps, | ||
} |
@@ -0,6 +1,12 @@ | ||
import { mapProps } from '../propTypes' | ||
export default { | ||
props: { | ||
resourceName: {}, | ||
field: {}, | ||
}, | ||
props: mapProps([ | ||
'shownViaNewRelationModal', | ||
'field', | ||
'viaResource', | ||
'viaResourceId', | ||
'viaRelationship', | ||
'resourceName', | ||
]), | ||
@@ -60,3 +66,3 @@ data: () => ({ | ||
}, | ||
} | ||
}, | ||
} |
import cardSizes from '../util/cardSizes' | ||
export default { | ||
props: { | ||
loadCards: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
props: { | ||
loadCards: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
}, | ||
data: () => ({ cards: [] }), | ||
data: () => ({ cards: [] }), | ||
/** | ||
* Fetch all of the metrics panels for this view | ||
*/ | ||
created() { | ||
this.fetchCards() | ||
}, | ||
watch: { | ||
cardsEndpoint() { | ||
this.fetchCards() | ||
}, | ||
}, | ||
methods: { | ||
async fetchCards() { | ||
// We disable fetching of cards when the component is being show | ||
// on a resource detail view to avoid extra network requests | ||
if (this.loadCards) { | ||
const { data: cards } = await Nova.request().get(this.cardsEndpoint, { | ||
params: this.extraCardParams, | ||
}) | ||
this.cards = cards | ||
} | ||
}, | ||
}, | ||
computed: { | ||
/** | ||
* Fetch all of the metrics panels for this view | ||
* Determine whether we have cards to show on the Dashboard | ||
*/ | ||
created() { | ||
this.fetchCards() | ||
shouldShowCards() { | ||
return this.cards.length > 0 | ||
}, | ||
watch: { | ||
cardsEndpoint() { | ||
this.fetchCards() | ||
}, | ||
/** | ||
* Return the small cards used for the Dashboard | ||
*/ | ||
smallCards() { | ||
return _.filter(this.cards, c => cardSizes.indexOf(c.width) !== -1) | ||
}, | ||
methods: { | ||
async fetchCards() { | ||
// We disable fetching of cards when the component is being show | ||
// on a resource detail view to avoid extra network requests | ||
if (this.loadCards) { | ||
const { data: cards } = await Nova.request().get(this.cardsEndpoint, { | ||
params: this.extraCardParams, | ||
}) | ||
this.cards = cards | ||
} | ||
}, | ||
/** | ||
* Return the full-width cards used for the Dashboard | ||
*/ | ||
largeCards() { | ||
return _.filter(this.cards, c => c.width == 'full') | ||
}, | ||
computed: { | ||
/** | ||
* Determine whether we have cards to show on the Dashboard | ||
*/ | ||
shouldShowCards() { | ||
return this.cards.length > 0 | ||
}, | ||
/** | ||
* Return the small cards used for the Dashboard | ||
*/ | ||
smallCards() { | ||
return _.filter(this.cards, c => cardSizes.indexOf(c.width) !== -1) | ||
}, | ||
/** | ||
* Return the full-width cards used for the Dashboard | ||
*/ | ||
largeCards() { | ||
return _.filter(this.cards, c => c.width == 'full') | ||
}, | ||
/** | ||
* Get the extra card params to pass to the endpoint. | ||
*/ | ||
extraCardParams() { | ||
return null | ||
}, | ||
/** | ||
* Get the extra card params to pass to the endpoint. | ||
*/ | ||
extraCardParams() { | ||
return null | ||
}, | ||
}, | ||
} |
Sorry, the diff of this file is too big to display
837374
25
25255