<template>
<div v-if="!initialized">{{ $__("Loading") }}</div>
- <div v-else-if="agreements" id="agreements_list">
+ <div v-else-if="agreement_count" id="agreements_list">
<Toolbar v-if="before_route_entered" />
- <fieldset v-if="agreements.length" class="filters">
+ <fieldset v-if="agreement_count > 0" class="filters">
<label for="expired_filter">{{ $__("Filter by expired") }}:</label>
<input
type="checkbox"
:value="$__('Filter')"
/>
</fieldset>
- <div v-if="agreements.length" class="page-section">
+ <div v-if="agreement_count > 0" class="page-section">
<table :id="table_id"></table>
</div>
<div v-else-if="initialized" class="dialog message">
data: function () {
return {
fp_config: flatpickr_defaults,
- agreements: [],
+ agreement_count: null,
initialized: false,
filters: {
by_expired: this.$route.query.by_expired || false,
vm.before_route_entered = true // FIXME This is ugly, but we need to distinguish when it's used as main component or child component (from EHoldingsEBSCOPAckagesShow for instance)
if (!vm.building_table) {
vm.building_table = true
- vm.getAgreements().then(() => vm.build_datatable())
+ vm.getAgreementCount().then(() => vm.build_datatable())
}
})
},
},
},
methods: {
- async getAgreements() {
+ async getAgreementCount() {
const client = APIClient.erm
- await client.agreements.getAll().then(
- agreements => {
- this.agreements = agreements
+ await client.agreements.count().then(
+ count => {
+ this.agreement_count = count
this.initialized = true
},
error => {}
mounted() {
if (!this.building_table) {
this.building_table = true
- this.getAgreements().then(() => this.build_datatable())
+ this.getAgreementCount().then(() => this.build_datatable())
}
},
components: { flatPickr, Toolbar },
<template>
<div v-if="!initialized">{{ $__("Loading") }}</div>
- <div v-else-if="licenses" id="licenses_list">
+ <div v-else-if="license_count" id="licenses_list">
<Toolbar />
- <div v-if="licenses.length" class="page-section">
+ <div v-if="license_count > 0" class="page-section">
<table :id="table_id"></table>
</div>
<div v-else-if="initialized" class="dialog message">
},
data: function () {
return {
- licenses: [],
+ license_count: null,
initialized: false,
}
},
beforeRouteEnter(to, from, next) {
next(vm => {
- vm.getLicenses().then(() => vm.build_datatable())
+ vm.getLicenseCount().then(() => vm.build_datatable())
})
},
methods: {
- async getLicenses() {
+ async getLicenseCount() {
const client = APIClient.erm
- await client.licenses.getAll().then(
- licenses => {
- this.licenses = licenses
+ await client.licenses.count().then(
+ count => {
+ this.license_count = count
this.initialized = true
},
error => {}
endpoint: "agreements/" + id,
body: agreement,
}),
- //count: () => this.count("agreements"), //TODO: Implement count method
+ count: (query = {}) =>
+ this.count({
+ endpoint:
+ "agreements?" +
+ new URLSearchParams({
+ _page: 1,
+ _per_page: 1,
+ ...(query && { q: JSON.stringify(query) }),
+ }),
+ }),
};
}
endpoint: "licenses/" + id,
body: license,
}),
+ count: (query = {}) =>
+ this.count({
+ endpoint:
+ "licenses?" +
+ new URLSearchParams({
+ _page: 1,
+ _per_page: 1,
+ ...(query && { q: JSON.stringify(query) }),
+ }),
+ }),
};
}