Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HKSID-270: fix project managers permissions #325

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ const ProjectFinancialSection: FC<IProjectFinancialSectionProps> = ({
options: IOption[],
size: 'full' | 'lg' | undefined,
shouldTranslate: boolean,
shouldNotBeDisabled?: boolean,
) => (

<SelectField
{...getFieldProps(name)}
options={options}
size={size}
shouldTranslate={shouldTranslate}
disabled={isInputDisabled}
disabled={shouldNotBeDisabled ? false : isInputDisabled}
readOnly={isUserOnlyViewer}
/>
);
Expand Down Expand Up @@ -93,14 +95,14 @@ const ProjectFinancialSection: FC<IProjectFinancialSectionProps> = ({
<div className="form-row">
<div className="form-col-sm">{renderNumberField('projectCostForecast', 'keur', true)}</div>
<div className="form-col-lg">
{renderSelectField('projectQualityLevel', projectQualityLevels, undefined, true)}
{renderSelectField('projectQualityLevel', projectQualityLevels, undefined, true, true)}
</div>
<div className="form-col-sm">{renderNumberField('projectWorkQuantity', 'm2', false)}</div>
</div>
<div className="form-row">
<div className="form-col-sm">{renderNumberField('planningCostForecast', 'keur', true)}</div>
<div className="form-col-lg">
{renderSelectField('planningPhase', planningPhases, undefined, true)}
{renderSelectField('planningPhase', planningPhases, undefined, true, true)}
</div>
<div className="form-col-sm">{renderNumberField('planningWorkQuantity', 'm2', false)}</div>
</div>
Expand All @@ -109,7 +111,7 @@ const ProjectFinancialSection: FC<IProjectFinancialSectionProps> = ({
{renderNumberField('constructionCostForecast', 'keur', true)}
</div>
<div className="form-col-lg">
{renderSelectField('constructionPhase', constructionPhases, undefined, true)}
{renderSelectField('constructionPhase', constructionPhases, undefined, true, true)}
</div>
<div className="form-col-sm">
{renderNumberField('constructionWorkQuantity', 'm2', false)}
Expand Down Expand Up @@ -151,7 +153,7 @@ const ProjectFinancialSection: FC<IProjectFinancialSectionProps> = ({
cancelEdit={isSaving}
/>

<OverrunRightField control={control} cancelEdit={isSaving} readOnly={isUserOnlyViewer} />
<OverrunRightField control={control} cancelEdit={isSaving} readOnly={isUserOnlyViewer} isInputDisabled={isInputDisabled}/>
<ListField
{...getFieldProps('preliminaryBudgetDivision')}
readOnly={true}
Expand Down
16 changes: 10 additions & 6 deletions src/components/Project/ProjectBasics/ProjectForm/ProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const ProjectForm = () => {
}
return null;
}, [project?.currentYearsSapValues]);

const isOnlyViewer = isUserOnlyViewer(user);

const [newProjectId, setNewProjectId] = useState('');
Expand Down Expand Up @@ -305,10 +305,10 @@ const ProjectForm = () => {

if (data?.projectClass && project.projectGroup) {

const projectGroup = groups.find(({id}) => id === project.projectGroup);
if (data.projectClass !== projectGroup?.classRelation) {
data = {...data, "projectGroup": null}
}
const projectGroup = groups.find(({ id }) => id === project.projectGroup);
if (data.projectClass !== projectGroup?.classRelation) {
data = { ...data, "projectGroup": null }
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only refactoring.

}

/* If project is under a district and user changes the class, the district has to be removed or the
Expand Down Expand Up @@ -520,7 +520,11 @@ const ProjectForm = () => {
{/* SECTION 7 - PROJECT PROGRAM */}
<ProjectProgramSection {...formProps} isUserOnlyViewer={isOnlyViewer} />
{/* BANNER */}
{!isOnlyViewer && <ProjectFormBanner onSubmit={submitCallback} isDirty={isDirty} />}
{!isOnlyViewer &&
<ProjectFormBanner
onSubmit={submitCallback}
isDirty={isDirty}
isInputDisabled={isInputDisabled} />}
</form>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ interface IProjectFormbannerProps {
| ((e?: BaseSyntheticEvent<object, unknown, unknown> | undefined) => Promise<void>)
| undefined;
isDirty: boolean;
isInputDisabled: boolean;
}

const ProjectFormBanner: FC<IProjectFormbannerProps> = ({ onSubmit, isDirty }) => {
const ProjectFormBanner: FC<IProjectFormbannerProps> = ({ onSubmit, isDirty, isInputDisabled }) => {
const dispatch = useAppDispatch();
const startYear = useAppSelector(selectStartYear);
const { t } = useTranslation();
Expand Down Expand Up @@ -61,7 +62,7 @@ const ProjectFormBanner: FC<IProjectFormbannerProps> = ({ onSubmit, isDirty }) =
{/** Add logic for disabling button later based on user type */}
<Button
data-testid={'open-delete-project-dialog-button'}
disabled={false}
disabled={isInputDisabled}
iconStart={<IconTrash />}
variant={ButtonVariant.Supplementary}
onClick={handleProjectDelete}
Expand Down
5 changes: 3 additions & 2 deletions src/components/shared/OverrunRightField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ interface IOverrunRightField {
control: HookFormControlType;
readOnly?: boolean;
cancelEdit?: boolean;
isInputDisabled: boolean;
}
const OverrunRightField: FC<IOverrunRightField> = ({ readOnly, control, cancelEdit }) => {
const OverrunRightField: FC<IOverrunRightField> = ({ readOnly, control, cancelEdit, isInputDisabled }) => {
const [editing, setEditing] = useState(false);
const { t } = useTranslation();

Expand All @@ -36,7 +37,7 @@ const OverrunRightField: FC<IOverrunRightField> = ({ readOnly, control, cancelEd
<FormFieldLabel
text={t('overrunRightValue', { value: field.value })}
onClick={!readOnly ? handleSetEditing : undefined}
disabled={readOnly}
disabled={isInputDisabled}
/>
</div>
{editing && (
Expand Down