Commit d0f6610a authored by Matija Obreza's avatar Matija Obreza

TaxonomySpecies: Dereferencing in services

parent 3bf62173
......@@ -10,6 +10,8 @@ import TaxonomySpeciesFilter from '@gringlobal/client/model/gringlobal/TaxonomyS
import CropDetails from '@gringlobal/client/model/gringlobal/CropDetails';
import CropAttachmentRequest from '@gringlobal/client/model/gringlobal/CropAttachmentRequest';
import CropAttach from '@gringlobal/client/model/gringlobal/CropAttach';
import { dereferenceReferences3 } from '@gringlobal/client/utilities';
import TaxonomySpecies from '@gringlobal/client/model/gringlobal/TaxonomySpecies';
const URL_REMOVE_FILE = UrlTemplate.parse('/api/v1/crop/attach/{cropId}/{attachmentId}');
const URL_UPLOAD_FILE = UrlTemplate.parse('/api/v1/crop/attach/{cropId}');
......@@ -116,7 +118,7 @@ class CropService {
* @param cropId undefined
* @param xhrConfig additional xhr config
*/
public listCropSpecies = (data: TaxonomySpeciesFilter, cropId: number, xhrConfig?: AxiosRequestConfig): Promise<any> => {
public listCropSpecies = (data: TaxonomySpeciesFilter, cropId: number, xhrConfig?: AxiosRequestConfig): Promise<FilteredPage<TaxonomySpecies>> => {
const apiUrl = URL_LIST_CROP_SPECIES.expand({ cropId });
// console.log(`Fetching from ${apiUrl}`);
......@@ -127,7 +129,13 @@ class CropService {
url: apiUrl,
method: 'POST',
...content,
}).then(({ data }) => data as undefined);
}).then(({ data }) => {
dereferenceReferences3(data.content, {
gen: { id: [ 'taxonomyGenus' ] },
coo: { id: [ 'ownedBy', 'taxonomyGenus.ownedBy', 'verifierCooperator' ] },
});
return data as FilteredPage<TaxonomySpecies>;
});
}
/**
......
......@@ -58,7 +58,7 @@ class TaxonomyService {
}).then((response) => {
dereferenceReferences3(response.data.content, {
gen: { id: [ 'taxonomyGenus' ] },
coo: { id: [ 'ownedBy' ] }, // , 'modifiedBy', 'createdBy' ] },
coo: { id: [ 'ownedBy', 'verifierCooperator' ] }, // , 'modifiedBy', 'createdBy' ] },
});
return response.data;
});
......
......@@ -20,6 +20,8 @@ import withBrowsePageBase, { WithBrowsePageBase } from 'ui/common/withBrowsePage
import Filters from 'taxonomy/ui/c/Filters';
import { CooperatorOwnedTableConfiguration as TableConfiguration } from '@gringlobal/client/ui/common/table/TableConfiguration';
import PageTitle from '@gringlobal/client/ui/common/PageTitle';
import Cooperator from '@gringlobal/client/model/gringlobal/Cooperator';
import { CooperatorLink } from 'ui/common/Links';
interface IBrowsePageProps extends React.ClassAttributes<any>, WithTranslation, WithBrowsePageBase {
......@@ -66,6 +68,7 @@ export const TaxonomySpeciesTableDefaultConfig = {
) : null;
},
name: (name: string, taxonomySpecies: TaxonomySpecies): JSX.Element => <PrintSpecies taxonomySpecies={ taxonomySpecies } />,
verifierCooperator: (verifierCooperator: Cooperator): JSX.Element => <CooperatorLink cooperator={ verifierCooperator } />,
},
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment