}\n onChange={(val)=>{\n onChange({target:{name:name, value:val}});\n }}\n selected={value}\n showTimeInput\n dateFormat={'P p'}\n showYearDropdown\n showMonthDropdown\n dropdownMode='select'\n dateFormatCalendar=\"MMMM\" \n locale={get_locale()}\n />\n );\n}\n ","import React from 'react';\nimport {Form} from 'react-bootstrap';\n\n\n/**\n * Custom radiogroup component.\n * Props:\n * options: name-value pairs of options\n * name: name of input\n * value: initial value and connection to parent state\n * onChange: onChange callback\n * disabled: disable whole component\n */\nclass RadioGroup extends React.Component {\n\n render(){\n const {options, name, value, onChange, disabled} = this.props;\n return (\n \n {options && options.map((el, i)=>(\n onChange({target:{name:name, value:el}})}\n key={i}\n >\n
onChange({target:{name:name, value:el}})}\n />\n \n \n ))}\n \n );\n }\n}\n\nexport default RadioGroup;","import React from 'react';\nimport Panel from '../CollapsePanel/CollapsePanel';\nimport BootstrapInput from '../FormInput/BootstrapInput2';\nimport Switch from '../Switch/Switch';\nimport Datepicker from '../Datepicker/Datepicker';\nimport Select from '../Select/Select';\nimport RadioGroup from '../RadioGroup/RadioGroup';\nimport { isBool, isDate, isString, isNumeric } from '../../helpers/enums';\n\n/**\n * Return input based on data type DatePicker for date, Select for Enums etc.\n */\nconst getInputProps = (field, enumparams) => {\n const inputProps = {};\n if (isNumeric(field.EventField.BuiltInType))\n inputProps.type = 'number';\n\n if (isString(field.EventField.BuiltInType) && field.UseTextarea && field.EventField.ValidationFunctionName !== 'enum')\n inputProps.as = 'textarea';\n\n if (isString(field.EventField.BuiltInType) && field.EventField.ValidationFunctionName === 'enum') {\n inputProps.component = field.UseBtnWidget ? RadioGroup : Select;\n inputProps.options = enumparams; //field.EventField.ValidationFunctionParameter.split(';').filter(el => el.trim() !== '').map(el => ({ label: el.trim(), value: el.trim() }));\n }\n\n if (isBool(field.EventField.BuiltInType)) {\n inputProps.component = Switch;\n inputProps.disableLabel = true;\n }\n\n if (isDate(field.EventField.BuiltInType)) {\n inputProps.component = Datepicker;\n }\n\n return inputProps;\n\n\n}\n\n/**\n * Component of filed on DataEntry form - form for customers.\n * Props:\n * - value: object holding values of all inner fields\n * - visible: visibility of group\n * - onChange: callback called on every change of inner inputs\n * - error: object of all form errors\n * - closed: if groups is collapsed by default\n * - group: settings of group itself\n */\nclass Group extends React.Component {\n\n render() {\n const { group, value, onChange, error, visible, allVisibility } = this.props;\n const check = error && group.EventFieldsGroupEventFields.filter(el => el.Visible).some(el => error[el.EventField.Name]);\n const style = visible === 0 ? { display: 'none' } : { display: 'block' };\n //debugger;\n return (\n \n {this.props.context.t(this.props.group.Name)} \n \n {/** inserting unescaped html directly - normaly considered as dangerous */}\n {group.InfoText ?
: null}\n {group.EventFieldsGroupEventFields.filter(el => el.Visible).map((f, i) => (\n {this.props.context.t(f.DisplayName ? f.DisplayName : f.EventField.Name)} {f.Required ? * : null}\n }\n value={value[f.EventField.Name]}\n readOnly={f.ReadOnly}\n disabled={f.ReadOnly}\n isDisabled={f.ReadOnly}\n onChange={onChange}\n error={error}\n visible={allVisibility[f.EventField.Name]}\n {...getInputProps(f, this.props.enumValues[f.EventField.Name])}\n />\n ))}\n \n \n );\n }\n}\n\nexport default Group;","import React from 'react';\nimport {Card, Col, Row} from 'react-bootstrap';\nimport BootstrapInput from '../FormInput/BootstrapInput2';\nimport Select from '../Select/Select';\nimport Switch from '../Switch/Switch';\nimport {Draggable} from 'react-beautiful-dnd';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\n\n\n/**\n * Constants for sort order applied on columns.\n */\nexport const SORT_ORDER = [\n { label: 'Default', value: 0 },\n { label: 'ASC', value: 1 },\n { label: 'DESC', value: 2 }\n];\n\n/**\n * This component is part of DataView create/update form. It wraps settings of individual columns.\n * Component is wrapped in Draggable to provide drag-drop functionality. See react-beatiful-dnd. \n * Props:\n * name: parent name, it is dynamic parent form so input names must be like parent[0].children\n * value: object holding all settings of the column and providing to parent\n * onChange: callback called on every input change\n * onRemove: callback called on removing this column from parent\n */\nexport default class extends React.Component {\n \n shouldComponentUpdate=(newProps)=>{\n return (this.props.index !== newProps.index ||\n this.props.value.EventField !== newProps.value.EventField ||\n this.props.value.DisplayName !== newProps.value.DisplayName ||\n this.props.value.Filter !== newProps.value.Filter ||\n (this.props.value.ColumnOrder && newProps.value.ColumnOrder && \n this.props.value.ColumnOrder.value !== newProps.value.ColumnOrder.value) ||\n this.props.value.Width !== newProps.value.Width ||\n this.props.value.WordWrap !== newProps.value.WordWrap ||\n this.props.value.Visible !== newProps.value.Visible);\n }\n\n render() {\n const {name, value, onChange, onRemove} = this.props;\n return (\n \n {(provided, snapshot)=>(\n \n \n \n \n \n \n \n \n \n \n {onRemove ? : null}\n
\n \n \n
\n \n \n
\n )}\n \n );\n }\n\n \n}","import React from 'react';\nimport ReactTable from 'react-table';\nimport axiosData from '../../helpers/axiosData';\nimport {SORT_ORDER} from '../../components/DataViewColumn/DataViewColumn';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport {withRouter} from 'react-router-dom';\nimport {isDate} from '../../helpers/enums';\nimport {get_locale} from '../../helpers/utils';\nimport {format, toDate} from 'date-fns';\n\n\nconst loc = get_locale();\n\n/**\n * Component to display list of associated events as table.\n * Props:\n * - rows: initial row\n * - value: object of AssociatedEventsSetting\n * - parentId: id of parent Event\n * - nodeId: nodeId\n */\nclass Grid extends React.PureComponent {\n _isMount = false;\n\n state={\n //rows to display\n rows: this.props.rows ? this.props.rows : [],\n //object of AssociatedEventSettings\n view: this.props.value ? this.props.value : {},\n //table loading spinner visibility\n isLoading: true\n }\n\n /**\n * Ajax call to load rows (events) from API.\n */\n loadRows=()=>{\n this.setState({isLoading: true}, ()=>{\n let view = this.state.view;\n let eventType = view.EventsDataView.WebEntries[0].EventTypePageEntity ? view.EventsDataView.WebEntries[0].EventTypePageEntity.EventType : this.props.eventType;\n axiosData.get(`/v1/${eventType.Name}/event/${this.props.parentId}/associated?nodeid=${this.props.nodeId}&eventtypeid=${eventType.ID}${view.UrlParams?'&'+view.UrlParams:''}`)\n .then(response=>{\n this.setState({isLoading:false, rows:response.data.Events.Values});\n })\n .catch(error=>{\n console.log(error);\n this.setState({isLoading:false});\n });\n });\n }\n\n /**\n * Call to open associated event oin browser.\n */\n openChildren = (dataEntryId, eventId, nodeid) => {\n this.props.history.push(`/dataentry/form/${dataEntryId}/${eventId}/${nodeid}/${this.props.parentId}/${this.props.parentFormId}/${this.props.nodeId}`); //form id / event id / node id / parent event id / parent node id\n this.loadRows();\n }\n\n /**\n * Redirect to new DataEntry form to create new associated event.\n */\n addChildren=()=>{\n if (this.state.view.EventsDataView.NewEventTypePage)\n this.props.history.push(`/dataentry/child/${this.state.view.EventsDataView.NewEventTypePage.ID}/${this.props.parentId}`);\n }\n\n componentWillUnount=()=>{\n this._isMount = false;\n }\n\n /**\n * Load initial settings, prepare table settings.\n */\n componentDidMount=()=>{\n this._isMount=true;\n const view = {...this.state.view};\n //Sort columns to respect same order as on Create form\n view.EventsDataView.Columns.sort((a,b) => a.Order > b.Order ? 1 : -1);\n //Add info to columns so it can be directly consumed by table component\n view.EventsDataView.Columns = view.EventsDataView.Columns.map(el=>({\n accessor: el.EventField.Name,\n Header: el.DisplayName ? el.DisplayName : el.EventField.Name,\n width: el.Width ? el.Width : undefined,\n show: el.Visible,\n filter: el.Filter ? (el.Filter.trim() === '{{[@Me]}}'? this.props.context.user.name : el.Filter) : undefined,\n Filter: el.Filter ? ({ filter, onChange }) => ( ): undefined,\n ColumnOrder: SORT_ORDER.find(o=>o.value === el.ColumnOrder),\n className: el.WordWrap ? 'wordWrap' : undefined,\n headerClassName: el.WordWrap ? 'wordWrap' : undefined,\n //if display data is datetime - display it in current locale format\n Cell: prop=>{\n if(prop.value && isDate(el.EventField.BuiltInType)){\n return ({format(toDate(prop.value), 'P p', {locale:loc})} )\n }\n return ({prop.value} ) \n }\n }));\n //set upgraded view to state\n this.setState({view:view}, (()=>{\n let eventType = view.EventsDataView.WebEntries[0].EventTypePageEntity ? view.EventsDataView.WebEntries[0].EventTypePageEntity.EventType : this.props.eventType;\n if(this._isMount){\n axiosData.get(`/v1/${eventType.ID}/event/${this.props.parentId}/associated?nodeid=${this.props.nodeId}&eventtypeid=${eventType.ID}${view.UrlParams?'&'+view.UrlParams:''}`)\n .then(response=>{\n this.setState({isLoading:false, rows:response.data.Events.Values});\n })\n .catch(error=>{\n console.log(error);\n this.setState({isLoading:false});\n });\n }\n }));\n \n }\n\n render(){\n if(this.state.view && this._isMount){\n\n return(\n \n \n {this.props.context.t(this.state.view.Label)}\n {\n this.state.view.EventsDataView.NewEventTypePage ? \n \n : null\n }\n \n \n \n {/** table component for more info see react-table docs */}\n {\n const id = filter.pivotId || filter.id\n return row[id] !== undefined ? String(row[id]).search(new RegExp(filter.value, 'i'))>-1 : true\n }}\n minRows={0}\n style={{height:'calc(250px)'}}\n getTrProps={(state, rowInfo, column) => {\n /**render every row as link to open child event */\n return {\n onClick: (e, handleOriginal) => {\n this.openChildren(this.state.view.EventsDataView.WebEntries[0].EventTypePageEntityId, rowInfo.original._EventID, rowInfo.original._NodeId);\n },\n style: {cursor: 'pointer'}\n };\n }}\n />\n \n );\n \n }\n return null;\n }\n}\n\nexport default withRouter(Grid);","import React from 'react';\nimport ReactTable from 'react-table';\nimport axiosData from '../../helpers/axiosData';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport {Button, ButtonGroup} from 'react-bootstrap';\nimport withContext from '../../hoc/withContext';\nimport Dropzone from 'react-dropzone';\n\n/**\n * Table to display file attachments for event.\n * Props:\n * -eventtypename\n * -eventId\n */\nclass List extends React.Component{\n\n state={\n //row/files for table\n rows:[],\n //table load spinner visibility\n isLoading: true\n }\n\n componentDidMount() {\n this.loadRows();\n }\n\n /**\n * Load files/row for table form API.\n */\n loadRows = () => {\n this.setState({isLoading: true});\n axiosData.get(`/v1/${this.props.eventtypename}/file/${this.props.eventId}`)\n .then(response => {\n this.setState({rows:response.data, isLoading: false});\n })\n .catch(error=>{\n console.log(error);\n this.setState({isLoading: false});\n });\n }\n\n /**\n * Drop callback of fileupload component aka Dropzone.\n */\n onDrop=(files)=>{\n let formData = new FormData();\n formData.append('file', files[0]);\n formData.append('eventId', this.props.eventId);\n axiosData.post(`/v1/${this.props.eventtypename}/file/${this.props.eventId}`, formData)\n .then(response=>{\n this.loadRows();\n })\n .catch(error=>console.log(error));\n }\n\n /**\n * Handler for deleting files.\n */\n removeHandler = (filename) => {\n axiosData.delete(`/v1/${this.props.eventtypename}/file/${this.props.eventId}/${filename}`)\n .then(response => {\n this.props.context.pushAlert({variant:'success', message: 'Item deleted.'});\n this.loadRows();\n })\n .catch(error=>{\n console.log(error);\n this.props.context.pushAlert({variant:'danger', message: 'Unable to delete item.'});\n this.loadRows();\n });\n }\n\n /**\n * Hadnler for downloading files.\n */\n downloadHandler=(filename)=>{\n axiosData.get(`/v1/${this.props.eventtypename}/file/${this.props.eventId}/${filename}`, {responseType: 'blob'})\n .then(response=>{\n const url = window.URL.createObjectURL(new Blob([response.data]));\n const link = document.createElement('a');\n link.href = url;\n link.setAttribute('download', filename);\n document.body.appendChild(link);\n link.click();\n })\n .catch(error=>console.log(error));\n }\n\n render(){\n\n return(\n \n {this.props.Title} \n \n
\n {({getRootProps, getInputProps, isDragActive}) => (\n \n \n {isDragActive ? \"Drop item here!\" : 'Click me or drag a file to upload!'}\n
\n )}\n \n
\n {/**Table component to display files. For docs see react-table */}\n {\n const id = filter.pivotId || filter.id\n return row[id] !== undefined ? String(row[id]).search(new RegExp(filter.value, 'i'))>-1 : true\n }}\n columns={\n [\n {Header:'Filename', accessor: 'FileName'},\n {width:150,filterable:false,Cell:({row})=>{\n return(\n \n this.downloadHandler(row.FileName)}> \n this.removeHandler(row.FileName)}> \n \n )}}\n ]\n }\n />\n \n );\n }\n}\n\nexport default withContext(List);","import React from 'react';\nimport ReactTable from 'react-table';\nimport axiosData from '../../helpers/axiosData';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport {Button, ButtonGroup} from 'react-bootstrap';\nimport withContext from '../../hoc/withContext';\n\n/**\n * Table to display office exports for event.\n * Props:\n * -nodeid\n * -eventId\n */\nclass List extends React.Component{\n\n state={\n //row/files for table\n rows:[],\n //table load spinner visibility\n isLoading: true\n }\n\n componentDidMount() {\n this.loadRows();\n }\n\n /**\n * Load files/row for table form API.\n */\n loadRows = () => {\n this.setState({isLoading: true});\n axiosData.get(`/v1/OfficeExport/${this.props.nodeId}/${this.props.eventId}`)\n .then(response => {\n this.setState({rows:response.data, isLoading: false});\n })\n .catch(error=>{\n console.log(error);\n this.setState({isLoading: false});\n });\n }\n\n /**\n * Handler for downloading files.\n */\n downloadHandler=(templatename)=>{\n axiosData.get(`/v1/OfficeExport/${this.props.nodeId}/${this.props.eventId}/${templatename}`, {responseType: 'blob'})\n .then(response=>{\n const url = window.URL.createObjectURL(new Blob([response.data]));\n const link = document.createElement('a');\n link.href = url;\n link.setAttribute('download', templatename);\n document.body.appendChild(link);\n link.click();\n })\n .catch(error=>console.log(error));\n }\n\n render(){\n\n return(\n \n {this.props.Title} \n {/**Table component to display files. For docs see react-table */}\n {\n const id = filter.pivotId || filter.id\n return row[id] !== undefined ? String(row[id]).search(new RegExp(filter.value, 'i'))>-1 : true\n }}\n columns={\n [\n {Header:'Template name', accessor: 'TemplateName'},\n {width:150,filterable:false,Cell:({row})=>{\n return(\n \n this.downloadHandler(row.TemplateName)}> \n \n )}}\n ]\n }\n />\n \n );\n }\n}\n\nexport default withContext(List);","import React from 'react';\nimport axios from '../../helpers/axiosWebEntry';\n//import _ from 'lodash';\nimport * as yup from 'yup';\nimport axiosData from '../../helpers/axiosData';\nimport axiosUser from '../../helpers/axiosUser';\nimport withContext from '../../hoc/withContext';\nimport { Button, ButtonGroup } from 'react-bootstrap';\nimport Group from '../../components/DataEntryGroup/DataEntryGroup'\nimport View from '../../components/AssociatedEventSettings/AssociatedEventsGrid';\nimport { isDate, isNumeric, isString } from '../../helpers/enums';\nimport queryString from 'query-string';\nimport Attachments from '../../components/Attachments/Attachments';\nimport OfficeExports from '../../components/OfficeExports/OfficeExports';\nimport debounce from 'lodash.debounce';\nimport Modal from 'react-bootstrap/Modal';\nimport AsyncSelect from '../../components/Select/AsyncSelect';\nimport BootstrapInput from '../../components/FormInput/BootstrapInput2';\n\n\n\n\nclass Entry extends React.PureComponent {\n constructor() {\n super()\n\n this.state = {\n entry: undefined,\n data: {},\n fields: [],\n _nodeId: undefined,\n _itemId: undefined,\n _lockState: 'Open',\n _createdBy: '',\n _ownedBy: '',\n _newOwner: '',\n _eventId: '',\n dirty: false,\n error: {},\n groupsVisibility: {},\n //visibilityControls: {},\n goBackSteps: -1,\n defaultEnumValues: {},\n enumValues: [], //2020-04-20 vlad: added to handle filtering of enum values\n show: false,\n _parentId: undefined\n }\n\n // Delay action 500 miliseconds\n this.onChangeDebounced = debounce(this.onChangeDebounced, 500)\n }\n\n schema = yup.lazy(obj => {\n const result = {};\n for (let key in this.state.fields) {\n let field = this.state.fields[key];\n\n let validation = yup;\n let validationEnabled = false;\n\n if (isString(field.EventField.BuiltInType) && field.FormatValidation !== undefined && field.FormatValidation !== '') {\n let message = (field.FormatValidationErrorMessage !== undefined && field.FormatValidationErrorMessage !== '')\n ? this.props.context.t(field.FormatValidationErrorMessage)\n : (this.props.context.t('String not in the correct format, format should be \"') + field.FormatValidation + '\".');\n\n validation = validation.string().matches(RegExp(field.FormatValidation), message);\n validationEnabled = true;\n }\n\n else if (isNumeric(field.EventField.BuiltInType) && field.RangeValidationLow !== undefined && field.RangeValidationLow !== '' && field.RangeValidationHigh !== undefined && field.RangeValidationHigh !== '') {\n let message = (field.RangeValidationErrorMessage !== undefined && field.RangeValidationErrorMessage !== '')\n ? this.props.context.t(field.RangeValidationErrorMessage)\n : (this.props.context.t('Range not within low: \"') + field.RangeValidationLow + this.props.context.t('\" and high: \"') + field.RangeValidationHigh + this.props.context.t('\" limits.'));\n\n validation = validation.number().typeError(this.props.context.t('Must be a number')).min(field.RangeValidationLow, message).max(field.RangeValidationHigh, message);\n validationEnabled = true;\n }\n\n if (this.state.fields[key].Required) {\n if (validationEnabled) {\n validation = validation.required(this.props.context.t(\"This Field is Required.\"));\n }\n else {\n validation = validation.mixed().test({\n test: value => (value || value === 0) ? true : false,\n message: this.props.context.t('This Field is Required.'),\n name: key\n });\n }\n validationEnabled = true;\n }\n\n if (validationEnabled)\n result[key] = validation;\n }\n return yup.object(result);\n\n });\n\n modalClose = () => {\n this.setState({ show: false });\n }\n modalShow = () => {\n this.setState({ show: true });\n }\n\n handleSubmit = (e) => {\n e.preventDefault();\n let goBackSteps\n if (this.props.history.location.state) {\n goBackSteps = this.props.history.location.state.goBackSteps\n } else {\n goBackSteps = -1\n }\n const name = e.target.name;\n\n if (name === 'SaveLock') {\n if (!window.confirm('Are you sure you want to lock this entry?')) {\n return;\n }\n }\n\n if (name === 'ChangeOwner') {\n if (!window.confirm('Are you sure you want to change owner of this entry?')) {\n return;\n }\n }\n\n\n\n this.schema.validate(this.state.data, { abortEarly: false })\n .then(valid => {\n const { match: { params } } = this.props;\n const values = {};\n const data = { ...this.state.data };\n const fields = { ...this.state.fields };\n for (let key in fields) {\n if (data[key] !== undefined && data[key] !== null && data[key].value !== undefined)\n values[key] = data[key].value;\n else\n values[key] = data[key];\n\n }\n\n if (this.state._itemId)\n values[\"id\"] = this.state._itemId;\n\n const reqData = { Values: values };\n if (params.parentId)\n reqData.ParentId = params.parentId;\n\n //if (this.state._nodeId)\n // reqData.nodeId = params.parentId;\n\n\n\n /*\n schema.validate(this.state.data, {abortEarly:false})\n .then(valid=>{*/\n\n this.props.context.showLoading();\n if (params && params.eventId) {\n let temp_nodeid = (this.state._nodeId) ? (\"?nodeid=\" + this.state._nodeId) : \"\";\n axiosData.put(`/v1/${this.state.entry.EventType.Name}/event/${params.eventId}${temp_nodeid}`, reqData)\n .then(response => {\n if (response.data.Result) {\n this.setState({ dirty: false });\n this.props.context.pushAlert({ variant: 'success', message: 'Item updated.' });\n this.props.context.hideLoading();\n if (name === 'SaveClose') {\n //this.props.history.go(this.state.goBackSteps);\n if (this.props.history.location.state) {\n this.props.history.go(this.props.history.location.state.goBackSteps)\n } else {\n // You can add a default action if a user lands on route from an external link\n this.props.history.push('/')\n }\n }\n else if (name === 'SaveLock') {\n this.props.context.showLoading();\n const lockvals = {};\n lockvals['eventid'] = params.eventId;\n lockvals['nodeid'] = this.state._nodeId;\n\n axiosData.post('/old/calls/custompost', {\n url: `eventlock`,\n values: lockvals\n })\n .then(response => {\n this.props.context.hideLoading();\n if (response.data.Result) {\n this.setState({ _lockState: 'Locked' });\n }\n else {\n this.props.context.pushAlert({ variant: 'danger', message: 'Error occured when locking the item.' });\n }\n })\n .catch(error => {\n console.log(error);\n });\n\n }\n else if (name === 'ChangeOwner') {\n this.props.context.showLoading();\n const reqvals = {};\n reqvals['eventid'] = params.eventId;\n reqvals['nodeid'] = this.state._nodeId;\n reqvals['newowner'] = this.state._newOwner;\n\n axiosData.post('/old/calls/custompost', {\n url: `changeowner`,\n values: reqvals\n })\n .then(response => {\n this.props.context.hideLoading();\n if (response.data.Result) {\n this.setState({ _ownedBy: this.state._newOwner });\n this.modalClose();\n this.props.context.pushAlert({ variant: 'success', message: 'Owner changed.' });\n //reload\n this.loadEvent(this.state.entry.EventType.Name, this.state._eventId, this.state._nodeId);\n }\n else {\n this.props.context.pushAlert({ variant: 'danger', message: 'Error occured when changing the owner of the item.' });\n }\n })\n .catch(error => {\n console.log(error);\n });\n\n }\n\n\n }\n else {\n this.props.context.pushAlert({ variant: 'danger', message: 'Error occured when saving the item.' });\n this.props.context.hideLoading();\n }\n }).catch(error => {\n this.props.context.pushAlert({ variant: 'danger', message: 'Error occured. Item was not updated.' });\n console.log(error);\n this.props.context.hideLoading();\n });\n } else {\n axiosData.post(`/v1/${this.state.entry.EventType.Name}/event`, reqData)\n .then(response => {\n if (response.data.Result) {\n this.setState({ dirty: false });\n this.props.context.pushAlert({ variant: 'success', message: 'Item created.' });\n if (name === 'SaveClose') {\n this.props.history.goBack();\n }\n else {\n this.setState({ _nodeId: response.data.NodeId });\n let limit = 4;\n let newGuid = response.data.Result;\n this._interval = this.setIntervalImmediately(() => {\n limit--;\n if (limit >= 0) {\n axiosData.post('/old/calls/custom', {\n url: `/api/client/AhlstromMunksjo/event?eventtypename=${this.state.entry.EventType.Name}&eventid=${newGuid}&nodeId=${response.data.NodeId}`\n })\n .then(response => {\n if (response.data.Events.Values.length) {\n clearInterval(this._interval);\n this.props.history.push({ pathname: `/dataentry/form/${params.id}/${newGuid}`, state: { goBackSteps: --goBackSteps } });\n }\n })\n .catch(error => {\n console.log(error);\n });\n } else {\n clearInterval(this._interval);\n this.props.context.hideLoading();\n }\n }, 5000);\n }\n }\n else {\n this.props.context.pushAlert({ variant: 'danger', message: 'Error occured. Item was not created.' });\n this.props.context.hideLoading();\n //clearInterval(this._interval);\n }\n\n }).catch(error => {\n this.props.context.pushAlert({ variant: 'danger', message: 'Error occured. Item was not created.' });\n this.props.context.pushAlert({ variant: 'danger', message: 'Error: ' + error });\n\n console.log(error);\n this.props.context.hideLoading();\n });\n }\n /*})\n .catch(errors=>{\n const error = {};\n errors.inner.forEach(el=>{\n set(error,el.path, el.message);\n });\n this.setState({error:error});\n });\n */\n })\n .catch(errors => {\n const error = {};\n errors.inner.forEach(el => {\n error[el.path] = el.message;\n });\n this.setState({ error: error });\n })\n\n }\n\n handleUnlock = (e) => {\n e.preventDefault();\n\n if (!window.confirm('Are you sure you want to unlock this entry?')) {\n return;\n }\n\n this.props.context.showLoading();\n const lockvals = {};\n lockvals['eventid'] = this.state._eventId;\n lockvals['nodeid'] = this.state._nodeId;\n\n axiosData.post('/old/calls/custompost', {\n url: `eventunlock`,\n values: lockvals\n })\n .then(response => {\n this.props.context.hideLoading();\n if (response.data.Result) {\n this.setState({ _lockState: 'Unlocked' });\n }\n else {\n this.props.context.pushAlert({ variant: 'danger', message: 'Error occured when locking the item.' });\n }\n })\n .catch(error => {\n console.log(error);\n });\n\n }\n\n\n\n onClose = () => {\n if (!this.state.dirty) {\n this.props.history.goBack();\n return;\n }\n if (window.confirm('There are unsaved changes, do you want to leave?')) {\n this.props.history.goBack();\n return;\n }\n }\n\n deleteEntry = () => {\n if (!window.confirm('Do you really want to delete this entry? This can not be undone.')) {\n return;\n }\n\n this.props.context.showLoading();\n\n //const reqData = {};\n //reqData['eventid'] = this.state._eventId;\n //reqData['nodeid'] = this.state._nodeId;\n\n\n axiosData.delete(`/v1/${this.state.entry.EventType.Name}/event/${this.state._eventId}`, { headers: { 'Content-Type': 'application/json; charset=utf-8' }, data: { NodeId: this.state._nodeId } })\n .then(response => {\n this.props.context.hideLoading();\n if (response.data != undefined && response.data.Result) {\n this.setState({\n entry: undefined,\n data: {},\n fields: [],\n _nodeId: undefined,\n _itemId: undefined,\n _lockState: 'Open',\n _createdBy: '',\n _ownedBy: '',\n _eventId: '',\n dirty: false,\n error: {},\n groupsVisibility: {},\n //visibilityControls: {},\n goBackSteps: -1,\n defaultEnumValues: {},\n enumValues: []\n });\n this.props.history.goBack();\n }\n else {\n this.props.context.pushAlert({ variant: 'danger', message: 'Error occured when deleting the item.' });\n }\n })\n .catch(error => {\n this.props.context.hideLoading();\n console.log(error);\n });\n }\n\n\n\n onChange = (e) => {\n const name = e.target.name;\n const value = e.target.value;\n this.setState(prevState => {\n const data = { ...prevState.data };\n const error = { ...this.state.error };\n //const groupsVisibility = { ...this.state.groupsVisibility }; //maybe\n data[name] = value;\n error[name] = undefined;\n\n\n //debounced actions like visibility\n this.onChangeDebounced(e, data);\n\n\n return { data: data, dirty: true, error: error, /*groupsVisibility: groupsVisibility*/ };\n });\n }\n\n onChangeDebounced = (e, data) => {\n const groupsVisibility = {}; //maybe\n const localEnumValues = JSON.parse(JSON.stringify(this.state.defaultEnumValues));\n\n // check visibility\n\n for (const fieldName in this.state.fields) {\n const field = this.state.fields[fieldName];\n if (field.AssociatedGroups) {\n\n\n //this is where the magic happens:\n this.setTargetsVisibilities(field, localEnumValues, groupsVisibility, data[fieldName]);\n\n\n }\n }\n this.setState({ groupsVisibility: groupsVisibility/*, visibilityControls: visibilityControls*/ });\n this.setState({ enumValues: localEnumValues });\n }\n\n loadEvent(eventType, guid, nodeId = undefined) {\n this.props.context.showLoading();\n\n //try to get it from local state (when redirected from create to edit)\n if (nodeId === undefined) {\n nodeId = this.state._nodeId;\n }\n\n if (nodeId === undefined) {\n if (this.props.history.location.state) {\n nodeId = this.props.history.location.state.passedNodeId;\n }\n }\n\n\n axiosData.post('/old/calls/custom', {\n url: `/api/client/AhlstromMunksjo/event?eventtypename=${eventType}&eventid=${guid}${nodeId ? '&nodeId=' + nodeId.toString() : ''}`\n })\n .then(response => {\n if (response.data && response.data.Events && response.data.Events.Values) {\n const systemColumns = ['_EventID', '_NodeId', '_EventTime', '_StorageTime', '_EventTypeID', '_ParentID', '_ID',\n '_CreatedBy', '_CreatedAt', '_ModifiedBy', '_ModifiedAt', '_LockedBy', '_LockedAt', '_UnlockedBy', '_UnlockedAt', '_LockState', '_OwnedBy'];\n const data = { ...this.state.data };\n //const groupsVisibility = { ...this.state.groupsVisibility }; //maybe\n const groupsVisibility = {}; //maybe\n const localEnumValues = JSON.parse(JSON.stringify(this.state.defaultEnumValues));\n for (const key in response.data.Events.Values[0]) {\n if (systemColumns.includes(key) || !this.state.fields.hasOwnProperty(key)) {\n if (key === '_NodeId') {\n this.setState({ _nodeId: response.data.Events.Values[0][key] })\n }\n else if (key === '_ID') {\n this.setState({ _itemId: response.data.Events.Values[0][key] })\n }\n else if (key === '_LockState') {\n this.setState({ _lockState: response.data.Events.Values[0][key] })\n }\n else if (key === '_CreatedBy') {\n this.setState({ _createdBy: response.data.Events.Values[0][key] })\n }\n else if (key === '_OwnedBy') {\n this.setState({ _ownedBy: response.data.Events.Values[0][key] })\n }\n else if (key === '_EventID') {\n this.setState({ _eventId: response.data.Events.Values[0][key] })\n }\n else if (key === '_ParentID') {\n this.setState({ _parentId: response.data.Events.Values[0][key] })\n }\n\n continue;\n }\n\n const field = this.state.fields[key];\n if (field.EventField.ValidationFunctionName === 'enum') {\n let tmpVal = response.data.Events.Values[0][key] ? response.data.Events.Values[0][key].trim() : undefined;\n data[field.EventField.Name] = (tmpVal === '' || tmpVal === undefined) ? undefined : { label: this.props.context.t(tmpVal), value: tmpVal };\n //enumValuesLocal[field.EventField.Name] = field.EventField.ValidationFunctionParameter.split(';').filter(el => el.trim() !== '').map(el => ({ label: el.trim(), value: el.trim() }));\n }\n else if (isDate(field.EventField.BuiltInType) && response.data.Events.Values[0][key]) {\n data[key] = new Date(response.data.Events.Values[0][key]);\n }\n else {\n data[key] = response.data.Events.Values[0][key];\n\n }\n\n\n //check groups and fields hiding with new values from the response\n\n if (field.AssociatedGroups) {\n //this is where the magic happens:\n this.setTargetsVisibilities(field, localEnumValues, groupsVisibility, data[key]);\n\n\n\n\n //visibilityControls[f.EventField.Name] = [...localVisibilityControls];\n this.setState({ groupsVisibility: groupsVisibility/*, visibilityControls: visibilityControls*/ });\n\n }\n\n this.setState({ enumValues: localEnumValues });\n\n\n\n\n\n\n\n\n //if (field.DefaultValue && !response.data.Events.Values[0][key] && this.state.visibilityControls[field.EventField.Name]) {\n // this.state.visibilityControls[field.EventField.Name].forEach(el => {\n // groupsVisibility[el]--;\n // });\n //} else if (!field.DefaultValue && response.data.Events.Values[0][key] && this.state.visibilityControls[field.EventField.Name]) {\n // this.state.visibilityControls[field.EventField.Name].forEach(el => {\n // groupsVisibility[el]++;\n // });\n //}\n }\n this.setState({ data: data, groupsVisibility: groupsVisibility });\n\n axiosUser.get('/rightsforusernameandevent?name=' + this.props.context.user.name + '&nodeId=' + this.state._nodeId + '&eventId=' + this.state._eventId + (this.state._ownedBy ? (\"&eventOwner=\" + this.state._ownedBy) : \"\"))\n .then(response => {\n const userrights = JSON.parse(response.data);\n var user = this.props.context.user;\n user.rights = userrights;\n localStorage.setItem('user', JSON.stringify(user));\n this.setState({ user: user });\n })\n .catch(error => {\n console.log(error);\n });\n\n }\n\n if (this.state._parentId !== undefined) {\n var pl = document.getElementById('parentlink');\n if (pl !== undefined && pl !== null)\n this.loadParentLink(this.state._parentId);\n }\n\n this.props.context.hideLoading();\n })\n .catch(error => {\n this.props.context.pushAlert({ variant: 'danger', message: 'Unable load event.' });\n console.log(error);\n this.props.context.hideLoading();\n });\n }\n\n loadEntry = (id, guid = undefined, nodeid = undefined) => {\n if (id) {\n this.props.context.showLoading();\n axios.get(`/eventtypepage/${id}`)\n .then(response => {\n const entry = JSON.parse(response.data);\n const data = {};\n const fields = {};\n\n const groupsVisibility = {}; //maybe\n var defaultEnumValues = {};\n var localEnumValues = [];\n\n entry.Groups.forEach(g => {\n g.EventFieldsGroupEventFields.forEach(f => {\n if (f.EventField.ValidationFunctionName === 'enum') {\n defaultEnumValues[f.EventField.Name] = f.EventField.ValidationFunctionParameter.split(';').filter(el => el.trim() !== '').map(el => ({ label: this.props.context.t(el.trim()), value: el.trim() }));\n }\n });\n });\n this.setState({ defaultEnumValues: defaultEnumValues });\n localEnumValues = JSON.parse(JSON.stringify(defaultEnumValues));\n\n\n\n this.props.context.setHeading(this.props.context.t(entry.Name));\n entry.Groups.forEach(g => {\n g.InfoText = g.InfoText.trim().length ? g.InfoText.trim() : undefined;\n g.EventFieldsGroupEventFields.forEach(f => {\n if (f.Visible) {\n fields[f.EventField.Name] = f;\n }\n\n if (f.DefaultValue) {\n if (f.EventField.ValidationFunctionName === 'enum')\n data[f.EventField.Name] = { label: this.props.context.t(f.DefaultValue), value: f.DefaultValue };\n else if (f.DefaultValue === '{{[@Me]}}')\n data[f.EventField.Name] = this.props.context.user.name;\n else if (f.DefaultValue.startsWith('{{') && f.DefaultValue.endsWith('}}')) {\n const param = f.DefaultValue.substring(2, f.DefaultValue.length - 2).trim();\n const parsed = queryString.parse(this.props.location.search);\n data[f.EventField.Name] = parsed[param] ? parsed[param] : undefined;\n }\n else\n data[f.EventField.Name] = f.DefaultValue;\n }\n else {\n data[f.EventField.Name] = isDate(f.EventField.BuiltInType) ? null : undefined;\n }\n\n if (f.AssociatedGroups) {\n //multiple values\n\n //const localVisibilityControls = {};\n\n\n\n\n //this is where the magic happens:\n this.setTargetsVisibilities(f, localEnumValues, groupsVisibility, f.DefaultValue);\n\n\n\n\n //visibilityControls[f.EventField.Name] = [...localVisibilityControls];\n this.setState({ groupsVisibility: groupsVisibility });\n }\n this.setState({ enumValues: localEnumValues });\n\n\n });\n g.EventFieldsGroupEventFields.sort((a, b) => a.Order > b.Order ? 1 : -1);\n\n });\n entry.Groups.sort((a, b) => a.Order > b.Order ? 1 : -1)\n this.setState({ entry: entry, data: data, fields: fields }, () => {\n if (guid) {\n this.loadEvent(this.state.entry.EventType.Name, guid, nodeid);\n }\n });\n this.props.context.hideLoading();\n })\n .catch(error => {\n this.props.context.pushAlert({ variant: 'danger', message: 'Unable to load the form.' });\n console.log(error);\n this.props.context.hideLoading();\n });\n }\n else\n this.props.context.pushAlert({ variant: 'danger', message: 'Unable to load the form.' });\n }\n\n componentWillReceiveProps = (nextProps) => {\n if (nextProps.match.url !== this.props.match.url) {\n const { match: { params } } = nextProps;\n this.loadEntry(params.id, params.eventId, params.nodeId);\n }\n }\n\n componentDidMount = () => {\n const { match: { params } } = this.props;\n this.loadEntry(params.id, params.eventId, params.nodeId);\n }\n\n\n setTargetsVisibilities(f, localEnumValues, groupsVisibility, valueToUse) {\n const localTargetsVisibility = {};\n\n const lines = f.AssociatedGroups.split('\\n').map(el => el.trim());\n lines.forEach(l => {\n var lineValue;\n var lineTargets;\n if (l.indexOf(\":\") > 0) {\n //value:\n var linesplit = l.split(':').map(el => el.trim());\n lineValue = linesplit[0].trim();\n lineTargets = linesplit[1].split(';').map(el => el.trim());\n lineTargets.forEach(target => {\n if (valueToUse == lineValue || (valueToUse != undefined && valueToUse.value == lineValue)) { // 1 - equals\n if (target.startsWith(\"!\")) { // 2 - inverse branch\n target = target.substring(1);\n if (target.indexOf(\"(\") >= 0) { // 3 - enum\n var { enumFieldName, filteredValues } = this.getEnumValues(target, true, localEnumValues);\n localEnumValues[enumFieldName] = [...filteredValues];\n }\n else { // 3 - not enum\n if (localTargetsVisibility.hasOwnProperty(target))\n localTargetsVisibility[target] = localTargetsVisibility[target] - 1;\n else\n localTargetsVisibility[target] = 0;\n }\n }\n else { // 2 - regular branch\n if (target.indexOf(\"(\") >= 0) { // 3 - enum\n var { enumFieldName, filteredValues } = this.getEnumValues(target, false, localEnumValues);\n localEnumValues[enumFieldName] = [...filteredValues];\n }\n else { // 3 - not enum\n if (localTargetsVisibility.hasOwnProperty(target))\n localTargetsVisibility[target] = localTargetsVisibility[target] + 1;\n else\n localTargetsVisibility[target] = 1;\n }\n }\n }\n else { // 1 - does not equal\n if (target.startsWith(\"!\")) { // 2 - inverse branch\n target = target.substring(1);\n if (target.indexOf(\"(\") >= 0) { // 3 - enum\n var { enumFieldName, filteredValues } = this.getEnumValues(target, false, localEnumValues);\n localEnumValues[enumFieldName] = [...filteredValues];\n }\n else { // 3 - not enum\n if (localTargetsVisibility.hasOwnProperty(target))\n localTargetsVisibility[target] = localTargetsVisibility[target] + 1;\n else\n localTargetsVisibility[target] = 1;\n }\n }\n else { // 2 - regular branch\n if (target.indexOf(\"(\") >= 0) { // 3 - enum\n var { enumFieldName, filteredValues } = this.getEnumValues(target, true, localEnumValues);\n localEnumValues[enumFieldName] = [...filteredValues];\n }\n else { // 3 - not enum\n if (localTargetsVisibility.hasOwnProperty(target))\n localTargetsVisibility[target] = localTargetsVisibility[target] - 1;\n else\n localTargetsVisibility[target] = 0;\n }\n }\n }\n });\n //localVisibilityControls[lineValue] = lineTargets;\n }\n else {\n //no value (so the below is true for any value)\n lineValue = \"###NOVALUE\";\n lineTargets = l.split(';').map(el => el.trim());\n lineTargets.forEach(target => {\n if (valueToUse) { // 1 - value \"equals\"\n if (target.startsWith(\"!\")) { // 2 - inverse branch\n target = target.substring(1);\n if (target.indexOf(\"(\") >= 0) { // 3 - enum\n var { enumFieldName, filteredValues } = this.getEnumValues(target, true, localEnumValues);\n localEnumValues[enumFieldName] = [...filteredValues];\n }\n else { // 3 - not enum\n if (localTargetsVisibility.hasOwnProperty(target))\n localTargetsVisibility[target] = localTargetsVisibility[target] - 1;\n else\n localTargetsVisibility[target] = 0;\n }\n }\n else { // 2 - regular branch\n if (target.indexOf(\"(\") >= 0) { // 3 - enum\n var { enumFieldName, filteredValues } = this.getEnumValues(target, false, localEnumValues);\n localEnumValues[enumFieldName] = [...filteredValues];\n }\n else { // 3 - not enum\n if (localTargetsVisibility.hasOwnProperty(target))\n localTargetsVisibility[target] = localTargetsVisibility[target] + 1;\n else\n localTargetsVisibility[target] = 1;\n }\n }\n }\n else { // 1 - value doesn't \"equal\"\n if (target.startsWith(\"!\")) { // 2 - inverse branch\n target = target.substring(1);\n if (target.indexOf(\"(\") >= 0) { // 3 - enum\n var { enumFieldName, filteredValues } = this.getEnumValues(target, false, localEnumValues);\n localEnumValues[enumFieldName] = [...filteredValues];\n }\n else { // 3 - not enum\n if (localTargetsVisibility.hasOwnProperty(target))\n localTargetsVisibility[target] = localTargetsVisibility[target] + 1;\n else\n localTargetsVisibility[target] = 1;\n }\n }\n else { // 2 - regular branch\n if (target.indexOf(\"(\") >= 0) { // 3 - enum\n var { enumFieldName, filteredValues } = this.getEnumValues(target, true, localEnumValues);\n localEnumValues[enumFieldName] = [...filteredValues];\n }\n else { // 3 - not enum\n if (localTargetsVisibility.hasOwnProperty(target))\n localTargetsVisibility[target] = localTargetsVisibility[target] - 1;\n else\n localTargetsVisibility[target] = 0;\n }\n }\n }\n });\n //localVisibilityControls[lineValue] = lineTargets;\n }\n });\n\n for (var target in localTargetsVisibility) {\n\n if (localTargetsVisibility[target] > 0) {\n if (groupsVisibility.hasOwnProperty(target))\n groupsVisibility[target] = groupsVisibility[target] + 1;\n else\n groupsVisibility[target] = 1\n } else {\n if (groupsVisibility.hasOwnProperty(target))\n groupsVisibility[target] = groupsVisibility[target] - 1;\n else\n groupsVisibility[target] = 0\n }\n if (groupsVisibility[target] < 0)\n groupsVisibility[target] = 0;\n }\n\n }\n\n getEnumValues(target, isThisInverted, localEnumValues) {\n var enumsplit = target.split('(');\n var enumFieldName = enumsplit[0];\n var enumvalues = enumsplit[1].replace(\")\", \"\").split(\",\").filter(el => el.trim() !== '').map(el => ({ label: this.props.context.t(el.trim()), value: el.trim() }));\n var filteredValues = {};\n if (isThisInverted) {\n //filters out only the exclusion\n filteredValues = localEnumValues[enumFieldName] !== undefined ? localEnumValues[enumFieldName].filter(el => !enumvalues.map(a => a.value).includes(el.value)) : [];\n }\n else {\n //filters out only the intersection\n filteredValues = localEnumValues[enumFieldName] !== undefined ? localEnumValues[enumFieldName].filter(el => enumvalues.map(a => a.value).includes(el.value)) : [];\n }\n return { enumFieldName, filteredValues };\n }\n\n\n shareEntry = (e) => {\n e.preventDefault();\n\n this.props.context.showLoading();\n const lockvals = {};\n lockvals['eventid'] = this.state._eventId;\n lockvals['nodeid'] = this.state._nodeId;\n\n axiosData.post('/old/calls/custompost', {\n url: `eventunlock`,\n values: lockvals\n })\n .then(response => {\n this.props.context.hideLoading();\n if (response.data.Result) {\n this.setState({ _lockState: 'Unlocked' });\n }\n else {\n this.props.context.pushAlert({ variant: 'danger', message: 'Error occured when locking the item.' });\n }\n })\n .catch(error => {\n console.log(error);\n });\n\n }\n\n\n\n getOwners = (query) => {\n return axiosUser.get('/allavailableowners', { params: { name: query } }).then(response => {\n if (response && response.data) {\n const tmp = JSON.parse(response.data).map((el, index) => ({ value: el, label: el }));\n return tmp;\n }\n return [];\n }).catch(error => console.log(error));\n }\n\n\n setNewOwner = (e) => {\n var val = e.target.value;\n this.setState({ _newOwner: val.value });\n }\n\n removeParentLink = () => {\n var pl = document.getElementById('parentlink');\n if (pl !== undefined && pl !== null)\n pl.remove();\n }\n\n loadParentLink = (parentId) => {\n if (parentId === undefined || typeof parentId !== 'string') {\n //this shouldn't happen, but just in case\n this.removeParentLink();\n return;\n }\n\n var eventtypeid = parentId.split('_')[0];\n\n //get parent form id first\n axios.get(`/EventTypePage/GetForEventType/${eventtypeid}`)\n .then(response => {\n const parentFormId = JSON.parse(response.data);\n\n //try a data call for parent record, so we know if we can see it\n axiosData.post('/old/calls/custom', {\n url: `/api/client/AhlstromMunksjo/event?eventtypeid=${eventtypeid}&eventid=${parentId}`\n })\n .then(response => {\n if (response.data && response.data.Events && response.data.Events.Values) {\n const parentNodeId = response.data.Events.Values[0]['_NodeId'];\n\n if (parentNodeId !== undefined) {\n //if all went well, show the correct link\n var pl = document.getElementById('parentlink');\n if (pl !== undefined && pl !== null) {\n pl.setAttribute('href', `/dataentry/form/${parentFormId}/${parentId}/${parentNodeId}`);\n pl.textContent = 'Link to parent record';\n }\n }\n }\n })\n .catch(error => {\n console.log(error);\n this.removeParentLink();\n });\n })\n .catch(error => {\n console.log(error);\n this.removeParentLink();\n });\n }\n\n\n render() {\n const { match: { params } } = this.props;\n var localParentId = params.parentId;\n if (localParentId === undefined || localParentId === null || localParentId === '')\n localParentId = this.state._parentId;\n if (this.state.entry)\n return (\n \n\n \n {params.eventId && localParentId && params.parentFormId ? (\n //if parent id is set show link to parent\n //if parent id is set so should be parent node id\n <>\n Link to parent record \n >\n )\n :\n params.eventId && localParentId ? (\n\n //only parentId is set up - we need to figure out the parentFormId and parentNodeId\n //but we do that in a separate api call - now we only show an inactive link\n <>\n Link to parent record (fetching) \n >\n\n )\n :\n null}\n \n\n {this.state._itemId !== undefined ? (this.props.context.t(this.state.entry.Name) + \" #\" + this.state._itemId) : this.props.context.t(this.state.entry.Name)} {this.state._lockState === \"Locked\" ? (this.props.context.t(\"[Locked]\")) : (\"\")} \n\n \n\n\n\n\n {\n this.state.entry.AllowAssociatedEvents && params.eventId && this.state._nodeId ? (\n \n \n {this.state.entry.AssociatedEventDataViews.map((view, i) => (\n \n ))}\n \n ) : null\n }\n {\n !this.state.entry.DisableAttachments && params.eventId && this.state._nodeId ? (\n <>\n \n \n >\n ) : null\n }\n {\n params.eventId && this.state._nodeId ? (\n <>\n \n \n >\n ) : null\n }\n\n \n \n Change owner \n \n \n \n\n \n \n \n Close\n \n \n Save new owner\n \n \n \n\n \n\n );\n else\n return null;\n }\n\n\n\n setIntervalImmediately(func, interval) {\n func();\n return setInterval(func, interval);\n }\n}\n\nexport default withContext(Entry);","import React from 'react';\nimport {Route, Switch} from 'react-router-dom';\nimport Form from './Form';\nimport List from './List';\nimport Entry from './Entry';\nimport {Container} from 'react-bootstrap';\n\nexport default props => (\n \n \n \n \n \n \n \n \n \n \n);\n\n","import React from 'react';\nimport {Button, ButtonGroup} from 'react-bootstrap';\nimport AsyncSelect from '../../components/Select/AsyncSelect';\nimport BootstrapInput from '../../components/FormInput/BootstrapInput2';\nimport Switch from '../../components/Switch/Switch';\nimport DataViewColumn from '../../components/DataViewColumn/DataViewColumn';\nimport {DragDropContext, Droppable} from 'react-beautiful-dnd';\nimport {set, cloneDeep} from 'lodash';\nimport {SORT_ORDER} from '../../components/DataViewColumn/DataViewColumn';\nimport withContext from '../../hoc/withContext';\nimport axios from '../../helpers/axiosWebEntry';\nimport axiosData from '../../helpers/axiosData';\nimport axiosUser from '../../helpers/axiosUser';\nimport {array_move} from '../../helpers/utils';\nimport * as yup from 'yup';\n\nconst schema = yup.object().shape({\n Name: yup.string().required('Required.'),\n URL: yup.string().required('Required.'), \n Roles: yup.array().required('Required.'),\n WebEntries: yup.array().required('Required.'),\n});\n\nclass Form extends React.Component {\n state = {\n dirty: false,\n data: {\n Name: '',\n URL: '',\n WebEntries: [],\n Roles: [],\n NewEventTypePage: undefined,\n VisibleInMenu: false,\n Columns: []\n },\n error:{}\n }\n \n componentDidMount=()=>{\n this.props.context.setHeading('Data View Form');\n const {match: {params}} = this.props;\n \n\n if(params.id){\n this.props.context.showLoading();\n axios.get(`/eventlistview/${params.id}`)\n .then(response => {\n const data = JSON.parse(response.data);\n data.WebEntries = data.WebEntries.map(el=>({value:el.EventTypePageEntity.ID, label:el.EventTypePageEntity.Name}));\n data.Roles = data.Roles.map(el=>({value:el.IdentityRole.Id, label:el.IdentityRole.Name}));\n data.NewEventTypePage = data.NewEventTypePage ? {label: data.NewEventTypePage.Name, value: data.NewEventTypePage.ID}: undefined;\n data.Columns.sort((a,b) => a.Order > b.Order ? 1 : -1);\n data.Columns = data.Columns.map(el=>({\n EventField: el.EventField.Name,\n DisplayName: el.DisplayName,\n Width: el.Width,\n Visible: el.Visible,\n Filter: el.Filter,\n WordWrap: el.WordWrap,\n ColumnOrder: el.ColumnOrder!==undefined ? SORT_ORDER.find(o=>o.value === el.ColumnOrder) : undefined\n }));\n this.setState({data:data});\n this.props.context.hideLoading();\n })\n .catch(error=>{\n console.log(error);\n this.props.context.hideLoading();\n });\n }\n }\n\n getRoles = (query) => {\n return axiosUser.get('/roles', {params:{name:query}}).then(response=>{\n if (response && response.data){\n const tmp = JSON.parse(response.data).map((el, index)=>({value:el.Id, label:el.Name}));\n return tmp;\n }\n return [];\n }).catch(error=>console.log(error));\n }\n\n getEntries = (query) => {\n return axios.get('/eventtypepage', {params:{name:query}}).then(response=>{\n if (response.data){\n const tmp = response.data.map((el, index)=>({value:el.id, label:el.name}));\n return tmp;\n }\n return [];\n }).catch(error=>console.log(error));\n }\n\n onChange=(e)=>{\n const name = e.target.name;\n const value = e.target.value;\n this.setState(prevState=>{\n const data = cloneDeep(prevState.data);\n const error = {...this.state.error}; \n set(data, name, value);\n set(error, name, undefined);\n return {data:data, dirty: true, error: error};\n });\n }\n\n onClose=()=>{\n if(!this.state.dirty){\n this.props.history.goBack();\n return;\n }\n if(window.confirm('There are unsaved changes, do you want to leave?')){\n this.props.history.goBack();\n return;\n }\n }\n\n onRemove=(index)=>{\n const data = {...this.state.data};\n data.Columns.splice(index, 1);\n this.setState({data:data});\n }\n\n onDragEnd = (fields) => {\n if(!fields.destination)\n return;\n const from = fields.source.index;\n const to = fields.destination.index;\n const data = {...this.state.data}\n array_move(data.Columns, from, to);\n this.setState({data:data});\n }\n\n loadColumns = () => {\n this.props.context.showLoading();\n axiosData.post('/old/calls/custom' ,{url: this.state.data.URL})\n .then(response=>{\n const systemColumns = ['_EventID', '_NodeId', '_EventTime', '_StorageTime', '_EventTypeID', '_ParentID', '_ID',\n '_CreatedBy', '_CreatedAt', '_ModifiedBy', '_ModifiedAt', '_LockedBy', '_LockedAt', '_UnlockedBy', '_UnlockedAt', '_LockState', '_OwnedBy'];\n const data = {...this.state.data};\n const fields = {};\n \n response.data.Events.Values.forEach(ev=>{\n for (let key in ev){\n if (key in fields || systemColumns.includes(key))\n continue;\n fields[key] = {\n EventField: key,\n DisplayName: '',\n Width: '',\n Filter: '',\n WordWrap: false,\n Visible: true,\n ColumnOrder: 0\n }\n }\n });\n data.Columns = Object.keys(fields).map(el=>fields[el]);\n this.setState({data:data});\n this.props.context.hideLoading();\n })\n .catch(error=>{\n console.log(error);\n this.props.context.pushAlert({variant:'danger', message:'Unable load or parse URL response structure.'});\n const data = {...this.state.data};\n data.Columns = [];\n this.setState({data:data});\n this.props.context.hideLoading();\n });\n \n }\n\n handleSubmit = (e) => {\n e.preventDefault();\n const name = e.target.name;\n schema.validate(this.state.data, {abortEarly:false})\n .then(valid=>{\n this.props.context.showLoading();\n const {match: {params}} = this.props;\n const data = {...this.state.data};\n data.Roles = data.Roles.map(item=>({IdentityRoleId: item.value}));\n data.WebEntries = data.WebEntries.map(el=>({\n EventTypePageEntity: {ID:el.value},\n \n }));\n data.NewEventTypePage = data.NewEventTypePage ? {ID:data.NewEventTypePage.value}: undefined;\n data.Columns = data.Columns.map((col,i)=>({\n ...col,\n ColumnOrder: col.ColumnOrder? col.ColumnOrder.value : undefined,\n Order: i,\n Width: col.Width ? col.Width : 0,\n EventField: {Name: col.EventField}\n }));\n if(params && params.id){\n axios.put(`/eventlistview/${data.ID}`, data)\n .then(response=>{\n this.setState({dirty: false});\n this.props.context.pushAlert({variant:'success', message: 'Item updated.'});\n this.props.context.hideLoading();\n if(name==='SaveClose')\n this.props.history.push('/dataview');\n }).catch(error=>{\n this.props.context.pushAlert({variant:'danger', message: 'Error occured. Item was not updated.'});\n console.log(error);\n this.props.context.hideLoading();\n });\n } else {\n axios.post(`/eventlistview`, data)\n .then(response=>{\n this.setState({dirty: false});\n this.props.context.pushAlert({variant:'success', message: 'Item created.'});\n this.props.context.hideLoading();\n if(name==='SaveClose')\n this.props.history.push('/dataview');\n else\n this.props.history.push(`/dataview/update/${response.data.id}`);\n }).catch(error=>{\n this.props.context.pushAlert({variant:'danger', message: 'Error occured. Item was not created.'});\n console.log(error);\n this.props.context.hideLoading();\n });\n }\n })\n .catch(errors=>{\n const error = {};\n errors.inner.forEach(el=>{\n set(error,el.path, el.message);\n });\n this.setState({error:error});\n })\n \n \n \n }\n\n render() {\n const error = this.state.error;\n return(\n \n );\n }\n}\n\nexport default withContext(Form);","import React from 'react';\nimport axios from '../../helpers/axiosWebEntry';\nimport withContext from '../../hoc/withContext';\nimport ReactTable from 'react-table';\n\n\nclass Roster extends React.Component {\n\n state={\n rows:[]\n }\n\n loadRows = () => {\n this.props.context.showLoading();\n axios.get('/eventlistview?loadDisabled=true')\n .then(response => {\n this.setState({rows:response.data});\n this.props.context.hideLoading();\n })\n .catch(error=>{\n console.log(error);\n this.props.context.hideLoading();\n });\n }\n\n componentDidMount=()=>{\n this.props.context.setHeading('Data Views');\n this.loadRows();\n }\n\n render() {\n return (\n \n {\n const id = filter.pivotId || filter.id\n return row[id] !== undefined ? String(row[id]).search(new RegExp(filter.value, 'i'))>-1 : true\n }}\n columns={\n [\n {accessor: 'id', show: false},\n {Header:'Name', accessor: 'name'},\n ]\n }\n getTdProps={(state, rowInfo, column, instance) => {\n if(column.id!=='actions')\n return {\n onClick: (e, handleOriginal)=>{\n if (handleOriginal) {\n handleOriginal();\n }\n this.props.history.push(`/dataview/detail/${rowInfo.row.id}`);\n\n },\n style: {cursor: 'pointer'}\n };\n return {};\n }}\n />\n
\n );\n }\n}\n\nexport default withContext(Roster);","import React from 'react';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport axios from '../../helpers/axiosWebEntry';\nimport withContext from '../../hoc/withContext';\nimport ReactTable from 'react-table';\nimport {ButtonGroup, Button} from 'react-bootstrap';\n\n\n\nclass List extends React.Component {\n\n state={\n rows:[]\n }\n\n addHandler = () => {\n this.props.history.push('/dataview/create/');\n }\n\n removeHandler = (id) => {\n this.props.context.showLoading();\n axios.delete(`/eventlistview/${id}`)\n .then(response => {\n this.props.context.pushAlert({variant:'success', message: 'Item deleted.'});\n this.loadRows();\n })\n .catch(error=>{\n console.log(error);\n this.props.context.pushAlert({variant:'danger', message: 'Unable to delete item.'});\n this.loadRows();\n });\n }\n\n loadRows = () => {\n this.props.context.showLoading();\n axios.get('/eventlistview?loadDisabled=true')\n .then(response => {\n this.setState({rows:response.data});\n this.props.context.hideLoading();\n })\n .catch(error=>{\n console.log(error);\n this.props.context.hideLoading();\n });\n }\n\n componentDidMount=()=>{\n this.props.context.setHeading('Data View Settings');\n this.loadRows();\n }\n\n render() {\n return (\n \n
Data Views \n {this.props.history.push('/dataview/create/')}}/>\n \n {\n const id = filter.pivotId || filter.id\n return row[id] !== undefined ? String(row[id]).search(new RegExp(filter.value, 'i'))>-1 : true\n }}\n columns={\n [\n {accessor: 'id', show: false},\n {Header:'Name', accessor: 'name'},\n {Header: 'Event Type', accessor: 'url'},\n {id: 'actions', filterable:false,width:150,Cell:({row})=>{\n if(row._original){\n return(\n \n {this.props.history.push(`/dataview/update/${row._original.id}`)}}> \n {this.removeHandler(row._original.id)}}> \n \n )\n }\n }}\n ]\n }\n getTdProps={(state, rowInfo, column, instance) => {\n if(column.id!=='actions')\n return {\n onClick: (e, handleOriginal)=>{\n if (handleOriginal) {\n handleOriginal();\n }\n this.props.history.push(`/dataview/detail/${rowInfo.row.id}`);\n\n },\n style: {cursor: 'pointer'}\n };\n return {};\n }}\n />\n \n );\n }\n}\n\nexport default withContext(List);","import React from 'react';\nimport ReactTable from 'react-table';\nimport 'react-table/react-table.css';\nimport { SORT_ORDER } from '../../components/DataViewColumn/DataViewColumn';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport axios from '../../helpers/axiosWebEntry';\nimport axiosData from '../../helpers/axiosData';\nimport withContext from '../../hoc/withContext';\nimport { isDate } from '../../helpers/enums';\nimport { get_locale } from '../../helpers/utils';\nimport { format, toDate } from 'date-fns';\nimport { Row, Col } from 'react-bootstrap';\nimport AsyncSelect from '../../components/Select/AsyncSelect';\n\n\nconst loc = get_locale();\n\nclass Detail extends React.Component {\n _isMount = false;\n\n state = {\n rows: [],\n isLoading: false,\n selectedView: undefined\n }\n\n loadRows = () => {\n this.setState({ isLoading: true }, () => {\n axiosData.post('/old/calls/custom', { url: this.state.data.URL })\n .then(response => {\n this.setState({ rows: response.data.Events.Values, isLoading: false });\n })\n .catch(error => {\n this.props.context.pushAlert({ variant: 'danger', message: 'Unable load data.' });\n this.setState({ isLoading: false });\n console.log(error);\n });\n });\n }\n\n loadView = (id) => {\n this.props.context.showLoading();\n axios.get(`/eventlistview/${id}`)\n .then(response => {\n const data = JSON.parse(response.data);\n\n\n this.props.context.setHeading(this.props.context.t(data.WebEntries[0].EventTypePageEntity.EventType.DisplayName));\n data.Columns.sort((a, b) => a.Order > b.Order ? 1 : -1);\n data.Columns = data.Columns.map(el => ({\n accessor: el.EventField.Name,\n Header: el.DisplayName ? this.props.context.t(el.DisplayName) : this.props.context.t(el.EventField.Name),\n width: el.Width ? el.Width : undefined,\n show: el.Visible,\n filter: el.Filter ? (el.Filter.trim() === '{{[@Me]}}' ? this.props.context.user.name : el.Filter) : undefined,\n Filter: el.Filter ? ({ filter, onChange }) => ( ) : undefined,\n ColumnOrder: SORT_ORDER.find(o => o.value === el.ColumnOrder),\n className: el.WordWrap ? 'wordWrap' : undefined,\n headerClassName: el.WordWrap ? 'wordWrap' : undefined,\n Cell: prop => {\n if (prop.value && isDate(el.EventField.BuiltInType)) {\n return ({format(toDate(prop.value), 'P p', { locale: loc })} )\n }\n return ({prop.value ? prop.value.toString() : null} )\n }\n }));\n\n //delete button for admin\n //if (this.props.context.user && this.props.context.user.roles && this.props.context.user.roles.includes('Admin')) {\n // data.Columns.Add({\n // accessor: \"DeleteButtonColumn\",\n // Header: \"Actions\",\n // //width: undefined,\n // show: true,\n // ColumnOrder: 999999,\n // Cell: ({ cell }) => (\n // {this.props.context.t(\"Delete\")} \n // \n // {cell.row.values.name}\n // \n // )\n // })\n //}\n\n\n data.sort = data.Columns.filter(el => el.ColumnOrder.value !== 0).map(el => ({\n id: el.accessor,\n desc: el.ColumnOrder.value > 1 ? true : false\n }));\n if (this._isMount) {\n this.setState({ data: data, isLoading: true, selectedView: { label: this.props.context.t(data.Name), value: data.ID } }, () => {\n this.loadRows();\n });\n }\n this.props.context.hideLoading();\n\n })\n .catch(error => {\n console.log(error);\n this.props.context.hideLoading();\n });\n }\n\n //deleteEntry = () => {\n // if (!window.confirm('Do you really want to delete this entry? This can not be undone.')) {\n // return;\n // }\n\n // this.props.context.showLoading();\n\n // //const reqData = {};\n // //reqData['eventid'] = this.state._eventId;\n // //reqData['nodeid'] = this.state._nodeId;\n\n\n // axiosData.delete(`/v1/${this.state.entry.EventType.Name}/event/${this.state._eventId}`, { headers: { 'Content-Type': 'application/json; charset=utf-8' }, data: { NodeId: this.state._nodeId } })\n // .then(response => {\n // this.props.context.hideLoading();\n // if (response.data != undefined && response.data.Result) {\n // this.props.context.pushAlert({ variant: 'success', message: 'Item deleted.' });\n // }\n // else {\n // this.props.context.pushAlert({ variant: 'danger', message: 'Error occured when deleting the item.' });\n // }\n // })\n // .catch(error => {\n // this.props.context.hideLoading();\n // console.log(error);\n // });\n //}\n\n componentWillUnount = () => {\n this._isMount = false;\n }\n\n componentDidMount = () => {\n this._isMount = true;\n const { match: { params } } = this.props;\n\n if (params.id)\n this.loadView(params.id);\n }\n\n onChangeView = (selected) => {\n this.setState({ selectedView: selected.target.value }, () => {\n this.loadView(this.state.selectedView.value);\n });\n }\n\n getViews = (query) => {\n return axios.get('/eventlistview', { params: { name: query, eventType: this.state.data.WebEntries[0].EventTypePageEntity.EventType.ID } }).then(response => {\n if (response && response.data) {\n const tmp = response.data.map((el, index) => ({ value: el.id, label: this.props.context.t(el.name) }));\n return tmp;\n }\n return [];\n }).catch(error => console.log(error));\n }\n\n render() {\n if (this.state.data) {\n return (\n \n
\n \n \n \n \n {this.state.data.NewEventTypePage ? (\n { this.props.history.push(`/dataentry/form/${this.state.data.NewEventTypePage.ID}`) }} />\n ) : null}\n \n \n\n
\n\n\n \n
{\n const id = filter.pivotId || filter.id\n return row[id] !== undefined ? String(row[id]).search(new RegExp(filter.value, 'i')) > -1 : true\n }}\n defaultFiltered={this.state.data.Columns.filter(c => c.filter).map(c => ({ id: c.accessor, value: c.filter }))}\n style={{ maxHeight: '75vh' }}\n getTrProps={(state, rowInfo, column) => {\n return {\n onClick: (e, handleOriginal) => {\n const webEntry = this.state.data.WebEntries.find(el => el.EventTypePageEntity.EventType.ID === rowInfo.original._EventTypeID);\n //pushing a history.location.state with goBackSteps = -1 so the Save&Exit button will go here\n this.props.history.push({ pathname: `/dataentry/form/${webEntry.EventTypePageEntity.ID}/${rowInfo.original._EventID}/${rowInfo.original._NodeId}/${rowInfo.original._ParentID}`, state: { goBackSteps: -1, passedNodeId: rowInfo.original._NodeId } });\n\n },\n style: { cursor: 'pointer' }\n };\n }}\n />\n \n );\n }\n return null;\n }\n}\n\nexport default withContext(Detail);","import React from 'react';\nimport {Route, Switch} from 'react-router-dom';\nimport Form from './Form';\nimport Roster from './Roster';\nimport List from './List';\nimport Detail from './Detail';\nimport {Container} from 'react-bootstrap';\n\nexport default props => (\n \n \n \n \n \n \n \n \n \n);\n\n","import React from 'react';\nimport * as yup from 'yup';\nimport axios from '../../helpers/axiosWebEntry';\nimport axiosUser from '../../helpers/axiosUser';\nimport AsyncSelect from '../../components/Select/AsyncSelect';\nimport { Button, ButtonGroup } from 'react-bootstrap';\nimport withContext from '../../hoc/withContext';\nimport BootstrapInput from '../../components/FormInput/BootstrapInput2';\n\nconst schema = yup.object().shape({\n Title: yup.string().required('Required.'),\n Order: yup.number().integer('Must be a integer.').required('Required'),\n Roles: yup.array().required('Required.'),\n //Link: yup.string().required('Required.'),\n Image: yup.string().required('Required.'),\n Parent: yup.mixed().required('Required.')\n});\n\nclass Form extends React.Component {\n state = {\n data: {\n ID: '',\n Title: undefined,\n Description: undefined,\n Order: 0,\n Roles: [],\n Link: undefined,\n Image: undefined,\n Parent: undefined\n },\n error: {},\n dirty: false,\n }\n\n componentDidMount = () => {\n const { match: { params } } = this.props;\n this.props.context.showLoading();\n\n if (!params.id) {\n this.setState(() => ({\n data: {\n Title: undefined,\n Description: undefined,\n Order: params.order ? params.order : 0,\n Roles: [],\n Link: undefined,\n Image: undefined,\n Parent: undefined\n },\n error: {},\n dirty: false,\n }), () => {\n if (!params.parent)\n return;\n axios.get(`/landingtile/${params.parent}`).then(response => {\n if (response && response.data) {\n const parent = JSON.parse(response.data);\n const data = { ...this.state.data };\n data.Parent = { value: parent.ID, label: parent.Title }\n this.setState({ data: data });\n }\n }).catch(error => console.log(error));\n });\n\n this.props.context.hideLoading();\n } else {\n axios.get(`/landingtile/${params.id}`)\n .then(response => {\n const data = JSON.parse(response.data);\n data.Roles = data.Roles.map(el => ({ value: el.IdentityRole.Id, label: el.IdentityRole.Name }));\n data.Parent = data.Parent ? { value: data.Parent.ID, label: data.Parent.Title } : undefined;\n this.setState({ data: data });\n this.props.context.hideLoading();\n })\n .catch(error => {\n console.log(error);\n this.props.context.hideLoading();\n });\n }\n }\n\n getTiles = (query) => {\n return axios.get('/landingtile', { params: { name: query } }).then(response => {\n if (response && response.data) {\n const tmp = response.data.map((el, index) => ({ value: el.id, label: el.title }));\n return tmp;\n }\n return [];\n }).catch(error => console.log(error));\n }\n\n getRoles = (query) => {\n return axiosUser.get('/roles', { params: { name: query } }).then(response => {\n if (response && response.data) {\n const tmp = JSON.parse(response.data).map((el, index) => ({ value: el.Id, label: el.Name }));\n return tmp;\n }\n return [];\n }).catch(error => console.log(error));\n }\n\n onChange = (e) => {\n const name = e.target.name;\n const value = e.target.value;\n const data = { ...this.state.data };\n const error = { ...this.state.error }\n data[name] = value;\n error[name] = undefined;\n this.setState({ data: data, error: error, dirty: true });\n }\n\n onClose = () => {\n if (!this.state.dirty) {\n this.props.history.goBack();\n return;\n }\n if (window.confirm('There are unsaved changes, do you want to leave?')) {\n this.props.history.goBack();\n return;\n }\n }\n\n handleSubmit = (e) => {\n const name = e.target.name;\n e.preventDefault();\n schema.validate(this.state.data, { abortEarly: false }).then(values => {\n this.props.context.showLoading();\n const { match: { params } } = this.props;\n const data = { ...this.state.data };\n data.ParentId = data.Parent.value;\n data.Roles = data.Roles.map(item => ({ IdentityRoleId: item.value }));\n\n if (params && params.id) {\n axios.put(`/landingtile/${data.ID}`, data)\n .then(response => {\n this.setState({ dirty: false });\n this.props.context.pushAlert({ variant: 'success', message: 'Item updated.' });\n this.props.context.hideLoading();\n if (name === 'SaveClose')\n this.props.history.goBack();\n }).catch(error => {\n this.props.context.pushAlert({ variant: 'danger', message: 'Error occured. Item was not updated.' });\n console.log(error);\n this.props.context.hideLoading();\n });\n } else {\n axios.post(`/landingtile`, data)\n .then(response => {\n this.setState({ dirty: false });\n this.props.context.pushAlert({ variant: 'success', message: 'Item created.' });\n this.props.context.hideLoading();\n if (name === 'SaveClose')\n this.props.history.goBack();\n else\n this.props.history.push(`/landingtile/update/${response.data.id}`);\n }).catch(error => {\n this.props.context.pushAlert({ variant: 'danger', message: 'Error occured. Item was not created.' });\n console.log(error);\n this.props.context.hideLoading();\n });\n }\n }).catch(errors => {\n console.log(errors);\n const error = {};\n errors.inner.forEach(el => {\n error[el.path] = el.message;\n });\n this.setState({ error: error });\n });\n\n }\n\n\n render() {\n const error = this.state.error;\n return (\n \n \n
\n );\n }\n}\n\nexport default withContext(Form);","import React from 'react';\nimport { Card } from 'react-bootstrap';\nimport { Link } from 'react-router-dom';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { withRouter } from 'react-router-dom';\nimport { isUrlAbsolute } from '../../helpers/utils';\n\n/**\n * Component of landing page card.\n * Props:\n * - allowEdit: display admin icons on tile\n * - disableRemoving: hide remove icon, used on root or add tiles\n * - onRemoveTile: callback called on removing tile from parent\n * - image: tile image\n * - title: tile title\n * - description: tile description text\n * - ID: tile id (from db)\n * - link: tile link; tile redirects on link; if not provided it will open page with child tiles\n */\nexport default withRouter(props => {\n const component = (\n \n {props.allowEdit ? (\n \n {\n e.preventDefault();\n props.history.push(`/landingtile/update/${props.ID}`);\n }} />\n\n {!props.DisableRemoving ?\n {\n e.preventDefault();\n props.onRemoveTile(props.ID);\n }} />\n : null\n }\n
\n ) : null}\n \n \n {props.context.t(props.Title)} \n \n {props.context.t(props.Description)}\n \n \n \n );\n\n return (\n \n {isUrlAbsolute(props.Link) ?\n (\n \n {component}\n \n ) :\n (\n \n {component}\n \n )\n }\n \n );\n});","import React from 'react';\nimport withContext from '../../hoc/withContext';\n\nconst NoTilesMessage = props => (\n props.hidemessage\n ? null\n : \n {props.context.user\n ? {process.env.REACT_APP_NO_ROLES_MESSAGE}
\n : {process.env.REACT_APP_NOT_LOGGED_MESSAGE}
\n }\n \n);\n\nexport default withContext(NoTilesMessage);","import React from 'react';\nimport Tile from '../../components/LandingPageCard/LandingPageCard';\nimport { Col, Row, Container } from 'react-bootstrap';\nimport NoTilesMessage from './NoTilesMessage';\nimport axios from '../../helpers/axiosWebEntry';\nimport { withRouter } from 'react-router-dom';\nimport withContext from '../../hoc/withContext';\nimport { isUrlAbsolute } from '../../helpers/utils';\n\n\n\nclass Landing extends React.Component {\n state = {\n tiles: [],\n current: undefined\n }\n\n componentDidMount = () => {\n const { match: { params } } = this.props;\n this.loadTile(params.id);\n }\n\n loadTile = (id) => {\n this.props.context.showLoading();\n axios.get(`/landingtile/${id || undefined}`)\n .then(response => {\n const data = JSON.parse(response.data);\n const current = { ...data };\n current.Image = isUrlAbsolute(current.Image) ? current.Image : `${process.env.REACT_APP_BLOB_STORAGE_ROOT}${current.Image}`\n const tiles = data.Children;\n tiles.sort((a, b) => a.Order > b.Order ? 1 : -1);\n tiles.forEach((item) => {\n item.Image = isUrlAbsolute(item.Image) ? item.Image : `${process.env.REACT_APP_BLOB_STORAGE_ROOT}${item.Image}`;\n });\n this.setState({ current: current, tiles: tiles });\n this.props.context.setHeading(this.props.context.t(current.Title));\n this.props.context.hideLoading();\n })\n .catch(error => {\n console.log(error);\n this.props.context.hideLoading();\n });\n }\n\n componentWillReceiveProps = (nextProps) => {\n if (nextProps.match.url !== this.props.match.url) {\n const { match: { params } } = nextProps;\n this.loadTile(params.id);\n }\n }\n\n removeTile = (id) => {\n if (!window.confirm('Do you want to remove the Tile?'))\n return;\n this.props.context.showLoading();\n axios.delete(`/landingtile/${id}`)\n .then(response => {\n this.props.context.pushAlert({ variant: 'success', message: 'Item deleted.' });\n let tiles = [...this.state.tiles];\n tiles = tiles.filter((el) => {\n return el.ID !== id;\n });\n this.setState({ tiles: tiles });\n this.props.context.hideLoading();\n })\n .catch(error => {\n console.log(error);\n this.props.context.pushAlert({ variant: 'danger', message: 'Unable to delete item.' });\n this.props.context.hideLoading();\n });\n }\n\n render() {\n return (\n \n \n \n {this.state.tiles.length ? this.state.tiles.map((t, i) => (\n \n )) : }\n {this.props.context.isAdmin() ?\n (\n \n \n \n ) : null}\n\n
\n \n \n );\n }\n}\n\nexport default withRouter(withContext(Landing));","import React from 'react';\nimport {Route, Switch} from 'react-router-dom';\nimport Form from './Form';\nimport {Container} from 'react-bootstrap';\nimport Landing from './Landing';\n\nexport default props => (\n \n \n \n \n \n \n \n \n);\n\n","import React from 'react';\nimport {Alert} from 'react-bootstrap';\n\n/*\n Component for showing error/success messages on top of application.\n Props:\n - dismissable: show cross on top right corner to close message\n - variant: same as bootstraps variant - changes color settings (default, success, error, warning etc.)\n - onRemove: on close callback\n - closeLabel: text for tooltip hint\n - show: boolean to show/hide alert\n - heading: Bold heading of alert\n - message: text of alert\n*/\n\nexport default props => (\n \n {props.heading ? (\n \n {props.heading}\n \n ): null}\n \n {props.message}\n
\n \n);\n","import React, { Component } from 'react';\nimport { Route, Switch, withRouter } from 'react-router-dom';\nimport ProtectedRoute from './helpers/ProtectedRoute';\nimport NavBar from './components/NavBar/NavBar';\nimport Login from './pages/Login/Login';\nimport Reset from './pages/Login/Reset';\nimport DataEntry from './pages/DataEntry/Index';\nimport DataView from './pages/DataView/Index';\nimport Landing from './pages/Landing/Index';\nimport withContext from './hoc/withContext';\nimport 'bootstrap/dist/css/bootstrap.css';\nimport 'react-quill/dist/quill.snow.css';\nimport { library } from '@fortawesome/fontawesome-svg-core';\nimport Alert from './components/Alert/Alert';\nimport LoadingOverlay from 'react-loading-overlay';\nimport { faSortUp, faSortDown, faPlus, faTimes, faPen, faEye, faEyeSlash, faMinus, faCalendar, faDownload, faSyncAlt } from '@fortawesome/free-solid-svg-icons';\nimport { fab } from '@fortawesome/free-brands-svg-icons';\nimport './App.css';\n\nimport { LoginCallback, Security } from '@okta/okta-react';\nimport { toRelativeUrl } from '@okta/okta-auth-js';\nimport { /*getOktaAuthObject*/ OktaAuthObject } from './helpers/adalConfig';\n\n\nlibrary.add(faSortUp);\nlibrary.add(faSortDown);\nlibrary.add(faPlus);\nlibrary.add(faMinus);\nlibrary.add(faTimes);\nlibrary.add(faPen);\nlibrary.add(faEye);\nlibrary.add(faEyeSlash);\nlibrary.add(faCalendar);\nlibrary.add(faDownload);\nlibrary.add(faSyncAlt);\nlibrary.add(fab);\n\n\n\n\nclass App extends Component {\n\n\n componentDidMount = () => {\n this.props.history.listen((location, action) => {\n this.props.context.clearAlerts();\n this.props.context.hideLoading();\n\n });\n }\n\n restoreOriginalUri = async (_oktaAuth, originalUri) => {\n this.props.history.replace(toRelativeUrl(originalUri, window.location.origin));\n //this.props.history.replace(toRelativeUrl(\"\", window.location.origin));\n };\n\n render() {\n return (\n //\n \n\n \n\n \n \n
({\n ...base,\n position: 'absolute',\n }),\n spinner: (base) => ({\n ...base,\n position: 'fixed',\n top: '50%'\n }),\n overlay: (base) => ({\n ...base,\n position: 'fixed',\n })\n }\n }>\n {this.props.context.alerts.map((alert, index) => (\n this.props.context.removeAlert(index)} />\n ))}\n \n\n {/*ugly hack because Okta has to be initialized OR not used at all*/}\n {OktaAuthObject !== undefined ?\n \n \n \n \n \n \n \n \n \n :\n \n \n \n \n \n \n \n \n \n }\n\n \n \n
\n\n \n // \n );\n }\n}\n\nexport default withContext(withRouter(App));\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read http://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.1/8 is considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit http://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See http://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl)\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister();\n });\n }\n}\n","import 'babel-polyfill';\n\nimport { AdalConfig, AdalAuthObject } from './helpers/adalConfig'\n\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\nimport { BrowserRouter as Router } from 'react-router-dom';\nimport { AuthProvider } from './contexts/Context';\nimport * as serviceWorker from './serviceWorker';\n//import { SecureRoute, Security, LoginCallback } from '@okta/okta-react';\n//import { OktaAuth, toRelativeUrl } from '@okta/okta-auth-js';\n//import { AuthOktaProvider } from './helpers/oktaAuth';\n\nif (AdalAuthObject !== undefined)\n AdalAuthObject.handleWindowCallback();\n\n\n\n//const oktaAuth = new OktaAuth(OktaConfig);\n\n//const restoreOriginalUri = async (_oktaAuth, originalUri) => {\n// this.props.history.replace(toRelativeUrl(originalUri, window.location.origin));\n//};\n\n\nif ((window === window.parent) && window === window.top) {\n // Having both of these checks is to prevent having a token in localstorage, but no user.\n if (AdalAuthObject !== undefined && !AdalAuthObject.isCallback(window.location.hash) && AdalAuthObject.getCachedUser()) {\n AdalAuthObject.acquireToken(AdalConfig.endpoints.api, (message, token, msg) => {\n if (token) {\n ReactDOM.render( , document.getElementById('root'));\n }\n })\n }\n //else if (AuthOktaContext) {\n // var token = AuthOktaContext.getAccessToken();\n // if (token) {\n // ReactDOM.render( , document.getElementById('root'));\n // }\n\n //}\n else {\n ReactDOM.render( , document.getElementById('root'));\n }\n serviceWorker.unregister();\n}\n"],"sourceRoot":""}