From b5920e15a10d32f43cea5db6945c040443049073 Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Sun, 14 Mar 2021 23:35:48 +0800 Subject: [PATCH 01/39] remove isSubmitting text in register form --- .../app/modules/auth/email-register/auth-email-register.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/webapp/app/modules/auth/email-register/auth-email-register.tsx b/src/main/webapp/app/modules/auth/email-register/auth-email-register.tsx index 1db102cd..55c2b734 100644 --- a/src/main/webapp/app/modules/auth/email-register/auth-email-register.tsx +++ b/src/main/webapp/app/modules/auth/email-register/auth-email-register.tsx @@ -97,7 +97,6 @@ export class AuthEmailRegister extends React.Component Already have an account? Sign in now - isSubmitting From a592885e6a7e89c8447be9088bafd5f9979cd0a0 Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Sun, 14 Mar 2021 23:36:48 +0800 Subject: [PATCH 02/39] event activity listing page WIP --- .../event-activity/event-activity.reducer.ts | 34 +++- .../event-activity/event-activity.tsx | 173 ++++++++---------- src/main/webapp/app/routes.tsx | 3 +- .../webapp/app/shared/util/tab.constants.ts | 5 + src/main/webapp/i18n/en/eventActivity.json | 4 +- src/main/webapp/i18n/zh-cn/eventActivity.json | 10 +- 6 files changed, 127 insertions(+), 102 deletions(-) diff --git a/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts b/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts index 5f3c1ad4..4f80e752 100644 --- a/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts +++ b/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts @@ -13,7 +13,9 @@ export const ACTION_TYPES = { UPDATE_EVENTACTIVITY: 'eventActivity/UPDATE_EVENTACTIVITY', DELETE_EVENTACTIVITY: 'eventActivity/DELETE_EVENTACTIVITY', SET_BLOB: 'eventActivity/SET_BLOB', - RESET: 'eventActivity/RESET' + RESET: 'eventActivity/RESET', + SET_EVENT_ACTIVITY_ID: 'SET_EVENT_ACTIVITY_ID', + SET_SHOW_ACTION_OPTIONS: 'SET_SHOW_ACTION_OPTIONS' }; const initialState = { @@ -23,7 +25,9 @@ const initialState = { entity: defaultValue, updating: false, totalItems: 0, - updateSuccess: false + updateSuccess: false, + selectedEventActivityId: 0, + showActionOptions: false }; export type EventActivityState = Readonly; @@ -99,6 +103,18 @@ export default (state: EventActivityState = initialState, action): EventActivity [name + 'ContentType']: contentType } }; + case ACTION_TYPES.SET_EVENT_ACTIVITY_ID: + const { eventActivityId } = action.payload; + return { + ...state, + selectedEventActivityId: eventActivityId + }; + case ACTION_TYPES.SET_SHOW_ACTION_OPTIONS: + const { show } = action.payload; + return { + ...state, + showActionOptions: show + }; case ACTION_TYPES.RESET: return { ...initialState @@ -165,6 +181,20 @@ export const setBlob = (name, data, contentType?) => ({ } }); +export const setSelectedEventActivityId = eventActivityId => ({ + type: ACTION_TYPES.SET_EVENT_ACTIVITY_ID, + payload: { + eventActivityId + } +}); + +export const setShowActionOptions = show => ({ + type: ACTION_TYPES.SET_SHOW_ACTION_OPTIONS, + payload: { + show + } +}); + export const reset = () => ({ type: ACTION_TYPES.RESET }); diff --git a/src/main/webapp/app/entities/event-activity/event-activity.tsx b/src/main/webapp/app/entities/event-activity/event-activity.tsx index 33dafb6f..ed57f59b 100644 --- a/src/main/webapp/app/entities/event-activity/event-activity.tsx +++ b/src/main/webapp/app/entities/event-activity/event-activity.tsx @@ -1,28 +1,20 @@ import React from 'react'; import { connect } from 'react-redux'; import { Link, RouteComponentProps } from 'react-router-dom'; -import { Button, Col, Row, Table } from 'reactstrap'; +import { Button, Modal, ModalHeader, ModalBody } from 'reactstrap'; // tslint:disable-next-line:no-unused-variable -import { - byteSize, - Translate, - ICrudGetAllAction, - TextFormat, - getSortState, - IPaginationBaseState, - JhiPagination, - JhiItemCount -} from 'react-jhipster'; +import { Translate, getSortState, IPaginationBaseState } from 'react-jhipster'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { IRootState } from 'app/shared/reducers'; -import { getEntities } from './event-activity.reducer'; -import { IEventActivity } from 'app/shared/model/event-activity.model'; -// tslint:disable-next-line:no-unused-variable -import { APP_DATE_FORMAT, APP_LOCAL_DATE_FORMAT } from 'app/config/constants'; +import { getEntities, setSelectedEventActivityId, setShowActionOptions } from './event-activity.reducer'; import { ITEMS_PER_PAGE } from 'app/shared/util/pagination.constants'; +import '../../styles/event-module.scss'; +import { CustomTab } from 'app/shared/components/customTab/custom-tab'; +import { eventTabList } from 'app/shared/util/tab.constants'; +import { ListingCard } from 'app/shared/components/listing-card/listing-card'; -export interface IEventActivityProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string }> {} +export interface IEventActivityProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string; eventId: string }> {} export type IEventActivityState = IPaginationBaseState; @@ -57,94 +49,87 @@ export class EventActivity extends React.Component { + this.props.setSelectedEventActivityId(eventActivityId); + this.props.setShowActionOptions(true); + }; + + toggleShowOptions = () => { + this.props.setShowActionOptions(!this.props.showActionOptions); + }; + render() { - const { eventActivityList, match, totalItems } = this.props; + const { eventActivityList, match, totalItems, selectedEventActivityId } = this.props; return (

Event Activities - +

+ +
+   - Create new Event Activity + Add - -
+
+ +
{eventActivityList && eventActivityList.length > 0 ? ( - - - - - - - - - - - - - {eventActivityList.map((eventActivity, i) => ( - - - - - - - - - - ))} - -
- ID - - Event Id - - Start Date - - Duration In Day{' '} - - - Name - - Description{' '} - - -
- - {eventActivity.eventId} - - {eventActivity.durationInDay}{eventActivity.name}{eventActivity.description} -
- - - -
-
+ eventActivityList.map((eventActivity, i) => ( + + + + Start Date:{' '} + {eventActivity.startDate} + + + + + Duration (In Day):{' '} + {eventActivity.durationInDay} + + + + + Description:{' '} + {eventActivity.description} + + + + )) ) : (
No Event Activities found
)}
-
0 ? '' : 'd-none'}> + + + + +

Options

