Commit 5b045dd0 authored by Maksym Tishchenko's avatar Maksym Tishchenko
Browse files

Managing CropTraitCodes

parent bc6ff00f
......@@ -68,6 +68,10 @@
"CropTrait_plural": "Crop traits",
"CropTraitLang": "Crop trait translation",
"CropTraitLang_plural": "Crop trait translations",
"CropTraitCode": "Crop trait code",
"CropTraitCode_plural": "Crop trait codes",
"CropTraitCodeLang": "Crop trait code translation",
"CropTraitCodeLang_plural": "Crop trait code translations",
"Inventory": "Inventory",
"InventoryAction": "Inventory action",
"InventoryAction_plural": "Inventory actions",
......@@ -117,7 +121,9 @@
"SourceDescriptorCode": "Source descriptor code",
"SourceDescriptorCode_plural": "Source descriptor codes",
"SourceDescriptorLang": "Source descriptor translation",
"SourceDescriptorLang_plural": "Source descriptor translations"
"SourceDescriptorLang_plural": "Source descriptor translations",
"SourceDescriptorCodeLang": "Source descriptor code translation",
"SourceDescriptorCodeLang_plural": "Source descriptor code translations"
},
"Cooperator": {
"id": "Cooperator ID",
......@@ -312,9 +318,11 @@
"attachDate": "Attach Date",
"attachDateCode": "Attach Date Format"
},
"CodeTraitLang": {
"CropTraitLang": {
"entity": "Crop trait",
"sysLangId": "Language"
"sysLang": "Language",
"title": "Title",
"description": "Description"
},
"CropTraitObservation": {
"cropTraitObservation": "Crop Trait Observation ID",
......@@ -1233,7 +1241,6 @@
"code": "Code"
},
"SourceDescriptorLang": {
"sourceDescriptor": "Descriptor",
"sysLang": "Language",
"title": "Title",
"description": "Description"
......
......@@ -53,6 +53,10 @@
"CropTrait_plural": "Crop traits",
"CropTraitLang": "Crop trait translation",
"CropTraitLang_plural": "Crop trait translations",
"CropTraitCode": "Crop trait code",
"CropTraitCode_plural": "Crop trait codes",
"CropTraitCodeLang": "Crop trait code translation",
"CropTraitCodeLang_plural": "Crop trait code translations",
"Inventory": "Inventory",
"InventoryAction": "Inventory action",
"InventoryAction_plural": "Inventory actions",
......@@ -102,7 +106,9 @@
"SourceDescriptorCode": "Source descriptor code",
"SourceDescriptorCode_plural": "Source descriptor codes",
"SourceDescriptorLang": "Source descriptor translation",
"SourceDescriptorLang_plural": "Source descriptor translations"
"SourceDescriptorLang_plural": "Source descriptor translations",
"SourceDescriptorCodeLang": "Source descriptor code translation",
"SourceDescriptorCodeLang_plural": "Source descriptor code translations"
},
"Cooperator": {
"id": "Cooperator ID",
......@@ -298,9 +304,11 @@
"attachDate": "Attach Date",
"attachDateCode": "Attach Date Format"
},
"CodeTraitLang": {
"CropTraitLang": {
"entity": "Crop trait",
"sysLangId": "Language"
"sysLang": "Language",
"title": "Title",
"description": "Description"
},
"CropTraitObservation": {
"cropTraitObservation": "Crop Trait Observation ID",
......@@ -1221,7 +1229,6 @@
"code": "Code"
},
"SourceDescriptorLang": {
"sourceDescriptor": "Descriptor",
"sysLang": "Language",
"title": "Title",
"description": "Description"
......
......@@ -20,7 +20,7 @@ const URL_UPLOAD_FILE = UrlTemplate.parse('/api/v1/crop-trait/attach/{cropTraitI
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_CODE_LANG = UrlTemplate.parse('/api/v1/crop-trait/code-lang/{id}');
const URL_DELETE_CROP_TRAIT_CODE_LANG = UrlTemplate.parse(`/api/v1/crop-trait/code/{entityId}/lang/{sysLangId}`);
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_UPDATE_CROP_TRAIT_CODE_ATTACH = `/api/v1/crop-trait/code/attach/meta`;
......@@ -31,11 +31,12 @@ const URL_GET_CROP_TRAIT_ATTACH = UrlTemplate.parse(`/api/v1/crop-trait/attach/m
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_LANG = UrlTemplate.parse(`/api/v1/crop-trait/code/{entityId}/lang/{sysLangId}`);
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';
const URL_GET_LANGS = UrlTemplate.parse('/api/v1/crop-trait/{cropTraitId}/langs');
const URL_LIST_CODE_LANGS = UrlTemplate.parse(`/api/v1/crop-trait/code/{entityId}/langs`);
const URL_UPSERT_CROP_TRAIT_LANG = UrlTemplate.parse('/api/v1/crop-trait/{cropTraitId}/lang/{sysLangId}');
const URL_DELETE_CROP_TRAIT_LANG = UrlTemplate.parse('/api/v1/crop-trait/{cropTraitId}/lang/{sysLangId}');
const URL_FILTER_OBSERVATIONS = '/api/v1/crop-trait/observations/list';
......@@ -131,7 +132,7 @@ class CropTraitService {
* @param id undefined
* @param xhrConfig additional xhr config
*/
public deleteCropTraitCode = (id: number, xhrConfig?: AxiosRequestConfig): Promise<any> => {
public deleteCropTraitCode = (id: number, xhrConfig?: AxiosRequestConfig): Promise<CropTraitCode> => {
const apiUrl = URL_DELETE_CROP_TRAIT_CODE.expand({ id });
// console.log(`Fetching from ${apiUrl}`);
......@@ -142,7 +143,7 @@ class CropTraitService {
url: apiUrl,
method: 'DELETE',
...content,
}).then(({ data }) => data as any);
}).then(({ data }) => data as CropTraitCode);
};
/**
......@@ -167,14 +168,15 @@ class CropTraitService {
};
/**
* deleteCropTraitCodeLang at /api/v1/crop-trait/code-lang/{id}
* deleteCropTraitCodeLang at /api/v1/crop-trait/code/{entityId}/lang/{sysLangId}
*
* @param id undefined
* @param entityId
* @param sysLangId
* @param xhrConfig additional xhr config
*/
public deleteCropTraitCodeLang = (id: number, xhrConfig?: AxiosRequestConfig): Promise<any> => {
public deleteCropTraitCodeLang = (entityId: number, sysLangId: number, xhrConfig?: AxiosRequestConfig): Promise<CropTraitCodeLang> => {
const apiUrl = URL_DELETE_CROP_TRAIT_CODE_LANG.expand({ id });
const apiUrl = URL_DELETE_CROP_TRAIT_CODE_LANG.expand({ entityId, sysLangId });
// console.log(`Fetching from ${apiUrl}`);
const content = { /* No content in request body */ };
......@@ -183,7 +185,7 @@ class CropTraitService {
url: apiUrl,
method: 'DELETE',
...content,
}).then(({ data }) => data as undefined);
}).then(({ data }) => data as CropTraitCodeLang);
};
/**
......@@ -394,11 +396,13 @@ class CropTraitService {
* updateCropTraitCodeLang at /api/v1/crop-trait/code-lang
*
* @param data Request body
* @param entityId
* @param sysLangId
* @param xhrConfig additional xhr config
*/
public updateCropTraitCodeLang = (data: CropTraitCodeLang, xhrConfig?: AxiosRequestConfig): Promise<CropTraitCodeLang> => {
public updateCropTraitCodeLang = (data: CropTraitCodeLang, entityId: number, sysLangId: number, xhrConfig?: AxiosRequestConfig): Promise<CropTraitCodeLang> => {
const apiUrl = URL_UPDATE_CROP_TRAIT_CODE_LANG;
const apiUrl = URL_UPDATE_CROP_TRAIT_CODE_LANG.expand({ entityId, sysLangId });
// console.log(`Fetching from ${apiUrl}`);
const content = { data };
......@@ -497,6 +501,26 @@ class CropTraitService {
}).then(({ data }) => data as Array<CropTraitLang>);
};
/**
* listCodeLang at /api/v1/crop-trait/code/{entityId}/langs
*
* @param entityId undefined
* @param xhrConfig additional xhr config
*/
public listCodeLang = (entityId: number, xhrConfig?: AxiosRequestConfig): Promise<Array<CropTraitCodeLang>> => {
const apiUrl = URL_LIST_CODE_LANGS.expand({ entityId });
// 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 Array<CropTraitCodeLang>);
}
/**
* upsertCropTraitLang at /api/v1/crop-trait/{cropTraitId}/lang/{sysLangId}
*
......
......@@ -368,7 +368,7 @@ class SourceDescriptorService {
* @param entityId undefined
* @param xhrConfig additional xhr config
*/
public listCodeLang = (entityId: number, xhrConfig?: AxiosRequestConfig): Promise<SourceDescriptorCodeLang> => {
public listCodeLang = (entityId: number, xhrConfig?: AxiosRequestConfig): Promise<Array<SourceDescriptorCodeLang>> => {
const apiUrl = URL_LIST_CODE_LANG.expand({ entityId });
// console.log(`Fetching from ${apiUrl}`);
......@@ -379,7 +379,7 @@ class SourceDescriptorService {
url: apiUrl,
method: 'GET',
...content,
}).then(({ data }) => data as SourceDescriptorCodeLang);
}).then(({ data }) => data as Array<SourceDescriptorCodeLang>);
}
}
......
......@@ -250,6 +250,8 @@
"title": "Source descriptor details",
"langEditTitle": "Edit source descriptor {{lang, lowercase}} translation",
"translations": "Translations",
"codeTranslations": "Code translations",
"codeLangEditTitle": "Edit source descriptor code {{lang, lowercase}} translation",
"codes": "Codes"
}
}
......@@ -436,6 +438,8 @@
"title": "Crop trait details",
"attachments": "Attachments",
"translations": "Translations",
"codeTranslations": "Code translations",
"codeLangEditTitle": "Edit crop trait code {{lang, lowercase}} translation",
"codes": "Codes"
}
}
......
......@@ -72,6 +72,8 @@
"title": "Source descriptor details",
"langEditTitle": "Edit source descriptor {{lang, lowercase}} translation",
"translations": "Translations",
"codeTranslations": "Code translations",
"codeLangEditTitle": "Edit source descriptor code {{lang, lowercase}} translation",
"codes": "Codes"
}
}
......
import { Field, Form, FormProps, FormRenderProps } from 'react-final-form';
import { WithStyles } from '@material-ui/core/styles';
import { WithTranslation, withTranslation } from 'react-i18next';
import { Grid } from '@material-ui/core';
import { TextField } from '@gringlobal-ce/client/ui/common/form/TextField';
import * as React from 'react';
import { required } from '@gringlobal-ce/client/utilities/validators';
import withDialog from 'ui/common/withDialog';
const SourceDescriptorCodeLangForm = ({ t, onSubmit, initialValues, classes, error }: FormProps & WithStyles & WithTranslation) =>
<Form
initialValues={ initialValues }
onSubmit={ onSubmit }
>
{ (props: FormRenderProps & WithStyles) => (
<form onSubmit={ props.handleSubmit } id="source-descriptor-code-lang-form">
<Grid container spacing={ 4 }>
{ [ 'title', 'description' ].map((property) => (
<Grid key={ property } item xs={ 12 } sm={ 6 }>
<Field
placeholder={ t(`client:model._.${property}`) }
name={ property }
type="text"
component={ TextField }
label={ t(`client:model._.${property}`) }
required
validate={ required }
/>
</Grid>
)) }
{ error && <Grid item xs={ 12 } style={ { color: 'red' } }>{ error }</Grid> }
</Grid>
</form>
)}
</Form>
export default withDialog(withTranslation()(SourceDescriptorCodeLangForm));
......@@ -16,6 +16,8 @@
"title": "Crop trait details",
"attachments": "Attachments",
"translations": "Translations",
"codeTranslations": "Code translations",
"codeLangEditTitle": "Edit crop trait code {{lang, lowercase}} translation",
"codes": "Codes"
}
}
......
......@@ -24,7 +24,7 @@ import HeaderTabs from '@gringlobal-ce/client/ui/common/tabs/HeaderTabs';
import { CooperatorOwnedTableConfiguration as TableConfiguration } from '@gringlobal-ce/client/ui/common/table/TableConfiguration';
import { TaxonomySpeciesTableDefaultConfig } from 'taxonomy/ui/TaxonomySpeciesBrowsePage';
import TabPanel from '@gringlobal-ce/client/ui/common/tabs/TabPanel';
import Table, { TextAlign } from '@gringlobal-ce/client/ui/common/table/Table';
import Table, { Renderers, TextAlign } from '@gringlobal-ce/client/ui/common/table/Table';
import AttachmentsDisplay from 'repository/ui/c/AttachmentsDisplay';
import FileUploader from '@gringlobal-ce/client/ui/common/file-uploader';
import CropTrait from '@gringlobal-ce/client/model/gringlobal/CropTrait';
......@@ -91,6 +91,9 @@ export const CropTraitTableDefaultConfig = {
dataTypeCode: ({ value }: { value: string }) => <CodeValueDisplay codeGroup={ CropTrait.CodeGroup.dataTypeCode } value={ value } />,
categoryCode: ({ value }: { value: string }) => <CodeValueDisplay codeGroup={ CropTrait.CodeGroup.categoryCode } value={ value } />,
originalValueTypeCode: ({ value }: { value: string }) => <CodeValueDisplay codeGroup={ CropTrait.CodeGroup.originalValueTypeCode } value={ value } />,
isArchived: Renderers.STRING_BOOL_RENDERER,
isCoded: Renderers.STRING_BOOL_RENDERER,
isPeerReviewed: Renderers.STRING_BOOL_RENDERER,
},
};
......
import { Field, Form, FormProps, FormRenderProps } from 'react-final-form';
import { WithStyles } from '@material-ui/core/styles';
import { WithTranslation, withTranslation } from 'react-i18next';
import { Grid } from '@material-ui/core';
import { TextField } from '@gringlobal-ce/client/ui/common/form/TextField';
import * as React from 'react';
import { required } from '@gringlobal-ce/client/utilities/validators';
import withDialog from 'ui/common/withDialog';
const CropTraitCodeForm = ({ t, onSubmit, initialValues, classes, error }: FormProps & WithStyles & WithTranslation) =>
<Form
initialValues={ initialValues }
onSubmit={ onSubmit }
>
{ (props: FormRenderProps & WithStyles) => (
<form onSubmit={ props.handleSubmit } id="crop-trait-code-form">
<Grid container spacing={ 2 }>
<Grid item xs={ 12 }>
<Field
placeholder={ t('client:model.TranslatedCropTraitCode.code') }
name="code"
type="text"
component={ TextField }
label={ t('client:model.TranslatedCropTraitCode.code') }
required
validate={ required }
/>
</Grid>
{ initialValues && !initialValues.id && (
<>
<Grid item xs={ 12 } sm={ 6 }>
<Field
placeholder={ t('client:model._.title') }
name="title"
type="text"
component={ TextField }
label={ t('client:model._.title') }
required
validate={ required }
/>
</Grid>
<Grid item xs={ 12 } sm={ 6 }>
<Field
placeholder={ t('client:model._.description') }
name="description"
type="text"
component={ TextField }
label={ t('client:model._.description') }
/>
</Grid>
</>
) }
{ error && <Grid item xs={ 12 } style={ { color: 'red' } }>{ error }</Grid> }
</Grid>
</form>
)}
</Form>
export default withDialog(withTranslation()(CropTraitCodeForm));
import { Field, Form, FormProps, FormRenderProps } from 'react-final-form';
import { WithStyles } from '@material-ui/core/styles';
import { WithTranslation, withTranslation } from 'react-i18next';
import { Grid } from '@material-ui/core';
import { TextField } from '@gringlobal-ce/client/ui/common/form/TextField';
import * as React from 'react';
import { required } from '@gringlobal-ce/client/utilities/validators';
import withDialog from 'ui/common/withDialog';
const CropTraitCodeLangForm = ({ t, onSubmit, initialValues, classes, error }: FormProps & WithStyles & WithTranslation) =>
<Form
initialValues={ initialValues }
onSubmit={ onSubmit }
>
{ (props: FormRenderProps & WithStyles) => (
<form onSubmit={ props.handleSubmit } id="crop-trait-code-lang-form">
<Grid container spacing={ 4 }>
{ [ 'title', 'description' ].map((property) => (
<Grid key={ property } item xs={ 12 } sm={ 6 }>
<Field
placeholder={ t(`client:model._.${property}`) }
name={ property }
type="text"
component={ TextField }
label={ t(`client:model._.${property}`) }
required
validate={ required }
/>
</Grid>
)) }
{ error && <Grid item xs={ 12 } style={ { color: 'red' } }>{ error }</Grid> }
</Grid>
</form>
)}
</Form>
export default withDialog(withTranslation()(CropTraitCodeLangForm));
Supports Markdown
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