diff --git a/src/components/FundManagement/FundAllocationFormAdd.vue b/src/components/FundManagement/FundAllocationFormAdd.vue index a2ad1f9..936da41 100644 --- a/src/components/FundManagement/FundAllocationFormAdd.vue +++ b/src/components/FundManagement/FundAllocationFormAdd.vue @@ -13,22 +13,16 @@ - - - + apiClient="acquisition" + :required="true" + /> Required
  • @@ -86,6 +80,7 @@ import { inject } from "vue" import { APIClient } from "../../fetch/api-client.js" import { setMessage, setWarning } from "../../messages" +import InfiniteScrollSelect from "../InfiniteScrollSelect.vue" export default { setup() { @@ -123,7 +118,7 @@ export default { methods: { async getDataRequiredForPageLoad(route) { const { params } = route - this.getFunds(params).then(() => { + this.getFund(params).then(() => { if(params.fund_allocation_id) { this.getFundAllocation(params.fund_allocation_id) } @@ -136,12 +131,10 @@ export default { this.fund_allocation = fund_allocation }) }, - async getFunds(params) { + async getFund(params) { const client = APIClient.acquisition - await client.funds.getAll(null, {}).then( - funds => { - this.funds = funds - const fund = funds.find(fund => fund.fund_id = params.fund_id) + await client.funds.get(params.fund_id).then( + fund => { this.selectedFund = fund this.fund_allocation.fund_id = fund.fund_id this.fund_allocation.ledger_id = fund.ledger_id @@ -188,6 +181,9 @@ export default { ) } } + }, + components: { + InfiniteScrollSelect } } diff --git a/src/components/FundManagement/FundFormAdd.vue b/src/components/FundManagement/FundFormAdd.vue index 1af7006..fa5933a 100644 --- a/src/components/FundManagement/FundFormAdd.vue +++ b/src/components/FundManagement/FundFormAdd.vue @@ -49,23 +49,17 @@ - - - + /> Required
  • @@ -191,6 +185,7 @@ import { inject } from "vue" import { storeToRefs } from "pinia" import { APIClient } from "../../fetch/api-client.js" import { setMessage, setWarning } from "../../messages" +import InfiniteScrollSelect from "../InfiniteScrollSelect.vue" export default { setup() { @@ -248,7 +243,7 @@ export default { fund_type: '', visible_to: [], }, - fiscal_years: [], + fiscalYear: null, ledgers: [], ledger_groups: [], } @@ -260,13 +255,13 @@ export default { }, methods: { async getDataRequiredForPageLoad(fund_id) { - this.getFiscalYears().then(() => { - if(fund_id) { - this.getFund(fund_id) - } else { - this.initialized = true - } - }) + if(fund_id) { + this.getFund(fund_id).then(() => { + this.getFiscalYear(this.fund.fiscal_yr_id) + }) + } else { + this.initialized = true + } }, async getFund(fund_id) { const client = APIClient.acquisition @@ -274,15 +269,15 @@ export default { this.fund = fund this.fund.visible_to = this.formatLibraryGroupIds(fund.visible_to) this.filterLedgersBySelectedFiscalYear(fund.fiscal_yr_id) - this.filterGroupsBySelectedLedger(fund.ledger_id) - this.initialized = true }) }, - async getFiscalYears() { + async getFiscalYear(fiscal_yr_id) { const client = APIClient.acquisition - await client.fiscal_years.getAll(null, {}, "koha_plugin_acquire_ledgers").then( - fiscal_years => { - this.fiscal_years = fiscal_years + await client.fiscal_years.get(fiscal_yr_id, { "x-koha-embed": "koha_plugin_acquire_ledgers" }).then( + fiscalYear => { + this.fiscalYear = fiscalYear + this.filterGroupsBySelectedLedger(this.fund.ledger_id) + this.initialized = true }, error => {} ) @@ -294,24 +289,28 @@ export default { this.fund.visible_to = [] return } - const fiscalYear = this.fiscal_years.find(fy => fy.fiscal_yr_id === e) - const { koha_plugin_acquire_ledgers: ledgers } = fiscalYear - if(!ledgers || ledgers.length === 0) { - setWarning("There are no ledgers attached to this fiscal year. Please create one or select a different fiscal year.") - this.ledger.fiscal_yr_id = null - return - } - this.ledgers = ledgers + + this.getFiscalYear(e).then(() => { + const { koha_plugin_acquire_ledgers: ledgers } = this.fiscalYear + if(!ledgers || ledgers.length === 0) { + setWarning("There are no ledgers attached to this fiscal year. Please create one or select a different fiscal year.") + this.ledger.fiscal_yr_id = null + return + } + this.ledgers = ledgers + }) if(e !== this.fund.fiscal_yr_id) { this.fund.ledger_id = null this.fund.visible_to = [] } }, filterGroupsBySelectedLedger(e) { - const selectedLedger = this.ledgers.find(ledger => ledger.ledger_id === e) - const applicableGroups = this.formatLibraryGroupIds(selectedLedger.visible_to) - this.ledger_groups = applicableGroups - this.resetOwnersAndVisibleGroups(applicableGroups) + const selectedLedger = this.fiscalYear.koha_plugin_acquire_ledgers.find(ledger => ledger.ledger_id === e) + if(selectedLedger) { + const applicableGroups = this.formatLibraryGroupIds(selectedLedger.visible_to) + this.ledger_groups = applicableGroups + this.resetOwnersAndVisibleGroups(applicableGroups) + } }, onSubmit(e) { e.preventDefault() @@ -354,6 +353,9 @@ export default { }, unmounted() { this.resetOwnersAndVisibleGroups() + }, + components: { + InfiniteScrollSelect } } diff --git a/src/components/FundManagement/FundManagementHome.vue b/src/components/FundManagement/FundManagementHome.vue index 4fd79b0..545ed65 100644 --- a/src/components/FundManagement/FundManagementHome.vue +++ b/src/components/FundManagement/FundManagementHome.vue @@ -93,41 +93,31 @@ - - - + apiClient="acquisition" + :filters="filterLimitations" + />
    - - - + apiClient="acquisition" + :filters="filterLimitations" + />
    { + if(this.filters[key]) { + filterLimitations[key] = this.filters[key] + } + }) + return filterLimitations + } + }, beforeRouteEnter(to, from, next) { next(vm => { vm.getDataRequiredForPageLoad() @@ -309,7 +311,7 @@ export default { this.$refs.ledgersTable.redraw(this.tableUrl('ledgers', filters)) }, clearFilters() { - this.filters = { + this.filters = { status: null, fund_type: null, owner: null, @@ -321,7 +323,8 @@ export default { components: { Toolbar, ToolbarLink, - KohaTable + KohaTable, + InfiniteScrollSelect } } diff --git a/src/components/FundManagement/FundShow.vue b/src/components/FundManagement/FundShow.vue index 2cf9e5d..072b99c 100644 --- a/src/components/FundManagement/FundShow.vue +++ b/src/components/FundManagement/FundShow.vue @@ -111,7 +111,7 @@ export default { methods: { async getFund(fund_id) { const client = APIClient.acquisition - await client.funds.get(fund_id, "fiscal_yr,ledger,koha_plugin_acquire_fund_allocations").then( + await client.funds.get(fund_id, { "x-koha-embed": "fiscal_yr,ledger,koha_plugin_acquire_fund_allocations" }).then( fund => { this.fund = fund this.initialized = true diff --git a/src/components/FundManagement/LedgerFormAdd.vue b/src/components/FundManagement/LedgerFormAdd.vue index b46a153..f951fb3 100644 --- a/src/components/FundManagement/LedgerFormAdd.vue +++ b/src/components/FundManagement/LedgerFormAdd.vue @@ -49,23 +49,17 @@ - - - + /> Required
  • @@ -286,6 +280,7 @@ import { inject } from "vue" import { storeToRefs } from "pinia" import { APIClient } from "../../fetch/api-client.js" import { setMessage, setWarning } from "../../messages" +import InfiniteScrollSelect from "../InfiniteScrollSelect.vue" export default { setup() { @@ -343,7 +338,7 @@ export default { os_warning_sum: null, os_limit_sum: null, }, - fiscal_years: [], + fiscal_year: null, currencies: [], fiscal_year_groups: [], } @@ -354,14 +349,15 @@ export default { }) }, methods: { - async getDataRequiredForPageLoad(ledger_id) { - this.getFiscalYears().then(() => { - this.getCurrencies().then(() => { - if(ledger_id) { - this.getLedger(ledger_id) - } + async getDataRequiredForPageLoad(ledger_id) { + this.getCurrencies().then(() => { + if(ledger_id) { + this.getLedger(ledger_id).then(() => { + this.getFiscalYear(this.ledger.fiscal_yr_id) + }) + } else { this.initialized = true - }) + } }) }, async getLedger(ledger_id) { @@ -373,11 +369,12 @@ export default { this.filterGroupsBySelectedFiscalYear(ledger.fiscal_yr_id) }) }, - async getFiscalYears() { + async getFiscalYear(fiscal_yr_id) { const client = APIClient.acquisition - await client.fiscal_years.getAll().then( - fiscal_years => { - this.fiscal_years = fiscal_years + await client.fiscal_years.get(fiscal_yr_id).then( + fiscal_year => { + this.fiscal_year = fiscal_year + this.initialized = true }, error => {} ) @@ -397,10 +394,11 @@ export default { this.ledger.visible_to = [] return } - const selectedFiscalyear = this.fiscal_years.find(fy => fy.fiscal_yr_id === e) - const applicableGroups = this.formatLibraryGroupIds(selectedFiscalyear.visible_to) - this.fiscal_year_groups = applicableGroups - this.resetOwnersAndVisibleGroups(applicableGroups) + this.getFiscalYear(e).then(() => { + const applicableGroups = this.formatLibraryGroupIds(this.fiscal_year.visible_to) + this.fiscal_year_groups = applicableGroups + this.resetOwnersAndVisibleGroups(applicableGroups) + }) if(e !== this.ledger.fiscal_yr_id) { this.ledger.visible_to = [] } @@ -448,6 +446,9 @@ export default { }, unmounted() { this.resetOwnersAndVisibleGroups() + }, + components: { + InfiniteScrollSelect } } diff --git a/src/components/InfiniteScrollSelect.vue b/src/components/InfiniteScrollSelect.vue index 1e8966c..5d84fbe 100644 --- a/src/components/InfiniteScrollSelect.vue +++ b/src/components/InfiniteScrollSelect.vue @@ -10,6 +10,7 @@ @option:selected="onSelected" @search="searchFilter($event)" ref="select" + :disabled="disabled" >