Commit 444024da authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '122-list-crop-traits' into 'master'

List crop traits

Closes #122

See merge request grin-global/grin-global-ui!99
parents dc66605e d0f6610a
......@@ -88,6 +88,27 @@
"previousState": "Previous State",
"newState": "New State"
},
"CropTrait": {
"categoryCode": "Category",
"codedName": "Name",
"crop": "Crop",
"dataTypeCode": "Data Type Code",
"id": "ID",
"isArchived": "Is archived",
"isCoded": "Is coded",
"isPeerReviewed": "Is peer reviewed",
"maxLength": "Maximum length",
"numericFormat": "Numeric format",
"numericMaximum": "Numeric maximum",
"numericMinimum": "Numeric minimum",
"ontologyUrl": "Ontology URL",
"originalValueFormat": "Original value format",
"originalValueTypeCode": "Original value Type Code"
},
"TranslatedCropTraitCode": {
"code": "Code",
"cropTrait": "Crop trait"
},
"Geography": {
"geography": "Geography",
"currentGeography": "Current Valid Geography",
......
import Cooperator from '@gringlobal/client/model/gringlobal/Cooperator';
import Crop from '@gringlobal/client/model/gringlobal/Crop';
/**
* CropTrait
*
* GRIN-Global CE API
*/
class CropTrait {
public createdBy: number;
public createdDate: Date;
public modifiedBy: number;
public modifiedDate: Date;
public ownedBy: Cooperator;
public ownedDate: Date;
public categoryCode: string;
public codedName: string;
public crop: Crop;
public dataTypeCode: string;
public id: number;
public isArchived: string;
public isCoded: string;
public isPeerReviewed: string;
public maxLength: number;
public note: string;
public numericFormat: string;
public numericMaximum: number;
public numericMinimum: number;
public ontologyUrl: string;
public originalValueFormat: string;
public originalValueTypeCode: string;
public static CodeValues = {
dataTypeCode: 'CROP_TRAIT_DATA_TYPE',
categoryCode: 'DESCRIPTOR_CATEGORY',
originalValueTypeCode: 'CROP_TRAIT_DATA_TYPE',
}
}
export default CropTrait;
import Cooperator from '@gringlobal/client/model/gringlobal/Cooperator';
import CropTrait from '@gringlobal/client/model/gringlobal/CropTrait';
import RepositoryFile from '@gringlobal/client/model/repository/RepositoryFile';
/**
* CropTraitAttach
*
* GRIN-Global CE API
*/
class CropTraitAttach {
public createdBy: number;
public createdDate: Date;
public modifiedBy: number;
public modifiedDate: Date;
public ownedBy: Cooperator;
public ownedDate: Date;
public title: string;
public virtualPath: string;
public thumbnailVirtualPath: string;
public contentType: string;
public isWebVisible: string;
public sortOrder: number;
public note: string;
public repositoryFile: RepositoryFile;
public id: number;
public attachCooperator: Cooperator;
public attachDate: Date;
public attachDateCode: string;
public categoryCode: string;
public cropTrait: CropTrait;
public description: string;
}
export default CropTraitAttach;
import CropTraitAttach from '@gringlobal/client/model/gringlobal/CropTraitAttach';
import RepositoryFile from '@gringlobal/client/model/repository/RepositoryFile';
/**
* CropTraitAttachmentRequest
*
* GRIN-Global CE API
*/
class CropTraitAttachmentRequest {
public fileMetadata: RepositoryFile;
public attachMetadata: CropTraitAttach;
}
export default CropTraitAttachmentRequest;
import Cooperator from '@gringlobal/client/model/gringlobal/Cooperator';
import CropTrait from '@gringlobal/client/model/gringlobal/CropTrait';
/**
* CropTraitCode
*
* GRIN-Global CE API
*/
class CropTraitCode {
public createdBy: number;
public createdDate: Date;
public modifiedBy: number;
public modifiedDate: Date;
public ownedBy: Cooperator;
public ownedDate: Date;
public code: string;
public cropTrait: CropTrait;
public id: number;
}
export default CropTraitCode;
import Cooperator from '@gringlobal/client/model/gringlobal/Cooperator';
import CropTraitCode from '@gringlobal/client/model/gringlobal/CropTraitCode';
import RepositoryFile from '@gringlobal/client/model/repository/RepositoryFile';
/**
* CropTraitCodeAttach
*
* GRIN-Global CE API
*/
class CropTraitCodeAttach {
public createdBy: number;
public createdDate: Date;
public modifiedBy: number;
public modifiedDate: Date;
public ownedBy: Cooperator;
public ownedDate: Date;
public title: string;
public virtualPath: string;
public thumbnailVirtualPath: string;
public contentType: string;
public isWebVisible: string;
public sortOrder: number;
public note: string;
public repositoryFile: RepositoryFile;
public id: number;
public attachCooperator: Cooperator;
public attachDate: Date;
public attachDateCode: string;
public categoryCode: string;
public cropTraitCode: CropTraitCode;
public description: string;
}
export default CropTraitCodeAttach;
import CropTraitCodeAttach from '@gringlobal/client/model/gringlobal/CropTraitCodeAttach';
import RepositoryFile from '@gringlobal/client/model/repository/RepositoryFile';
/**
* CropTraitCodeAttachmentRequest
*
* GRIN-Global CE API
*/
class CropTraitCodeAttachmentRequest {
public fileMetadata: RepositoryFile;
public attachMetadata: CropTraitCodeAttach;
}
export default CropTraitCodeAttachmentRequest;
import Cooperator from '@gringlobal/client/model/gringlobal/Cooperator';
import CropTraitCode from '@gringlobal/client/model/gringlobal/CropTraitCode';
import SysLang from '@gringlobal/client/model/gringlobal/SysLang';
/**
* CropTraitCodeLang
*
* GRIN-Global CE API
*/
class CropTraitCodeLang {
public createdBy: number;
public createdDate: Date;
public modifiedBy: number;
public modifiedDate: Date;
public ownedBy: Cooperator;
public ownedDate: Date;
public entity: CropTraitCode;
public description: string;
public title: string;
public sysLang: SysLang;
public id: number;
}
export default CropTraitCodeLang;
import CooperatorFilter from '@gringlobal/client/model/gringlobal/CooperatorFilter';
import DateFilter from '@gringlobal/client/model/common/DateFilter';
import StringFilter from '@gringlobal/client/model/common/StringFilter';
/**
* CropTraitFilter
*
* GRIN-Global CE API
*/
class CropTraitFilter {
public NOT: CropTraitFilter;
public NULL: string[];
public NOTNULL: string[];
public id: number[];
public createdBy: number[];
public createdDate: DateFilter;
public modifiedBy: number[];
public modifiedDate: DateFilter;
public ownedBy: CooperatorFilter;
public ownedDate: DateFilter;
public crop: number[];
public codedName: string[];
public categoryCode: string[];
public description: StringFilter;
}
export default CropTraitFilter;
import Cooperator from '@gringlobal/client/model/gringlobal/Cooperator';
import CropTrait from '@gringlobal/client/model/gringlobal/CropTrait';
import SysLang from '@gringlobal/client/model/gringlobal/SysLang';
/**
* CropTraitLang
*
* GRIN-Global CE API
*/
class CropTraitLang {
public createdBy: number;
public createdDate: Date;
public modifiedBy: number;
public modifiedDate: Date;
public ownedBy: Cooperator;
public ownedDate: Date;
public entity: CropTrait;
public description: string;
public title: string;
public sysLang: SysLang;
public id: number;
}
export default CropTraitLang;
import Cooperator from '@gringlobal/client/model/gringlobal/Cooperator';
import Crop from '@gringlobal/client/model/gringlobal/Crop';
import TranslatedCropTraitCode from '@gringlobal/client/model/gringlobal/TranslatedCropTraitCode';
/**
* TranslatedCropTrait
*
* GRIN-Global CE API
*/
class TranslatedCropTrait {
public createdBy: number;
public createdDate: Date;
public modifiedBy: number;
public modifiedDate: Date;
public ownedBy: Cooperator;
public ownedDate: Date;
public categoryCode: string;
public codedName: string;
public crop: Crop;
public dataTypeCode: string;
public id: number;
public isArchived: string;
public isCoded: string;
public isPeerReviewed: string;
public maxLength: number;
public note: string;
public numericFormat: string;
public numericMaximum: number;
public numericMinimum: number;
public ontologyUrl: string;
public originalValueFormat: string;
public originalValueTypeCode: string;
public title: string;
public description: string;
public codes: TranslatedCropTraitCode[];
}
export default TranslatedCropTrait;
import Cooperator from '@gringlobal/client/model/gringlobal/Cooperator';
import CropTrait from '@gringlobal/client/model/gringlobal/CropTrait';
/**
* TranslatedCropTraitCode
*
* GRIN-Global CE API
*/
class TranslatedCropTraitCode {
public createdBy: number;
public createdDate: Date;
public modifiedBy: number;
public modifiedDate: Date;
public ownedBy: Cooperator;
public ownedDate: Date;
public code: string;
public cropTrait: CropTrait;
public id: number;
public title: string;
public description: string;
}
export default TranslatedCropTraitCode;
......@@ -77,6 +77,27 @@
"previousState": "Previous State",
"newState": "New State"
},
"CropTrait": {
"categoryCode": "Category",
"codedName": "Name",
"crop": "Crop",
"dataTypeCode": "Data Type Code",
"id": "ID",
"isArchived": "Is archived",
"isCoded": "Is coded",
"isPeerReviewed": "Is peer reviewed",
"maxLength": "Maximum length",
"numericFormat": "Numeric format",
"numericMaximum": "Numeric maximum",
"numericMinimum": "Numeric minimum",
"ontologyUrl": "Ontology URL",
"originalValueFormat": "Original value format",
"originalValueTypeCode": "Original value Type Code"
},
"TranslatedCropTraitCode": {
"code": "Code",
"cropTrait": "Crop trait"
},
"Geography": {
"geography": "Geography",
"currentGeography": "Current Valid Geography",
......
......@@ -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}');
......@@ -21,6 +23,7 @@ const URL_UPDATE_CROP = '/api/v1/crop';
const URL_CREATE_CROP = '/api/v1/crop';
const URL_LIST_CROPS = '/api/v1/crop/list';
const URL_FILTER_CROPS = '/api/v1/crop/filter';
const URL_AUTOCOMPLETE_CROPS = '/api/v1/crop/autocomplete';
/**
......@@ -115,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}`);
......@@ -126,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>;
});
}
/**
......@@ -263,6 +272,28 @@ class CropService {
method: 'POST',
...content,
}).then(({ data }) => data as FilteredPage<Crop>);
};
/**
* autocomplete at /api/v1/crop/autocomplete
*
* @param term undefined
* @param xhrConfig additional xhr config
*/
public autocomplete = (term: string, xhrConfig?: AxiosRequestConfig): Promise<Crop[]> => {
const qs = QueryString.stringify({
term: term || undefined,
}, {});
const apiUrl = URL_AUTOCOMPLETE_CROPS + (qs ? `?${qs}` : '');
// console.log(`Fetching from ${apiUrl}`);
const content = { /* No content in request body */ };
return this._axios.request({
...xhrConfig,
url: apiUrl,
method: 'GET',
...content,
}).then(({ data }) => data as Crop[]);
}
}
......
import * as UrlTemplate from 'url-template';
import * as QueryString from 'query-string';
import { AxiosInstance, AxiosRequestConfig } from 'axios';
import { IPageRequest } from '@gringlobal/client/model/page';
import CropTrait from '@gringlobal/client/model/gringlobal/CropTrait';
import CropTraitFilter from '@gringlobal/client/model/gringlobal/CropTraitFilter';
import TranslatedCropTrait from '@gringlobal/client/model/gringlobal/TranslatedCropTrait';
import FilteredPage from '@gringlobal/client/model/page/FilteredPage';
import CropTraitLang from '@gringlobal/client/model/gringlobal/CropTraitLang';
import CropTraitCodeLang from '@gringlobal/client/model/gringlobal/CropTraitCodeLang';
import TranslatedCropTraitCode from '@gringlobal/client/model/gringlobal/TranslatedCropTraitCode';
import CropTraitCode from '@gringlobal/client/model/gringlobal/CropTraitCode';
const URL_UPLOAD_FILE = UrlTemplate.parse('/api/v1/crop-trait/attach/{cropTraitId}');
const URL_GET_TRANSLATED = UrlTemplate.parse('/api/v1/crop-trait/{id}');
const URL_REMOVE = UrlTemplate.parse('/api/v1/crop-trait/{id}');
const URL_DELETE_CROP_TRAIT_CODE = UrlTemplate.parse('/api/v1/crop-trait/code/{id}');
const URL_DELETE_CROP_TRAIT_LANG = UrlTemplate.parse('/api/v1/crop-trait/lang/{id}');
const URL_DELETE_CROP_TRAIT_CODE_LANG = UrlTemplate.parse('/api/v1/crop-trait/code-lang/{id}');
const URL_UPLOAD_TRAIT_CODE_FILE = UrlTemplate.parse('/api/v1/crop-trait/code/attach/{cropTraitCodeId}');
const URL_REMOVE_TRAIT_CODE_FILE = UrlTemplate.parse('/api/v1/crop-trait/code/attach/{cropTraitCodeId}/{attachmentId}');
const URL_REMOVE_FILE = UrlTemplate.parse('/api/v1/crop-trait/attach/{cropTraitId}/{attachmentId}');
const URL_UPDATE_CROP_TRAIT_LANG = '/api/v1/crop-trait/lang';
const URL_UPDATE = '/api/v1/crop-trait';
const URL_CREATE = '/api/v1/crop-trait';
const URL_UPDATE_CROP_TRAIT_CODE_LANG = '/api/v1/crop-trait/code-lang';
const URL_UPDATE_CROP_TRAIT_CODE = '/api/v1/crop-trait/code';
const URL_CREATE_CROP_TRAIT_CODE_WITH_LANG = '/api/v1/crop-trait/code';
const URL_LIST = '/api/v1/crop-trait/list';
/**
* CropTrait service
*
* GRIN-Global CE API
*/
class CropTraitService {
private _axios: AxiosInstance;
public constructor(axios: AxiosInstance) {
this._axios = axios;
}
/**
* uploadFile at /api/v1/crop-trait/attach/{cropTraitId}
*
* @param data Request body
* @param cropTraitId undefined
* @param xhrConfig additional xhr config
*/
public uploadFile = (data: object, cropTraitId: number, xhrConfig?: AxiosRequestConfig): Promise<any> => { // todo: types
const apiUrl = URL_UPLOAD_FILE.expand({ cropTraitId });
// console.log(`Fetching from ${apiUrl}`);
const content = { data };
return this._axios.request({
...xhrConfig,
url: apiUrl,
method: 'POST',
...content,
}).then(({ data }) => data as undefined);
};
/**
* getTranslated at /api/v1/crop-trait/{id}
*
* @param id undefined
* @param xhrConfig additional xhr config
*/
public getTranslated = (id: number, xhrConfig?: AxiosRequestConfig): Promise<TranslatedCropTrait> => {
const apiUrl = URL_GET_TRANSLATED.expand({ id });
// console.log(`Fetching from ${apiUrl}`);
const content = { /* No content in request body */ };
return this._axios.request({
...xhrConfig,
url: apiUrl,
method: 'GET',
...content,
}).then(({ data }) => data as TranslatedCropTrait);
};
/**
* remove at /api/v1/crop-trait/{id}
*
* @param id undefined
* @param xhrConfig additional xhr config
*/
public remove = (id: number, xhrConfig?: AxiosRequestConfig): Promise<CropTrait> => {
const apiUrl = URL_REMOVE.expand({ id });
// console.log(`Fetching from ${apiUrl}`);
const content = { /* No content in request body */ };
return this._axios.request({
...xhrConfig,
url: apiUrl,
method: 'DELETE',
...content,
}).then(({ data }) => data as CropTrait);
};
/**
* deleteCropTraitCode at /api/v1/crop-trait/code/{id}
*
* @param id undefined
* @param xhrConfig additional xhr config
*/
public deleteCropTraitCode = (id: number, xhrConfig?: AxiosRequestConfig): Promise<any> => {
const apiUrl = URL_DELETE_CROP_TRAIT_CODE.expand({ id });
// console.log(`Fetching from ${apiUrl}`);
const content = { /* No content in request body */ };
return this._axios.request({
...xhrConfig,
url: apiUrl,
method: 'DELETE',
...content,
}).then(({ data }) => data as any);
};
/**
* deleteCropTraitLang at /api/v1/crop-trait/lang/{id}
*
* @param id undefined
* @param xhrConfig additional xhr config
*/
public deleteCropTraitLang = (id: number, xhrConfig?: AxiosRequestConfig): Promise<any> => {
const apiUrl = URL_DELETE_CROP_TRAIT_LANG.expand({ id });
// console.log(`Fetching from ${apiUrl}`);
const content = { /* No content in request body */ };