Commit ecf2a0f6 authored by Oleksii Savran's avatar Oleksii Savran Committed by Matija Obreza
Browse files

List Request actions

parent 4483d7c0
......@@ -349,6 +349,17 @@
"completedDate": "Completed Date",
"feedback": "Feedback"
},
"OrderRequestAction": {
"actionNameCode": "Action Name",
"startedDate": "Start Date",
"startedDateCode": "Start Date Format",
"completedDate": "Completed Date",
"completedDateCode": "Completed Date Format",
"cooperator": "Cooperator",
"actionCost": "Action cost",
"actionInformation": "Action Information",
"orderRequestId": "Order Request ID"
},
"OrderRequestItem": {
"id": "Order Request Item ID",
"orderRequest": "Order Number",
......
......@@ -24,7 +24,9 @@ class OrderRequestAction {
public actionInformation: string;
public orderRequestId: number;
public static CodeGroup = {
actionNameCode: 'ORDER_REQUEST_ACTION',
}
}
export default OrderRequestAction;
......@@ -338,6 +338,17 @@
"completedDate": "Completed Date",
"feedback": "Feedback"
},
"OrderRequestAction": {
"actionNameCode": "Action Name",
"startedDate": "Start Date",
"startedDateCode": "Start Date Format",
"completedDate": "Completed Date",
"completedDateCode": "Completed Date Format",
"cooperator": "Cooperator",
"actionCost": "Action cost",
"actionInformation": "Action Information",
"orderRequestId": "Order Request ID"
},
"OrderRequestItem": {
"id": "Order Request Item ID",
"orderRequest": "Order Number",
......
......@@ -487,7 +487,9 @@
"list": "Requests for material"
},
"details": {
"title": "Request"
"title": "Request",
"items": "Items",
"actions": "Actions"
}
},
"c": {
......
......@@ -7,6 +7,7 @@ import {
SAGA_RECEIVE_REQUEST, RECEIVE_REQUEST,
SAGA_RECEIVE_REQUEST_ITEMS, RECEIVE_REQUEST_ITEMS,
SAGA_CREATE_REQUEST, RECEIVE_NEW_REQUEST, CLEAR_REQUEST,
SAGA_RECEIVE_REQUEST_ACTIONS, RECEIVE_REQUEST_ACTIONS,
} from 'request/constants';
// Model
import OrderRequest from '@gringlobal/client/model/gringlobal/OrderRequest';
......@@ -17,6 +18,7 @@ import { IPageRequest, FilteredPage, Page, SortDirection } from '@gringlobal/cli
// Service
import { RequestService } from '@gringlobal/client/service';
import { dereferenceReferences3 } from '@gringlobal/client/utilities';
import OrderRequestAction from '@gringlobal/client/model/gringlobal/OrderRequestAction';
// import OrderRequestItem from '@gringlobal/client/model/gringlobal/OrderRequestItem';
......@@ -26,6 +28,7 @@ export const requestPublicSagas = [
takeEvery(SAGA_CREATE_REQUEST, createOrderRequestSaga),
takeEvery(RECEIVE_NEW_REQUEST, redirectToNewRequestSaga),
takeEvery(SAGA_RECEIVE_REQUEST_ITEMS, listOrderRequestItemsSaga),
takeEvery(SAGA_RECEIVE_REQUEST_ACTIONS, listOrderRequestActionsSaga),
];
function* getOrderRequestSaga(action) {
......@@ -90,6 +93,29 @@ function * listOrderRequestsSaga(action) {
});
}
function* listOrderRequestActionsSaga(action) {
const filter = { id: [ action.payload.id ] };
const pageRequest = { direction: [ SortDirection.DESC ], properties: [ 'createdDate' ] };
yield put({
type: 'API',
target: RECEIVE_REQUEST_ACTIONS,
method: RequestService.listOrderActions,
params: [filter, pageRequest],
onSuccess: (requestActions: FilteredPage<OrderRequestAction>) => {
dereferenceReferences3(requestActions.content, {
coo: { id: [ 'ownedBy', 'createdBy', 'modifiedBy' ] },
});
return requestActions;
},
});
}
export const listOrderRequestActionsAction = (id: number | string) => ({
type: SAGA_RECEIVE_REQUEST_ACTIONS,
payload: { id },
});
export const listOrderRequestsAction = (filter: OrderRequestFilter = {}, pageR: IPageRequest = { page: 0, size: 100, direction: [ SortDirection.DESC ], properties: [ 'modifiedDate' ] }) => ({
type: SAGA_LIST_REQUESTS,
payload: {
......
......@@ -3,8 +3,10 @@ export const SAGA_LIST_REQUESTS = 'saga/request/public/LIST';
export const SAGA_RECEIVE_REQUEST_ITEMS = 'saga/request/public/RECEIVE_ITEMS';
export const SAGA_CREATE_REQUEST = 'saga/request/public/CREATE';
export const RECEIVE_NEW_REQUEST = 'saga/request/public/RECEIVE_NEW';
export const SAGA_RECEIVE_REQUEST_ACTIONS = 'saga/request/public/RECEIVE_ACTIONS';
export const CLEAR_REQUEST = 'success/request/public/CLEAR_REQUEST';
export const RECEIVE_REQUEST = 'success/request/public/RECEIVE_REQUEST';
export const RECEIVE_REQUESTS_LIST = 'success/request/public/LIST';
export const RECEIVE_REQUEST_ITEMS = 'success/request/public/RECEIVE_ITEMS';
export const RECEIVE_REQUEST_ACTIONS = 'success/request/public/RECEIVE_ACTIONS';
import update from 'immutability-helper';
// Constants
import { RECEIVE_REQUESTS_LIST, RECEIVE_REQUEST, CLEAR_REQUEST, RECEIVE_REQUEST_ITEMS } from 'request/constants';
import { RECEIVE_REQUESTS_LIST, RECEIVE_REQUEST, CLEAR_REQUEST, RECEIVE_REQUEST_ITEMS, RECEIVE_REQUEST_ACTIONS } from 'request/constants';
// Model
import OrderRequest from '@gringlobal/client/model/gringlobal/OrderRequest';
import { FilteredPage } from '@gringlobal/client/model/page';
import { ApiCall } from '@gringlobal/client/model/common';
import Inventory from '@gringlobal/client/model/gringlobal/Inventory';
import OrderRequestAction from '@gringlobal/client/model/gringlobal/OrderRequestAction';
const initialState: {
requestList: ApiCall<FilteredPage<OrderRequest>>,
request: ApiCall<OrderRequest>,
requestItems: ApiCall<FilteredPage<Inventory>>,
requestActions: ApiCall<FilteredPage<OrderRequestAction>>,
} = {
requestList: null,
request: null,
requestItems: null,
requestActions: null,
};
const publicReducer = (state = initialState, action) => {
......@@ -24,6 +27,7 @@ const publicReducer = (state = initialState, action) => {
return update(state, {
request: { $set: null },
requestItems: { $set: null },
requestActions: { $set: null },
});
}
case RECEIVE_REQUEST: {
......@@ -92,6 +96,17 @@ const publicReducer = (state = initialState, action) => {
},
});
}
case RECEIVE_REQUEST_ACTIONS: {
if (!action.payload) {
return update(state, { requestActions: { $set: null } });
}
const { apiCall } = action.payload;
return update(state, {
requestActions: {
$set: apiCall,
},
});
}
default:
return state;
}
......
......@@ -5,7 +5,9 @@
"list": "Requests for material"
},
"details": {
"title": "Request"
"title": "Request",
"items": "Items",
"actions": "Actions"
}
},
"c": {
......
......@@ -6,7 +6,7 @@ import { WithTranslation, withTranslation } from 'react-i18next';
// Action
import { ApiCall } from '@gringlobal/client/model/common';
import { getOrderRequestAction, listOrderRequestItemsAction } from 'request/action/public';
import { getOrderRequestAction, listOrderRequestItemsAction, listOrderRequestActionsAction } from 'request/action/public';
import { RequestService } from '@gringlobal/client/service';
import OrderRequest from '@gringlobal/client/model/gringlobal/OrderRequest';
import ContentHeader from '@gringlobal/client/ui/common/heading/ContentHeader';
......@@ -25,6 +25,8 @@ import { CodeValueDisplay } from 'common/CodeValue';
import { InventoryName } from 'common/Inventory';
import ButtonBar from '@gringlobal/client/ui/common/button/ButtonBar';
import PageTitle from '@gringlobal/client/ui/common/PageTitle';
import OrderRequestAction from '@gringlobal/client/model/gringlobal/OrderRequestAction';
import { BasicRequestActionsTable as RequestActionsTable } from 'request/ui/c/RequestActionsTable';
const OrderRequestItemTableConfig = new TableConfiguration({
defaultColumns: [
......@@ -47,9 +49,11 @@ const OrderRequestItemTableConfig = new TableConfiguration({
interface IDetailsPageProps extends React.ClassAttributes<any>, WithTranslation {
id: number;
getOrderRequestAction: (id: string | number) => void;
listOrderRequestActionsAction: (id: string | number) => void;
listOrderRequestItemsAction: (id: number, filter: OrderRequestItemFilter) => void;
requestCall: ApiCall<OrderRequest>;
requestItemsCall: ApiCall<FilteredPage<OrderRequestItem>>;
requestActionsCall: ApiCall<FilteredPage<OrderRequestAction>>;
}
class OrderRequestDetailsPage extends React.Component<IDetailsPageProps> {
......@@ -82,9 +86,10 @@ class OrderRequestDetailsPage extends React.Component<IDetailsPageProps> {
}
private reloadData = () => {
const { id, getOrderRequestAction, listOrderRequestItemsAction } = this.props;
const { id, getOrderRequestAction, listOrderRequestItemsAction, listOrderRequestActionsAction } = this.props;
getOrderRequestAction(id);
listOrderRequestItemsAction(id, {});
listOrderRequestActionsAction(id);
}
private rowToggled = (toggledRow: number, selectedRows: number[], rowData: any) => {
......@@ -131,7 +136,7 @@ class OrderRequestDetailsPage extends React.Component<IDetailsPageProps> {
}
public render(): React.ReactNode {
const { requestCall, requestItemsCall, t } = this.props;
const { requestCall, requestItemsCall, requestActionsCall, t } = this.props;
const { selectedItems } = this.state;
const columns = OrderRequestItemTableConfig.getColumns(requestItemsCall && requestItemsCall.data && requestItemsCall.data.content ? requestItemsCall.data.content[0] : null);
if (!requestCall) {
......@@ -193,7 +198,7 @@ class OrderRequestDetailsPage extends React.Component<IDetailsPageProps> {
</Card>
<Card>
<CardHeader title="Items" />
<CardHeader title={ t('request.public.p.details.items') } />
{ requestItemsCall && requestItemsCall.data && requestItemsCall.data.totalElements > 0 &&
<CardActions>
<ButtonBar>
......@@ -224,6 +229,10 @@ class OrderRequestDetailsPage extends React.Component<IDetailsPageProps> {
onRowToggled={ this.rowToggled }
/>
</Card>
<Card>
<CardHeader title={ t('request.public.p.details.actions') } />
<RequestActionsTable actions={ requestActionsCall.data && requestActionsCall.data.content }/>
</Card>
</>
}
</>
......@@ -235,11 +244,13 @@ const mapStateToProps = (state, ownProps) => ({
id: ownProps.match.params.id,
requestCall: state.request.public.request,
requestItemsCall: state.request.public.requestItems,
requestActionsCall: state.request.public.requestActions,
});
const mapDispatchToProps = (dispatch) => bindActionCreators({
getOrderRequestAction,
listOrderRequestItemsAction,
listOrderRequestActionsAction,
}, dispatch);
......
import * as React from 'react';
// Model
import OrderRequestAction from '@gringlobal/client/model/gringlobal/OrderRequestAction';
// UI
import { CooperatorOwnedTableConfiguration as TableConfiguration } from '@gringlobal/client/ui/common/table/TableConfiguration';
import Table, { Renderers, TextAlign } from '@gringlobal/client/ui/common/table/Table';
import { CodeValueDisplay } from 'common/CodeValue';
const BasicRequestActionsTableConfigProps = {
defaultColumns: [
'startedDate',
'completedDate',
'actionNameCode',
'note',
'createdBy',
'modifiedBy',
],
defaultColumnSettings: {
id: { readonly: true, align: TextAlign.right },
},
columnsRenderers: {
startedDate: Renderers.DATE_RENDERER,
completedDate: Renderers.DATE_RENDERER,
actionNameCode: (codeValue) => <CodeValueDisplay codeGroup={ OrderRequestAction.CodeGroup.actionNameCode } value={ codeValue } />,
},
};
const BasicRequestActionsTableConfig = new TableConfiguration(BasicRequestActionsTableConfigProps);
export const BasicRequestActionsTable = ({ actions }: { actions: OrderRequestAction[] }) => {
return (
<Table
noWrap
tableKey="request-basic-actionlist-table"
type={ 'OrderRequestAction' }
columns={ BasicRequestActionsTableConfig.defaultColumns }
data={ actions }
tableConfig={ BasicRequestActionsTableConfig }
/>
)
};
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