From dcc5ee7dca0a2b53323ba86afd630b342d0da3f1 Mon Sep 17 00:00:00 2001 From: Juha Kovero Date: Tue, 15 Sep 2020 15:50:55 +0300 Subject: [PATCH 01/16] plot application template --- .../attributes/PlotApplicationsAttributes.js | 0 src/components/sideMenu/SideMenu.js | 26 ++++++++-- src/plotApplications/actions.js | 0 .../attributes-mock-data.json | 3 ++ .../components/PlotApplicationsListPage.js | 46 ++++++++++++++++++ .../components/PlotApplicationsPage.js | 47 +++++++++++++++++++ src/plotApplications/constants.js | 0 src/plotApplications/enums.js | 0 src/plotApplications/formValidators.js | 0 src/plotApplications/helpers.js | 0 src/plotApplications/mock-data.json | 3 ++ src/plotApplications/reducer.js | 0 src/plotApplications/requests.js | 0 src/plotApplications/saga.js | 0 src/plotApplications/selectors.js | 0 src/plotApplications/spec.js | 0 src/plotApplications/types.js | 0 src/root/routes.js | 6 +++ 18 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 src/components/attributes/PlotApplicationsAttributes.js create mode 100644 src/plotApplications/actions.js create mode 100644 src/plotApplications/attributes-mock-data.json create mode 100644 src/plotApplications/components/PlotApplicationsListPage.js create mode 100644 src/plotApplications/components/PlotApplicationsPage.js create mode 100644 src/plotApplications/constants.js create mode 100644 src/plotApplications/enums.js create mode 100644 src/plotApplications/formValidators.js create mode 100644 src/plotApplications/helpers.js create mode 100644 src/plotApplications/mock-data.json create mode 100644 src/plotApplications/reducer.js create mode 100644 src/plotApplications/requests.js create mode 100644 src/plotApplications/saga.js create mode 100644 src/plotApplications/selectors.js create mode 100644 src/plotApplications/spec.js create mode 100644 src/plotApplications/types.js diff --git a/src/components/attributes/PlotApplicationsAttributes.js b/src/components/attributes/PlotApplicationsAttributes.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/components/sideMenu/SideMenu.js b/src/components/sideMenu/SideMenu.js index a13122140..4e64501cd 100644 --- a/src/components/sideMenu/SideMenu.js +++ b/src/components/sideMenu/SideMenu.js @@ -188,21 +188,39 @@ class SideMenu extends Component {
  • Muistettavat ehdot
  • -
  • Vuokrausperiaatteet
  • Tilastot ja raportit
  • -
  • Tonttihaut
  • -
  • Täydennysrakentamiskorvaukset
  • Maankäyttösopimukset
  • - + + + { + _isMounted: boolean + + state = { + } + + static contextTypes = { + router: PropTypes.object, + }; + + componentDidMount() { + } + + render() { + return ( + + + ); + } +} + + +export default flowRight( + withRouter, + connect( + () => { + return { + }; + } + ), +)(PlotApplicationsListPage); diff --git a/src/plotApplications/components/PlotApplicationsPage.js b/src/plotApplications/components/PlotApplicationsPage.js new file mode 100644 index 000000000..1b0313c33 --- /dev/null +++ b/src/plotApplications/components/PlotApplicationsPage.js @@ -0,0 +1,47 @@ +// @flow +import React, {Component} from 'react'; +import PropTypes from 'prop-types'; +import {connect} from 'react-redux'; +import {withRouter} from 'react-router'; +import flowRight from 'lodash/flowRight'; + +import FullWidthContainer from '$components/content/FullWidthContainer'; + +type Props = { +} + +type State = { +} + +class PlotApplicationsPage extends Component { + state = { + activeTab: 0, + isRestoreModalOpen: false, + } + + static contextTypes = { + router: PropTypes.object, + }; + + timerAutoSave: any + + componentDidMount() { + } + + render() { + return( + + + ); + } +} + +export default flowRight( + withRouter, + connect( + () => { + return { + }; + } + ), +)(PlotApplicationsPage); diff --git a/src/plotApplications/constants.js b/src/plotApplications/constants.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/plotApplications/enums.js b/src/plotApplications/enums.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/plotApplications/formValidators.js b/src/plotApplications/formValidators.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/plotApplications/helpers.js b/src/plotApplications/helpers.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/plotApplications/mock-data.json b/src/plotApplications/mock-data.json new file mode 100644 index 000000000..077404aaa --- /dev/null +++ b/src/plotApplications/mock-data.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/src/plotApplications/reducer.js b/src/plotApplications/reducer.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/plotApplications/requests.js b/src/plotApplications/requests.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/plotApplications/saga.js b/src/plotApplications/saga.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/plotApplications/selectors.js b/src/plotApplications/selectors.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/plotApplications/spec.js b/src/plotApplications/spec.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/plotApplications/types.js b/src/plotApplications/types.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/root/routes.js b/src/root/routes.js index 3b89501ec..9287a94b7 100644 --- a/src/root/routes.js +++ b/src/root/routes.js @@ -23,7 +23,9 @@ import NewContactPage from '$src/contacts/components/NewContactPage'; import NewInfillDevelopmentPage from '$src/infillDevelopment/components/NewInfillDevelopmentPage'; import NewRentBasisPage from '$src/rentbasis/components/NewRentBasisPage'; import PlotSearchListPage from '$src/plotSearch/components/PlotSearchListPage'; +import PlotApplicationsListPage from '$src/plotApplications/components/PlotApplicationsListPage'; import PlotSearchPage from '$src/plotSearch/components/PlotSearchPage'; +import PlotApplicationsPage from '$src/plotApplications/components/PlotApplicationsPage'; import RentBasisListPage from '$src/rentbasis/components/RentBasisListPage'; import RentBasisPage from '$src/rentbasis/components/RentBasisPage'; import SapInvoicesListPage from '$src/sapInvoice/components/SapInvoicesListPage'; @@ -50,6 +52,7 @@ export const Routes = { LEASEHOLD_TRANSFER: 'leasehold_transfer', LOGOUT: 'logout', PLOT_SEARCH: 'plotSearch', + PLOT_APPLICATIONS: 'plotApplications', RENT_BASIS: 'rent_basis', RENT_BASIS_NEW: 'rent_basis_new', SAP_INVOICES: 'sap_invoices', @@ -79,6 +82,7 @@ export const getRouteById = (id: string): string => { [Routes.LEASEHOLD_TRANSFER]: '/vuokraoikeudensiirrot', [Routes.LOGOUT]: '/logout', [Routes.PLOT_SEARCH]: '/tonttihaku', + [Routes.PLOT_APPLICATIONS]: '/tonttihakemukset', [Routes.RENT_BASIS]: '/vuokrausperusteet', [Routes.RENT_BASIS_NEW]: '/uusivuokrausperuste', [Routes.SAP_INVOICES]: '/saplaskut', @@ -118,6 +122,8 @@ export default + + ; From 4aa841914ee4ae9197ae3b6ee068aff31bf4b580 Mon Sep 17 00:00:00 2001 From: Juha Kovero Date: Tue, 29 Sep 2020 12:54:05 +0300 Subject: [PATCH 02/16] plot applications --- .../attributes/PlotApplicationsAttributes.js | 58 ++++++++ src/enums.js | 2 + src/plotApplications/actions.js | 31 ++++ .../attributes-mock-data.json | 20 ++- .../components/CreatePlotApplicationForm.js | 107 +++++++++++++ .../components/CreatePlotApplicationsModal.js | 49 ++++++ .../components/PlotApplicationsListPage.js | 140 +++++++++++++++++- .../components/search/Search.js | 101 +++++++++++++ src/plotApplications/mock-data.json | 9 +- src/plotApplications/reducer.js | 49 ++++++ src/plotApplications/saga.js | 38 +++++ src/plotApplications/selectors.js | 22 +++ src/plotApplications/types.js | 21 +++ .../components/CreatePlotSearchModal.js | 2 +- src/root/createRootReducer.js | 2 + src/root/createRootSaga.js | 2 + src/root/types.js | 2 + 17 files changed, 648 insertions(+), 7 deletions(-) create mode 100644 src/plotApplications/components/CreatePlotApplicationForm.js create mode 100644 src/plotApplications/components/CreatePlotApplicationsModal.js create mode 100644 src/plotApplications/components/search/Search.js diff --git a/src/components/attributes/PlotApplicationsAttributes.js b/src/components/attributes/PlotApplicationsAttributes.js index e69de29bb..8fdc68d55 100644 --- a/src/components/attributes/PlotApplicationsAttributes.js +++ b/src/components/attributes/PlotApplicationsAttributes.js @@ -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 { + componentDidMount() { + const { + fetchPlotApplicationsAttributes, + isFetchingPlotApplicationsAttributes, + plotApplicationsAttributes, + } = this.props; + + if(!isFetchingPlotApplicationsAttributes && !plotApplicationsAttributes) { + fetchPlotApplicationsAttributes(); + } + } + + render() { + return ; + } + }; +} + +const withPlotApplicationsAttributes = flowRight( + connect( + (state) => { + return{ + plotApplicationsAttributes: getPlotApplicationsAttributes(state), + isFetchingPlotApplicationsAttributes: getIsFetchingPlotApplicationsAttributes(state), + plotApplicationsMethods: getPlotApplicationsMethods(state), + }; + }, + { + fetchPlotApplicationsAttributes, + }, + ), + PlotApplicationsAttributes, +); + +export {withPlotApplicationsAttributes}; diff --git a/src/enums.js b/src/enums.js index d7d8d353d..68b3b6f1a 100644 --- a/src/enums.js +++ b/src/enums.js @@ -439,6 +439,8 @@ 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', }; /** diff --git a/src/plotApplications/actions.js b/src/plotApplications/actions.js index e69de29bb..10166374e 100644 --- a/src/plotApplications/actions.js +++ b/src/plotApplications/actions.js @@ -0,0 +1,31 @@ +// @flow +import {createAction} from 'redux-actions'; +import type {Attributes, Methods} from '../types'; + +import type { + FetchPlotApplicationsListAction, + ReceivePlotApplicationsListAction, + PlotApplicationsList, + ReceiveMethodsAction, + AttributesNotFoundAction, + ReceiveAttributesAction, + FetchAttributesAction, +} from './types'; + +export const fetchPlotApplicationsList = (search: string): FetchPlotApplicationsListAction => + createAction('mvj/plotApplications/FETCH_ALL')(search); + +export const receivePlotApplicationsList = (list: PlotApplicationsList): ReceivePlotApplicationsListAction => + createAction('mvj/plotApplications/RECEIVE_ALL')(list); + +export const fetchAttributes = (): FetchAttributesAction => + createAction('mvj/plotApplications/FETCH_ATTRIBUTES')(); + +export const receiveMethods = (methods: Methods): ReceiveMethodsAction => + createAction('mvj/plotApplications/RECEIVE_METHODS')(methods); + +export const attributesNotFound = (): AttributesNotFoundAction => + createAction('mvj/plotApplications/ATTRIBUTES_NOT_FOUND')(); + +export const receiveAttributes = (attributes: Attributes): ReceiveAttributesAction => + createAction('mvj/plotApplications/RECEIVE_ATTRIBUTES')(attributes); diff --git a/src/plotApplications/attributes-mock-data.json b/src/plotApplications/attributes-mock-data.json index 0e0dcd235..626a7e75c 100644 --- a/src/plotApplications/attributes-mock-data.json +++ b/src/plotApplications/attributes-mock-data.json @@ -1,3 +1,21 @@ { - + "name": "PlotSearch list", + "description": "", + "fields": { + "name": { + "type": "string", + "required": true, + "read_only": false, + "label": "Nimi" + } + }, + "methods": { + "DELETE": true, + "GET": true, + "HEAD": true, + "OPTIONS": true, + "PATCH": true, + "POST": true, + "PUT": true + } } \ No newline at end of file diff --git a/src/plotApplications/components/CreatePlotApplicationForm.js b/src/plotApplications/components/CreatePlotApplicationForm.js new file mode 100644 index 000000000..5a6585ae8 --- /dev/null +++ b/src/plotApplications/components/CreatePlotApplicationForm.js @@ -0,0 +1,107 @@ +// @flow +import React, {Component} from 'react'; +import {connect} from 'react-redux'; +import {change, formValueSelector, reduxForm} from 'redux-form'; +import {Row, Column} from 'react-foundation'; +import flowRight from 'lodash/flowRight'; +import get from 'lodash/get'; + +import Button from '$components/button/Button'; +import FormField from '$components/form/FormField'; +import ModalButtonWrapper from '$components/modal/ModalButtonWrapper'; +import {FormNames} from '$src/enums'; +import {ButtonColors} from '$components/enums'; +import {getAttributes} from '$src/plotApplications/selectors'; + +import type {Attributes} from '$src/types'; + +type Props = { + attributes: Attributes, + change: Function, + onClose: Function, + onSubmit: Function, + valid: boolean, + name: string, +} + +class CreatePlotApplicationsForm extends Component { + firstField: any + + setRefForFirstField = (element: any) => { + this.firstField = element; + } + + setFocus = () => { + if(this.firstField) { + this.firstField.focus(); + } + } + + handleCreate = () => { + const { + onSubmit, + name, + } = this.props; + + onSubmit({ + name: name, + }); + }; + + render() { + const { + attributes, + onClose, + valid, + } = this.props; + + return ( +
    + + + + + + +