Skip to content

Commit

Permalink
Merge pull request #323 from City-of-Helsinki/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
kovedev committed Nov 30, 2020
2 parents 12f1bff + 622eff8 commit 9ed29b1
Show file tree
Hide file tree
Showing 49 changed files with 2,973 additions and 394 deletions.
58 changes: 58 additions & 0 deletions src/components/attributes/PlotApplicationsAttributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// @flow
import React, {PureComponent} from 'react';
import {connect} from 'react-redux';
import flowRight from 'lodash/flowRight';

import {fetchAttributes as fetchPlotApplicationsAttributes} from '$src/plotApplications/actions';
import {
getAttributes as getPlotApplicationsAttributes,
getIsFetchingAttributes as getIsFetchingPlotApplicationsAttributes,
getPlotApplicationsMethods,
} from '$src/plotApplications/selectors';

import type {Attributes, Methods} from '$src/types';

function PlotApplicationsAttributes(WrappedComponent: any) {
type Props = {
fetchPlotApplicationsAttributes: Function,
isFetchingPlotApplicationsAttributes: boolean,
plotApplicationsAttributes: Attributes,
plotApplicationsMethods: Methods,
}

return class PlotApplicationsAttributes extends PureComponent<Props> {
componentDidMount() {
const {
fetchPlotApplicationsAttributes,
isFetchingPlotApplicationsAttributes,
plotApplicationsAttributes,
} = this.props;

if(!isFetchingPlotApplicationsAttributes && !plotApplicationsAttributes) {
fetchPlotApplicationsAttributes();
}
}

render() {
return <WrappedComponent {...this.props} />;
}
};
}

const withPlotApplicationsAttributes = flowRight(
connect(
(state) => {
return{
plotApplicationsAttributes: getPlotApplicationsAttributes(state),
isFetchingPlotApplicationsAttributes: getIsFetchingPlotApplicationsAttributes(state),
plotApplicationsMethods: getPlotApplicationsMethods(state),
};
},
{
fetchPlotApplicationsAttributes,
},
),
PlotApplicationsAttributes,
);

export {withPlotApplicationsAttributes};
19 changes: 18 additions & 1 deletion src/components/attributes/PlotSearchAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,29 @@ import React, {PureComponent} from 'react';
import {connect} from 'react-redux';
import flowRight from 'lodash/flowRight';

import {fetchAttributes as fetchPlotSearchAttributes} from '$src/plotSearch/actions';
import {
fetchAttributes as fetchPlotSearchAttributes,
fetchPlotSearchSubtypes,
} from '$src/plotSearch/actions';
import {
getAttributes as getPlotSearchAttributes,
getIsFetchingAttributes as getIsFetchingPlotSearchAttributes,
getPlotSearchMethods,
getPlotSearchSubTypes,
getIsFetching,
} from '$src/plotSearch/selectors';

import type {Attributes, Methods} from '$src/types';

