Bug 38201: Group table related config options together
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
9e1fa0ac77
commit
24e12c1723
|
|
@ -26,7 +26,9 @@ export default {
|
|||
edit: "RecordSourcesFormAddEdit",
|
||||
},
|
||||
apiClient: APIClient.record_sources.record_sources,
|
||||
resourceTableUrl: APIClient.record_sources.httpClient._baseURL,
|
||||
table: {
|
||||
resourceTableUrl: APIClient.record_sources.httpClient._baseURL,
|
||||
},
|
||||
i18n: {
|
||||
deleteConfirmationMessage: $__(
|
||||
"Are you sure you want to remove this record source?"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
</template>
|
||||
<template #filters="{ table }">
|
||||
<ResourceListFilters
|
||||
v-if="instancedResource.addFiltersToList"
|
||||
v-if="instancedResource.table.addFilters"
|
||||
:instancedResource="instancedResource"
|
||||
:table="table"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export default {
|
|||
const { vendors } = storeToRefs(vendorStore);
|
||||
|
||||
const extendedAttributesResourceType = "agreement";
|
||||
const tableFilters = [
|
||||
const filters = [
|
||||
{
|
||||
name: "by_expired",
|
||||
type: "checkbox",
|
||||
|
|
@ -75,7 +75,6 @@ export default {
|
|||
edit: "AgreementsFormAddEdit",
|
||||
},
|
||||
apiClient: APIClient.erm.agreements,
|
||||
resourceTableUrl: APIClient.erm.httpClient._baseURL + "agreements",
|
||||
i18n: {
|
||||
deleteConfirmationMessage: $__(
|
||||
"Are you sure you want to remove this agreement?"
|
||||
|
|
@ -86,10 +85,14 @@ export default {
|
|||
emptyListMessage: $__("There are no agreements defined"),
|
||||
newLabel: $__("New agreement"),
|
||||
},
|
||||
table: {
|
||||
addFilters: true,
|
||||
resourceTableUrl:
|
||||
APIClient.erm.httpClient._baseURL + "agreements",
|
||||
filters,
|
||||
},
|
||||
embedded: props.embedded,
|
||||
addFiltersToList: true,
|
||||
extendedAttributesResourceType,
|
||||
agreement_table_settings,
|
||||
resourceAttrs: [
|
||||
{
|
||||
name: "agreement_id",
|
||||
|
|
@ -634,13 +637,12 @@ export default {
|
|||
],
|
||||
moduleStore: "ERMStore",
|
||||
vendors,
|
||||
tableFilters,
|
||||
props: props,
|
||||
});
|
||||
|
||||
const defaults = baseResource.getFilterValues(
|
||||
baseResource.route.query,
|
||||
tableFilters
|
||||
filters
|
||||
);
|
||||
|
||||
const tableOptions = {
|
||||
|
|
@ -648,7 +650,7 @@ export default {
|
|||
embed: "user_roles,vendor,extended_attributes,+strings",
|
||||
},
|
||||
url: () => tableUrl(defaults),
|
||||
table_settings: baseResource.agreement_table_settings,
|
||||
table_settings: agreement_table_settings,
|
||||
add_filters: true,
|
||||
filters_options: {
|
||||
2: [
|
||||
|
|
|
|||
|
|
@ -34,8 +34,11 @@ export default {
|
|||
edit: "EHoldingsLocalPackagesFormAddEdit",
|
||||
},
|
||||
apiClient: APIClient.erm.localPackages,
|
||||
resourceTableUrl:
|
||||
APIClient.erm.httpClient._baseURL + "eholdings/local/packages",
|
||||
table: {
|
||||
resourceTableUrl:
|
||||
APIClient.erm.httpClient._baseURL +
|
||||
"eholdings/local/packages",
|
||||
},
|
||||
i18n: {
|
||||
deleteConfirmationMessage: $__(
|
||||
"Are you sure you want to remove this local package?"
|
||||
|
|
@ -47,7 +50,6 @@ export default {
|
|||
newLabel: $__("New package"),
|
||||
},
|
||||
extendedAttributesResourceType: "package",
|
||||
eholdings_packages_table_settings,
|
||||
vendors,
|
||||
props,
|
||||
moduleStore: "ERMStore",
|
||||
|
|
@ -188,7 +190,7 @@ export default {
|
|||
null,
|
||||
],
|
||||
},
|
||||
table_settings: baseResource.eholdings_packages_table_settings,
|
||||
table_settings: eholdings_packages_table_settings,
|
||||
add_filters: true,
|
||||
filters_options: {
|
||||
1: [
|
||||
|
|
|
|||
|
|
@ -49,8 +49,11 @@ export default {
|
|||
edit: "EHoldingsLocalTitlesFormAddEdit",
|
||||
},
|
||||
apiClient: APIClient.erm.localTitles,
|
||||
resourceTableUrl:
|
||||
APIClient.erm.httpClient._baseURL + "eholdings/local/titles",
|
||||
table: {
|
||||
resourceTableUrl:
|
||||
APIClient.erm.httpClient._baseURL +
|
||||
"eholdings/local/titles",
|
||||
},
|
||||
i18n: {
|
||||
deleteConfirmationMessage: $__(
|
||||
"Are you sure you want to remove this title?"
|
||||
|
|
@ -61,7 +64,6 @@ export default {
|
|||
emptyListMessage: $__("There are no titles defined"),
|
||||
newLabel: $__("New title"),
|
||||
},
|
||||
eholdings_titles_table_settings,
|
||||
vendors,
|
||||
props,
|
||||
additionalToolbarButtons,
|
||||
|
|
@ -445,7 +447,7 @@ export default {
|
|||
null,
|
||||
],
|
||||
},
|
||||
table_settings: baseResource.eholdings_titles_table_settings,
|
||||
table_settings: eholdings_titles_table_settings,
|
||||
add_filters: true,
|
||||
filters_options: {
|
||||
3: () =>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@ export default {
|
|||
edit: "LicensesFormAddEdit",
|
||||
},
|
||||
apiClient: APIClient.erm.licenses,
|
||||
resourceTableUrl: APIClient.erm.httpClient._baseURL + "licenses",
|
||||
table: {
|
||||
resourceTableUrl:
|
||||
APIClient.erm.httpClient._baseURL + "licenses",
|
||||
},
|
||||
i18n: {
|
||||
deleteConfirmationMessage: $__(
|
||||
"Are you sure you want to remove this license?"
|
||||
|
|
@ -48,7 +51,6 @@ export default {
|
|||
newLabel: $__("New license"),
|
||||
},
|
||||
extendedAttributesResourceType,
|
||||
license_table_settings,
|
||||
vendors,
|
||||
props,
|
||||
moduleStore: "ERMStore",
|
||||
|
|
@ -287,7 +289,7 @@ export default {
|
|||
const tableOptions = {
|
||||
url: baseResource.getResourceTableUrl(),
|
||||
options: { embed: "vendor,extended_attributes,+strings" },
|
||||
table_settings: baseResource.license_table_settings,
|
||||
table_settings: license_table_settings,
|
||||
add_filters: true,
|
||||
filters_options: {
|
||||
2: [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export default {
|
|||
const PreservationStore = inject("PreservationStore");
|
||||
const { config } = storeToRefs(PreservationStore);
|
||||
|
||||
const tableFilters = [
|
||||
const filters = [
|
||||
{
|
||||
id: "status_filter",
|
||||
name: "status_filter",
|
||||
|
|
@ -118,9 +118,12 @@ export default {
|
|||
edit: "TrainsFormAddEdit",
|
||||
},
|
||||
apiClient: APIClient.preservation.trains,
|
||||
resourceTableUrl:
|
||||
APIClient.preservation.httpClient._baseURL + "trains",
|
||||
addFiltersToList: true,
|
||||
table: {
|
||||
resourceTableUrl:
|
||||
APIClient.preservation.httpClient._baseURL + "trains",
|
||||
addFilters: true,
|
||||
filters,
|
||||
},
|
||||
i18n: {
|
||||
deleteConfirmationMessage: $__(
|
||||
"Are you sure you want to remove this train?"
|
||||
|
|
@ -136,7 +139,6 @@ export default {
|
|||
config,
|
||||
props,
|
||||
additionalToolbarButtons,
|
||||
tableFilters,
|
||||
moduleStore: "PreservationStore",
|
||||
resourceAttrs: [
|
||||
{
|
||||
|
|
@ -234,7 +236,7 @@ export default {
|
|||
|
||||
const defaults = baseResource.getFilterValues(
|
||||
baseResource.route.query,
|
||||
tableFilters
|
||||
filters
|
||||
);
|
||||
const tableOptions = {
|
||||
options: {
|
||||
|
|
|
|||
|
|
@ -161,9 +161,11 @@ export default {
|
|||
list: "WaitingList",
|
||||
},
|
||||
apiClient: APIClient.preservation.waiting_list_items,
|
||||
resourceTableUrl:
|
||||
APIClient.preservation.httpClient._baseURL +
|
||||
"/waiting-list/items",
|
||||
table: {
|
||||
resourceTableUrl:
|
||||
APIClient.preservation.httpClient._baseURL +
|
||||
"/waiting-list/items",
|
||||
},
|
||||
i18n: {
|
||||
deleteConfirmationMessage: $__(
|
||||
"Are you sure you want to remove this item from the waiting list?"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
<template>
|
||||
<fieldset v-if="instancedResource.tableFilters?.length > 0" class="filters">
|
||||
<fieldset
|
||||
v-if="instancedResource.table.filters?.length > 0"
|
||||
class="filters"
|
||||
>
|
||||
<template v-if="instancedResource.getTableFilterFormElementsLabel()"
|
||||
>{{ instancedResource.getTableFilterFormElementsLabel()
|
||||
}}{{ " " }}</template
|
||||
>
|
||||
<template
|
||||
v-for="(filter, index) in instancedResource.tableFilters"
|
||||
v-for="(filter, index) in instancedResource.table.filters"
|
||||
v-bind:key="index"
|
||||
>
|
||||
<FormElement :resource="filters" :attr="filter" :index="index" />
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export default {
|
|||
* If you need to include filters in your List component, add them as an array here.
|
||||
* The filters follow the format of resourceAttrs and are passed into the useBaseResource method
|
||||
*/
|
||||
const tableFilters = [];
|
||||
const filters = [];
|
||||
|
||||
/*
|
||||
* If you want to amend the default buttons in the toolbar, include this method and pass it into the useBaseResource method
|
||||
|
|
@ -84,7 +84,6 @@ export default {
|
|||
edit: "SkeletonsFormAddEdit",
|
||||
},
|
||||
apiClient: APIClient.skel.skeletons,
|
||||
resourceTableUrl: APIClient.skel.httpClient._baseURL + "skeletons",
|
||||
i18n: {
|
||||
deleteConfirmationMessage: $__(
|
||||
"Are you sure you want to remove this skeleton?"
|
||||
|
|
@ -95,14 +94,17 @@ export default {
|
|||
emptyListMessage: $__("There are no skeletons defined"),
|
||||
newLabel: $__("New skeleton"),
|
||||
},
|
||||
table: {
|
||||
resourceTableUrl:
|
||||
APIClient.skel.httpClient._baseURL + "skeletons",
|
||||
addFilters: true,
|
||||
filters,
|
||||
},
|
||||
embedded: props.embedded,
|
||||
addFiltersToList: true,
|
||||
extendedAttributesResourceType,
|
||||
skeleton_table_settings,
|
||||
resourceAttrs: [],
|
||||
moduleStore: "examplesStore",
|
||||
examples,
|
||||
tableFilters,
|
||||
props: props,
|
||||
additionalToolbarButtons,
|
||||
defaultToolbarButtons,
|
||||
|
|
@ -116,7 +118,7 @@ export default {
|
|||
*/
|
||||
const defaults = baseResource.getFilterValues(
|
||||
baseResource.route.query,
|
||||
tableFilters
|
||||
filters
|
||||
);
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -140,8 +140,10 @@ export default {
|
|||
edit: "VendorFormAddEdit",
|
||||
},
|
||||
apiClient: APIClient.acquisition.vendors,
|
||||
resourceTableUrl:
|
||||
APIClient.acquisition.httpClient._baseURL + "vendors",
|
||||
table: {
|
||||
resourceTableUrl:
|
||||
APIClient.acquisition.httpClient._baseURL + "vendors",
|
||||
},
|
||||
i18n: {
|
||||
deleteConfirmationMessage: $__(
|
||||
"Are you sure you want to remove this vendor?"
|
||||
|
|
|
|||
|
|
@ -24,19 +24,17 @@ import {
|
|||
* @param {String} resourceConfig.resourceName - The name of the resource.
|
||||
* @param {String} resourceConfig.idAttr - The name of the id attribute of the resource.
|
||||
* @param {String} resourceConfig.nameAttr - The name attribute of the resource.
|
||||
* @param {String} resourceConfig.components.show - The name of the show component.
|
||||
* @param {String} resourceConfig.components.add - The name of the add component.
|
||||
* @param {String} resourceConfig.components.edit - The name of the edit component.
|
||||
* @param {String} resourceConfig.components.list - The name of the list component.
|
||||
* @param {String} resourceConfig.components - An object containing the names of the components ("show", "add", "list", "edit")
|
||||
* @param {Object} resourceConfig.i18n - The i18n object.
|
||||
* @param {Object} resourceConfig.apiClient - The API client for the resource.
|
||||
* @param {String} resourceConfig.resourceTableUrl - The URL to the resource table.
|
||||
* @param {Object} resourceConfig.table - Contains the table configuration.
|
||||
* @param {String} resourceConfig.table.resourceTableUrl - The URL to the resource table.
|
||||
* @param {Array} resourceConfig.resourceAttrs - An array of attributes that relate to the resource's properties and how they should appear in the form/show/list components.
|
||||
* @param {Object} resourceConfig.props - The props passed to the resource component.
|
||||
* OPTIONAL:
|
||||
* @param {String} resourceConfig.moduleStore - The name of the module store that holds resource related data (authorised values, permissions etc)
|
||||
* @param {Boolean} resourceConfig.addFiltersToList - A flag to indicate whether to add filters to the list component for the datatable.
|
||||
* @param {Object} resourceConfig.tableFilters - The table filters for the resource. Follows the format for the resourceAttrs parameter.
|
||||
* @param {Boolean} resourceConfig.table.addFilters - A flag to indicate whether to add filters to the list component for the datatable.
|
||||
* @param {Object} resourceConfig.table.filters - The table filters for the resource. Follows the format for the resourceAttrs parameter.
|
||||
* @param {Function} resourceConfig.afterResourceFetch - A function to call after the resource is fetched. This can be used to edit resource data or fetch additional data
|
||||
* @param {Boolean} resourceConfig.embedded - A flag to indicate whether the resource is actually being used as a child component of another resource e.g. embedding a list of agreeements into EBSCO package agreements
|
||||
* @param {String} resourceConfig.extendedAttributesResourceType - The resource type for extended attributes, if applicable.
|
||||
|
|
@ -307,7 +305,7 @@ export function useBaseResource(resourceConfig) {
|
|||
* @return {string}
|
||||
*/
|
||||
const getResourceTableUrl = () => {
|
||||
return resourceConfig.resourceTableUrl;
|
||||
return resourceConfig.table.resourceTableUrl;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -325,7 +323,7 @@ export function useBaseResource(resourceConfig) {
|
|||
|
||||
/**
|
||||
* Builds an object of filter name-value pairs based on the provided
|
||||
* query object and filterData (tableFilters by default).
|
||||
* query object and filterData ('filters' by default).
|
||||
*
|
||||
* Iterates over the query object keys and updates the filterOptions
|
||||
* object with the new values. If a filter name is not found in
|
||||
|
|
@ -338,8 +336,8 @@ export function useBaseResource(resourceConfig) {
|
|||
const getFilterValues = (query, filterData = []) => {
|
||||
const filters = filterData
|
||||
? filterData
|
||||
: resourceConfig.tableFilters
|
||||
? resourceConfig.tableFilters
|
||||
: resourceConfig.table.filters
|
||||
? resourceConfig.table.filters
|
||||
: [];
|
||||
const filterOptions = filters.reduce((acc, filter) => {
|
||||
acc[filter.name] = filter.value;
|
||||
|
|
|
|||
Loading…
Reference in New Issue