-
Notifications
You must be signed in to change notification settings - Fork 3
/
WorkflowEditor.SCOPE.react.js
173 lines (158 loc) · 4.42 KB
/
WorkflowEditor.SCOPE.react.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { showroomScopeDecorator } from '@opuscapita/react-showroom-client';
import { I18nManager } from '@opuscapita/i18n';
import FullName from './customComponents/FullName.react';
import messages from '../../i18n';
// const messages = {
// en: {
// fsmWorkflowEditor: {
// actions: {
// testAction: { // like in workflow.actions
// label: 'Test Action',
// params: {
// nickname: {
// label: 'Nickname'
// },
// fullName: {
// label: 'Full Name'
// }
// }
// },
// sendMail: {
// label: 'Send Email',
// params: {
// fromAddress: {
// label: "Sender' address"
// }
// }
// }
// },
// conditions: { // like in workflow.conditions
// userHasRoles: {
// label: 'User Has Roles',
// params: {
// restrictedRoles: {
// label: 'Only these roles are allowed'
// }
// }
// }
// },
// states: {
// approved: {
// label: 'Approved'
// },
// inspectionRequired: {
// label: "Inspection Required"
// }
// }
// }
// },
// de: {
// fsmWorkflowEditor: {
// actions: {
// testAction: { // like in workflow.actions
// label: 'Testaktion',
// params: {
// nickname: {
// label: 'Spitzname'
// },
// fullName: {
// label: 'vollständiger Name'
// }
// }
// },
// sendMail: {
// label: 'E-Mail senden',
// params: {
// fromAddress: {
// label: "von der Adresse"
// }
// }
// }
// },
// conditions: { // like in workflow.conditions
// userHasRoles: {
// label: 'Benutzer hat Rollen',
// params: {
// restrictedRoles: {
// label: 'eingeschränkte Rollen'
// }
// }
// }
// },
// states: {
// approved: {
// label: 'Genehmigt'
// },
// inspectionRequired: {
// label: "Inspektion erforderlich"
// }
// }
// }
// }
// }
const wrapper = ({ i18n }) => class extends React.PureComponent {
static childContextTypes = {
i18n: PropTypes.object.isRequired
}
getChildContext() {
return { i18n }
}
render() {
return this.props.children()
}
}
// This @showroomScopeDecorator modify React.Component prototype by adding _renderChildren() method.
@showroomScopeDecorator// eslint-disable-line react/no-multi-comp
export default class WorkflowEditorScope extends PureComponent {
static childContextTypes = {
i18n: PropTypes.object.isRequired
}
constructor(...args) {
super(...args);
this.i18n = new I18nManager();
this.i18n.register(`fsmWorkflowEditor`, messages);
}
state = {
locale: 'en'
}
handleChangeLanguage = ({ target: { value } }) => this.setState({ locale: value }, _ => {
this.i18n = new I18nManager({ locale: value });
this.i18n.register(`${value}-${Math.random()}`, messages);
this.forceUpdate()
});
componentsRegistry = {
fullName: FullName
}
render() {
const { locale } = this.state;
const Wrapper = wrapper({ i18n: this.i18n });
return (
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div style={{ marginBottom: '40px' }}>
<div className='form-group'>
<label htmlFor='inputEmail3' className='col-sm-2 control-label'>
Locale (this is not a part of editor)
</label>
<div className='col-sm-10'>
<select onChange={this.handleChangeLanguage} value={locale} className='form-control'>
<option value='en'>en</option>
<option value='de'>de</option>
<option value='fi'>fi</option>
<option value='no'>no</option>
<option value='ru'>ru</option>
<option value='sv'>sv</option>
</select>
</div>
</div>
</div>
<div>
<Wrapper>
{_ => this._renderChildren()}
</Wrapper>
</div>
</div>
);
}
}