|
|
@@ -10,7 +10,6 @@ import ListGroupItem from 'react-bootstrap/es/ListGroupItem';
|
|
|
import Modal from 'react-bootstrap/es/Modal';
|
|
|
|
|
|
import AppContainer from '../../services/AppContainer';
|
|
|
-import PageContainer from '../../services/PageContainer';
|
|
|
|
|
|
import { createSubscribedElement } from '../UnstatedUtils';
|
|
|
|
|
|
@@ -47,17 +46,16 @@ class GrantSelector extends React.Component {
|
|
|
}, // appeared only one of these 'grant: 5'
|
|
|
];
|
|
|
|
|
|
- const { pageContainer } = this.props;
|
|
|
-
|
|
|
this.state = {
|
|
|
userRelatedGroups: [],
|
|
|
isSelectGroupModalShown: false,
|
|
|
+ grant: this.props.grant,
|
|
|
grantGroup: null,
|
|
|
};
|
|
|
- if (pageContainer.state.grantGroupId != null) {
|
|
|
+ if (this.props.grantGroupId != null) {
|
|
|
this.state.grantGroup = {
|
|
|
- _id: pageContainer.state.grantGroupId,
|
|
|
- name: pageContainer.state.grantGroupName,
|
|
|
+ _id: this.props.grantGroupId,
|
|
|
+ name: this.props.grantGroupName,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
@@ -126,8 +124,6 @@ class GrantSelector extends React.Component {
|
|
|
* change event handler for grant selector
|
|
|
*/
|
|
|
changeGrantHandler() {
|
|
|
- const { pageContainer } = this.props;
|
|
|
-
|
|
|
const grant = +this.grantSelectorInputEl.value;
|
|
|
|
|
|
// select group
|
|
|
@@ -140,15 +136,19 @@ class GrantSelector extends React.Component {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- this.setState({ grantGroup: null });
|
|
|
- pageContainer.setState({ grant, grantGroupId: null, grantGroupName: null });
|
|
|
+ this.setState({ grant, grantGroup: null });
|
|
|
+
|
|
|
+ if (this.props.onUpdateGrant != null) {
|
|
|
+ this.props.onUpdateGrant({ grant, grantGroupId: null, grantGroupName: null });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
groupListItemClickHandler(grantGroup) {
|
|
|
- const { pageContainer } = this.props;
|
|
|
+ this.setState({ grant: 5, grantGroup });
|
|
|
|
|
|
- this.setState({ grantGroup });
|
|
|
- pageContainer.setState({ grant: 5, grantGroupId: grantGroup._id, grantGroupName: grantGroup.name });
|
|
|
+ if (this.props.onUpdateGrant != null) {
|
|
|
+ this.props.onUpdateGrant({ grant: 5, grantGroupId: grantGroup._id, grantGroupName: grantGroup.name });
|
|
|
+ }
|
|
|
|
|
|
// hide modal
|
|
|
this.hideSelectGroupModal();
|
|
|
@@ -160,10 +160,10 @@ class GrantSelector extends React.Component {
|
|
|
* @memberof GrantSelector
|
|
|
*/
|
|
|
renderGrantSelector() {
|
|
|
- const { t, pageContainer } = this.props;
|
|
|
+ const { t } = this.props;
|
|
|
|
|
|
let index = 0;
|
|
|
- let selectedValue = pageContainer.state.grant;
|
|
|
+ let selectedValue = this.state.grant;
|
|
|
const grantElems = this.availableGrants.map((opt) => {
|
|
|
const dataContent = `<i class="icon icon-fw ${opt.iconClass} ${opt.styleClass}"></i> <span class="${opt.styleClass}">${t(opt.label)}</span>`;
|
|
|
return <option key={index++} value={opt.grant} data-content={dataContent}>{t(opt.label)}</option>;
|
|
|
@@ -287,13 +287,18 @@ class GrantSelector extends React.Component {
|
|
|
* Wrapper component for using unstated
|
|
|
*/
|
|
|
const GrantSelectorWrapper = (props) => {
|
|
|
- return createSubscribedElement(GrantSelector, props, [AppContainer, PageContainer]);
|
|
|
+ return createSubscribedElement(GrantSelector, props, [AppContainer]);
|
|
|
};
|
|
|
|
|
|
GrantSelector.propTypes = {
|
|
|
t: PropTypes.func.isRequired, // i18next
|
|
|
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
- pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
|
|
|
+
|
|
|
+ grant: PropTypes.number.isRequired,
|
|
|
+ grantGroupId: PropTypes.string,
|
|
|
+ grantGroupName: PropTypes.string,
|
|
|
+
|
|
|
+ onUpdateGrant: PropTypes.func,
|
|
|
};
|
|
|
|
|
|
export default withTranslation()(GrantSelectorWrapper);
|