Skip to content

Commit

Permalink
Merge pull request #41 from sayoungestguy/ActivityInvite
Browse files Browse the repository at this point in the history
Activity invite
  • Loading branch information
sayoungestguy authored Oct 22, 2024
2 parents 056149f + 9ec7aba commit 67a6389
Show file tree
Hide file tree
Showing 24 changed files with 430 additions and 400 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<springdoc-openapi-starter-webmvc-api.version>2.5.0</springdoc-openapi-starter-webmvc-api.version>
<sonar.organization>sayoungestguy</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.coverage.exclusions>**/*DTO*.*, **/domain/**, **/service/criteria/**, **/test/**</sonar.coverage.exclusions>
<sonar.coverage.exclusions>**/test/**</sonar.coverage.exclusions>
<sonar.cpd.exclusions>**/*DTO*.*, **/domain/**, **/service/criteria/**, **/test/**</sonar.cpd.exclusions>
<sonar.exclusions>**/test/**</sonar.exclusions>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ public ActivityInviteQueryService(
@Transactional(readOnly = true)
public Page<ActivityInviteDTO> findByCriteria(ActivityInviteCriteria criteria, Pageable page) {
// log.debug("find by criteria : {}, page: {}", criteria, page);
User currentUser = userService.getUserById().orElseThrow(() -> new UsernameNotFoundException("User not found"));
boolean isAdmin = SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN);
if (currentUser != null && !isAdmin) {
// Set the creatorProfileId in the criteria to match the current user
if (criteria == null) {
criteria = new ActivityInviteCriteria();
}
LongFilter userFilter = new LongFilter();
userFilter.setEquals(currentUser.getId());
criteria.setInviteeProfileId(userFilter);
}
// User currentUser = userService.getUserById().orElseThrow(() -> new UsernameNotFoundException("User not found"));
// boolean isAdmin = SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN);
// if (currentUser != null && !isAdmin) {
// // Set the creatorProfileId in the criteria to match the current user
// if (criteria == null) {
// criteria = new ActivityInviteCriteria();
// }
// LongFilter userFilter = new LongFilter();
// userFilter.setEquals(currentUser.getId());
// criteria.setInviteeProfileId(userFilter);
// }
final Specification<ActivityInvite> specification = createSpecification(criteria);
return activityInviteRepository.findAll(specification, page).map(activityInviteMapper::toDto);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/.h2.server.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#H2 Server Properties
#Tue Oct 15 23:21:09 SGT 2024
#Tue Oct 22 23:51:01 SGT 2024
0=JHipster H2 (Disk)|org.h2.Driver|jdbc\:h2\:file\:./target/h2db/db/scaleup|scaleup
webSSL=false
webAllowOthers=true
webPort=8092
webSSL=false
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { Button, Row, Col } from 'reactstrap';
import { TextFormat } from 'react-jhipster';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import { APP_DATE_FORMAT, APP_LOCAL_DATE_FORMAT } from 'app/config/constants';
import { APP_DATE_FORMAT } from 'app/config/constants';
import { useAppDispatch, useAppSelector } from 'app/config/store';

import { getActivityInviteById } from './activity-invite.reducer';
import { getActivityById } from 'app/entities/activity/activity.reducer';
import { getUserProfileById } from 'app/entities/user-profile/user-profile.reducer';
import { getCodeTableById } from 'app/entities/code-tables/code-tables.reducer';

export const ActivityInviteDetail = () => {
const dispatch = useAppDispatch();
Expand All @@ -19,6 +22,23 @@ export const ActivityInviteDetail = () => {
}, []);

const activityInviteEntity = useAppSelector(state => state.activityInvite.entity);

useEffect(() => {
if (activityInviteEntity?.activity?.id) {
dispatch(getActivityById(activityInviteEntity?.activity?.id));
}
if (activityInviteEntity?.inviteeProfile?.id) {
dispatch(getUserProfileById(activityInviteEntity?.inviteeProfile?.id));
}
if (activityInviteEntity?.status?.id) {
dispatch(getCodeTableById(activityInviteEntity?.status?.id));
}
}, [dispatch, activityInviteEntity]);

const activityName = useAppSelector(state => (activityInviteEntity?.activity?.id ? state.activity.entity : null));
const inviteeProfile = useAppSelector(state => (activityInviteEntity.inviteeProfile?.id ? state.userProfile.entity : null));
const status = useAppSelector(state => (activityInviteEntity?.status?.id ? state.codeTables.entity : null));

return (
<Row>
<Col md="8">
Expand Down Expand Up @@ -57,11 +77,11 @@ export const ActivityInviteDetail = () => {
) : null}
</dd>
<dt>Activity</dt>
<dd>{activityInviteEntity.activity ? activityInviteEntity.activity.id : ''}</dd>
<dd>{activityName ? activityName.activityName : ''}</dd>
<dt>Invitee Profile</dt>
<dd>{activityInviteEntity.inviteeProfile ? activityInviteEntity.inviteeProfile.id : ''}</dd>
<dd>{inviteeProfile ? inviteeProfile.nickname : ''}</dd>
<dt>Status</dt>
<dd>{activityInviteEntity.status ? activityInviteEntity.status.id : ''}</dd>
<dd>{status ? status.codeValue : ''}</dd>
</dl>
<Button tag={Link} to="/activity-invite" replace color="info" data-cy="entityDetailsBackButton">
<FontAwesomeIcon icon="arrow-left" /> <span className="d-none d-md-inline">Back</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import React, { useState, useEffect } from 'react';
import React, { useEffect } from 'react';
import { Link, useNavigate, useParams } from 'react-router-dom';
import { Button, Row, Col, FormText } from 'reactstrap';
import { isNumber, ValidatedField, ValidatedForm } from 'react-jhipster';
import { Button, Row, Col } from 'reactstrap';
import { ValidatedField, ValidatedForm } from 'react-jhipster';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import { convertDateTimeFromServer, convertDateTimeToServer, displayDefaultDateTime } from 'app/shared/util/date-utils';
import { mapIdList } from 'app/shared/util/entity-utils';
import { useAppDispatch, useAppSelector } from 'app/config/store';

import { IActivity } from 'app/shared/model/activity.model';
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';
import { getEntities as getCodeTables } from 'app/entities/code-tables/code-tables.reducer';
import { IActivityInvite } from 'app/shared/model/activity-invite.model';
import { getAllUserProfiles as getUserProfiles } from 'app/entities/user-profile/user-profile.reducer';
import { getCodeTables as getCodeTables } from 'app/entities/code-tables/code-tables.reducer';
import { getActivityInviteById, updateEntity, createEntity, reset } from './activity-invite.reducer';

export const ActivityInviteUpdate = () => {
Expand Down Expand Up @@ -108,47 +103,23 @@ export const ActivityInviteUpdate = () => {
<p>Loading...</p>
) : (
<ValidatedForm defaultValues={defaultValues()} onSubmit={saveEntity}>
{!isNew ? (
<ValidatedField name="id" required readOnly id="activity-invite-id" label="ID" validate={{ required: true }} />
) : null}
{!isNew ? <ValidatedField name="id" required readOnly id="activity-invite-id" label="ID" /> : null}
<ValidatedField
label="Will Participate"
id="activity-invite-willParticipate"
name="willParticipate"
data-cy="willParticipate"
check
type="checkbox"
/>
<ValidatedField label="Created By" id="activity-invite-createdBy" name="createdBy" data-cy="createdBy" type="text" />
<ValidatedField
label="Created Date"
id="activity-invite-createdDate"
name="createdDate"
data-cy="createdDate"
type="datetime-local"
placeholder="YYYY-MM-DD HH:mm"
/>
<ValidatedField
label="Last Modified By"
id="activity-invite-lastModifiedBy"
name="lastModifiedBy"
data-cy="lastModifiedBy"
type="text"
/>
<ValidatedField
label="Last Modified Date"
id="activity-invite-lastModifiedDate"
name="lastModifiedDate"
data-cy="lastModifiedDate"
type="datetime-local"
placeholder="YYYY-MM-DD HH:mm"
/>
<ValidatedField id="activity-invite-activity" name="activity" data-cy="activity" label="Activity" type="select">
id="activity-invite-activity"
name="activity"
data-cy="activity"
label="Activity"
type="select"
disabled={!isNew}
validate={{
required: { value: true, message: 'This field is required.' },
}}
>
<option value="" key="0" />
{activities
? activities.map(otherEntity => (
<option value={otherEntity.id} key={otherEntity.id}>
{otherEntity.id}
{otherEntity.activityName}
</option>
))
: null}
Expand All @@ -159,27 +130,44 @@ export const ActivityInviteUpdate = () => {
data-cy="inviteeProfile"
label="Invitee Profile"
type="select"
disabled={!isNew}
validate={{
required: { value: true, message: 'This field is required.' },
}}
>
<option value="" key="0" />
{userProfiles
? userProfiles.map(otherEntity => (
<option value={otherEntity.id} key={otherEntity.id}>
{otherEntity.id}
</option>
))
? userProfiles
//.filter(userProfile => userProfile.id )

Check warning on line 141 in src/main/webapp/app/entities/activity-invite/activity-invite-update.tsx

View workflow job for this annotation

GitHub Actions / Frontend Test Stage

Expected space or tab after '//' in comment
.map(otherEntity => (
<option value={otherEntity.id} key={otherEntity.id}>
{otherEntity.nickname}
</option>
))
: null}
</ValidatedField>
<ValidatedField id="activity-invite-status" name="status" data-cy="status" label="Status" type="select">
<ValidatedField
id="activity-invite-status"
name="status"
data-cy="status"
label="Status"
type="select"
validate={{
required: { value: true, message: 'This field is required.' },
}}
>
<option value="" key="0" />
{codeTables
? codeTables.map(otherEntity => (
<option value={otherEntity.id} key={otherEntity.id}>
{otherEntity.id}
</option>
))
? codeTables
.filter(codeTable => codeTable.id >= 3 && codeTable.id <= 5)
.map(otherEntity => (
<option value={otherEntity.id} key={otherEntity.id}>
{otherEntity.codeValue}
</option>
))
: null}
</ValidatedField>
<Button tag={Link} id="cancel-save" data-cy="entityCreateCancelButton" to="/activity" replace color="info">
<Button tag={Link} id="cancel-save" data-cy="entityCreateCancelButton" to="/activity-invite" replace color="info">
<FontAwesomeIcon icon="arrow-left" />
&nbsp;
<span className="d-none d-md-inline">Back</span>
Expand Down
Loading

0 comments on commit 67a6389

Please sign in to comment.