function PlotSearchAttributes(WrappedComponent: any) {
type Props = {
fetchPlotSearchAttributes: Function,
fetchPlotSearchSubtypes: Function,
isFetchingPlotSearchAttributes: boolean,
isFetching: boolean,
plotSearchAttributes: Attributes,
plotSearchMethods: Methods,
plotSearchSubTypes: Object,
}

return class PlotSearchAttributes extends PureComponent<Props> {
Expand All @@ -26,11 +34,17 @@ function PlotSearchAttributes(WrappedComponent: any) {
fetchPlotSearchAttributes,
isFetchingPlotSearchAttributes,
plotSearchAttributes,
fetchPlotSearchSubtypes,
plotSearchSubTypes,
isFetching,
} = this.props;

if(!isFetchingPlotSearchAttributes && !plotSearchAttributes) {
fetchPlotSearchAttributes();
}
if(!isFetching && !plotSearchSubTypes) {
fetchPlotSearchSubtypes();
}
}

render() {
Expand All @@ -46,10 +60,13 @@ const withPlotSearchAttributes = flowRight(
plotSearchAttributes: getPlotSearchAttributes(state),
isFetchingPlotSearchAttributes: getIsFetchingPlotSearchAttributes(state),
plotSearchMethods: getPlotSearchMethods(state),
plotSearchSubTypes: getPlotSearchSubTypes(state),
isFetching: getIsFetching(state),
};
},
{
fetchPlotSearchAttributes,
fetchPlotSearchSubtypes,
},
),
PlotSearchAttributes,
Expand Down
26 changes: 22 additions & 4 deletions src/components/sideMenu/SideMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,39 @@ class SideMenu extends Component<Props, State> {
<li><Link onClick={handleClick} to={getRouteById(Routes.AREA_NOTES)}>Muistettavat ehdot</Link></li>
</Authorization>


<Authorization allow={hasPermissions(usersPermissions, UsersPermissions.VIEW_BASISOFRENT)}>
<li><Link onClick={handleClick} to={getRouteById(Routes.RENT_BASIS)}>Vuokrausperiaatteet</Link></li>
</Authorization>

<li><Link onClick={handleClick} to={getRouteById(Routes.LEASE_STATISTIC_REPORT)}>Tilastot ja raportit</Link></li>

<li><Link style={{color: '#b7b7b7'}} ref={this.setLinkRef} onClick={handleClick} to={getRouteById(Routes.PLOT_SEARCH)}>Tonttihaut</Link></li>

<Authorization allow={hasPermissions(usersPermissions, UsersPermissions.VIEW_INFILLDEVELOPMENTCOMPENSATION)}>
<li><Link style={{color: '#b7b7b7'}} onClick={handleClick} to={getRouteById(Routes.INFILL_DEVELOPMENTS)}>Täydennysrakentamiskorvaukset</Link></li>
</Authorization>

<li><Link style={{color: '#b7b7b7'}} onClick={handleClick} to={getRouteById(Routes.LAND_USE_CONTRACTS)}>Maankäyttösopimukset</Link></li>


<SubMenu
header='Tonttihaut ja kilpailut'
isOpen={subMenuKey === 'plot'}
items={[
{
allow: true,
onClick: handleClick,
text: 'Tonttihaut',
to: getRouteById(Routes.PLOT_SEARCH),
},
{
allow: true,
onClick: handleClick,
text: 'Tonttihakemukset',
to: getRouteById(Routes.PLOT_APPLICATIONS),
},
]}
menuKey='plot'
onHeaderClick={this.handleHeaderClick}
/>

<Authorization allow={hasPermissions(usersPermissions, UsersPermissions.ADD_LEASEBASISOFRENT) ||
hasPermissions(usersPermissions, UsersPermissions.VIEW_INDEX) ||
hasPermissions(usersPermissions, UsersPermissions.VIEW_JOBRUN) ||
Expand Down
9 changes: 9 additions & 0 deletions src/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ export const ConfirmationModalTexts = {
LABEL: 'Haluatko varmasti poistaa tonttihaun?',
TITLE: 'Poista tonttihaku',
},
DELETE_PLOT_APPLICATION: {
BUTTON: 'Poista tonttihakemus',
LABEL: 'Haluatko varmasti poistaa tonttihakemuksen?',
TITLE: 'Poista tonttihakemus',
},
};

/**
Expand Down Expand Up @@ -440,6 +445,9 @@ export const FormNames = {
TRADE_REGISTER_SEARCH: 'trade-register-search-form',
PLOT_SEARCH_BASIC_INFORMATION: 'plot-search-basic-information-form',
PLOT_SEARCH_APPLICATION: 'plot-search-application-form',
PLOT_APPLICATIONS_CREATE: 'plot-application-create-form',
PLOT_APPLICATIONS_SEARCH: 'plot-application-search',
PLOT_APPLICATION: 'plot-application',
};

/**
Expand All @@ -464,5 +472,6 @@ export const PermissionMissingTexts = {
STATISTICS_AND_REPORTS: 'Ei oikeuksia tilastoihin ja raportteihin',
TRADE_REGISTER: 'Ei oikeuksia kaupparekisteriotteisiin',
PLOT_SEARCH: 'Ei oikeuksia tonttihakuun',
PLOT_APPLICATIONS: 'Ei oikeuksia tonttihakukemusiin',
LAND_USE_CONTRACTS: 'Ei oikeuksia maankäyttösopimuksiin',
};
2 changes: 0 additions & 2 deletions src/leases/components/leaseSections/leaseArea/LeaseArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ const LeaseArea = ({
<Column small={0} large={6}>
{/* silence is golden */}
</Column>
{console.log(area)}
<Column small={12} large={6}>
<Collapse
className='collapse__secondary'
Expand All @@ -345,7 +344,6 @@ const LeaseArea = ({
</BoxItemContainer>
</Collapse>
</Column>
{console.log(area)}
</Row>
</Authorization>
</Fragment>
Expand Down
10 changes: 9 additions & 1 deletion src/leases/components/leaseSections/leaseArea/PlanUnitItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,22 @@ const PlanUnitItem = ({
return (
<BoxItem className='no-border-on-first-child no-border-on-last-child'>
<Row>
<Column small={12} medium={9} large={9}>
<Column small={12} medium={8} large={8}>
<Authorization allow={isFieldAllowedToRead(attributes, LeasePlanUnitsFieldPaths.IDENTIFIER)}>
<FormTextTitle uiDataKey={getUiDataLeaseKey(LeasePlanUnitsFieldPaths.IDENTIFIER)}>
{LeasePlanUnitsFieldTitles.IDENTIFIER}
</FormTextTitle>
<FormText>{planUnit.identifier || '-'}</FormText>
</Authorization>
</Column>
<Column small={12} medium={2} large={2}>
<Authorization allow={isFieldAllowedToRead(attributes, LeasePlanUnitsFieldPaths.IS_MASTER)}>
<FormTextTitle uiDataKey={getUiDataLeaseKey(LeasePlanUnitsFieldPaths.IS_MASTER)}>
{LeasePlanUnitsFieldTitles.IS_MASTER}
</FormTextTitle>
<FormText>{planUnit.is_master ? 'Kyllä' : 'Ei'}</FormText>
</Authorization>
</Column>
<Column small={12} medium={3} large={3}>
<Authorization allow={isFieldAllowedToRead(attributes, LeasePlanUnitsFieldPaths.GEOMETRY)}>
{!areaArchived && !isEmpty(planUnit.geometry) &&
Expand Down
Loading

0 comments on commit 9ed29b1

Please sign in to comment.