UNPKG

cluedin-widget

Version:
600 lines (467 loc) • 22.4 kB
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[28],{ /***/ 2064: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PropsMapperMediaQueriesHOC = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = __webpack_require__(0); var _react2 = _interopRequireDefault(_react); var _propTypes = __webpack_require__(1); var _propTypes2 = _interopRequireDefault(_propTypes); var _debounce = __webpack_require__(265); var _debounce2 = _interopRequireDefault(_debounce); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * Mobile first (intended to work only with minWidth) * * const myPropsMapper = props => { return (do stuff) }; * const myPropsMapper = ({ shouldTooltipBeVisible }) => { return (do stuff) }; * * const rules = [{ * minWidth: 700, // number * mapper: myPropsMapper, * }] * * <PropsContainerQuery rules={rules} /> */ var applyRules = function applyRules(props, rules, width, height) { if (rules.length === 0) { return props; } var result = _extends({}, props); // let internalRules = rules.filter(rule => 'minWidth' in rule); // TODO improve /** * we only apply the mapper if the available * WINDOW/VIEWPORT width * is wider or equal than the 'minWidth' condition * if you order you rules correcty you get a nice * logical, ascending, flow of overwrite * Mobile first FTW */ var internalRules = rules.filter(function (_ref) { var minWidth = _ref.minWidth, minHeight = _ref.minHeight; return width >= minWidth || height >= minHeight; }); if (internalRules.length === 0) { return props; } internalRules.forEach(function (_ref2) { var mapper = _ref2.mapper; result = _extends({}, result, mapper(props)); }); return result; }; /** * @deprecated * use PropMapperMediaQueries.js */ var PropsMapperMediaQueriesHOC = exports.PropsMapperMediaQueriesHOC = function (_Component) { _inherits(PropsMapperMediaQueriesHOC, _Component); function PropsMapperMediaQueriesHOC(props) { _classCallCheck(this, PropsMapperMediaQueriesHOC); var _this = _possibleConstructorReturn(this, (PropsMapperMediaQueriesHOC.__proto__ || Object.getPrototypeOf(PropsMapperMediaQueriesHOC)).call(this, props)); var debounceDelay = _this.props.debounceDelay; _this.handleResize = (0, _debounce2.default)(_this.handleResize.bind(_this), debounceDelay).bind(_this); _this.state = { width: null, height: null }; return _this; } _createClass(PropsMapperMediaQueriesHOC, [{ key: 'componentDidMount', value: function componentDidMount() { if (window) { window.addEventListener('resize', this.handleResize); this.forceUpdate(); } this.handleResize(); this.forceUpdate(); } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { if (window) { window.removeEventListener('resize', this.handleResize); } } }, { key: 'handleResize', value: function handleResize() { if (window) { var _window = window, height = _window.innerHeight, width = _window.innerWidth; this.setState({ width: width, height: height }); } } }, { key: 'render', value: function render() { var _props = this.props, children = _props.children, rules = _props.rules, restOfProps = _objectWithoutProperties(_props, ['children', 'rules']); var _state = this.state, width = _state.width, height = _state.height; var theChild = _react2.default.Children.only(children); var mappedProps = applyRules(_extends({}, restOfProps, theChild.props), rules, width, height); return _react2.default.cloneElement(theChild, mappedProps); } }]); return PropsMapperMediaQueriesHOC; }(_react.Component); PropsMapperMediaQueriesHOC.propTypes = { rules: _propTypes2.default.array, children: _propTypes2.default.node, debounceDelay: _propTypes2.default.number }; PropsMapperMediaQueriesHOC.defaultProps = { rules: [], children: null, debounceDelay: 180 }; exports.default = PropsMapperMediaQueriesHOC; /***/ }), /***/ 2335: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); // EXTERNAL MODULE: ./node_modules/react/index.js var react = __webpack_require__(0); var react_default = /*#__PURE__*/__webpack_require__.n(react); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/classCallCheck.js var classCallCheck = __webpack_require__(12); var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/createClass.js var createClass = __webpack_require__(13); var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js var possibleConstructorReturn = __webpack_require__(14); var possibleConstructorReturn_default = /*#__PURE__*/__webpack_require__.n(possibleConstructorReturn); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/getPrototypeOf.js var getPrototypeOf = __webpack_require__(15); var getPrototypeOf_default = /*#__PURE__*/__webpack_require__.n(getPrototypeOf); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/inherits.js var inherits = __webpack_require__(16); var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits); // EXTERNAL MODULE: ./node_modules/react-intl/lib/index.es.js var index_es = __webpack_require__(4); // EXTERNAL MODULE: ./node_modules/redux-form/es/index.js var es = __webpack_require__(66); // EXTERNAL MODULE: ./node_modules/react-redux/es/index.js + 18 modules var react_redux_es = __webpack_require__(8); // EXTERNAL MODULE: ./node_modules/recompose/es/Recompose.js var Recompose = __webpack_require__(6); // EXTERNAL MODULE: ./node_modules/connected-react-router/lib/index.js var lib = __webpack_require__(25); // EXTERNAL MODULE: ./node_modules/uxi/Widget/index.js var Widget = __webpack_require__(40); var Widget_default = /*#__PURE__*/__webpack_require__.n(Widget); // EXTERNAL MODULE: ./node_modules/uxi/internal/PropsMapperMediaQueriesHOC.js var PropsMapperMediaQueriesHOC = __webpack_require__(2064); var PropsMapperMediaQueriesHOC_default = /*#__PURE__*/__webpack_require__.n(PropsMapperMediaQueriesHOC); // EXTERNAL MODULE: ./core/modules/core/components/composites/alerts/DefaultAlert.js var DefaultAlert = __webpack_require__(115); // EXTERNAL MODULE: ./core/modules/core/actions.js var actions = __webpack_require__(60); // EXTERNAL MODULE: ./core/modules/core/components/composites/PageLoader.js var PageLoader = __webpack_require__(38); // EXTERNAL MODULE: ./core/modules/consent/actions.js + 1 modules var consent_actions = __webpack_require__(42); // EXTERNAL MODULE: ./core/modules/integration/actions.js + 1 modules var integration_actions = __webpack_require__(55); // EXTERNAL MODULE: ./core/modules/consent/converter.js var converter = __webpack_require__(267); // EXTERNAL MODULE: ./node_modules/uxi/Stepper/index.js var Stepper = __webpack_require__(80); // EXTERNAL MODULE: ./node_modules/uxi/internal/wrapInClientFormHOC.js var wrapInClientFormHOC = __webpack_require__(1900); var wrapInClientFormHOC_default = /*#__PURE__*/__webpack_require__.n(wrapInClientFormHOC); // EXTERNAL MODULE: ./core/modules/consent/components/composites/uniqueIdentifier/UniqueIdentifiersSelector.js + 2 modules var UniqueIdentifiersSelector = __webpack_require__(1930); // EXTERNAL MODULE: ./core/modules/consent/components/containers/ProcessorChooserContainer.js + 4 modules var ProcessorChooserContainer = __webpack_require__(1928); // CONCATENATED MODULE: ./core/modules/consent/components/containers/SingleConsentOnlyForm.js var UniqueIdentifiersSelectorClientForm = wrapInClientFormHOC_default()(UniqueIdentifiersSelector["a" /* default */]); var UniqueIdentifiersSelectorContainerWithReduxForm = Object(es["reduxForm"])({ form: 'UniqueIdentifiersSelectorContainer' })(UniqueIdentifiersSelectorClientForm); var SingleConsentOnlyForm_SingleConsentOnlyForm = /*#__PURE__*/ function (_Component) { inherits_default()(SingleConsentOnlyForm, _Component); function SingleConsentOnlyForm(props) { var _this; classCallCheck_default()(this, SingleConsentOnlyForm); _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(SingleConsentOnlyForm).call(this, props)); _this.state = { selectedIntegration: null, selectedUniqueIdentifier: {} }; return _this; } createClass_default()(SingleConsentOnlyForm, [{ key: "getContent", value: function getContent() { var _this2 = this; var _this$props = this.props, contentStyle = _this$props.contentStyle, isSaving = _this$props.isSaving; var selectedIntegration = this.state.selectedIntegration; if (!selectedIntegration) { return react_default.a.createElement(ProcessorChooserContainer["a" /* default */], { contentStyle: contentStyle || {}, integrationSelected: [], addProcessor: function addProcessor(integration) { _this2.addProcessor(integration); } }); } return react_default.a.createElement(UniqueIdentifiersSelectorContainerWithReduxForm, { isSaving: isSaving, integration: selectedIntegration.config || { name: selectedIntegration.Name }, onClickAddUniqueIdentifier: function onClickAddUniqueIdentifier(identifier) { _this2.addUniqueIdentifierHandler(identifier); } }); } }, { key: "resetIntegration", value: function resetIntegration() { this.setState({ selectedIntegration: null }); } }, { key: "addProcessor", value: function addProcessor(integration) { this.setState({ selectedIntegration: integration }); } }, { key: "addUniqueIdentifierHandler", value: function addUniqueIdentifierHandler(identifier) { var onClickAddUniqueIdentifierFromSelector = this.props.onClickAddUniqueIdentifierFromSelector; var selectedIntegration = this.state.selectedIntegration; var providerId = selectedIntegration.Id; if (onClickAddUniqueIdentifierFromSelector) { onClickAddUniqueIdentifierFromSelector({ identifiers: identifier.key, Consent: identifier.explanation || 'consent', IsRequired: !!identifier.required, ProviderId: providerId, integration: selectedIntegration }); } } }, { key: "render", value: function render() { var _this3 = this; var selectedIntegration = this.state.selectedIntegration; var activeStep = selectedIntegration ? 2 : 1; return react_default.a.createElement("div", null, react_default.a.createElement(Stepper["Stepper"], { linear: true, activeStep: activeStep }, react_default.a.createElement(Stepper["Step"], null, react_default.a.createElement(Stepper["StepButton"], { onClick: function onClick() { _this3.resetIntegration(); } }, react_default.a.createElement(index_es["FormattedMessage"], { id: "module-consent-AddUniqueIdentifier-step1", defaultMessage: "Choose Data Processor" }))), react_default.a.createElement(Stepper["Step"], null, react_default.a.createElement(Stepper["StepButton"], null, react_default.a.createElement(index_es["FormattedMessage"], { id: "module-consent-AddUniqueIdentifier-step2", defaultMessage: "Setup Personal Identifiers (optional)" })))), react_default.a.createElement("div", { style: { borderTop: '1px solid #ccc' } }, this.getContent())); } }]); return SingleConsentOnlyForm; }(react["Component"]); /* harmony default export */ var containers_SingleConsentOnlyForm = (SingleConsentOnlyForm_SingleConsentOnlyForm); // CONCATENATED MODULE: ./core/modules/consent/components/containers/SingleConsentFormContainer.js var SingleConsentFormContainer_SingleConsentFormContainer = /*#__PURE__*/ function (_Component) { inherits_default()(SingleConsentFormContainer, _Component); function SingleConsentFormContainer() { classCallCheck_default()(this, SingleConsentFormContainer); return possibleConstructorReturn_default()(this, getPrototypeOf_default()(SingleConsentFormContainer).apply(this, arguments)); } createClass_default()(SingleConsentFormContainer, [{ key: "onClickAddUniqueIdentifierFromSelector", value: function onClickAddUniqueIdentifierFromSelector(processor) { var _this$props = this.props, generateForm = _this$props.generateForm, currentOrganization = _this$props.currentOrganization; var identifiers = processor.identifiers ? processor.identifiers.map(function (v) { return v.value; }) : []; generateForm({ AutomaticDecision: false, AutomaticProcessing: false, Consent: processor.Consent || 'consent', Name: processor.integration.Name, IsRequired: processor.IsRequired, ProviderId: processor.ProviderId, IdentifiersString: JSON.stringify(identifiers || '[]'), OrganizationId: currentOrganization.Id }); } }, { key: "render", value: function render() { var _this = this; var _this$props2 = this.props, id = _this$props2.id, isSaving = _this$props2.isSaving, invalid = _this$props2.invalid; return react_default.a.createElement(Widget_default.a, { title: id ? react_default.a.createElement(index_es["FormattedMessage"], { id: "module-consent-editSingleContentForm", defaultMessage: "Edit Consent" }) : react_default.a.createElement(index_es["FormattedMessage"], { id: "module-consent-createSingleContentForm", defaultMessage: "Create Consent" }) }, invalid && react_default.a.createElement(DefaultAlert["a" /* default */], null), react_default.a.createElement(PropsMapperMediaQueriesHOC_default.a, { debounceDelay: 32, rules: [{ minHeight: 770, mapper: function mapper() { return { contentStyle: { borderBottom: '1px solid #ccc', overflowY: 'scroll', height: "calc(100vh - (\n 48px\n + 58px /* app header */\n + 30px /* widget padding top */\n + 30px /* widget padding bottom */\n + 54px /* footer height */\n + 50px /* widget's header */\n + 54px /* widget's stepper */\n + 59px /* widget's search bar */\n + 67px /* request new processort btn */\n ))" } }; } }] }, react_default.a.createElement(containers_SingleConsentOnlyForm, { isSaving: isSaving, contentStyle: { borderBottom: '1px solid #ccc', overflowY: 'auto', height: 'auto' }, onClickAddUniqueIdentifierFromSelector: function onClickAddUniqueIdentifierFromSelector(consent) { _this.onClickAddUniqueIdentifierFromSelector(consent); } }))); } }]); return SingleConsentFormContainer; }(react["Component"]); var SingleConsentFormContainerEnhanced = Object(Recompose["b" /* compose */])(Object(Recompose["c" /* lifecycle */])({ componentDidMount: function componentDidMount() { this.props.fetchConsentConfiguration(); }, componentDidUpdate: function componentDidUpdate() { var _this$props3 = this.props, done = _this$props3.done, resetForm = _this$props3.resetForm; if (done) { resetForm(); } }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { var redirectToListAndClearSavingResult = this.props.redirectToListAndClearSavingResult; if (nextProps.done) { redirectToListAndClearSavingResult(); } } }), Object(Recompose["a" /* branch */])(function (_ref) { var isFetching = _ref.isFetching; return isFetching; }, Object(Recompose["e" /* renderComponent */])(PageLoader["a" /* default */])))(SingleConsentFormContainer_SingleConsentFormContainer); var SingleConsentFormContainer_mapToStateProps = function mapToStateProps(state, _ref2) { var id = _ref2.id; var _state$integration = state.integration, allIntegrations = _state$integration.allIntegrations, isFetchingAllIntegrations = _state$integration.isFetchingAllIntegrations, _state$consent = state.consent, isFetchingConsentConfigurationForEdit = _state$consent.isFetchingConsentConfigurationForEdit, consentConfigurationEdit = _state$consent.consentConfigurationEdit, invalidConsentConfigurationEdit = _state$consent.invalidConsentConfigurationEdit, isSavingSingleConsentFormResult = _state$consent.isSavingSingleConsentFormResult, doneSavingSingleConsentFormResult = _state$consent.doneSavingSingleConsentFormResult, invalidSavingSingleConsentFormResult = _state$consent.invalidSavingSingleConsentFormResult, _state$org = state.org, isFetchingOrganization = _state$org.isFetchingOrganization, organization = _state$org.organization; var isFetching = isFetchingConsentConfigurationForEdit || isFetchingAllIntegrations || isFetchingOrganization; return { isSaving: isSavingSingleConsentFormResult, done: doneSavingSingleConsentFormResult, isFetching: isFetching, currentOrganization: organization, consentForm: id && !isFetching && consentConfigurationEdit ? Object(converter["c" /* toConsentFormViewModel */])(consentConfigurationEdit, allIntegrations) : { uniqueIdentifiers: [], processors: [] }, invalid: invalidConsentConfigurationEdit || invalidSavingSingleConsentFormResult, id: id }; }; var SingleConsentFormContainer_mapDispatchToProps = function mapDispatchToProps(dispatch, _ref3) { var id = _ref3.id; return { fetchConsentConfiguration: function fetchConsentConfiguration() { if (id) { dispatch(Object(consent_actions["q" /* shouldFetchConsentFormByIdForEdit */])(id)); } dispatch(Object(integration_actions["n" /* shouldFetchAllIntegrations */])()); }, generateForm: function generateForm(consentForm) { dispatch(Object(consent_actions["I" /* shouldSaveSingleConsentFormOnBackEnd */])(consentForm)); }, resetForm: function resetForm() { dispatch(Object(consent_actions["g" /* clearSingleResult */])()); dispatch(Object(es["reset"])('UniqueIdentifiersSelectorContainer')); }, redirectToListAndClearSavingResult: function redirectToListAndClearSavingResult() { dispatch(Object(actions["c" /* shouldShowAlert */])({ type: 'success', title: react_default.a.createElement(index_es["FormattedMessage"], { id: "module-consent-SingleConsentAddedTitleAlert", defaultMessage: "Single Consent added" }), description: react_default.a.createElement(index_es["FormattedMessage"], { id: "module-consent-SingleConsentAddedContentAlert", defaultMessage: "Single Consent has been added correctly." }) })); dispatch(Object(lib["push"])('/consent/consents')); } }; }; /* harmony default export */ var containers_SingleConsentFormContainer = (Object(react_redux_es["connect"])(SingleConsentFormContainer_mapToStateProps, SingleConsentFormContainer_mapDispatchToProps)(SingleConsentFormContainerEnhanced)); // CONCATENATED MODULE: ./core/modules/consent/components/pages/SingleConsentFormPage.js var SingleConsentFormPage_SingleConsentFormPage = function SingleConsentFormPage() { return react_default.a.createElement(containers_SingleConsentFormContainer, null); }; /* harmony default export */ var pages_SingleConsentFormPage = __webpack_exports__["default"] = (SingleConsentFormPage_SingleConsentFormPage); /***/ }) }]);