Commit 3bf62173 authored by Oleksii Savran's avatar Oleksii Savran

Updated services, creating TranslatedCropTrait with title and description

parent da745acc
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 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;
......@@ -8,15 +8,26 @@ 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';
/**
......@@ -92,6 +103,66 @@ class CropTraitService {
}).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 */ };
return this._axios.request({
...xhrConfig,
url: apiUrl,
method: 'DELETE',
...content,
}).then(({ data }) => data as any);
};
/**
* deleteCropTraitCodeLang at /api/v1/crop-trait/code-lang/{id}
*
* @param id undefined
* @param xhrConfig additional xhr config
*/
public deleteCropTraitCodeLang = (id: number, xhrConfig?: AxiosRequestConfig): Promise<any> => {
const apiUrl = URL_DELETE_CROP_TRAIT_CODE_LANG.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 undefined);
};
/**
* uploadTraitCodeFile at /api/v1/crop-trait/code/attach/{cropTraitCodeId}
*
......@@ -155,6 +226,26 @@ class CropTraitService {
}).then(({ data }) => data as undefined);
};
/**
* updateCropTraitLang at /api/v1/crop-trait/lang
*
* @param data Request body
* @param xhrConfig additional xhr config
*/
public updateCropTraitLang = (data: CropTraitLang, xhrConfig?: AxiosRequestConfig): Promise<CropTraitLang> => {
const apiUrl = URL_UPDATE_CROP_TRAIT_LANG;
// console.log(`Fetching from ${apiUrl}`);
const content = { data };
return this._axios.request({
...xhrConfig,
url: apiUrl,
method: 'PUT',
...content,
}).then(({ data }) => data as CropTraitLang);
};
/**
* update at /api/v1/crop-trait
*
......@@ -181,7 +272,7 @@ class CropTraitService {
* @param data Request body
* @param xhrConfig additional xhr config
*/
public create = (data: CropTrait, xhrConfig?: AxiosRequestConfig): Promise<CropTrait> => {
public create = (data: TranslatedCropTrait, xhrConfig?: AxiosRequestConfig): Promise<TranslatedCropTrait> => {
const apiUrl = URL_CREATE;
// console.log(`Fetching from ${apiUrl}`);
......@@ -192,7 +283,67 @@ class CropTraitService {
url: apiUrl,
method: 'POST',
...content,
}).then(({ data }) => data as CropTrait);
}).then(({ data }) => data as TranslatedCropTrait);
};
/**
* updateCropTraitCodeLang at /api/v1/crop-trait/code-lang
*
* @param data Request body
* @param xhrConfig additional xhr config
*/
public updateCropTraitCodeLang = (data: CropTraitCodeLang, xhrConfig?: AxiosRequestConfig): Promise<CropTraitCodeLang> => {
const apiUrl = URL_UPDATE_CROP_TRAIT_CODE_LANG;
// console.log(`Fetching from ${apiUrl}`);
const content = { data };
return this._axios.request({
...xhrConfig,
url: apiUrl,
method: 'PUT',
...content,
}).then(({ data }) => data as CropTraitCodeLang);
};
/**
* updateCropTraitCode at /api/v1/crop-trait/code
*
* @param data Request body
* @param xhrConfig additional xhr config
*/
public updateCropTraitCode = (data: CropTraitCode, xhrConfig?: AxiosRequestConfig): Promise<CropTraitCode> => {
const apiUrl = URL_UPDATE_CROP_TRAIT_CODE;
// console.log(`Fetching from ${apiUrl}`);
const content = { data };
return this._axios.request({
...xhrConfig,
url: apiUrl,
method: 'PUT',
...content,
}).then(({ data }) => data as CropTraitCode);
};
/**
* createCropTraitCodeWithLang at /api/v1/crop-trait/code
*
* @param data Request body
* @param xhrConfig additional xhr config
*/
public createCropTraitCodeWithLang = (data: TranslatedCropTraitCode, xhrConfig?: AxiosRequestConfig): Promise<TranslatedCropTraitCode> => {
const apiUrl = URL_CREATE_CROP_TRAIT_CODE_WITH_LANG;
// console.log(`Fetching from ${apiUrl}`);
const content = { data };
return this._axios.request({
...xhrConfig,
url: apiUrl,
method: 'POST',
...content,
}).then(({ data }) => data as TranslatedCropTraitCode);
};
/**
......
......@@ -4,6 +4,7 @@ import { withStyles, WithStyles, createStyles } from '@material-ui/core/styles';
import { useTranslation } from 'react-i18next';
// Model
import CropTrait from '@gringlobal/client/model/gringlobal/CropTrait';
import TranslatedCropTrait from '@gringlobal/client/model/gringlobal/TranslatedCropTrait';
// UI
import { TextField } from '@gringlobal/client/ui/common/form/TextField';
import { Grid, Button, CardActions } from '@material-ui/core';
......@@ -21,7 +22,7 @@ const styles = (theme) => createStyles({
});
interface ICropTraitForm extends React.ClassAttributes<any>, FormProps {
initialValues: Partial<CropTrait>;
initialValues: Partial<TranslatedCropTrait>;
}
function CropTraitFormInternal(props: FormRenderProps & WithStyles) {
......@@ -164,6 +165,29 @@ function CropTraitFormInternal(props: FormRenderProps & WithStyles) {
/>
</Grid>
</Grid>
<Grid container spacing={ 4 }>
<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>
</Grid>
<CardActions>
<Button type="submit" variant="contained" color="primary">{ t('common:action.submit') }</Button>
</CardActions>
......
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