+ + +
+
+ + {/*
0 ? '' : 'd-none'}> @@ -157,7 +142,7 @@ export class EventActivity extends React.Component -
+
*/}
); } @@ -165,11 +150,15 @@ export class EventActivity extends React.Component ({ eventActivityList: eventActivity.entities, - totalItems: eventActivity.totalItems + totalItems: eventActivity.totalItems, + selectedEventActivityId: eventActivity.selectedEventActivityId, + showActionOptions: eventActivity.showActionOptions }); const mapDispatchToProps = { - getEntities + getEntities, + setSelectedEventActivityId, + setShowActionOptions }; type StateProps = ReturnType; diff --git a/src/main/webapp/app/routes.tsx b/src/main/webapp/app/routes.tsx index 9e2caddf..82201d3e 100644 --- a/src/main/webapp/app/routes.tsx +++ b/src/main/webapp/app/routes.tsx @@ -31,7 +31,8 @@ const Routes = () => ( - + {/* */} + diff --git a/src/main/webapp/app/shared/util/tab.constants.ts b/src/main/webapp/app/shared/util/tab.constants.ts index 7943e13f..7e620e9e 100644 --- a/src/main/webapp/app/shared/util/tab.constants.ts +++ b/src/main/webapp/app/shared/util/tab.constants.ts @@ -11,6 +11,11 @@ export const eventTabList: ITabInfo[] = [ tabTranslateKey: 'clubmanagementApp.eventChecklist.tab', tabRoute: '/event/checklist' }, + { + tabName: 'Activities', + tabTranslateKey: 'clubmanagementApp.eventActivity.tab', + tabRoute: '/entity/event-activity/event/1' + }, { tabName: 'Budget', tabTranslateKey: 'clubmanagementApp.eventBudget.tab', diff --git a/src/main/webapp/i18n/en/eventActivity.json b/src/main/webapp/i18n/en/eventActivity.json index 2c55db74..653bbee5 100644 --- a/src/main/webapp/i18n/en/eventActivity.json +++ b/src/main/webapp/i18n/en/eventActivity.json @@ -18,10 +18,10 @@ }, "eventId": "Event Id", "startDate": "Start Date", - "durationInDay": "Duration In Day", + "durationInDay": "Duration (In Day)", "name": "Name", "description": "Description", - "tab": "Timeline" + "tab": "Activities" } } } diff --git a/src/main/webapp/i18n/zh-cn/eventActivity.json b/src/main/webapp/i18n/zh-cn/eventActivity.json index 3b9acd12..608be06d 100644 --- a/src/main/webapp/i18n/zh-cn/eventActivity.json +++ b/src/main/webapp/i18n/zh-cn/eventActivity.json @@ -17,11 +17,11 @@ "title": "Event Activity" }, "eventId": "Event Id", - "startDate": "Start Date", - "durationInDay": "Duration In Day", - "name": "Name", - "description": "Description", - "tab": "Timeline" + "startDate": "开始日期", + "durationInDay": "为期(天数)", + "name": "名程", + "description": "描述", + "tab": "Activities" } } } From e390e6464f06ef3a86e06acff6ca20bab169a911 Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Tue, 16 Mar 2021 22:06:36 +0800 Subject: [PATCH 03/39] event activity listing done --- .../entities/event-activity/event-activity.reducer.ts | 9 +++++++++ .../app/entities/event-activity/event-activity.tsx | 10 ++++++---- src/main/webapp/app/entities/event-activity/index.tsx | 2 +- .../app/entities/event-checklist/event-checklist.tsx | 3 +-- src/main/webapp/app/routes.tsx | 1 + src/main/webapp/app/shared/type/event-custom-action.ts | 2 +- src/main/webapp/app/shared/util/date-utils.ts | 4 ++++ 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts b/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts index 4f80e752..5ab74acc 100644 --- a/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts +++ b/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts @@ -5,6 +5,7 @@ import { cleanEntity } from 'app/shared/util/entity-utils'; import { REQUEST, SUCCESS, FAILURE } from 'app/shared/reducers/action-type.util'; import { IEventActivity, defaultValue } from 'app/shared/model/event-activity.model'; +import { IGetAllByEventId } from 'app/shared/type/event-custom-action'; export const ACTION_TYPES = { FETCH_EVENTACTIVITY_LIST: 'eventActivity/FETCH_EVENTACTIVITY_LIST', @@ -136,6 +137,14 @@ export const getEntities: ICrudGetAllAction = (page, size, sort) }; }; +export const getEventActivitiesByEventId: IGetAllByEventId = (eventId, page, size, sort) => { + const requestUrl = `${apiUrl}/event/${eventId}${sort ? `?page=${page}&size=${size}&sort=${sort}` : ''}`; + return { + type: ACTION_TYPES.FETCH_EVENTACTIVITY_LIST, + payload: axios.get(`${requestUrl}${sort ? '&' : '?'}cacheBuster=${new Date().getTime()}`) + }; +}; + export const getEntity: ICrudGetAction = id => { const requestUrl = `${apiUrl}/${id}`; return { diff --git a/src/main/webapp/app/entities/event-activity/event-activity.tsx b/src/main/webapp/app/entities/event-activity/event-activity.tsx index ed57f59b..88705b6a 100644 --- a/src/main/webapp/app/entities/event-activity/event-activity.tsx +++ b/src/main/webapp/app/entities/event-activity/event-activity.tsx @@ -7,12 +7,13 @@ import { Translate, getSortState, IPaginationBaseState } from 'react-jhipster'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { IRootState } from 'app/shared/reducers'; -import { getEntities, setSelectedEventActivityId, setShowActionOptions } from './event-activity.reducer'; +import { getEventActivitiesByEventId, setSelectedEventActivityId, setShowActionOptions } from './event-activity.reducer'; import { ITEMS_PER_PAGE } from 'app/shared/util/pagination.constants'; import '../../styles/event-module.scss'; import { CustomTab } from 'app/shared/components/customTab/custom-tab'; import { eventTabList } from 'app/shared/util/tab.constants'; import { ListingCard } from 'app/shared/components/listing-card/listing-card'; +import { convertDateTimeFromServerToLocaleDate } from 'app/shared/util/date-utils'; export interface IEventActivityProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string; eventId: string }> {} @@ -45,8 +46,9 @@ export class EventActivity extends React.Component this.setState({ activePage }, () => this.sortEntities()); getEntities = () => { + const { eventId } = this.props.match.params; const { activePage, itemsPerPage, sort, order } = this.state; - this.props.getEntities(activePage - 1, itemsPerPage, `${sort},${order}`); + this.props.getEventActivitiesByEventId(Number.parseInt(eventId, 10), activePage - 1, itemsPerPage, `${sort},${order}`); }; showCardAction = (eventActivityId: number) => { @@ -86,7 +88,7 @@ export class EventActivity extends React.Component Start Date:{' '} - {eventActivity.startDate} + {convertDateTimeFromServerToLocaleDate(eventActivity.startDate)} @@ -156,7 +158,7 @@ const mapStateToProps = ({ eventActivity }: IRootState) => ({ }); const mapDispatchToProps = { - getEntities, + getEventActivitiesByEventId, setSelectedEventActivityId, setShowActionOptions }; diff --git a/src/main/webapp/app/entities/event-activity/index.tsx b/src/main/webapp/app/entities/event-activity/index.tsx index 8c9588d4..94d6ca15 100644 --- a/src/main/webapp/app/entities/event-activity/index.tsx +++ b/src/main/webapp/app/entities/event-activity/index.tsx @@ -14,7 +14,7 @@ const Routes = ({ match }) => ( - + diff --git a/src/main/webapp/app/entities/event-checklist/event-checklist.tsx b/src/main/webapp/app/entities/event-checklist/event-checklist.tsx index ab740c03..57f6f753 100644 --- a/src/main/webapp/app/entities/event-checklist/event-checklist.tsx +++ b/src/main/webapp/app/entities/event-checklist/event-checklist.tsx @@ -49,9 +49,8 @@ export class EventChecklist extends React.Component { const eventId = this.props.match.params.eventId; - window.console.log('Event Id: ', eventId); const { activePage, itemsPerPage, sort, order } = this.state; - this.props.getChecklistsByEventId(eventId, activePage - 1, itemsPerPage, `${sort},${order}`); + this.props.getChecklistsByEventId(Number.parseInt(eventId, 10), activePage - 1, itemsPerPage, `${sort},${order}`); }; showCardAction = (eventChecklistId: number) => { diff --git a/src/main/webapp/app/routes.tsx b/src/main/webapp/app/routes.tsx index 82201d3e..f01974bb 100644 --- a/src/main/webapp/app/routes.tsx +++ b/src/main/webapp/app/routes.tsx @@ -31,6 +31,7 @@ const Routes = () => ( + {/* TODO: Use Back PrivateRoute */} {/* */} diff --git a/src/main/webapp/app/shared/type/event-custom-action.ts b/src/main/webapp/app/shared/type/event-custom-action.ts index b686f8e9..df1d36fd 100644 --- a/src/main/webapp/app/shared/type/event-custom-action.ts +++ b/src/main/webapp/app/shared/type/event-custom-action.ts @@ -1,7 +1,7 @@ import { IPayload } from 'react-jhipster'; export declare type IGetAllByEventId = ( - eventId: string, + eventId: number, page?: number, size?: number, sort?: string diff --git a/src/main/webapp/app/shared/util/date-utils.ts b/src/main/webapp/app/shared/util/date-utils.ts index 6336b9fd..5c6236ed 100644 --- a/src/main/webapp/app/shared/util/date-utils.ts +++ b/src/main/webapp/app/shared/util/date-utils.ts @@ -5,3 +5,7 @@ import { APP_LOCAL_DATETIME_FORMAT, APP_LOCAL_DATETIME_FORMAT_Z } from 'app/conf export const convertDateTimeFromServer = date => (date ? moment(date).format(APP_LOCAL_DATETIME_FORMAT) : null); export const convertDateTimeToServer = date => (date ? moment(date, APP_LOCAL_DATETIME_FORMAT_Z).toDate() : null); + +export const convertDateTimeFromServerToLocaleDate = date => (date ? new Date(date.toLocaleString()).toLocaleDateString() : ''); + +export const convertDateTimeFromServerToLocaleDateTime = date => (date ? new Date(date.toLocaleString()).toLocaleString() : ''); From 559a8566085fa2652d375a67978d89146dcdcd02 Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Tue, 16 Mar 2021 23:58:47 +0800 Subject: [PATCH 04/39] create event activity done --- .../event-activity/event-activity-create.tsx | 150 ++++++++++++++++++ .../event-activity/event-activity.reducer.ts | 5 +- .../app/entities/event-activity/index.tsx | 9 +- .../event-checklist/event-checklist.tsx | 1 - src/main/webapp/app/styles/custom.scss | 5 + src/main/webapp/i18n/en/eventActivity.json | 2 + src/main/webapp/i18n/en/global.json | 1 + src/main/webapp/i18n/zh-cn/eventActivity.json | 2 + src/main/webapp/i18n/zh-cn/global.json | 1 + 9 files changed, 169 insertions(+), 7 deletions(-) create mode 100644 src/main/webapp/app/entities/event-activity/event-activity-create.tsx diff --git a/src/main/webapp/app/entities/event-activity/event-activity-create.tsx b/src/main/webapp/app/entities/event-activity/event-activity-create.tsx new file mode 100644 index 00000000..449ae9c2 --- /dev/null +++ b/src/main/webapp/app/entities/event-activity/event-activity-create.tsx @@ -0,0 +1,150 @@ +import React from 'react'; +import { connect } from 'react-redux'; +import { Link, RouteComponentProps } from 'react-router-dom'; +import { Button, Row, Col, Label } from 'reactstrap'; +import { AvForm, AvGroup, AvInput, AvField } from 'availity-reactstrap-validation'; +import { Translate } from 'react-jhipster'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { IRootState } from 'app/shared/reducers'; +import { createEntity, reset } from './event-activity.reducer'; +import { convertDateTimeToServer } from 'app/shared/util/date-utils'; + +export interface IEventActivityCreateProps extends StateProps, DispatchProps, RouteComponentProps<{ id: string; eventId: string }> {} + +export interface IEventActivityCreateState { + isNew: boolean; +} + +export class EventActivityCreate extends React.Component { + constructor(props) { + super(props); + this.state = { + isNew: !this.props.match.params || !this.props.match.params.id + }; + } + + componentWillUpdate(nextProps, nextState) { + if (nextProps.updateSuccess !== this.props.updateSuccess && nextProps.updateSuccess) { + this.handleClose(); + } + } + + componentDidMount() { + this.props.reset(); + } + + saveEntity = (event, errors, values) => { + values.startDate = convertDateTimeToServer(values.startDate); + + if (errors.length === 0) { + const { eventActivityEntity } = this.props; + const entity = { + ...eventActivityEntity, + ...values + }; + + this.props.createEntity(entity); + } + }; + + handleClose = () => { + this.props.history.push(`/entity/event-activity/event/${this.props.match.params.eventId}`); + }; + + render() { + const { eventId } = this.props.match.params; + const { eventActivityEntity, loading, updating, errorMessage } = this.props; + + const { description } = eventActivityEntity; + + return ( +
+ + +

+ Create Event Activity +

+ +
+ + + {loading ? ( +

Loading...

+ ) : ( + + + )} + +
+
+ ); + } +} + +const mapStateToProps = (storeState: IRootState) => ({ + eventActivityEntity: storeState.eventActivity.entity, + loading: storeState.eventActivity.loading, + updating: storeState.eventActivity.updating, + updateSuccess: storeState.eventActivity.updateSuccess, + errorMessage: storeState.eventActivity.errorMessage +}); + +const mapDispatchToProps = { + createEntity, + reset +}; + +type StateProps = ReturnType; +type DispatchProps = typeof mapDispatchToProps; + +export default connect( + mapStateToProps, + mapDispatchToProps +)(EventActivityCreate); diff --git a/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts b/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts index 5ab74acc..1a3f494d 100644 --- a/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts +++ b/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts @@ -6,6 +6,7 @@ import { REQUEST, SUCCESS, FAILURE } from 'app/shared/reducers/action-type.util' import { IEventActivity, defaultValue } from 'app/shared/model/event-activity.model'; import { IGetAllByEventId } from 'app/shared/type/event-custom-action'; +import { deprecate } from 'util'; export const ACTION_TYPES = { FETCH_EVENTACTIVITY_LIST: 'eventActivity/FETCH_EVENTACTIVITY_LIST', @@ -158,7 +159,7 @@ export const createEntity: ICrudPutAction = entity => async disp type: ACTION_TYPES.CREATE_EVENTACTIVITY, payload: axios.post(apiUrl, cleanEntity(entity)) }); - dispatch(getEntities()); + dispatch(getEventActivitiesByEventId(entity.eventId)); return result; }; @@ -167,7 +168,7 @@ export const updateEntity: ICrudPutAction = entity => async disp type: ACTION_TYPES.UPDATE_EVENTACTIVITY, payload: axios.put(apiUrl, cleanEntity(entity)) }); - dispatch(getEntities()); + dispatch(getEventActivitiesByEventId(entity.eventId)); return result; }; diff --git a/src/main/webapp/app/entities/event-activity/index.tsx b/src/main/webapp/app/entities/event-activity/index.tsx index 94d6ca15..8efbf662 100644 --- a/src/main/webapp/app/entities/event-activity/index.tsx +++ b/src/main/webapp/app/entities/event-activity/index.tsx @@ -6,17 +6,18 @@ import ErrorBoundaryRoute from 'app/shared/error/error-boundary-route'; import EventActivity from './event-activity'; import EventActivityDetail from './event-activity-detail'; import EventActivityUpdate from './event-activity-update'; +import EventActivityCreate from './event-activity-create'; import EventActivityDeleteDialog from './event-activity-delete-dialog'; const Routes = ({ match }) => ( <> - - - + + + - + ); diff --git a/src/main/webapp/app/entities/event-checklist/event-checklist.tsx b/src/main/webapp/app/entities/event-checklist/event-checklist.tsx index 57f6f753..ec1c42a1 100644 --- a/src/main/webapp/app/entities/event-checklist/event-checklist.tsx +++ b/src/main/webapp/app/entities/event-checklist/event-checklist.tsx @@ -56,7 +56,6 @@ export class EventChecklist extends React.Component { this.props.setSelectedEventChecklistId(eventChecklistId); this.props.setShowActionOptions(true); - window.console.log('SHOW ', this.props.match.path); }; toggleShowOptions = () => { diff --git a/src/main/webapp/app/styles/custom.scss b/src/main/webapp/app/styles/custom.scss index e913dcfe..c395edcc 100644 --- a/src/main/webapp/app/styles/custom.scss +++ b/src/main/webapp/app/styles/custom.scss @@ -33,3 +33,8 @@ max-width: 400px; } } + +.text-error { + color: red; + font-size: 1.1rem; +} diff --git a/src/main/webapp/i18n/en/eventActivity.json b/src/main/webapp/i18n/en/eventActivity.json index 653bbee5..4be5d7fb 100644 --- a/src/main/webapp/i18n/en/eventActivity.json +++ b/src/main/webapp/i18n/en/eventActivity.json @@ -3,6 +3,8 @@ "eventActivity": { "home": { "title": "Event Activities", + "createTitle": "Create Event Activity", + "updateTitle": "Update Event Activity", "createLabel": "Create a new Event Activity", "createOrEditLabel": "Create or edit a Event Activity", "notFound": "No Event Activity found" diff --git a/src/main/webapp/i18n/en/global.json b/src/main/webapp/i18n/en/global.json index 78c27e45..719bfe42 100644 --- a/src/main/webapp/i18n/en/global.json +++ b/src/main/webapp/i18n/en/global.json @@ -111,6 +111,7 @@ "cancel": "Cancel", "delete": "Delete", "edit": "Edit", + "create": "Create", "update": "Update", "open": "Open", "save": "Save", diff --git a/src/main/webapp/i18n/zh-cn/eventActivity.json b/src/main/webapp/i18n/zh-cn/eventActivity.json index 608be06d..292fd407 100644 --- a/src/main/webapp/i18n/zh-cn/eventActivity.json +++ b/src/main/webapp/i18n/zh-cn/eventActivity.json @@ -3,6 +3,8 @@ "eventActivity": { "home": { "title": "Event Activities", + "createTitle": "创建 Event Activity", + "updateTitle": "更新 Event Activity", "createLabel": "创建新 Event Activity", "createOrEditLabel": "创建或编辑 Event Activity", "notFound": "No Event Activity found" diff --git a/src/main/webapp/i18n/zh-cn/global.json b/src/main/webapp/i18n/zh-cn/global.json index 814375cc..9e1666ec 100644 --- a/src/main/webapp/i18n/zh-cn/global.json +++ b/src/main/webapp/i18n/zh-cn/global.json @@ -111,6 +111,7 @@ "cancel": "取消", "delete": "删除", "edit": "编辑", + "create": "创建", "update": "更新", "open": "Open", "save": "保存", From d3adbb7a6746a765c5b8cdac1891f35b137a4534 Mon Sep 17 00:00:00 2001 From: Clement Date: Wed, 17 Mar 2021 01:53:45 +0800 Subject: [PATCH 05/39] Set up event crew FE fascade --- src/main/webapp/app/app.tsx | 5 +- src/main/webapp/app/config/icon-loader.ts | 6 +- .../app/entities/event-crew/event-crew.scss | 17 ++++ .../webapp/app/entities/event-crew/frame.tsx | 89 +++++++++++++++++++ 4 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 src/main/webapp/app/entities/event-crew/event-crew.scss create mode 100644 src/main/webapp/app/entities/event-crew/frame.tsx diff --git a/src/main/webapp/app/app.tsx b/src/main/webapp/app/app.tsx index bd90af0a..fc741954 100644 --- a/src/main/webapp/app/app.tsx +++ b/src/main/webapp/app/app.tsx @@ -20,6 +20,8 @@ import { AUTHORITIES } from 'app/config/constants'; import AppRoutes from 'app/routes'; import { fetchAccount } from './shared/services/auth.service'; +import Frame from 'app/entities/event-crew/frame'; + const baseHref = document .querySelector('base') .getAttribute('href') @@ -50,7 +52,8 @@ export class App extends React.Component {
- + {/* */} +
diff --git a/src/main/webapp/app/config/icon-loader.ts b/src/main/webapp/app/config/icon-loader.ts index 67418895..6727a0a9 100644 --- a/src/main/webapp/app/config/icon-loader.ts +++ b/src/main/webapp/app/config/icon-loader.ts @@ -37,6 +37,8 @@ import { faFacebookF } from '@fortawesome/free-brands-svg-icons/faFacebookF'; import { faGoogle } from '@fortawesome/free-brands-svg-icons/faGoogle'; import { faEllipsisV } from '@fortawesome/free-solid-svg-icons/faEllipsisV'; import { faEllipsisH } from '@fortawesome/free-solid-svg-icons/faEllipsisH'; +import { faCar } from '@fortawesome/free-solid-svg-icons/faCar'; +import { faWhatsappSquare } from '@fortawesome/free-brands-svg-icons/faWhatsappSquare'; import { library } from '@fortawesome/fontawesome-svg-core'; @@ -78,6 +80,8 @@ export const loadIcons = () => { faFacebookF, faGoogle, faEllipsisV, - faEllipsisH + faEllipsisH, + faCar, + faWhatsappSquare ); }; diff --git a/src/main/webapp/app/entities/event-crew/event-crew.scss b/src/main/webapp/app/entities/event-crew/event-crew.scss new file mode 100644 index 00000000..afb27b98 --- /dev/null +++ b/src/main/webapp/app/entities/event-crew/event-crew.scss @@ -0,0 +1,17 @@ +td { + font-size: 12px; + padding-top: 12px !important; + padding-bottom: 12px !important; +} + +th { + font-size: 14px; + color: #000; + border-top: none !important; + border-bottom: 1px solid #7b7b7b !important; +} + +.icon-btn { + padding: 0px !important; + font-size: 12px; +} diff --git a/src/main/webapp/app/entities/event-crew/frame.tsx b/src/main/webapp/app/entities/event-crew/frame.tsx new file mode 100644 index 00000000..39be6bab --- /dev/null +++ b/src/main/webapp/app/entities/event-crew/frame.tsx @@ -0,0 +1,89 @@ +import './event-crew.scss'; + +import React from 'react'; +import { Button, Container, Table } from 'reactstrap'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import EventModal from 'app/modules/events/event-modal'; +import { CustomTab } from 'app/shared/components/customTab/custom-tab'; +import { eventTabList } from 'app/shared/util/tab.constants'; + +const UserList = [ + { id: 1, name: 'Chan Ka Chun', role: 'Head', provideTransport: false, contactNumber: '12345' }, + { id: 2, name: 'Clement Saw', role: 'Activity', provideTransport: true, contactNumber: '33345' }, + { id: 3, name: 'Lu Xianze', role: 'Publicity', provideTransport: true, contactNumber: '88334' }, + { id: 4, name: 'Yaw Jian Hao', role: 'Logistic', provideTransport: true, contactNumber: '32112' }, + { id: 5, name: 'Sia Sim Cheong', role: 'Registration', provideTransport: false, contactNumber: '78231' } +]; + +class Frame extends React.Component { + state = { modalIsOpen: false, eventId: null }; + + tableList = UserList.map((user, index) => { + const onHandleClick = () => { + this.contactUser(user.contactNumber); + }; + + const onToggleModal = () => this.openModal(user.id); + + return ( + + {index + 1} + {user.name} + {user.role} + {user.provideTransport ? : null} + + + + + + + + ); + }); + + openModal = eventId => { + this.setState({ modalIsOpen: true, eventId }); + }; + + closeModal = () => { + this.setState({ modalIsOpen: false, eventId: null }); + }; + + contactUser = contactNumber => { + window.open(`https://wa.me/${contactNumber}`, '_blank'); + }; + + render() { + return ( + + +

Events

+
+ +
+ + + + + + + + + + {this.tableList} +
#NameRole + + +
+
+ ); + } +} + +export default Frame; From b64e2d8e62091f5fca8dc941da48061e4707e55b Mon Sep 17 00:00:00 2001 From: Clement Date: Wed, 17 Mar 2021 15:43:32 +0800 Subject: [PATCH 06/39] Refactor event table into components --- .../webapp/app/entities/event-crew/frame.tsx | 66 ++++--------------- .../components/eventTable/EventTable.tsx | 33 ++++++++++ .../components/eventTable/EventTableRow.tsx | 41 ++++++++++++ .../app/shared/model/event-crew.model.ts | 3 + 4 files changed, 89 insertions(+), 54 deletions(-) create mode 100644 src/main/webapp/app/shared/components/eventTable/EventTable.tsx create mode 100644 src/main/webapp/app/shared/components/eventTable/EventTableRow.tsx diff --git a/src/main/webapp/app/entities/event-crew/frame.tsx b/src/main/webapp/app/entities/event-crew/frame.tsx index 39be6bab..f4d6057a 100644 --- a/src/main/webapp/app/entities/event-crew/frame.tsx +++ b/src/main/webapp/app/entities/event-crew/frame.tsx @@ -1,50 +1,24 @@ import './event-crew.scss'; import React from 'react'; -import { Button, Container, Table } from 'reactstrap'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { Button, Container } from 'reactstrap'; import EventModal from 'app/modules/events/event-modal'; import { CustomTab } from 'app/shared/components/customTab/custom-tab'; import { eventTabList } from 'app/shared/util/tab.constants'; - -const UserList = [ - { id: 1, name: 'Chan Ka Chun', role: 'Head', provideTransport: false, contactNumber: '12345' }, - { id: 2, name: 'Clement Saw', role: 'Activity', provideTransport: true, contactNumber: '33345' }, - { id: 3, name: 'Lu Xianze', role: 'Publicity', provideTransport: true, contactNumber: '88334' }, - { id: 4, name: 'Yaw Jian Hao', role: 'Logistic', provideTransport: true, contactNumber: '32112' }, - { id: 5, name: 'Sia Sim Cheong', role: 'Registration', provideTransport: false, contactNumber: '78231' } +import { IEventCrew, EventCrewRole } from 'app/shared/model/event-crew.model'; +import { EventTable } from 'app/shared/components/eventTable/EventTable'; + +const userList: IEventCrew[] = [ + { id: 1, name: 'Chan Ka Chun', role: EventCrewRole.HEAD, provideTransport: false, contactNumber: '12345' }, + { id: 2, name: 'Clement Saw', role: EventCrewRole.HEAD, provideTransport: true, contactNumber: '33345' }, + { id: 3, name: 'Lu Xianze', role: EventCrewRole.HEAD, provideTransport: true, contactNumber: '88334' }, + { id: 4, name: 'Yaw Jian Hao', role: EventCrewRole.HEAD, provideTransport: true, contactNumber: '32112' }, + { id: 5, name: 'Sia Sim Cheong', role: EventCrewRole.HEAD, provideTransport: false, contactNumber: '78231' } ]; class Frame extends React.Component { state = { modalIsOpen: false, eventId: null }; - tableList = UserList.map((user, index) => { - const onHandleClick = () => { - this.contactUser(user.contactNumber); - }; - - const onToggleModal = () => this.openModal(user.id); - - return ( - - {index + 1} - {user.name} - {user.role} - {user.provideTransport ? : null} - - - - - - - - ); - }); - openModal = eventId => { this.setState({ modalIsOpen: true, eventId }); }; @@ -53,10 +27,6 @@ class Frame extends React.Component { this.setState({ modalIsOpen: false, eventId: null }); }; - contactUser = contactNumber => { - window.open(`https://wa.me/${contactNumber}`, '_blank'); - }; - render() { return ( @@ -65,22 +35,10 @@ class Frame extends React.Component {
- - - - - - - - - - {this.tableList} -
#NameRole - - -
+
); } diff --git a/src/main/webapp/app/shared/components/eventTable/EventTable.tsx b/src/main/webapp/app/shared/components/eventTable/EventTable.tsx new file mode 100644 index 00000000..13af03eb --- /dev/null +++ b/src/main/webapp/app/shared/components/eventTable/EventTable.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import { Table } from 'reactstrap'; +import { EventTableRow } from './EventTableRow'; +import { IEventCrew } from 'app/shared/model/event-crew.model'; + +export interface IEventTableProps { + users: IEventCrew[]; + openModal: Function; +} + +export class EventTable extends React.Component { + tableList = this.props.users.map((user, index) => { + return ; + }); + + render() { + return ( + + + + + + + + + {this.tableList} +
#NameRole + + +
+ ); + } +} diff --git a/src/main/webapp/app/shared/components/eventTable/EventTableRow.tsx b/src/main/webapp/app/shared/components/eventTable/EventTableRow.tsx new file mode 100644 index 00000000..5867ec0f --- /dev/null +++ b/src/main/webapp/app/shared/components/eventTable/EventTableRow.tsx @@ -0,0 +1,41 @@ +import React from 'react'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { Button } from 'reactstrap'; +import { IEventCrew } from 'app/shared/model/event-crew.model'; + +export interface IEventTableRowProps { + user: IEventCrew; + index: number; + openModal: Function; +} + +export class EventTableRow extends React.Component { + onToggleModal = () => this.props.openModal(this.props.user.id); + + contactUser = () => { + window.open(`https://wa.me/${this.props.user.contactNumber}`, '_blank'); + }; + + render() { + const { user, index } = this.props; + + return ( + + {index + 1} + {user.name} + {user.role} + {user.provideTransport ? : null} + + + + + + + + ); + } +} diff --git a/src/main/webapp/app/shared/model/event-crew.model.ts b/src/main/webapp/app/shared/model/event-crew.model.ts index 9b89b163..67b63c8b 100644 --- a/src/main/webapp/app/shared/model/event-crew.model.ts +++ b/src/main/webapp/app/shared/model/event-crew.model.ts @@ -4,9 +4,12 @@ export const enum EventCrewRole { export interface IEventCrew { id?: number; + name?: String; userId?: number; eventId?: number; + contactNumber?: String; role?: EventCrewRole; + provideTransport?: boolean; } export const defaultValue: Readonly = {}; From e9b9afb582bf948aad9666087735b1b540b4a334 Mon Sep 17 00:00:00 2001 From: Clement Date: Wed, 17 Mar 2021 16:47:42 +0800 Subject: [PATCH 07/39] Refactor Event Table and Row for reusability with eventAttendee --- src/main/webapp/app/entities/event-crew/frame.tsx | 13 +++++++++++-- .../app/shared/components/customTab/custom-tab.tsx | 7 ++++++- .../app/shared/components/eventTable/EventTable.tsx | 13 +++++++------ .../shared/components/eventTable/EventTableRow.tsx | 7 ++++--- .../webapp/app/shared/model/event-attendee.model.ts | 3 +++ 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/main/webapp/app/entities/event-crew/frame.tsx b/src/main/webapp/app/entities/event-crew/frame.tsx index f4d6057a..0a979cfc 100644 --- a/src/main/webapp/app/entities/event-crew/frame.tsx +++ b/src/main/webapp/app/entities/event-crew/frame.tsx @@ -7,8 +7,9 @@ import { CustomTab } from 'app/shared/components/customTab/custom-tab'; import { eventTabList } from 'app/shared/util/tab.constants'; import { IEventCrew, EventCrewRole } from 'app/shared/model/event-crew.model'; import { EventTable } from 'app/shared/components/eventTable/EventTable'; +import { IEventAttendee } from 'app/shared/model/event-attendee.model'; -const userList: IEventCrew[] = [ +const crewList: IEventCrew[] = [ { id: 1, name: 'Chan Ka Chun', role: EventCrewRole.HEAD, provideTransport: false, contactNumber: '12345' }, { id: 2, name: 'Clement Saw', role: EventCrewRole.HEAD, provideTransport: true, contactNumber: '33345' }, { id: 3, name: 'Lu Xianze', role: EventCrewRole.HEAD, provideTransport: true, contactNumber: '88334' }, @@ -16,6 +17,14 @@ const userList: IEventCrew[] = [ { id: 5, name: 'Sia Sim Cheong', role: EventCrewRole.HEAD, provideTransport: false, contactNumber: '78231' } ]; +const attendeeList: IEventAttendee[] = [ + { id: 1, name: 'Chan Ka Chun', year: 1, provideTransport: false, contactNumber: '12345' }, + { id: 2, name: 'Clement Saw', year: 1, provideTransport: true, contactNumber: '33345' }, + { id: 3, name: 'Lu Xianze', year: 1, provideTransport: true, contactNumber: '88334' }, + { id: 4, name: 'Yaw Jian Hao', year: 1, provideTransport: true, contactNumber: '32112' }, + { id: 5, name: 'Sia Sim Cheong', year: 1, provideTransport: false, contactNumber: '78231' } +]; + class Frame extends React.Component { state = { modalIsOpen: false, eventId: null }; @@ -38,7 +47,7 @@ class Frame extends React.Component { - + ); } diff --git a/src/main/webapp/app/shared/components/customTab/custom-tab.tsx b/src/main/webapp/app/shared/components/customTab/custom-tab.tsx index 4ae035a7..5640432a 100644 --- a/src/main/webapp/app/shared/components/customTab/custom-tab.tsx +++ b/src/main/webapp/app/shared/components/customTab/custom-tab.tsx @@ -35,7 +35,12 @@ export class CustomTab extends React.Component { const TabItems = ({ itemsList, activeTab }) => itemsList.map(item => ( - - -   -   - Save - + +
)} @@ -164,15 +138,15 @@ const mapStateToProps = (storeState: IRootState) => ({ eventActivityEntity: storeState.eventActivity.entity, loading: storeState.eventActivity.loading, updating: storeState.eventActivity.updating, - updateSuccess: storeState.eventActivity.updateSuccess + updateSuccess: storeState.eventActivity.updateSuccess, + errorMessage: storeState.eventActivity.errorMessage, + eventEntity: storeState.event.entity }); const mapDispatchToProps = { getEntity, updateEntity, - setBlob, - createEntity, - reset + getEventEntity }; type StateProps = ReturnType; diff --git a/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts b/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts index 1a3f494d..17b77b7e 100644 --- a/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts +++ b/src/main/webapp/app/entities/event-activity/event-activity.reducer.ts @@ -5,7 +5,7 @@ import { cleanEntity } from 'app/shared/util/entity-utils'; import { REQUEST, SUCCESS, FAILURE } from 'app/shared/reducers/action-type.util'; import { IEventActivity, defaultValue } from 'app/shared/model/event-activity.model'; -import { IGetAllByEventId } from 'app/shared/type/event-custom-action'; +import { IGetActionWithEventId, IGetAllByEventId, IDeleteActionWithEventId } from 'app/shared/type/event-custom-action'; import { deprecate } from 'util'; export const ACTION_TYPES = { @@ -146,8 +146,8 @@ export const getEventActivitiesByEventId: IGetAllByEventId = (ev }; }; -export const getEntity: ICrudGetAction = id => { - const requestUrl = `${apiUrl}/${id}`; +export const getEntity: IGetActionWithEventId = (id, eventId) => { + const requestUrl = `${apiUrl}/${id}/event/${eventId}`; return { type: ACTION_TYPES.FETCH_EVENTACTIVITY, payload: axios.get(requestUrl) @@ -172,13 +172,13 @@ export const updateEntity: ICrudPutAction = entity => async disp return result; }; -export const deleteEntity: ICrudDeleteAction = id => async dispatch => { +export const deleteEntity: IDeleteActionWithEventId = (id, eventId) => async dispatch => { const requestUrl = `${apiUrl}/${id}`; const result = await dispatch({ type: ACTION_TYPES.DELETE_EVENTACTIVITY, payload: axios.delete(requestUrl) }); - dispatch(getEntities()); + dispatch(getEventActivitiesByEventId(eventId as number)); return result; }; diff --git a/src/main/webapp/app/entities/event-activity/event-activity.tsx b/src/main/webapp/app/entities/event-activity/event-activity.tsx index 88705b6a..c9524c7b 100644 --- a/src/main/webapp/app/entities/event-activity/event-activity.tsx +++ b/src/main/webapp/app/entities/event-activity/event-activity.tsx @@ -116,13 +116,25 @@ export class EventActivity extends React.Component

Options

- - + + {eventCrew.userId} + {eventCrew.eventId} + + + + +
+ + + +
+ + + )); +} + export default Frame; diff --git a/src/main/webapp/app/entities/event-crew/index.tsx b/src/main/webapp/app/entities/event-crew/index.tsx index 25a5f761..c4145813 100644 --- a/src/main/webapp/app/entities/event-crew/index.tsx +++ b/src/main/webapp/app/entities/event-crew/index.tsx @@ -11,12 +11,12 @@ import EventCrewDeleteDialog from './event-crew-delete-dialog'; const Routes = ({ match }) => ( <> - - - - + + + + - + ); diff --git a/src/main/webapp/app/modules/events/event-modal.tsx b/src/main/webapp/app/modules/events/event-modal.tsx index 6b4cf5ec..60587163 100644 --- a/src/main/webapp/app/modules/events/event-modal.tsx +++ b/src/main/webapp/app/modules/events/event-modal.tsx @@ -1,19 +1,16 @@ import React from 'react'; import { Modal, ModalBody, ModalHeader, Button } from 'reactstrap'; -import { RouteComponentProps, withRouter } from 'react-router-dom'; +import { Link, RouteComponentProps, withRouter } from 'react-router-dom'; import './event-modal.scss'; export interface IEventModalProps extends RouteComponentProps { isOpen: Boolean; toggleModal: Function; - eventId: number; + updatePath: String; + deletePath: String; } class EventModal extends React.Component { - onButtonClick = () => { - this.props.history.push(`/update/${this.props.eventId}`); - }; - render() { return ( @@ -21,11 +18,13 @@ class EventModal extends React.Component {

Options

-
- +
diff --git a/src/main/webapp/app/routes.tsx b/src/main/webapp/app/routes.tsx index 9e2caddf..82201d3e 100644 --- a/src/main/webapp/app/routes.tsx +++ b/src/main/webapp/app/routes.tsx @@ -31,7 +31,8 @@ const Routes = () => ( - + {/* */} + diff --git a/src/main/webapp/app/shared/model/event-crew.model.ts b/src/main/webapp/app/shared/model/event-crew.model.ts index 67b63c8b..1af513a5 100644 --- a/src/main/webapp/app/shared/model/event-crew.model.ts +++ b/src/main/webapp/app/shared/model/event-crew.model.ts @@ -9,7 +9,6 @@ export interface IEventCrew { eventId?: number; contactNumber?: String; role?: EventCrewRole; - provideTransport?: boolean; } export const defaultValue: Readonly = {}; diff --git a/src/main/webapp/app/shared/type/event-custom-action.ts b/src/main/webapp/app/shared/type/event-custom-action.ts index b686f8e9..df1d36fd 100644 --- a/src/main/webapp/app/shared/type/event-custom-action.ts +++ b/src/main/webapp/app/shared/type/event-custom-action.ts @@ -1,7 +1,7 @@ import { IPayload } from 'react-jhipster'; export declare type IGetAllByEventId = ( - eventId: string, + eventId: number, page?: number, size?: number, sort?: string From 8dd43ca6f4cbb7ee191e0eae2e2faf38d96b3d49 Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 22 Mar 2021 02:53:27 +0800 Subject: [PATCH 14/39] Create new actions in event-crew-reducer.tsx to get entities by eventId. Refine EventTable and EventTableRow. --- .../event-crew/event-crew-delete-dialog.tsx | 8 +- .../entities/event-crew/event-crew-update.tsx | 129 ++++++++++++------ .../entities/event-crew/event-crew.reducer.ts | 20 ++- .../app/entities/event-crew/event-crew.tsx | 32 ++--- .../components/eventTable/EventTable.tsx | 14 +- .../components/eventTable/EventTableRow.tsx | 16 ++- .../app/shared/model/event-attendee.model.ts | 2 +- .../app/shared/model/event-crew.model.ts | 5 +- .../app/shared/type/event-custom-action.ts | 4 + src/main/webapp/i18n/en/eventCrew.json | 2 + src/main/webapp/i18n/zh-cn/eventCrew.json | 3 +- 11 files changed, 156 insertions(+), 79 deletions(-) diff --git a/src/main/webapp/app/entities/event-crew/event-crew-delete-dialog.tsx b/src/main/webapp/app/entities/event-crew/event-crew-delete-dialog.tsx index 4b2562bc..fbe6421b 100644 --- a/src/main/webapp/app/entities/event-crew/event-crew-delete-dialog.tsx +++ b/src/main/webapp/app/entities/event-crew/event-crew-delete-dialog.tsx @@ -7,9 +7,9 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { IEventCrew } from 'app/shared/model/event-crew.model'; import { IRootState } from 'app/shared/reducers'; -import { getEntity, deleteEntity } from './event-crew.reducer'; +import { getEntity, deleteEntity, deleteEntityWithEventId } from './event-crew.reducer'; -export interface IEventCrewDeleteDialogProps extends StateProps, DispatchProps, RouteComponentProps<{ id: string }> {} +export interface IEventCrewDeleteDialogProps extends StateProps, DispatchProps, RouteComponentProps<{ id: string; eventId: string }> {} export class EventCrewDeleteDialog extends React.Component { componentDidMount() { @@ -17,7 +17,7 @@ export class EventCrewDeleteDialog extends React.Component { - this.props.deleteEntity(this.props.eventCrewEntity.id); + this.props.deleteEntityWithEventId(this.props.eventCrewEntity.id, this.props.match.params.eventId); this.handleClose(event); }; @@ -59,7 +59,7 @@ const mapStateToProps = ({ eventCrew }: IRootState) => ({ eventCrewEntity: eventCrew.entity }); -const mapDispatchToProps = { getEntity, deleteEntity }; +const mapDispatchToProps = { getEntity, deleteEntity, deleteEntityWithEventId }; type StateProps = ReturnType; type DispatchProps = typeof mapDispatchToProps; diff --git a/src/main/webapp/app/entities/event-crew/event-crew-update.tsx b/src/main/webapp/app/entities/event-crew/event-crew-update.tsx index 6129868f..6429ecd4 100644 --- a/src/main/webapp/app/entities/event-crew/event-crew-update.tsx +++ b/src/main/webapp/app/entities/event-crew/event-crew-update.tsx @@ -9,25 +9,48 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { IRootState } from 'app/shared/reducers'; import { getEntity, updateEntity, createEntity, reset } from './event-crew.reducer'; -import { IEventCrew } from 'app/shared/model/event-crew.model'; +import { IEventCrew, EventCrewRole } from 'app/shared/model/event-crew.model'; // tslint:disable-next-line:no-unused-variable import { convertDateTimeFromServer, convertDateTimeToServer } from 'app/shared/util/date-utils'; import { mapIdList } from 'app/shared/util/entity-utils'; +import { IUser } from 'app/shared/model/user.model'; +import axios from 'axios'; +import { IEvent } from 'app/shared/model/event.model'; -export interface IEventCrewUpdateProps extends StateProps, DispatchProps, RouteComponentProps<{ id: string }> {} +export interface IEventCrewUpdateProps extends StateProps, DispatchProps, RouteComponentProps<{ id: string; eventId: string }> {} export interface IEventCrewUpdateState { isNew: boolean; + users: IUser[]; + event: IEvent; } export class EventCrewUpdate extends React.Component { constructor(props) { super(props); this.state = { - isNew: !this.props.match.params || !this.props.match.params.id + isNew: !this.props.match.params || !this.props.match.params.id, + users: [], + event: null }; } + getUsersAndEvent = async () => { + const users = await axios.get(`/api/users/`); + const event = await axios.get(`api/events/${this.props.match.params.eventId}`); + this.setState({ users: users.data, event: event.data }); + }; + + compareFirstName = (a, b) => { + if (a.firstName < b.firstName) { + return -1; + } + if (a.firstName > b.firstName) { + return 1; + } + return 0; + }; + componentWillUpdate(nextProps, nextState) { if (nextProps.updateSuccess !== this.props.updateSuccess && nextProps.updateSuccess) { this.handleClose(); @@ -37,11 +60,16 @@ export class EventCrewUpdate extends React.Component { if (errors.length === 0) { const { eventCrewEntity } = this.props; @@ -51,28 +79,25 @@ export class EventCrewUpdate extends React.Component { - this.props.history.push('/entity/event-crew'); + this.props.history.push(`/entity/event-crew/event/${this.props.match.params.eventId}`); }; render() { const { eventCrewEntity, loading, updating } = this.props; const { isNew } = this.state; - return (
-

- Create or edit a EventCrew -

+

{isNew ? 'Create Event Crew' : 'Edit Event Crew'}

@@ -81,25 +106,46 @@ export class EventCrewUpdate extends React.ComponentLoading...

) : ( - {!isNew ? ( - - - - - ) : null} - - )} diff --git a/src/main/webapp/app/entities/event-crew/event-crew.reducer.ts b/src/main/webapp/app/entities/event-crew/event-crew.reducer.ts index fcfb7d42..c590675e 100644 --- a/src/main/webapp/app/entities/event-crew/event-crew.reducer.ts +++ b/src/main/webapp/app/entities/event-crew/event-crew.reducer.ts @@ -5,7 +5,7 @@ import { cleanEntity } from 'app/shared/util/entity-utils'; import { REQUEST, SUCCESS, FAILURE } from 'app/shared/reducers/action-type.util'; import { IEventCrew, defaultValue } from 'app/shared/model/event-crew.model'; -import { IGetAllByEventId } from 'app/shared/type/event-custom-action'; +import { IGetAllByEventId, IDeleteEvent, IPutEvent } from 'app/shared/type/event-custom-action'; export const ACTION_TYPES = { FETCH_EVENTCREW_LIST: 'eventCrew/FETCH_EVENTCREW_LIST', @@ -121,21 +121,21 @@ export const getEntity: ICrudGetAction = id => { }; }; -export const createEntity: ICrudPutAction = entity => async dispatch => { +export const createEntity: IPutEvent = (entity, eventId) => async dispatch => { const result = await dispatch({ type: ACTION_TYPES.CREATE_EVENTCREW, payload: axios.post(apiUrl, cleanEntity(entity)) }); - dispatch(getEntities()); + dispatch(getEventCrewByEventId(eventId)); return result; }; -export const updateEntity: ICrudPutAction = entity => async dispatch => { +export const updateEntity: IPutEvent = (entity, eventId) => async dispatch => { const result = await dispatch({ type: ACTION_TYPES.UPDATE_EVENTCREW, payload: axios.put(apiUrl, cleanEntity(entity)) }); - dispatch(getEntities()); + dispatch(getEventCrewByEventId(eventId)); return result; }; @@ -149,6 +149,16 @@ export const deleteEntity: ICrudDeleteAction = id => async dispatch return result; }; +export const deleteEntityWithEventId: IDeleteEvent = (id, eventId) => async dispatch => { + const requestUrl = `${apiUrl}/${id}`; + const result = await dispatch({ + type: ACTION_TYPES.DELETE_EVENTCREW, + payload: axios.delete(requestUrl) + }); + dispatch(getEventCrewByEventId(eventId)); + return result; +}; + export const reset = () => ({ type: ACTION_TYPES.RESET }); diff --git a/src/main/webapp/app/entities/event-crew/event-crew.tsx b/src/main/webapp/app/entities/event-crew/event-crew.tsx index aace4dfa..8a6b5624 100644 --- a/src/main/webapp/app/entities/event-crew/event-crew.tsx +++ b/src/main/webapp/app/entities/event-crew/event-crew.tsx @@ -9,7 +9,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { ITEMS_PER_PAGE } from 'app/shared/util/pagination.constants'; import { IRootState } from 'app/shared/reducers'; import { getEntities, getEventCrewByEventId } from './event-crew.reducer'; -import { IEventCrew } from 'app/shared/model/event-crew.model'; +import { IEventCrew, EventCrewRole } from 'app/shared/model/event-crew.model'; // tslint:disable-next-line:no-unused-variable import { APP_DATE_FORMAT, APP_LOCAL_DATE_FORMAT } from 'app/config/constants'; import { CustomTab } from 'app/shared/components/customTab/custom-tab'; @@ -40,20 +40,20 @@ export class EventCrew extends React.Component { this.props.getEventCrewByEventId(Number.parseInt(eventId, 10)); } - sort = prop => () => { - this.setState( - { - order: this.state.order === 'asc' ? 'desc' : 'asc', - sort: prop - }, - () => this.sortEntities() - ); - }; - - sortEntities() { - this.getEntities(); - this.props.history.push(`${this.props.location.pathname}?page=${this.state.activePage}&sort=${this.state.sort},${this.state.order}`); - } + // sort = prop => () => { + // this.setState( + // { + // order: this.state.order === 'asc' ? 'desc' : 'asc', + // sort: prop + // }, + // () => this.sortEntities() + // ); + // }; + + // sortEntities() { + // this.getEntities(); + // this.props.history.push(`${this.props.location.pathname}?page=${this.state.activePage}&sort=${this.state.sort},${this.state.order}`); + // } getEntities = () => { const { eventId } = this.props.match.params; @@ -90,7 +90,7 @@ export class EventCrew extends React.Component { ) : (
- No Event Crews found + No Event Crews found {}
)}
diff --git a/src/main/webapp/app/shared/components/eventTable/EventTable.tsx b/src/main/webapp/app/shared/components/eventTable/EventTable.tsx index b3964ca2..27a7a1a8 100644 --- a/src/main/webapp/app/shared/components/eventTable/EventTable.tsx +++ b/src/main/webapp/app/shared/components/eventTable/EventTable.tsx @@ -5,15 +5,11 @@ import { IEventCrew } from 'app/shared/model/event-crew.model'; import { IEventAttendee } from 'app/shared/model/event-attendee.model'; export interface IEventTableProps { - users: IEventCrew[] | IEventAttendee[] | any[]; + users: ReadonlyArray | ReadonlyArray; openModal: Function; } export class EventTable extends React.Component { - tableList = this.props.users.map((user, index) => ( - - )); - render() { return ( @@ -21,13 +17,17 @@ export class EventTable extends React.Component { - + - {this.tableList} + + {this.props.users.map((user, index) => ( + + ))} +
# Name{this.props.users[0].role ? 'Role' : 'Year'}{'role' in this.props.users[0] ? 'Role' : 'Year'}
); } diff --git a/src/main/webapp/app/shared/components/eventTable/EventTableRow.tsx b/src/main/webapp/app/shared/components/eventTable/EventTableRow.tsx index eb3450c6..9f256a81 100644 --- a/src/main/webapp/app/shared/components/eventTable/EventTableRow.tsx +++ b/src/main/webapp/app/shared/components/eventTable/EventTableRow.tsx @@ -5,12 +5,13 @@ import { IEventCrew } from 'app/shared/model/event-crew.model'; import { IEventAttendee } from 'app/shared/model/event-attendee.model'; export interface IEventTableRowProps { - user: IEventCrew | IEventAttendee | any; + user: IEventCrew | IEventAttendee; index: number; openModal: Function; } export class EventTableRow extends React.Component { + state = { user: this.props.user }; onToggleModal = () => this.props.openModal(this.props.user.id); contactUser = () => { @@ -20,12 +21,19 @@ export class EventTableRow extends React.Component { render() { const { user, index } = this.props; + let thirdColumn; + if ('role' in user) { + thirdColumn = user.role; + } else if ('year' in user) { + thirdColumn = user.year; + } + return ( {index + 1} - {user.name} - {user.role ? user.role : user.year} - {user.provideTransport ? : null} + {user.userName} + {thirdColumn} + {'provideTransport' in user ? : null} - - - ); - } -} - -{ - eventCrewList.map((eventCrew, i) => ( - - - - - {eventCrew.userId} - {eventCrew.eventId} - - - - -
- - - -
- - - )); -} - -export default Frame; From 1801b455c2e1360ed0dd0f8bbcd7f2c282e99e29 Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Sun, 28 Mar 2021 22:52:52 +0800 Subject: [PATCH 18/39] update event budget i18n json --- src/main/webapp/i18n/en/budget.json | 20 ++++++++++---------- src/main/webapp/i18n/zh-cn/budget.json | 18 +++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/webapp/i18n/en/budget.json b/src/main/webapp/i18n/en/budget.json index 6a6d83f3..dce421fe 100644 --- a/src/main/webapp/i18n/en/budget.json +++ b/src/main/webapp/i18n/en/budget.json @@ -1,20 +1,20 @@ { "clubmanagementApp": { - "budget": { + "eventBudget": { "home": { - "title": "Budgets", - "createLabel": "Create a new Budget", - "createOrEditLabel": "Create or edit a Budget", - "notFound": "No Budget found" + "title": "Event Budgets", + "createLabel": "Create a new Event Budget", + "createOrEditLabel": "Create or edit a Event Budget", + "notFound": "No Event Budget found" }, - "created": "A new Budget is created with identifier {{ param }}", - "updated": "A Budget is updated with identifier {{ param }}", - "deleted": "A Budget is deleted with identifier {{ param }}", + "created": "A new Event Budget is created with identifier {{ param }}", + "updated": "A Event Budget is updated with identifier {{ param }}", + "deleted": "A Event Budget is deleted with identifier {{ param }}", "delete": { - "question": "Are you sure you want to delete Budget {{ id }}?" + "question": "Are you sure you want to delete Event Budget {{ id }}?" }, "detail": { - "title": "Budget" + "title": "Event Budget" }, "eventId": "Event Id", "amount": "Amount", diff --git a/src/main/webapp/i18n/zh-cn/budget.json b/src/main/webapp/i18n/zh-cn/budget.json index 1ba8ae0c..e6db564d 100644 --- a/src/main/webapp/i18n/zh-cn/budget.json +++ b/src/main/webapp/i18n/zh-cn/budget.json @@ -2,19 +2,19 @@ "clubmanagementApp": { "budget": { "home": { - "title": "Budgets", - "createLabel": "创建新 Budget", - "createOrEditLabel": "创建或编辑 Budget", - "notFound": "No Budget found" + "title": "活动预算", + "createLabel": "创建新活动预算", + "createOrEditLabel": "创建或编辑活动预算", + "notFound": "无活动预算" }, - "created": "Budget {{ param }} 创建成功", - "updated": "Budget {{ param }} 更新成功", - "deleted": "Budget {{ param }} 删除成功", + "created": "活动预算 {{ param }} 创建成功", + "updated": "活动预算 {{ param }} 更新成功", + "deleted": "活动预算 {{ param }} 删除成功", "delete": { - "question": "你确定要删除 Budget {{ id }} 吗?" + "question": "你确定要删除活动预算 {{ id }} 吗?" }, "detail": { - "title": "Budget" + "title": "活动预算" }, "eventId": "Event Id", "amount": "Amount", From 58e327009d61af38c3e7e811a9f7d54b480c29f6 Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Sun, 28 Mar 2021 22:53:46 +0800 Subject: [PATCH 19/39] basic event budget listing page --- .../app/entities/budget/budget.reducer.ts | 49 ++++- .../webapp/app/entities/budget/budget.tsx | 172 +++++++++--------- 2 files changed, 129 insertions(+), 92 deletions(-) diff --git a/src/main/webapp/app/entities/budget/budget.reducer.ts b/src/main/webapp/app/entities/budget/budget.reducer.ts index cac02698..0414823b 100644 --- a/src/main/webapp/app/entities/budget/budget.reducer.ts +++ b/src/main/webapp/app/entities/budget/budget.reducer.ts @@ -5,6 +5,7 @@ import { cleanEntity } from 'app/shared/util/entity-utils'; import { REQUEST, SUCCESS, FAILURE } from 'app/shared/reducers/action-type.util'; import { IBudget, defaultValue } from 'app/shared/model/budget.model'; +import { IGetAllByEventId } from 'app/shared/type/event-custom-action'; export const ACTION_TYPES = { FETCH_BUDGET_LIST: 'budget/FETCH_BUDGET_LIST', @@ -13,7 +14,9 @@ export const ACTION_TYPES = { UPDATE_BUDGET: 'budget/UPDATE_BUDGET', DELETE_BUDGET: 'budget/DELETE_BUDGET', SET_BLOB: 'budget/SET_BLOB', - RESET: 'budget/RESET' + RESET: 'budget/RESET', + SET_EVENT_BUDGET_ID: 'eventChecklist/SET_EVENT_BUDGET_ID', + SET_SHOW_ACTION_OPTIONS: 'eventChecklist/SET_SHOW_ACTION_OPTIONS' }; const initialState = { @@ -22,7 +25,10 @@ const initialState = { entities: [] as ReadonlyArray, entity: defaultValue, updating: false, - updateSuccess: false + totalItems: 0, + updateSuccess: false, + selectedEventBudgetId: 0, + showActionOptions: false }; export type BudgetState = Readonly; @@ -64,7 +70,8 @@ export default (state: BudgetState = initialState, action): BudgetState => { return { ...state, loading: false, - entities: action.payload.data + entities: action.payload.data, + totalItems: parseInt(action.payload.headers['x-total-count'], 10) }; case SUCCESS(ACTION_TYPES.FETCH_BUDGET): return { @@ -101,12 +108,24 @@ export default (state: BudgetState = initialState, action): BudgetState => { return { ...initialState }; + case ACTION_TYPES.SET_EVENT_BUDGET_ID: + const { eventBudgetId } = action.payload; + return { + ...state, + selectedEventBudgetId: eventBudgetId + }; + case ACTION_TYPES.SET_SHOW_ACTION_OPTIONS: + const { show } = action.payload; + return { + ...state, + showActionOptions: show + }; default: return state; } }; -const apiUrl = 'api/budgets'; +const apiUrl = 'api/event-budget'; // Actions @@ -115,6 +134,14 @@ export const getEntities: ICrudGetAllAction = (page, size, sort) => ({ payload: axios.get(`${apiUrl}?cacheBuster=${new Date().getTime()}`) }); +export const getEventBudgetByEventId: IGetAllByEventId = (eventId, page, size, sort) => { + const requestUrl = `${apiUrl}/event/${eventId}${sort ? `?page=${page}&size=${size}&sort=${sort}` : ''}`; + return { + type: ACTION_TYPES.FETCH_BUDGET_LIST, + payload: axios.get(`${requestUrl}${sort ? '&' : '?'}cacheBuster=${new Date().getTime()}`) + }; +}; + export const getEntity: ICrudGetAction = id => { const requestUrl = `${apiUrl}/${id}`; return { @@ -163,3 +190,17 @@ export const setBlob = (name, data, contentType?) => ({ export const reset = () => ({ type: ACTION_TYPES.RESET }); + +export const setSelectedEventBudgetId = eventBudgetId => ({ + type: ACTION_TYPES.SET_EVENT_BUDGET_ID, + payload: { + eventBudgetId + } +}); + +export const setShowActionOptions = show => ({ + type: ACTION_TYPES.SET_SHOW_ACTION_OPTIONS, + payload: { + show + } +}); diff --git a/src/main/webapp/app/entities/budget/budget.tsx b/src/main/webapp/app/entities/budget/budget.tsx index 5010afbe..9f8f5ad6 100644 --- a/src/main/webapp/app/entities/budget/budget.tsx +++ b/src/main/webapp/app/entities/budget/budget.tsx @@ -1,106 +1,99 @@ import React from 'react'; import { connect } from 'react-redux'; -import { Link, RouteComponentProps } from 'react-router-dom'; -import { Button, Col, Row, Table } from 'reactstrap'; -// tslint:disable-next-line:no-unused-variable -import { byteSize, Translate, ICrudGetAllAction } from 'react-jhipster'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { RouteComponentProps } from 'react-router-dom'; +import { getSortState, IPaginationBaseState, Translate } from 'react-jhipster'; import { IRootState } from 'app/shared/reducers'; -import { getEntities } from './budget.reducer'; -import { IBudget } from 'app/shared/model/budget.model'; -// tslint:disable-next-line:no-unused-variable -import { APP_DATE_FORMAT, APP_LOCAL_DATE_FORMAT } from 'app/config/constants'; +import { getEventBudgetByEventId, setSelectedEventBudgetId, setShowActionOptions } from './budget.reducer'; +import { eventTabList } from 'app/shared/util/tab.constants'; +import { CustomTab } from 'app/shared/components/customTab/custom-tab'; +import { ITEMS_PER_PAGE } from 'app/shared/util/pagination.constants'; +import { ListingCard } from 'app/shared/components/listing-card/listing-card'; -export interface IBudgetProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string }> {} +export interface IBudgetProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string; eventId: string }> {} + +export type IEventBudgetState = IPaginationBaseState; + +export class Budget extends React.Component { + state: IEventBudgetState = { + ...getSortState(this.props.location, ITEMS_PER_PAGE) + }; -export class Budget extends React.Component { componentDidMount() { - this.props.getEntities(); + this.getEntities(); + } + + sort = prop => () => { + this.setState( + { + order: this.state.order === 'asc' ? 'desc' : 'asc', + sort: prop + }, + () => this.sortEntities() + ); + }; + + sortEntities() { + this.getEntities(); + this.props.history.push(`${this.props.location.pathname}?page=${this.state.activePage}&sort=${this.state.sort},${this.state.order}`); } + handlePagination = activePage => this.setState({ activePage }, () => this.sortEntities()); + + getEntities = () => { + const eventId = this.props.match.params.eventId; + const { activePage, itemsPerPage, sort, order } = this.state; + this.props.getEventBudgetByEventId(eventId, activePage - 1, itemsPerPage, `${sort},${order}`); + }; + + showCardAction = (eventBudgetId: number) => { + this.props.setSelectedEventBudgetId(eventBudgetId); + this.props.setShowActionOptions(true); + }; + render() { - const { budgetList, match } = this.props; + const { budgetList, match, totalItems } = this.props; + const { eventId } = this.props.match.params; + return (
-

- Budgets - - -   - Create new Budget - +

+ Event Budgets

+ {/* Stats of Budget */} +
{budgetList && budgetList.length > 0 ? ( - - - - - - - - - - - - - {budgetList.map((budget, i) => ( - - - - - - - - - - ))} - -
- ID - - Event Id - - Amount - - Type - - Name - - Details - -
- - {budget.eventId}{budget.amount} - - {budget.name}{budget.details} -
- - - -
-
+ budgetList.map((eventBudget, i) => ( + + + + Name: + {eventBudget.name} + + + + + Type: + {eventBudget.type} + + + + + Details: + {eventBudget.details} + + + + )) ) : (
- No Budgets found + No Event Budgets found
)}
@@ -110,11 +103,14 @@ export class Budget extends React.Component { } const mapStateToProps = ({ budget }: IRootState) => ({ - budgetList: budget.entities + budgetList: budget.entities, + totalItems: budget.totalItems }); const mapDispatchToProps = { - getEntities + getEventBudgetByEventId, + setSelectedEventBudgetId, + setShowActionOptions }; type StateProps = ReturnType; From 4f8b58d3cab26ff29ad681adcc599ea28d948d83 Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Wed, 31 Mar 2021 22:39:31 +0800 Subject: [PATCH 20/39] complete budget listing with real vs budget stats --- src/main/webapp/app/_bootstrap-variables.scss | 4 +- .../app/entities/budget/budget.reducer.ts | 36 ++++- .../webapp/app/entities/budget/budget.tsx | 123 ++++++++++++++++-- src/main/webapp/app/entities/budget/index.tsx | 10 +- .../webapp/app/shared/model/budget.model.ts | 7 + src/main/webapp/app/styles/custom.scss | 8 ++ src/main/webapp/i18n/en/budget.json | 6 +- src/main/webapp/i18n/zh-cn/budget.json | 12 +- 8 files changed, 181 insertions(+), 25 deletions(-) diff --git a/src/main/webapp/app/_bootstrap-variables.scss b/src/main/webapp/app/_bootstrap-variables.scss index 619e92bb..eaf13959 100644 --- a/src/main/webapp/app/_bootstrap-variables.scss +++ b/src/main/webapp/app/_bootstrap-variables.scss @@ -13,5 +13,7 @@ $theme-colors: ( 'secondary': #068ab4, 'tertiary': #154b67, 'action': #1db2a1, - 'cancel': #dd5959 + 'cancel': #dd5959, + 'expense': #c21717, + 'income': #0e516d ); diff --git a/src/main/webapp/app/entities/budget/budget.reducer.ts b/src/main/webapp/app/entities/budget/budget.reducer.ts index 0414823b..0a6680c4 100644 --- a/src/main/webapp/app/entities/budget/budget.reducer.ts +++ b/src/main/webapp/app/entities/budget/budget.reducer.ts @@ -4,7 +4,7 @@ import { ICrudGetAction, ICrudGetAllAction, ICrudPutAction, ICrudDeleteAction } import { cleanEntity } from 'app/shared/util/entity-utils'; import { REQUEST, SUCCESS, FAILURE } from 'app/shared/reducers/action-type.util'; -import { IBudget, defaultValue } from 'app/shared/model/budget.model'; +import { IBudget, defaultValue, IEventBudgetTotal, defaultEventBudgetTotal } from 'app/shared/model/budget.model'; import { IGetAllByEventId } from 'app/shared/type/event-custom-action'; export const ACTION_TYPES = { @@ -16,7 +16,9 @@ export const ACTION_TYPES = { SET_BLOB: 'budget/SET_BLOB', RESET: 'budget/RESET', SET_EVENT_BUDGET_ID: 'eventChecklist/SET_EVENT_BUDGET_ID', - SET_SHOW_ACTION_OPTIONS: 'eventChecklist/SET_SHOW_ACTION_OPTIONS' + SET_SHOW_ACTION_OPTIONS: 'eventChecklist/SET_SHOW_ACTION_OPTIONS', + FETCH_TOTAL_BUDGET_AMOUNT: 'budget/FETCH_TOTAL_BUDGET_AMOUNT', + FETCH_TOTAL_REAL_AMOUNT: 'budget/FETCH_TOTAL_REAL_AMOUNT' }; const initialState = { @@ -28,7 +30,9 @@ const initialState = { totalItems: 0, updateSuccess: false, selectedEventBudgetId: 0, - showActionOptions: false + showActionOptions: false, + eventBudgetTotal: defaultEventBudgetTotal, + eventRealTotal: defaultEventBudgetTotal }; export type BudgetState = Readonly; @@ -120,6 +124,16 @@ export default (state: BudgetState = initialState, action): BudgetState => { ...state, showActionOptions: show }; + case SUCCESS(ACTION_TYPES.FETCH_TOTAL_BUDGET_AMOUNT): + return { + ...state, + eventBudgetTotal: action.payload.data + }; + case SUCCESS(ACTION_TYPES.FETCH_TOTAL_REAL_AMOUNT): + return { + ...state, + eventRealTotal: action.payload.data + }; default: return state; } @@ -204,3 +218,19 @@ export const setShowActionOptions = show => ({ show } }); + +export const getEventBudgetTotal: ICrudGetAction = eventId => { + const requestUrl = `${apiUrl}/event/${eventId}/total`; + return { + type: ACTION_TYPES.FETCH_TOTAL_BUDGET_AMOUNT, + payload: axios.get(requestUrl) + }; +}; + +export const getEventRealTotal: ICrudGetAction = eventId => { + const requestUrl = `api/transactions/event/${eventId}/total`; + return { + type: ACTION_TYPES.FETCH_TOTAL_REAL_AMOUNT, + payload: axios.get(requestUrl) + }; +}; diff --git a/src/main/webapp/app/entities/budget/budget.tsx b/src/main/webapp/app/entities/budget/budget.tsx index 9f8f5ad6..40603407 100644 --- a/src/main/webapp/app/entities/budget/budget.tsx +++ b/src/main/webapp/app/entities/budget/budget.tsx @@ -1,14 +1,24 @@ import React from 'react'; import { connect } from 'react-redux'; -import { RouteComponentProps } from 'react-router-dom'; +import { Link, RouteComponentProps } from 'react-router-dom'; +import { Modal, ModalHeader, ModalBody, Button } from 'reactstrap'; import { getSortState, IPaginationBaseState, Translate } from 'react-jhipster'; import { IRootState } from 'app/shared/reducers'; -import { getEventBudgetByEventId, setSelectedEventBudgetId, setShowActionOptions } from './budget.reducer'; +import { + getEventBudgetByEventId, + setSelectedEventBudgetId, + setShowActionOptions, + getEventBudgetTotal, + getEventRealTotal +} from './budget.reducer'; import { eventTabList } from 'app/shared/util/tab.constants'; +import classnames from 'classnames'; +import '../../styles/event-module.scss'; import { CustomTab } from 'app/shared/components/customTab/custom-tab'; import { ITEMS_PER_PAGE } from 'app/shared/util/pagination.constants'; import { ListingCard } from 'app/shared/components/listing-card/listing-card'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; export interface IBudgetProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string; eventId: string }> {} @@ -21,6 +31,8 @@ export class Budget extends React.Component { componentDidMount() { this.getEntities(); + this.getEventBudgetTotal(); + this.getEventRealTotal(); } sort = prop => () => { @@ -46,13 +58,27 @@ export class Budget extends React.Component { this.props.getEventBudgetByEventId(eventId, activePage - 1, itemsPerPage, `${sort},${order}`); }; + getEventBudgetTotal = () => { + const eventId = this.props.match.params.eventId; + this.props.getEventBudgetTotal(eventId); + }; + + getEventRealTotal = () => { + const eventId = this.props.match.params.eventId; + this.props.getEventRealTotal(eventId); + }; + showCardAction = (eventBudgetId: number) => { this.props.setSelectedEventBudgetId(eventBudgetId); this.props.setShowActionOptions(true); }; + toggleShowOptions = () => { + this.props.setShowActionOptions(!this.props.showActionOptions); + }; + render() { - const { budgetList, match, totalItems } = this.props; + const { budgetList, match, totalItems, selectedEventBudgetId, eventBudgetTotal, eventRealTotal } = this.props; const { eventId } = this.props.match.params; return ( @@ -60,32 +86,82 @@ export class Budget extends React.Component {

Event Budgets

+ {/* Stats of Budget */} - -
+
+ {eventBudgetTotal.hasOwnProperty('totalExpense') && ( +
+

+ Budget: +

+ + + Income:   + RM {eventBudgetTotal.totalIncome.toFixed(2)} + + + Expense:   + RM {eventBudgetTotal.totalExpense.toFixed(2)} + + +
+ )} + {eventRealTotal.hasOwnProperty('totalExpense') && ( +
+

+ Real Amount: +

+ + + Income:   + RM {eventRealTotal.totalIncome.toFixed(2)} + + + Expense:   + RM {eventRealTotal.totalExpense.toFixed(2)} + + +
+ )} +
+
+ + +   + Add + +
+
{budgetList && budgetList.length > 0 ? ( budgetList.map((eventBudget, i) => ( + + {'RM ' + eventBudget.amount.toFixed(2).toString()} + - Name: + Name:{' '} {eventBudget.name} - Type: + Type:{' '} {eventBudget.type} - Details: + Details:{' '} {eventBudget.details} @@ -97,6 +173,25 @@ export class Budget extends React.Component {
)}
+ + + + +

Options

+ + +
+

); } @@ -104,13 +199,19 @@ export class Budget extends React.Component { const mapStateToProps = ({ budget }: IRootState) => ({ budgetList: budget.entities, - totalItems: budget.totalItems + totalItems: budget.totalItems, + selectedEventBudgetId: budget.selectedEventBudgetId, + showActionOptions: budget.showActionOptions, + eventBudgetTotal: budget.eventBudgetTotal, + eventRealTotal: budget.eventRealTotal }); const mapDispatchToProps = { getEventBudgetByEventId, setSelectedEventBudgetId, - setShowActionOptions + setShowActionOptions, + getEventBudgetTotal, + getEventRealTotal }; type StateProps = ReturnType; diff --git a/src/main/webapp/app/entities/budget/index.tsx b/src/main/webapp/app/entities/budget/index.tsx index d3766ab3..25faa8b6 100644 --- a/src/main/webapp/app/entities/budget/index.tsx +++ b/src/main/webapp/app/entities/budget/index.tsx @@ -11,12 +11,12 @@ import BudgetDeleteDialog from './budget-delete-dialog'; const Routes = ({ match }) => ( <> - - - - + + + + - + ); diff --git a/src/main/webapp/app/shared/model/budget.model.ts b/src/main/webapp/app/shared/model/budget.model.ts index 0db63654..d35d8b48 100644 --- a/src/main/webapp/app/shared/model/budget.model.ts +++ b/src/main/webapp/app/shared/model/budget.model.ts @@ -13,3 +13,10 @@ export interface IBudget { } export const defaultValue: Readonly = {}; + +export interface IEventBudgetTotal { + totalExpense?: number; + totalIncome?: number; +} + +export const defaultEventBudgetTotal: Readonly = {}; diff --git a/src/main/webapp/app/styles/custom.scss b/src/main/webapp/app/styles/custom.scss index e913dcfe..c9745865 100644 --- a/src/main/webapp/app/styles/custom.scss +++ b/src/main/webapp/app/styles/custom.scss @@ -25,6 +25,14 @@ color: white; } +.text-expense { + color: var(--expense) !important; +} + +.text-income { + color: var(--income) !important; +} + .mobile-fullWidth { width: 80%; } diff --git a/src/main/webapp/i18n/en/budget.json b/src/main/webapp/i18n/en/budget.json index dce421fe..350f4a5e 100644 --- a/src/main/webapp/i18n/en/budget.json +++ b/src/main/webapp/i18n/en/budget.json @@ -20,7 +20,11 @@ "amount": "Amount", "type": "Type", "name": "Name", - "details": "Details" + "details": "Details", + "budget": "Budget", + "realAmount": "Real Amount", + "income": "Income", + "expense": "Expense" } } } diff --git a/src/main/webapp/i18n/zh-cn/budget.json b/src/main/webapp/i18n/zh-cn/budget.json index e6db564d..228f67ba 100644 --- a/src/main/webapp/i18n/zh-cn/budget.json +++ b/src/main/webapp/i18n/zh-cn/budget.json @@ -17,10 +17,14 @@ "title": "活动预算" }, "eventId": "Event Id", - "amount": "Amount", - "type": "Type", - "name": "Name", - "details": "Details" + "amount": "数额", + "type": "种类", + "name": "名", + "details": "详情", + "budget": "预算", + "realAmount": "实数", + "income": "收入", + "expense": "消费" } } } From dc6059809b4b12e952adc58bc61ae13b8c24de82 Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Wed, 31 Mar 2021 22:45:20 +0800 Subject: [PATCH 21/39] resolve typo of name --- src/main/webapp/i18n/zh-cn/eventActivity.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/i18n/zh-cn/eventActivity.json b/src/main/webapp/i18n/zh-cn/eventActivity.json index 22c1f393..156179cc 100644 --- a/src/main/webapp/i18n/zh-cn/eventActivity.json +++ b/src/main/webapp/i18n/zh-cn/eventActivity.json @@ -21,7 +21,7 @@ "eventId": "Event Id", "startDate": "开始日期", "durationInDay": "为期(天数)", - "name": "名程", + "name": "名称", "description": "描述", "tab": "Activities" } From 221bd4c69d293a54ec534e2bc6a6d70c1b1e8a30 Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Wed, 31 Mar 2021 22:53:30 +0800 Subject: [PATCH 22/39] update name --- src/main/webapp/i18n/zh-cn/budget.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/i18n/zh-cn/budget.json b/src/main/webapp/i18n/zh-cn/budget.json index 228f67ba..7c73d5d8 100644 --- a/src/main/webapp/i18n/zh-cn/budget.json +++ b/src/main/webapp/i18n/zh-cn/budget.json @@ -19,7 +19,7 @@ "eventId": "Event Id", "amount": "数额", "type": "种类", - "name": "名", + "name": "名称", "details": "详情", "budget": "预算", "realAmount": "实数", From a9c63ca4e60250bb2d96828605ba23befabbed50 Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 2 Apr 2021 16:03:45 +0800 Subject: [PATCH 23/39] Added translates --- .../app/entities/event-crew/event-crew-delete-dialog.tsx | 4 ++-- .../webapp/app/entities/event-crew/event-crew-update.tsx | 5 +++-- src/main/webapp/app/entities/event/event-detail.tsx | 6 ++++-- src/main/webapp/app/shared/reducers/modal.ts | 0 src/main/webapp/i18n/en/event.json | 2 ++ src/main/webapp/i18n/zh-cn/event.json | 4 ++++ 6 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 src/main/webapp/app/shared/reducers/modal.ts diff --git a/src/main/webapp/app/entities/event-crew/event-crew-delete-dialog.tsx b/src/main/webapp/app/entities/event-crew/event-crew-delete-dialog.tsx index bd2f0338..8ab29f7d 100644 --- a/src/main/webapp/app/entities/event-crew/event-crew-delete-dialog.tsx +++ b/src/main/webapp/app/entities/event-crew/event-crew-delete-dialog.tsx @@ -38,13 +38,13 @@ export class EventCrewDeleteDialog extends React.Component
- + - +   + + + + )} + + + + ); + } +} + +const mapStateToProps = (storeState: IRootState) => ({ + budgetEntity: storeState.budget.entity, + loading: storeState.budget.loading, + updating: storeState.budget.updating, + updateSuccess: storeState.budget.updateSuccess, + errorMessage: storeState.budget.errorMessage +}); + +const mapDispatchToProps = { + createEntity, + reset +}; + +type StateProps = ReturnType; +type DispatchProps = typeof mapDispatchToProps; + +export default connect( + mapStateToProps, + mapDispatchToProps +)(EventBudgetCreate); diff --git a/src/main/webapp/app/entities/budget/budget.reducer.ts b/src/main/webapp/app/entities/budget/budget.reducer.ts index 0a6680c4..9233349b 100644 --- a/src/main/webapp/app/entities/budget/budget.reducer.ts +++ b/src/main/webapp/app/entities/budget/budget.reducer.ts @@ -15,8 +15,8 @@ export const ACTION_TYPES = { DELETE_BUDGET: 'budget/DELETE_BUDGET', SET_BLOB: 'budget/SET_BLOB', RESET: 'budget/RESET', - SET_EVENT_BUDGET_ID: 'eventChecklist/SET_EVENT_BUDGET_ID', - SET_SHOW_ACTION_OPTIONS: 'eventChecklist/SET_SHOW_ACTION_OPTIONS', + SET_EVENT_BUDGET_ID: 'budget/SET_EVENT_BUDGET_ID', + SET_SHOW_ACTION_OPTIONS: 'budget/SET_SHOW_ACTION_OPTIONS', FETCH_TOTAL_BUDGET_AMOUNT: 'budget/FETCH_TOTAL_BUDGET_AMOUNT', FETCH_TOTAL_REAL_AMOUNT: 'budget/FETCH_TOTAL_REAL_AMOUNT' }; @@ -169,7 +169,7 @@ export const createEntity: ICrudPutAction = entity => async dispatch => type: ACTION_TYPES.CREATE_BUDGET, payload: axios.post(apiUrl, cleanEntity(entity)) }); - dispatch(getEntities()); + dispatch(getEventBudgetByEventId(entity.eventId.toString())); return result; }; diff --git a/src/main/webapp/app/entities/budget/index.tsx b/src/main/webapp/app/entities/budget/index.tsx index 25faa8b6..93a9f18c 100644 --- a/src/main/webapp/app/entities/budget/index.tsx +++ b/src/main/webapp/app/entities/budget/index.tsx @@ -5,13 +5,14 @@ import ErrorBoundaryRoute from 'app/shared/error/error-boundary-route'; import Budget from './budget'; import BudgetDetail from './budget-detail'; +import BudgetCreate from './budget-create'; import BudgetUpdate from './budget-update'; import BudgetDeleteDialog from './budget-delete-dialog'; const Routes = ({ match }) => ( <> - + diff --git a/src/main/webapp/i18n/en/budget.json b/src/main/webapp/i18n/en/budget.json index 350f4a5e..f18c2547 100644 --- a/src/main/webapp/i18n/en/budget.json +++ b/src/main/webapp/i18n/en/budget.json @@ -1,30 +1,9 @@ { "clubmanagementApp": { - "eventBudget": { - "home": { - "title": "Event Budgets", - "createLabel": "Create a new Event Budget", - "createOrEditLabel": "Create or edit a Event Budget", - "notFound": "No Event Budget found" - }, + "budget": { "created": "A new Event Budget is created with identifier {{ param }}", "updated": "A Event Budget is updated with identifier {{ param }}", - "deleted": "A Event Budget is deleted with identifier {{ param }}", - "delete": { - "question": "Are you sure you want to delete Event Budget {{ id }}?" - }, - "detail": { - "title": "Event Budget" - }, - "eventId": "Event Id", - "amount": "Amount", - "type": "Type", - "name": "Name", - "details": "Details", - "budget": "Budget", - "realAmount": "Real Amount", - "income": "Income", - "expense": "Expense" + "deleted": "A Event Budget is deleted with identifier {{ param }}" } } } diff --git a/src/main/webapp/i18n/en/eventBudget.json b/src/main/webapp/i18n/en/eventBudget.json index 990389c3..e991dc90 100644 --- a/src/main/webapp/i18n/en/eventBudget.json +++ b/src/main/webapp/i18n/en/eventBudget.json @@ -3,7 +3,7 @@ "eventBudget": { "home": { "title": "Event Budget", - "createLabel": "Create a new Event Budget", + "createLabel": "Create Event Budget", "createOrEditLabel": "Create or edit a Event Budget", "notFound": "No Event Budget found" }, @@ -21,7 +21,11 @@ "name": "Name", "details": "Details", "type": "Type", - "tab": "Budget" + "budget": "Budget", + "tab": "Budget", + "realAmount": "Real Amount", + "income": "Income", + "expense": "Expense" } } } diff --git a/src/main/webapp/i18n/en/global.json b/src/main/webapp/i18n/en/global.json index 6a7b34a0..c9736750 100644 --- a/src/main/webapp/i18n/en/global.json +++ b/src/main/webapp/i18n/en/global.json @@ -99,6 +99,9 @@ "field": { "id": "ID" }, + "select": { + "selectOne": "Select One" + }, "ribbon": { "dev": "Development" }, diff --git a/src/main/webapp/i18n/zh-cn/budget.json b/src/main/webapp/i18n/zh-cn/budget.json index 7c73d5d8..6fd7ea3e 100644 --- a/src/main/webapp/i18n/zh-cn/budget.json +++ b/src/main/webapp/i18n/zh-cn/budget.json @@ -1,30 +1,9 @@ { "clubmanagementApp": { "budget": { - "home": { - "title": "活动预算", - "createLabel": "创建新活动预算", - "createOrEditLabel": "创建或编辑活动预算", - "notFound": "无活动预算" - }, "created": "活动预算 {{ param }} 创建成功", "updated": "活动预算 {{ param }} 更新成功", - "deleted": "活动预算 {{ param }} 删除成功", - "delete": { - "question": "你确定要删除活动预算 {{ id }} 吗?" - }, - "detail": { - "title": "活动预算" - }, - "eventId": "Event Id", - "amount": "数额", - "type": "种类", - "name": "名称", - "details": "详情", - "budget": "预算", - "realAmount": "实数", - "income": "收入", - "expense": "消费" + "deleted": "活动预算 {{ param }} 删除成功" } } } diff --git a/src/main/webapp/i18n/zh-cn/eventBudget.json b/src/main/webapp/i18n/zh-cn/eventBudget.json index dd200ce4..7a1fb9cf 100644 --- a/src/main/webapp/i18n/zh-cn/eventBudget.json +++ b/src/main/webapp/i18n/zh-cn/eventBudget.json @@ -2,26 +2,30 @@ "clubmanagementApp": { "eventBudget": { "home": { - "title": "Event Budget", - "createLabel": "创建新 Event Budget", - "createOrEditLabel": "创建或编辑 Event Budget", - "notFound": "No Event Budget found" + "title": "活动预算", + "createLabel": "创建活动预算", + "createOrEditLabel": "创建或编辑活动预算", + "notFound": "无活动预算" }, - "created": "Event Budget {{ param }} 创建成功", - "updated": "Event Budget {{ param }} 更新成功", - "deleted": "Event Budget {{ param }} 删除成功", + "created": "活动预算 {{ param }} 创建成功", + "updated": "活动预算 {{ param }} 更新成功", + "deleted": "活动预算 {{ param }} 删除成功", "delete": { - "question": "你确定要删除 Event Budget {{ id }} 吗?" + "question": "你确定要删除活动预算 {{ id }} 吗?" }, "detail": { - "title": "Event Budget" + "title": "活动预算" }, "eventId": "Event Id", - "amount": "Amount", - "name": "Name", - "details": "Details", - "type": "Type", - "tab": "Budget" + "amount": "数额", + "type": "种类", + "name": "名称", + "details": "详情", + "budget": "预算", + "tab": "预算", + "realAmount": "实数", + "income": "收入", + "expense": "消费" } } } diff --git a/src/main/webapp/i18n/zh-cn/global.json b/src/main/webapp/i18n/zh-cn/global.json index daa4607b..30b7f3d6 100644 --- a/src/main/webapp/i18n/zh-cn/global.json +++ b/src/main/webapp/i18n/zh-cn/global.json @@ -100,6 +100,9 @@ "field": { "id": "ID" }, + "select": { + "selectOne": "选择" + }, "ribbon": { "dev": "Development" }, From 45de46605568641c728517c34e2d89eb49697fda Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Sat, 3 Apr 2021 16:51:32 +0800 Subject: [PATCH 25/39] issue 53 delete event budget --- .../app/entities/budget/budget-delete-dialog.tsx | 13 ++++++------- .../webapp/app/entities/budget/budget.reducer.ts | 10 +++++----- src/main/webapp/app/entities/budget/budget.tsx | 16 ++++++++++++++-- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/main/webapp/app/entities/budget/budget-delete-dialog.tsx b/src/main/webapp/app/entities/budget/budget-delete-dialog.tsx index 2be6fc42..05234ce8 100644 --- a/src/main/webapp/app/entities/budget/budget-delete-dialog.tsx +++ b/src/main/webapp/app/entities/budget/budget-delete-dialog.tsx @@ -2,22 +2,21 @@ import React from 'react'; import { connect } from 'react-redux'; import { RouteComponentProps } from 'react-router-dom'; import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap'; -import { Translate, ICrudGetAction, ICrudDeleteAction } from 'react-jhipster'; +import { Translate } from 'react-jhipster'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { IBudget } from 'app/shared/model/budget.model'; import { IRootState } from 'app/shared/reducers'; import { getEntity, deleteEntity } from './budget.reducer'; -export interface IBudgetDeleteDialogProps extends StateProps, DispatchProps, RouteComponentProps<{ id: string }> {} +export interface IBudgetDeleteDialogProps extends StateProps, DispatchProps, RouteComponentProps<{ id: string; eventId: string }> {} export class BudgetDeleteDialog extends React.Component { componentDidMount() { - this.props.getEntity(this.props.match.params.id); + this.props.getEntity(this.props.match.params.id, this.props.match.params.eventId); } confirmDelete = event => { - this.props.deleteEntity(this.props.budgetEntity.id); + this.props.deleteEntity(this.props.budgetEntity.id, this.props.budgetEntity.eventId); this.handleClose(event); }; @@ -33,8 +32,8 @@ export class BudgetDeleteDialog extends React.Component Confirm delete operation - - + + Are you sure you want to delete this Budget? diff --git a/src/main/webapp/app/entities/budget/budget.reducer.ts b/src/main/webapp/app/entities/budget/budget.reducer.ts index 9233349b..51ebb5ad 100644 --- a/src/main/webapp/app/entities/budget/budget.reducer.ts +++ b/src/main/webapp/app/entities/budget/budget.reducer.ts @@ -156,8 +156,8 @@ export const getEventBudgetByEventId: IGetAllByEventId = (eventId, page }; }; -export const getEntity: ICrudGetAction = id => { - const requestUrl = `${apiUrl}/${id}`; +export const getEntity: ICrudGetAction = (id, eventId) => { + const requestUrl = `${apiUrl}/${id}/event/${eventId}`; return { type: ACTION_TYPES.FETCH_BUDGET, payload: axios.get(requestUrl) @@ -182,13 +182,13 @@ export const updateEntity: ICrudPutAction = entity => async dispatch => return result; }; -export const deleteEntity: ICrudDeleteAction = id => async dispatch => { - const requestUrl = `${apiUrl}/${id}`; +export const deleteEntity: ICrudDeleteAction = (id, eventId) => async dispatch => { + const requestUrl = `${apiUrl}/${id}/event/${eventId}`; const result = await dispatch({ type: ACTION_TYPES.DELETE_BUDGET, payload: axios.delete(requestUrl) }); - dispatch(getEntities()); + dispatch(getEventBudgetByEventId(eventId.toString())); return result; }; diff --git a/src/main/webapp/app/entities/budget/budget.tsx b/src/main/webapp/app/entities/budget/budget.tsx index 40603407..3f046b87 100644 --- a/src/main/webapp/app/entities/budget/budget.tsx +++ b/src/main/webapp/app/entities/budget/budget.tsx @@ -178,13 +178,25 @@ export class Budget extends React.Component {

Options

- -   - -   -   - Save - + + )} @@ -164,7 +180,8 @@ const mapStateToProps = (storeState: IRootState) => ({ budgetEntity: storeState.budget.entity, loading: storeState.budget.loading, updating: storeState.budget.updating, - updateSuccess: storeState.budget.updateSuccess + updateSuccess: storeState.budget.updateSuccess, + errorMessage: storeState.budget.errorMessage }); const mapDispatchToProps = { diff --git a/src/main/webapp/app/entities/budget/budget.reducer.ts b/src/main/webapp/app/entities/budget/budget.reducer.ts index 51ebb5ad..ef316841 100644 --- a/src/main/webapp/app/entities/budget/budget.reducer.ts +++ b/src/main/webapp/app/entities/budget/budget.reducer.ts @@ -5,7 +5,7 @@ import { cleanEntity } from 'app/shared/util/entity-utils'; import { REQUEST, SUCCESS, FAILURE } from 'app/shared/reducers/action-type.util'; import { IBudget, defaultValue, IEventBudgetTotal, defaultEventBudgetTotal } from 'app/shared/model/budget.model'; -import { IGetAllByEventId } from 'app/shared/type/event-custom-action'; +import { IGetAllByEventId, IDeleteEvent, IPutEvent, IGetEvent } from 'app/shared/type/event-custom-action'; export const ACTION_TYPES = { FETCH_BUDGET_LIST: 'budget/FETCH_BUDGET_LIST', @@ -156,7 +156,7 @@ export const getEventBudgetByEventId: IGetAllByEventId = (eventId, page }; }; -export const getEntity: ICrudGetAction = (id, eventId) => { +export const getEntity: IGetEvent = (id, eventId) => { const requestUrl = `${apiUrl}/${id}/event/${eventId}`; return { type: ACTION_TYPES.FETCH_BUDGET, @@ -182,7 +182,7 @@ export const updateEntity: ICrudPutAction = entity => async dispatch => return result; }; -export const deleteEntity: ICrudDeleteAction = (id, eventId) => async dispatch => { +export const deleteEntity: IDeleteEvent = (id, eventId) => async dispatch => { const requestUrl = `${apiUrl}/${id}/event/${eventId}`; const result = await dispatch({ type: ACTION_TYPES.DELETE_BUDGET, diff --git a/src/main/webapp/app/shared/type/event-custom-action.ts b/src/main/webapp/app/shared/type/event-custom-action.ts index b686f8e9..cbd0cd1f 100644 --- a/src/main/webapp/app/shared/type/event-custom-action.ts +++ b/src/main/webapp/app/shared/type/event-custom-action.ts @@ -1,4 +1,4 @@ -import { IPayload } from 'react-jhipster'; +import { IPayload, IPayloadResult } from 'react-jhipster'; export declare type IGetAllByEventId = ( eventId: string, @@ -6,3 +6,7 @@ export declare type IGetAllByEventId = ( size?: number, sort?: string ) => IPayload | ((dispatch: any) => IPayload); + +export declare type IDeleteEvent = (id?: number | string, eventId?: number | string) => IPayload | IPayloadResult; +export declare type IPutEvent = (data?: T, eventId?: number | string) => IPayload | IPayloadResult; +export declare type IGetEvent = (id: string | number, eventId?: number | string) => IPayload | ((dispatch: any) => IPayload); diff --git a/src/main/webapp/i18n/en/eventBudget.json b/src/main/webapp/i18n/en/eventBudget.json index e991dc90..ec57068a 100644 --- a/src/main/webapp/i18n/en/eventBudget.json +++ b/src/main/webapp/i18n/en/eventBudget.json @@ -4,6 +4,7 @@ "home": { "title": "Event Budget", "createLabel": "Create Event Budget", + "editLabel": "Update Event Budget", "createOrEditLabel": "Create or edit a Event Budget", "notFound": "No Event Budget found" }, diff --git a/src/main/webapp/i18n/en/global.json b/src/main/webapp/i18n/en/global.json index c9736750..5f6bc662 100644 --- a/src/main/webapp/i18n/en/global.json +++ b/src/main/webapp/i18n/en/global.json @@ -119,7 +119,8 @@ "update": "Update", "open": "Open", "save": "Save", - "view": "View" + "view": "View", + "create": "Create" }, "detail": { "field": "Field", @@ -145,7 +146,7 @@ "error": { "internalServerError": "Internal server error", "server.not.reachable": "Server not reachable", - "url.not.found": "Not found", + "urlNotFound": "URL Not found", "NotNull": "Field {{ fieldName }} cannot be empty!", "Size": "Field {{ fieldName }} does not meet min/max size requirements!", "userexists": "Login name already used!", diff --git a/src/main/webapp/i18n/zh-cn/eventBudget.json b/src/main/webapp/i18n/zh-cn/eventBudget.json index 7a1fb9cf..6b380447 100644 --- a/src/main/webapp/i18n/zh-cn/eventBudget.json +++ b/src/main/webapp/i18n/zh-cn/eventBudget.json @@ -4,6 +4,7 @@ "home": { "title": "活动预算", "createLabel": "创建活动预算", + "editLabel": "编辑活动预算", "createOrEditLabel": "创建或编辑活动预算", "notFound": "无活动预算" }, diff --git a/src/main/webapp/i18n/zh-cn/global.json b/src/main/webapp/i18n/zh-cn/global.json index 30b7f3d6..ac13858d 100644 --- a/src/main/webapp/i18n/zh-cn/global.json +++ b/src/main/webapp/i18n/zh-cn/global.json @@ -120,7 +120,8 @@ "update": "更新", "open": "Open", "save": "保存", - "view": "查看" + "view": "查看", + "create": "创建" }, "detail": { "field": "字段", @@ -145,7 +146,7 @@ "error": { "internalServerError": "Internal server error", "server.not.reachable": "服务器无法访问", - "url.not.found": "Not found", + "urlNotFound": "Not found", "NotNull": "域 {{fieldName}} 不能为空!", "Size": "域 {{fieldName}} 不满足最大/最小值限制!", "userexists": "该用户名已存在!", diff --git a/src/test/javascript/spec/app/config/notification-middleware.spec.ts b/src/test/javascript/spec/app/config/notification-middleware.spec.ts index 7c4e3b4c..db114065 100644 --- a/src/test/javascript/spec/app/config/notification-middleware.spec.ts +++ b/src/test/javascript/spec/app/config/notification-middleware.spec.ts @@ -176,7 +176,7 @@ describe('Notification Middleware', () => { expect(err.response.data.message).toEqual('Not found'); }); const toastMsg = (toastify.toast as any).error.getCall(0).args[0]; - expect(toastMsg).toContain('error.url.not.found'); + expect(toastMsg).toContain('error.urlNotFound'); }); it('should trigger an error toast message and return promise error for 0 response code', async () => { await store.dispatch(NO_SERVER_ERROR).catch(err => { From 948ee18a02eeba1d00248750fb41673c50daa860 Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Wed, 7 Apr 2021 20:29:14 +0800 Subject: [PATCH 30/39] update validation message --- src/main/webapp/app/entities/budget/budget-create.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/app/entities/budget/budget-create.tsx b/src/main/webapp/app/entities/budget/budget-create.tsx index b36d9463..bd29b116 100644 --- a/src/main/webapp/app/entities/budget/budget-create.tsx +++ b/src/main/webapp/app/entities/budget/budget-create.tsx @@ -73,7 +73,7 @@ export class EventBudgetCreate extends React.Component { type="number" name="amount" validate={{ - required: { value: true, errorMessage: 'Please Enter an amount for this budget' }, + required: { value: true, errorMessage: 'Please enter an amount for this budget' }, min: { value: 0, errorMessage: 'Amount cannot be less than 0' }, pattern: { value: '^([0-9]*.?[0-9]{1,2})$', errorMessage: 'Please enter a valid amount with max of 2 decimal values' } }} @@ -89,7 +89,7 @@ export class EventBudgetCreate extends React.Component { name="name" required validate={{ - required: { value: true, errorMessage: 'Please Enter a name for this budget' }, + required: { value: true, errorMessage: 'Please enter a name for this budget' }, maxLength: { value: 100, errorMessage: 'Name cannot be more than 100 characters' } }} /> From f42aa765aa588ce234563ef0a69aa2e7c1da84d0 Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Wed, 7 Apr 2021 20:36:29 +0800 Subject: [PATCH 31/39] update Custom Tab tabList props --- src/main/webapp/app/entities/event-activity/event-activity.tsx | 3 ++- src/main/webapp/app/entities/event/event-detail.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/app/entities/event-activity/event-activity.tsx b/src/main/webapp/app/entities/event-activity/event-activity.tsx index c9524c7b..c5a7044c 100644 --- a/src/main/webapp/app/entities/event-activity/event-activity.tsx +++ b/src/main/webapp/app/entities/event-activity/event-activity.tsx @@ -62,12 +62,13 @@ export class EventActivity extends React.Component

Event Activities

- +
diff --git a/src/main/webapp/app/entities/event/event-detail.tsx b/src/main/webapp/app/entities/event/event-detail.tsx index 43e5e95c..79cc2daf 100644 --- a/src/main/webapp/app/entities/event/event-detail.tsx +++ b/src/main/webapp/app/entities/event/event-detail.tsx @@ -25,11 +25,12 @@ export class EventDetail extends React.Component { render() { const { eventEntity } = this.props; + const { id } = this.props.match.params; return (

Event Details

- +
{eventEntity.fileName} From 988559946604a714e9433847633bbe9cfdd66285 Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Wed, 7 Apr 2021 21:00:20 +0800 Subject: [PATCH 32/39] update activity listing duration format --- .../app/entities/event-activity/event-activity.tsx | 6 ++++-- src/main/webapp/app/shared/util/duration-utils.ts | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/app/entities/event-activity/event-activity.tsx b/src/main/webapp/app/entities/event-activity/event-activity.tsx index c9524c7b..928bd004 100644 --- a/src/main/webapp/app/entities/event-activity/event-activity.tsx +++ b/src/main/webapp/app/entities/event-activity/event-activity.tsx @@ -14,6 +14,7 @@ import { CustomTab } from 'app/shared/components/customTab/custom-tab'; import { eventTabList } from 'app/shared/util/tab.constants'; import { ListingCard } from 'app/shared/components/listing-card/listing-card'; import { convertDateTimeFromServerToLocaleDate } from 'app/shared/util/date-utils'; +import { convertDaysDurationToTimeFormat, timeFormatDurationToString } from 'app/shared/util/duration-utils'; export interface IEventActivityProps extends StateProps, DispatchProps, RouteComponentProps<{ url: string; eventId: string }> {} @@ -62,12 +63,13 @@ export class EventActivity extends React.Component

Event Activities

- +
@@ -94,7 +96,7 @@ export class EventActivity extends React.Component Duration (In Day):{' '} - {eventActivity.durationInDay} + {timeFormatDurationToString(convertDaysDurationToTimeFormat(eventActivity.durationInDay))} diff --git a/src/main/webapp/app/shared/util/duration-utils.ts b/src/main/webapp/app/shared/util/duration-utils.ts index c18217b9..550e5180 100644 --- a/src/main/webapp/app/shared/util/duration-utils.ts +++ b/src/main/webapp/app/shared/util/duration-utils.ts @@ -12,3 +12,17 @@ export const convertTimeFormatToDaysDuration = ({ days, hours, minutes }) => { let duration = (days ? days : 0) + (hours ? hours / 24.0 : 0) + (minutes ? minutes / 60.0 / 24.0 : 0); return Number.parseFloat(duration).toFixed(5); }; + +export const timeFormatDurationToString = ({ days, hours, minutes }) => { + let stringDuration = ''; + if (days) { + stringDuration += days + ' days '; + } + if (hours) { + stringDuration += hours + ' hours '; + } + if (minutes) { + stringDuration += minutes + ' minutes'; + } + return stringDuration; +}; From 311fbe0f04d2443965dc062fc8d6f0300a8d0aec Mon Sep 17 00:00:00 2001 From: HowardYaw Date: Wed, 7 Apr 2021 22:11:10 +0800 Subject: [PATCH 33/39] create eventActivity duration --- .../event-activity/event-activity-create.tsx | 22 ++++++++++++++++--- .../event-activity/event-activity.tsx | 2 +- .../webapp/app/shared/util/duration-utils.ts | 4 ++-- src/main/webapp/i18n/en/eventActivity.json | 1 + src/main/webapp/i18n/zh-cn/eventActivity.json | 1 + 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main/webapp/app/entities/event-activity/event-activity-create.tsx b/src/main/webapp/app/entities/event-activity/event-activity-create.tsx index 03e1002a..363a6b13 100644 --- a/src/main/webapp/app/entities/event-activity/event-activity-create.tsx +++ b/src/main/webapp/app/entities/event-activity/event-activity-create.tsx @@ -11,6 +11,7 @@ import { getEntity as getEventEntity } from '../event/event.reducer'; import { convertDateTimeToServer } from 'app/shared/util/date-utils'; import moment from 'moment'; import { APP_LOCAL_DATETIME_FORMAT } from 'app/config/constants'; +import { convertTimeFormatToDaysDuration } from 'app/shared/util/duration-utils'; export interface IEventActivityCreateProps extends StateProps, DispatchProps, RouteComponentProps<{ id: string; eventId: string }> {} @@ -33,6 +34,12 @@ export class EventActivityCreate extends React.Component { values.startDate = convertDateTimeToServer(values.startDate); + values['durationInDay'] = convertTimeFormatToDaysDuration({ + days: values.durationDay, + hours: values.durationHour, + minutes: values.durationMinute + }); + if (errors.length === 0) { const { eventActivityEntity } = this.props; const entity = { @@ -102,10 +109,19 @@ export class EventActivityCreate extends React.Component -