️ This Gitlab will be shut down at 2021-12-31 23:59:59.
Students and staff can migrate to gitlab.utwente.nl.
SNT members can migrate to gitlab.snt.utwente.nl.
Contact bestuur@snt.utwente.nl for more information.

Migrate your projects today!
Export your project using the webinterface or use a script.

Commit da53c149 authored by TJHeeringa's avatar TJHeeringa

Various stuff and statistics

parent 1349df25
......@@ -2070,6 +2070,32 @@
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.3.3.tgz",
"integrity": "sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow=="
},
"@types/d3-path": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-2.0.1.tgz",
"integrity": "sha512-6K8LaFlztlhZO7mwsZg7ClRsdLg3FJRzIIi6SZXDWmmSJc2x8dd2VkESbLXdk3p8cuvz71f36S0y8Zv2AxqvQw=="
},
"@types/d3-scale": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/@types/d3-scale/-/d3-scale-3.3.2.tgz",
"integrity": "sha512-gGqr7x1ost9px3FvIfUMi5XA/F/yAf4UkUDtdQhpH92XCT0Oa7zkkRzY61gPVJq+DxpHn/btouw5ohWkbBsCzQ==",
"requires": {
"@types/d3-time": "^2"
}
},
"@types/d3-shape": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/@types/d3-shape/-/d3-shape-2.1.3.tgz",
"integrity": "sha512-HAhCel3wP93kh4/rq+7atLdybcESZ5bRHDEZUojClyZWsRuEMo3A52NGYJSh48SxfxEU6RZIVbZL2YFZ2OAlzQ==",
"requires": {
"@types/d3-path": "^2"
}
},
"@types/d3-time": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-2.1.1.tgz",
"integrity": "sha512-9MVYlmIgmRR31C5b4FVSWtuMmBHh2mOWQYfl7XAYOa8dsnb7iEmUmRSWSFgXFtkjxO65d7hTUHQC+RhR/9IWFg=="
},
"@types/eslint-visitor-keys": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
......@@ -2193,6 +2219,11 @@
"@types/react": "*"
}
},
"@types/resize-observer-browser": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/@types/resize-observer-browser/-/resize-observer-browser-0.1.6.tgz",
"integrity": "sha512-61IfTac0s9jvNtBCpyo86QeaN8qqpMGHdK0uGKCCIy2dt5/Yk84VduHIdWAcmkC5QvdkPL0p5eWYgUZtHKKUVg=="
},
"@types/stack-utils": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz",
......@@ -5189,6 +5220,11 @@
}
}
},
"css-unit-converter": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/css-unit-converter/-/css-unit-converter-1.1.2.tgz",
"integrity": "sha512-IiJwMC8rdZE0+xiEZHeru6YoONC4rfPMqGm2W85jMIbkFvv5nFTwJVFHam2eFrN6txmoUYFAFXiv8ICVeTO0MA=="
},
"css-vendor": {
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/css-vendor/-/css-vendor-2.0.8.tgz",
......@@ -5353,6 +5389,73 @@
"type": "^1.0.1"
}
},
"d3-array": {
"version": "2.12.1",
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.12.1.tgz",
"integrity": "sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ==",
"requires": {
"internmap": "^1.0.0"
}
},
"d3-color": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/d3-color/-/d3-color-2.0.0.tgz",
"integrity": "sha512-SPXi0TSKPD4g9tw0NMZFnR95XVgUZiBH+uUTqQuDu1OsE2zomHU7ho0FISciaPvosimixwHFl3WHLGabv6dDgQ=="
},
"d3-format": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/d3-format/-/d3-format-2.0.0.tgz",
"integrity": "sha512-Ab3S6XuE/Q+flY96HXT0jOXcM4EAClYFnRGY5zsjRGNy6qCYrQsMffs7cV5Q9xejb35zxW5hf/guKw34kvIKsA=="
},
"d3-interpolate": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-2.0.1.tgz",
"integrity": "sha512-c5UhwwTs/yybcmTpAVqwSFl6vrQ8JZJoT5F7xNFK9pymv5C0Ymcc9/LIJHtYIggg/yS9YHw8i8O8tgb9pupjeQ==",
"requires": {
"d3-color": "1 - 2"
}
},
"d3-path": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/d3-path/-/d3-path-2.0.0.tgz",
"integrity": "sha512-ZwZQxKhBnv9yHaiWd6ZU4x5BtCQ7pXszEV9CU6kRgwIQVQGLMv1oiL4M+MK/n79sYzsj+gcgpPQSctJUsLN7fA=="
},
"d3-scale": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-3.3.0.tgz",
"integrity": "sha512-1JGp44NQCt5d1g+Yy+GeOnZP7xHo0ii8zsQp6PGzd+C1/dl0KGsp9A7Mxwp+1D1o4unbTTxVdU/ZOIEBoeZPbQ==",
"requires": {
"d3-array": "^2.3.0",
"d3-format": "1 - 2",
"d3-interpolate": "1.2.0 - 2",
"d3-time": "^2.1.1",
"d3-time-format": "2 - 3"
}
},
"d3-shape": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-2.1.0.tgz",
"integrity": "sha512-PnjUqfM2PpskbSLTJvAzp2Wv4CZsnAgTfcVRTwW03QR3MkXF8Uo7B1y/lWkAsmbKwuecto++4NlsYcvYpXpTHA==",
"requires": {
"d3-path": "1 - 2"
}
},
"d3-time": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/d3-time/-/d3-time-2.1.1.tgz",
"integrity": "sha512-/eIQe/eR4kCQwq7yxi7z4c6qEXf2IYGcjoWB5OOQy4Tq9Uv39/947qlDcN2TLkiTzQWzvnsuYPB9TrWaNfipKQ==",
"requires": {
"d3-array": "2"
}
},
"d3-time-format": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-3.0.0.tgz",
"integrity": "sha512-UXJh6EKsHBTjopVqZBhFysQcoXSv/5yLONZvkQ5Kk3qbwiUYkdX17Xa1PT6U1ZWXGGfB1ey5L8dKMlFq2DO0Ag==",
"requires": {
"d3-time": "1 - 2"
}
},
"damerau-levenshtein": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.6.tgz",
......@@ -5416,6 +5519,11 @@
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA="
},
"decimal.js-light": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/decimal.js-light/-/decimal.js-light-2.5.1.tgz",
"integrity": "sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg=="
},
"decode-uri-component": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
......@@ -6928,6 +7036,11 @@
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
},
"fast-equals": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-2.0.3.tgz",
"integrity": "sha512-0EMw4TTUxsMDpDkCg0rXor2gsg+npVrMIHbEhvD0HZyIhUX6AktC/yasm+qKwfyswd06Qy95ZKk8p2crTo0iPA=="
},
"fast-glob": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-2.2.7.tgz",
......@@ -8614,6 +8727,11 @@
"side-channel": "^1.0.2"
}
},
"internmap": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/internmap/-/internmap-1.0.1.tgz",
"integrity": "sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw=="
},
"invariant": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
......@@ -10588,6 +10706,11 @@
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
"integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY="
},
"lodash.debounce": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
"integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168="
},
"lodash.defaults": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz",
......@@ -10680,6 +10803,11 @@
"lodash._reinterpolate": "^3.0.0"
}
},
"lodash.throttle": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz",
"integrity": "sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ="
},
"lodash.union": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.union/-/lodash.union-4.6.0.tgz",
......@@ -17500,6 +17628,17 @@
}
}
},
"react-resize-detector": {
"version": "6.7.6",
"resolved": "https://registry.npmjs.org/react-resize-detector/-/react-resize-detector-6.7.6.tgz",
"integrity": "sha512-/6RZlul1yePSoYJxWxmmgjO320moeLC/khrwpEVIL+D2EjLKhqOwzFv+H8laMbImVj7Zu4FlMa0oA7au3/ChjQ==",
"requires": {
"@types/resize-observer-browser": "^0.1.6",
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
"resize-observer-polyfill": "^1.5.1"
}
},
"react-router": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-5.2.0.tgz",
......@@ -17703,6 +17842,37 @@
"throttle-debounce": "^2.1.0"
}
},
"react-smooth": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/react-smooth/-/react-smooth-2.0.0.tgz",
"integrity": "sha512-wK4dBBR6P21otowgMT9toZk+GngMplGS1O5gk+2WSiHEXIrQgDvhR5IIlT74Vtu//qpTcipkgo21dD7a7AUNxw==",
"requires": {
"fast-equals": "^2.0.0",
"raf": "^3.4.0",
"react-transition-group": "2.9.0"
},
"dependencies": {
"dom-helpers": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.4.0.tgz",
"integrity": "sha512-LnuPJ+dwqKDIyotW1VzmOZ5TONUN7CwkCR5hrgawTUbkBGYdeoNLZo6nNfGkCrjtE1nXXaj7iMMpDa8/d9WoIA==",
"requires": {
"@babel/runtime": "^7.1.2"
}
},
"react-transition-group": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-2.9.0.tgz",
"integrity": "sha512-+HzNTCHpeQyl4MJ/bdE0u6XRMe9+XG/+aL4mCxVN4DnPBQ0/5bfHWPDuOZUzYdMj94daZaZdCCc1Dzt9R/xSSg==",
"requires": {
"dom-helpers": "^3.4.0",
"loose-envify": "^1.4.0",
"prop-types": "^15.6.2",
"react-lifecycles-compat": "^3.0.4"
}
}
}
},
"react-spinkit": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/react-spinkit/-/react-spinkit-3.0.0.tgz",
......@@ -17818,6 +17988,41 @@
"util.promisify": "^1.0.0"
}
},
"recharts": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/recharts/-/recharts-2.1.0.tgz",
"integrity": "sha512-Eq2AlhaLmYL8DMNXkGMAylgGvNmHFdb6BDmN3pAK31s9ty4P9ApYrpKJ1eW3222nayQxoaMJHxcxoaswo5AuqA==",
"requires": {
"@types/d3-scale": "^3.0.0",
"@types/d3-shape": "^2.0.0",
"classnames": "^2.2.5",
"d3-interpolate": "^2.0.1",
"d3-scale": "^3.2.3",
"d3-shape": "^2.0.0",
"eventemitter3": "^4.0.1",
"lodash": "^4.17.19",
"react-is": "16.10.2",
"react-resize-detector": "^6.6.3",
"react-smooth": "^2.0.0",
"recharts-scale": "^0.4.4",
"reduce-css-calc": "^2.1.8"
},
"dependencies": {
"react-is": {
"version": "16.10.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.10.2.tgz",
"integrity": "sha512-INBT1QEgtcCCgvccr5/86CfD71fw9EPmDxgiJX4I2Ddr6ZsV6iFXsuby+qWJPtmNuMY0zByTsG4468P7nHuNWA=="
}
}
},
"recharts-scale": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/recharts-scale/-/recharts-scale-0.4.5.tgz",
"integrity": "sha512-kivNFO+0OcUNu7jQquLXAxz1FIwZj8nrj+YkOKc5694NbjCvcT6aSZiIzNzd2Kul4o4rTto8QVR9lMNtxD4G1w==",
"requires": {
"decimal.js-light": "^2.4.1"
}
},
"recursive-readdir": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz",
......@@ -17835,6 +18040,22 @@
"strip-indent": "^1.0.1"
}
},
"reduce-css-calc": {
"version": "2.1.8",
"resolved": "https://registry.npmjs.org/reduce-css-calc/-/reduce-css-calc-2.1.8.tgz",
"integrity": "sha512-8liAVezDmUcH+tdzoEGrhfbGcP7nOV4NkGE3a74+qqvE7nt9i4sKLGBuZNOnpI4WiGksiNPklZxva80061QiPg==",
"requires": {
"css-unit-converter": "^1.1.1",
"postcss-value-parser": "^3.3.0"
},
"dependencies": {
"postcss-value-parser": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz",
"integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ=="
}
}
},
"reftools": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/reftools/-/reftools-1.1.5.tgz",
......
......@@ -37,10 +37,10 @@ import { ValidatorForm } from "react-material-ui-form-validator";
import FontAwesomeIconHolder from "../Fields/FontAwesomeIconHolder";
export const AssociationForm = ({ association, handleChange, onUpdate, onCancel }) => {
export const AssociationForm = ({ association, handleChange, onSubmit, onCancel }) => {
return (
<ValidatorForm
onSubmit={onUpdate}
onSubmit={onSubmit}
onError={errors => console.log(errors)}
>
<Typography variant={"h5"}>General</Typography>
......@@ -296,7 +296,7 @@ AssociationForm.propTypes = {
association: PropTypes.object.isRequired,
handleChange: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired,
onUpdate: PropTypes.func.isRequired
onSubmit: PropTypes.func.isRequired
};
export default AssociationForm;
\ No newline at end of file
import Button from "@material-ui/core/Button";
import Wrapper from "App/Components/Fields/Wrapper";
import PropTypes from "prop-types";
import React from "react";
import { ValidatorForm } from "react-material-ui-form-validator";
export const GenericInfoFormForm = ({ Form, formObject, handleFormObjectChange, onSubmit, onCancel, allowDelete, submitButtonText }) => {
return (
<ValidatorForm
onSubmit={onSubmit}
onError={errors => console.log(errors)}
>
<Form formObject={formObject} handleFormObjectChange={handleFormObjectChange}/>
<Wrapper>
<div>
<Button variant={"outlined"} color={"secondary"} disabled={!allowDelete}>
Delete
</Button>
</div>
<div>
<Button type={"submit"} variant={"contained"} color={"primary"}>{ submitButtonText }</Button>
&nbsp;
<Button variant={"contained"} onClick={onCancel}>Cancel</Button>
</div>
</Wrapper>
</ValidatorForm>
);
};
GenericInfoFormForm.propTypes = {
Form: PropTypes.elementType.isRequired,
formObject: PropTypes.object.isRequired,
handleFormObjectChange: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired,
allowDelete: PropTypes.bool.isRequired,
submitButtonText: PropTypes.string
};
GenericInfoFormForm.defaultProps = {
submitButtonText: "save"
}
export default GenericInfoFormForm;
\ No newline at end of file
......@@ -3,6 +3,9 @@ import MenuItem from "@material-ui/core/MenuItem";
import Typography from "@material-ui/core/Typography";
import AccountTreeIcon from "@material-ui/icons/AccountTree";
import AnnouncementIcon from "@material-ui/icons/Announcement";
import BeachAccessIcon from "@material-ui/icons/BeachAccess";
import BookmarksIcon from "@material-ui/icons/Bookmarks";
import CalendarToday from "@material-ui/icons/CalendarToday";
import ContactsIcon from "@material-ui/icons/Contacts";
import Create from "@material-ui/icons/Create";
import DescriptionIcon from "@material-ui/icons/Description";
......@@ -11,11 +14,12 @@ import EmailIcon from "@material-ui/icons/Email";
import EventAvailableIcon from "@material-ui/icons/EventAvailable";
import EventBusyIcon from "@material-ui/icons/EventBusy";
import PhotoIcon from "@material-ui/icons/Photo";
import RemoveIcon from "@material-ui/icons/Remove";
import PropTypes from "prop-types";
import React from "react";
import { ValidatorForm } from "react-material-ui-form-validator";
import BeachAccessIcon from '@material-ui/icons/BeachAccess';
import BookmarksIcon from '@material-ui/icons/Bookmarks';
import {useLocation, useRouteMatch} from "react-router-dom";
import { useAlertHandler } from "../../Contexts/AlertHandler";
import {useAPI} from "../../Contexts/API";
import DateField from "../Fields/DateField";
......@@ -25,15 +29,12 @@ import NumberField from "../Fields/NumberField";
import SelectField from "../Fields/SelectField";
import TextField from "../Fields/TextField";
import Wrapper from "../Fields/Wrapper";
import {useLocation} from "react-router-dom";
import RemoveIcon from "@material-ui/icons/Remove";
import CalendarToday from "@material-ui/icons/CalendarToday";
export const GroupForm = ({ group, parentable_groups, handleGroupChange, update, deleteAllowed, onSucces, onCancel, onDelete}) => {
const API = useAPI();
const alerthandler = useAlertHandler();
const {pathname: path} = useLocation();
const { url } = useRouteMatch();
const handleSubmit = () => {
// make a copy of the group so that the null key operation don't accidentally change the group prop
......@@ -58,7 +59,7 @@ export const GroupForm = ({ group, parentable_groups, handleGroupChange, update,
const postGroup = (group) => {
let groupToBePosted = group;
delete groupToBePosted["permissions"];
if (path.includes("boards")) {
if (url.includes("boards")) {
groupToBePosted["board_group"] = true;
}
return API.callv3({
......@@ -86,7 +87,7 @@ export const GroupForm = ({ group, parentable_groups, handleGroupChange, update,
json_or_form_data: "form-data",
on_succes: (data) => {
alerthandler.handleAlertHandler("green", "Save successful");
onSucces(data);
onSucces({...data, groupmemberships: group.groupmemberships});
},
on_failure: () => {
alerthandler.handleAlertHandler("red", "Save failed");
......
......@@ -27,7 +27,7 @@ const SpecificDataFieldForm = ({ data_field: propDataField, association, onSucce
const handleDataChange = (field, value) => {
if (field === "mandatory" && value) {
setDataField(prevState => ({...prevState, "mandatory": true, "board_only": false, "default": ""}));
setDataField(prevState => ({...prevState, "mandatory": true, "board_only": false, "default": "False"}));
} else {
setDataField(prevState => ({...prevState, [field]: value}));
}
......@@ -163,6 +163,7 @@ const SpecificDataFieldForm = ({ data_field: propDataField, association, onSucce
name={"Default"}
value={data_field.default}
onChange={handleDataChange}
required
/>
</Wrapper>
}
......
......@@ -11,7 +11,7 @@ import SpecificDataField from "../Fields/SpecificDataField";
import Wrapper from "../Fields/Wrapper";
export const SpecificDataForm = ({ specificData: propSpecificData, association, membership, onUpdate }) => {
export const SpecificDataForm = ({ specificData: propSpecificData, association, membership, onUpdate, onCancel }) => {
const alerthandler = useAlertHandler();
const API = useAPI();
......@@ -91,6 +91,7 @@ export const SpecificDataForm = ({ specificData: propSpecificData, association,
};
const cancelDataChanges = () => {
setSpecificDataChanges({});
onCancel();
};
return (
......
......@@ -2,10 +2,20 @@ import Info from "App/Components/Info/Info";
import PropTypes from "prop-types";
import React, {useMemo} from "react";
import {useDataFields} from "../../Contexts/Members";
const SpecificData = ({ specific_data }) => {
const { collection: dataFields } = useDataFields();
const dataFieldToTypeDict = Object.fromEntries(dataFields.map(dataField=>[dataField.name, dataField.type]));
console.log(specific_data, dataFields);
const data = useMemo(()=>
Object.fromEntries(specific_data.map(sp=>[sp.name, sp.value]))
,[specific_data]);
Object.fromEntries(specific_data.map(sp=>[sp.name, dataFieldToTypeDict[sp.name] === "Boolean"
? (sp.value === "True" ? "Yes" : "No")
: sp.value
]))
,[specific_data, dataFieldToTypeDict]);
return (
<Info
......
......@@ -45,7 +45,7 @@ const AssociationInfoForm = ({ association, ...props }) => {
return (
<InfoForm
onUpdate={onUpdate}
onSubmit={onUpdate}
title={"About the association"}
infoFormObject={association}
infoOrForm={"info"}
......
......@@ -38,17 +38,17 @@ Group.propTypes = {
Group.defaultProps = {
group: {
association: null,
full_name: null,
short_name: null,
description: null,
number: null,
creed: null,
email: null,
founding_date: null,
dissolution_date: null,
photo: null,
parent_group: null
association: "",
full_name: "",
short_name: "",
description: "",
number: "",
creed: "",
email: "",
founding_date: "",
dissolution_date: "",
photo: "",
parent_group: ""
}
};
......
......@@ -10,7 +10,7 @@ import Block from "../PageLayout/Content/Block";
const dummyFunction = () => {};
const defaultFieldAndValueToStateChanges = (field, value, prevState) => ({...prevState, [field]: value});
const InfoForm = ({infoFormObject: propInfoFormObject, InfoComponent, FormComponent, fieldAndValueToStateChanges, title, onUpdate: propOnUpdate, onDelete: propOnDelete, onCreate: propOnCreate, onCancel: propOnCancel, initialInfoOrFormState, showInfoFormStateButton, ...props}) => {
const InfoForm = ({infoFormObject: propInfoFormObject, InfoComponent, FormComponent, fieldAndValueToStateChanges, title, onDelete: propOnDelete, onSubmit: propOnSubmit, initialInfoOrFormState, showInfoFormStateButton, MoreActionButtonGroup, enableDelete, ...props}) => {
const [infoFormObjectChanges, setInfoFormObjectChanges] = useState({});
const infoFormObject = {...propInfoFormObject, ...infoFormObjectChanges};
......@@ -24,20 +24,15 @@ const InfoForm = ({infoFormObject: propInfoFormObject, InfoComponent, FormCompon
toggleFormType();
setInfoFormObjectChanges({});
}, [toggleFormType, setInfoFormObjectChanges]);
const onUpdate = ()=>{
propOnUpdate(infoFormObject);
const onSubmit = ()=>{
propOnSubmit(infoFormObject);
baseCallback();
};
const onDelete = ()=>{
propOnDelete(infoFormObject);
baseCallback();
};
const onCreate = ()=>{
propOnCreate(infoFormObject);
baseCallback();
};
const onCancel = ()=>{
propOnCancel(infoFormObject);
baseCallback();
};
......@@ -47,6 +42,7 @@ const InfoForm = ({infoFormObject: propInfoFormObject, InfoComponent, FormCompon
<Wrapper>
<Typography variant={"h4"}>{ title }</Typography>
<div>
<MoreActionButtonGroup formType={formType} infoFormObject={infoFormObject}/>
{ showInfoFormStateButton && <Button color={"primary"} variant={"contained"} onClick={toggleFormType}>{ formType === "info" ? "Edit" : "View" }</Button> }
</div>
</Wrapper>
......@@ -61,10 +57,10 @@ const InfoForm = ({infoFormObject: propInfoFormObject, InfoComponent, FormCompon
<FormComponent
formObject={infoFormObject}
handleFormObjectChange={handleInfoFormObjectChange}
onCreate={onCreate}
onUpdate={onUpdate}
onSubmit={onSubmit}
onDelete={onDelete}
onCancel={onCancel}
enableDelete={enableDelete}
{...props}
/>
) }
......@@ -75,26 +71,25 @@ const InfoForm = ({infoFormObject: propInfoFormObject, InfoComponent, FormCompon
InfoForm.propTypes = {
initialInfoOrFormState: PropTypes.string,
showInfoFormStateButton: PropTypes.bool,
enableDelete: PropTypes.bool,
infoFormObject: PropTypes.object,
InfoComponent: PropTypes.elementType.isRequired,
FormComponent: PropTypes.elementType.isRequired,
fieldAndValueToStateChanges: PropTypes.func,
title: PropTypes.string.isRequired,
onCreate: PropTypes.func,
onUpdate: PropTypes.func,
onSubmit: PropTypes.func.isRequired,
onDelete: PropTypes.func,
onCancel: PropTypes.func
MoreActionButtonGroup: PropTypes.elementType
};
InfoForm.defaultProps = {
onCreate: dummyFunction,
onUpdate: dummyFunction,