diff --git a/deploy/shared/s-pipes-engine/scripts/form-generation.sms.ttl b/deploy/shared/s-pipes-engine/scripts/form-generation.sms.ttl index 1f6cb558..7f1b16f0 100644 --- a/deploy/shared/s-pipes-engine/scripts/form-generation.sms.ttl +++ b/deploy/shared/s-pipes-engine/scripts/form-generation.sms.ttl @@ -282,6 +282,7 @@ ASK WHERE { }""" ; ] ; sm:next form-mod:construct-answers ; + sm:next form-mod:construct-comments; sm:next form-mod:filter-origin-path-id ; sml:constructQuery [ a sp:Construct ; @@ -316,6 +317,26 @@ WHERE { sml:replace true ; . +form-mod:construct-comments + a sml:ApplyConstruct ; + sm:next form-mod:rename-form-entities ; + sml:constructQuery [ + a sp:Construct ; + sp:text """CONSTRUCT { + ?sampleQ form:has-comment ?c . + ?c ?cp ?co . +} +WHERE { + ?dataQ form:is-cross-form-clone-of-question ?sampleQ . + ?dataQ form:has-comment ?c . + OPTIONAL { + ?c ?cp ?co . + } . +}""" ; + ] ; + sml:replace false ; +. + form-mod:construct-answers a sml:ApplyConstruct ; diff --git a/src/components/record/RecordController.jsx b/src/components/record/RecordController.jsx index 9ef2b463..d215ae37 100644 --- a/src/components/record/RecordController.jsx +++ b/src/components/record/RecordController.jsx @@ -26,6 +26,7 @@ import { withRouter } from "react-router-dom"; import { EXTENSIONS } from "../../../config"; import { trackPromise } from "react-promise-tracker"; import PropTypes from "prop-types"; +import { loadUsers } from "../../actions/UsersActions.js"; class RecordController extends React.Component { constructor(props) { @@ -51,6 +52,8 @@ class RecordController extends React.Component { this.setState({ showAlert: true }); this.props.unloadSavedRecord(); } + + this.props.loadUsers(); } componentDidUpdate(prevProps, prevState, snapshot) { @@ -241,6 +244,8 @@ RecordController.propTypes = { loadFormgen: PropTypes.func.isRequired, formTemplatesLoaded: PropTypes.object.isRequired, location: PropTypes.object.isRequired, + loadUsers: PropTypes.func.isRequired, + users: PropTypes.array.isRequired, }; export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(withI18n(withRouter(RecordController)))); @@ -254,6 +259,7 @@ function mapStateToProps(state) { viewHandlers: state.router.viewHandlers, formTemplatesLoaded: state.formTemplates.formTemplatesLoaded, formgen: state.record.formgen, + users: state.users.usersLoaded.users, }; } @@ -266,5 +272,6 @@ function mapDispatchToProps(dispatch) { unloadSavedRecord: bindActionCreators(unloadSavedRecord, dispatch), loadFormgen: bindActionCreators(loadFormgen, dispatch), transitionToWithOpts: bindActionCreators(transitionToWithOpts, dispatch), + loadUsers: bindActionCreators(loadUsers, dispatch), }; } diff --git a/src/components/record/RecordForm.jsx b/src/components/record/RecordForm.jsx index b8eb6f1d..7c372ff0 100644 --- a/src/components/record/RecordForm.jsx +++ b/src/components/record/RecordForm.jsx @@ -1,5 +1,3 @@ -"use strict"; - import React from "react"; import SForms, { Constants } from "@kbss-cvut/s-forms"; import PropTypes from "prop-types"; @@ -18,6 +16,7 @@ import PromiseTrackingMask from "../misc/PromiseTrackingMask"; import { trackPromise } from "react-promise-tracker"; import { ROLE } from "../../constants/DefaultConstants.js"; import { hasRole } from "../../utils/RoleUtils.js"; +import { connect } from "react-redux"; // import "intelligent-tree-select/lib/styles.css" // const componentMapping = SmartComponents.getComponentMapping(); @@ -70,15 +69,21 @@ class RecordForm extends React.Component { const result = await axiosBackend.get(`${FORM_GEN_POSSIBLE_VALUES_URL}?query=${encodeURIComponent(query)}`); return result.data; }; + _addLabelsToUsers(users) { + return users.map((user) => ({ + ...user, + id: user.uri, + label: `${user.firstName} ${user.lastName} (${user.username})`, + })); + } _getUsersOptions() { - const currentUser = this.props.currentUser; + const users = this.props.users || []; return { - users: [{ id: currentUser.uri, label: currentUser.firstName + " " + currentUser.lastName }], - currentUser: currentUser.uri, + users: this._addLabelsToUsers(users), + currentUser: this.props.currentUser.uri, }; } - _getIconsOptions() { if (hasRole(this.props.currentUser, ROLE.COMMENT_RECORD_QUESTIONS)) { return { @@ -148,6 +153,13 @@ RecordForm.propTypes = { isFormValid: PropTypes.func, form: PropTypes.object, updateForm: PropTypes.func, + users: PropTypes.array.isRequired, }; -export default injectIntl(withI18n(RecordForm, { forwardRef: true }), { forwardRef: true }); +export default connect(mapStateToProps)(injectIntl(withI18n(RecordForm, { forwardRef: true }), { forwardRef: true })); + +function mapStateToProps(state) { + return { + users: state.users.usersLoaded.users, + }; +}