Skip to content

Commit

Permalink
Activity Page Current & Past + Show Skill name instead of ID
Browse files Browse the repository at this point in the history
  • Loading branch information
sayoungestguy committed Sep 3, 2024
1 parent cd6df27 commit 295fe39
Show file tree
Hide file tree
Showing 16 changed files with 342 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public ResponseEntity<ActivityDTO> partialUpdateActivity(
public ResponseEntity<List<ActivityDTO>> getAllActivities(@org.springdoc.core.annotations.ParameterObject Pageable pageable) {
log.debug("REST request to get a page of Activities");
Page<ActivityDTO> page = activityService.findAllByCurrentUser(pageable);
// Page<ActivityDTO> page = activityService.findAll(pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page);
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/.h2.server.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#H2 Server Properties
#Thu Aug 29 00:36:11 SGT 2024
#Sun Sep 01 14:42:04 SGT 2024
0=JHipster H2 (Disk)|org.h2.Driver|jdbc\:h2\:file\:./target/h2db/db/scaleup|scaleup
webSSL=false
webAllowOthers=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { mapIdList } from 'app/shared/util/entity-utils';
import { useAppDispatch, useAppSelector } from 'app/config/store';

import { IActivity } from 'app/shared/model/activity.model';
import { getEntities as getActivities } from 'app/entities/activity/activity.reducer';
import { getAllActivity as getActivities } from 'app/entities/activity/activity.reducer';
import { IUserProfile } from 'app/shared/model/user-profile.model';
import { getEntities as getUserProfiles } from 'app/entities/user-profile/user-profile.reducer';
import { ICodeTables } from 'app/shared/model/code-tables.model';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import { useAppDispatch, useAppSelector } from 'app/config/store';
import { getEntity, deleteEntity } from './activity.reducer';
import { getActivityById, deleteEntity } from './activity.reducer';

export const ActivityDeleteDialog = () => {
const dispatch = useAppDispatch();
Expand All @@ -17,7 +17,7 @@ export const ActivityDeleteDialog = () => {
const [loadModal, setLoadModal] = useState(false);

useEffect(() => {
dispatch(getEntity(id));
dispatch(getActivityById(id));
setLoadModal(true);
}, []);

Expand Down
26 changes: 2 additions & 24 deletions src/main/webapp/app/entities/activity/activity-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { APP_DATE_FORMAT, APP_LOCAL_DATE_FORMAT } from 'app/config/constants';
import { useAppDispatch, useAppSelector } from 'app/config/store';

import { getEntity } from './activity.reducer';
import { getActivityById } from './activity.reducer';

export const ActivityDetail = () => {
const dispatch = useAppDispatch();

const { id } = useParams<'id'>();

useEffect(() => {
dispatch(getEntity(id));
dispatch(getActivityById(id));
}, []);

const activityEntity = useAppSelector(state => state.activity.entity);
Expand Down Expand Up @@ -46,28 +46,6 @@ export const ActivityDetail = () => {
<span id="details">Details</span>
</dt>
<dd>{activityEntity.details}</dd>
<dt>
<span id="createdBy">Created By</span>
</dt>
<dd>{activityEntity.createdBy}</dd>
<dt>
<span id="createdDate">Created Date</span>
</dt>
<dd>
{activityEntity.createdDate ? <TextFormat value={activityEntity.createdDate} type="date" format={APP_DATE_FORMAT} /> : null}
</dd>
<dt>
<span id="lastModifiedBy">Last Modified By</span>
</dt>
<dd>{activityEntity.lastModifiedBy}</dd>
<dt>
<span id="lastModifiedDate">Last Modified Date</span>
</dt>
<dd>
{activityEntity.lastModifiedDate ? (
<TextFormat value={activityEntity.lastModifiedDate} type="date" format={APP_DATE_FORMAT} />
) : null}
</dd>
<dt>Creator Profile</dt>
<dd>{activityEntity.creatorProfile ? activityEntity.creatorProfile.id : ''}</dd>
<dt>Skill</dt>
Expand Down
77 changes: 46 additions & 31 deletions src/main/webapp/app/entities/activity/activity-update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import { useAppDispatch, useAppSelector } from 'app/config/store';
import { IUserProfile } from 'app/shared/model/user-profile.model';
import { getEntities as getUserProfiles } from 'app/entities/user-profile/user-profile.reducer';
import { ISkill } from 'app/shared/model/skill.model';
import { getEntities as getSkills } from 'app/entities/skill/skill.reducer';
import { getAllSkills as getSkills } from 'app/entities/skill/skill.reducer';
import { IActivity } from 'app/shared/model/activity.model';
import { getEntity, updateEntity, createEntity, reset } from './activity.reducer';
import { getActivityById, updateEntity, createEntity, reset } from './activity.reducer';
import { min } from 'lodash';

export const ActivityUpdate = () => {
const dispatch = useAppDispatch();
Expand All @@ -36,7 +37,7 @@ export const ActivityUpdate = () => {

useEffect(() => {
if (!isNew) {
dispatch(getEntity(id));
dispatch(getActivityById(id));
}

dispatch(getUserProfiles({}));
Expand Down Expand Up @@ -96,7 +97,7 @@ export const ActivityUpdate = () => {
<Row className="justify-content-center">
<Col md="8">
<h2 id="scaleupApp.activity.home.createOrEditLabel" data-cy="ActivityCreateUpdateHeading">
Create or edit a Activity
{isNew ? 'Create an Activity' : 'Edit an Activity'}
</h2>
</Col>
</Row>
Expand All @@ -118,48 +119,53 @@ export const ActivityUpdate = () => {
required: { value: true, message: 'This field is required.' },
}}
/>
<ValidatedField label="Duration" id="activity-duration" name="duration" data-cy="duration" type="text" />
<ValidatedField
label="Duration"
id="activity-duration"
name="duration"
data-cy="duration"
type="text"
validate={{
required: { value: true, message: 'This field is required' },
min: { value: 1, message: 'Value must be more than 0' },
max: { value: 999, message: 'Value cannot be more than 999' },
validate: {
notDecimal: value => Number.isInteger(Number(value)) || 'Value cannot be a decimal',
notNegative: value => value >= 0 || 'Value cannot be negative',
},
}}
/>
<ValidatedField
label="Venue"
id="activity-venue"
name="venue"
data-cy="venue"
type="text"
validate={{
required: { value: true, message: 'This field is required' },
maxLength: { value: 255, message: 'This field cannot be longer than 255 characters.' },
}}
/>
<ValidatedField
label="Details"
id="activity-details"
name="details"
data-cy="details"
type="textarea"
validate={{
required: { value: true, message: 'This field is required' },
maxLength: { value: 255, message: 'This field cannot be longer than 255 characters.' },
}}
/>
<ValidatedField label="Details" id="activity-details" name="details" data-cy="details" type="textarea" />
{/*<ValidatedField label="Created By" id="activity-createdBy" name="createdBy" data-cy="createdBy" type="text" />*/}
{/*<ValidatedField*/}
{/* label="Created Date"*/}
{/* id="activity-createdDate"*/}
{/* name="createdDate"*/}
{/* data-cy="createdDate"*/}
{/* type="datetime-local"*/}
{/* placeholder="YYYY-MM-DD HH:mm"*/}
{/*/>*/}
{/*<ValidatedField*/}
{/* label="Last Modified By"*/}
{/* id="activity-lastModifiedBy"*/}
{/* name="lastModifiedBy"*/}
{/* data-cy="lastModifiedBy"*/}
{/* type="text"*/}
{/*/>*/}
{/*<ValidatedField*/}
{/* label="Last Modified Date"*/}
{/* id="activity-lastModifiedDate"*/}
{/* name="lastModifiedDate"*/}
{/* data-cy="lastModifiedDate"*/}
{/* type="datetime-local"*/}
{/* placeholder="YYYY-MM-DD HH:mm"*/}
{/*/>*/}
<ValidatedField
id="activity-creatorProfile"
name="creatorProfile"
data-cy="creatorProfile"
label="Creator Profile"
type="select"
validate={{
required: { value: true, message: 'This field is required' },
}}
>
<option value="" key="0" />
{userProfiles
Expand All @@ -170,7 +176,16 @@ export const ActivityUpdate = () => {
))
: null}
</ValidatedField>
<ValidatedField id="activity-skill" name="skill" data-cy="skill" label="Skill" type="select">
<ValidatedField
id="activity-skill"
name="skill"
data-cy="skill"
label="Skill"
type="select"
validate={{
required: { value: true, message: 'This field is required' },
}}
>
<option value="" key="0" />
{skills
? skills.map(otherEntity => (
Expand Down
10 changes: 5 additions & 5 deletions src/main/webapp/app/entities/activity/activity.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const apiUrl = 'api/activities';

// Actions

export const getEntities = createAsyncThunk(
export const getAllActivity = createAsyncThunk(
'activity/fetch_entity_list',
async ({ page, size, sort }: IQueryParams) => {
const requestUrl = `${apiUrl}?${sort ? `page=${page}&size=${size}&sort=${sort}&` : ''}cacheBuster=${new Date().getTime()}`;
Expand All @@ -29,7 +29,7 @@ export const getEntities = createAsyncThunk(
{ serializeError: serializeAxiosError },
);

export const getEntity = createAsyncThunk(
export const getActivityById = createAsyncThunk(
'activity/fetch_entity',
async (id: string | number) => {
const requestUrl = `${apiUrl}/${id}`;
Expand Down Expand Up @@ -78,7 +78,7 @@ export const ActivitySlice = createEntitySlice({
initialState,
extraReducers(builder) {
builder
.addCase(getEntity.fulfilled, (state, action) => {
.addCase(getActivityById.fulfilled, (state, action) => {
state.loading = false;
state.entity = action.payload.data;
})
Expand All @@ -87,7 +87,7 @@ export const ActivitySlice = createEntitySlice({
state.updateSuccess = true;
state.entity = {};
})
.addMatcher(isFulfilled(getEntities), (state, action) => {
.addMatcher(isFulfilled(getAllActivity), (state, action) => {
const { data, headers } = action.payload;
const links = parseHeaderForLinks(headers.link);

Expand All @@ -105,7 +105,7 @@ export const ActivitySlice = createEntitySlice({
state.updateSuccess = true;
state.entity = action.payload.data;
})
.addMatcher(isPending(getEntities, getEntity), state => {
.addMatcher(isPending(getAllActivity, getActivityById), state => {
state.errorMessage = null;
state.updateSuccess = false;
state.loading = true;
Expand Down
Loading

0 comments on commit 295fe39

Please sign in to comment.