react-form-builder-more-flexibility 1.0.58 → 1.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/845.app.js +1 -1
- package/dist/app.js +1 -1
- package/lib/form-elements-edit.js +364 -246
- package/package.json +1 -1
|
@@ -5,11 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
8
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
11
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
11
12
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
12
13
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
15
|
var _react = _interopRequireDefault(require("react"));
|
|
14
16
|
var _reactTextareaAutosize = _interopRequireDefault(require("react-textarea-autosize"));
|
|
15
17
|
var _draftJs = require("draft-js");
|
|
@@ -19,13 +21,14 @@ var _dynamicOptionList = _interopRequireDefault(require("./dynamic-option-list")
|
|
|
19
21
|
var _requests = require("./stores/requests");
|
|
20
22
|
var _UUID = _interopRequireDefault(require("./UUID"));
|
|
21
23
|
var _IntlMessages = _interopRequireDefault(require("./language-provider/IntlMessages"));
|
|
24
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
26
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
23
27
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
24
28
|
var toolbar = {
|
|
25
29
|
options: ['inline', 'list', 'textAlign', 'fontSize', 'link', 'history'],
|
|
26
30
|
inline: {
|
|
27
31
|
inDropdown: false,
|
|
28
|
-
className: undefined,
|
|
29
32
|
options: ['bold', 'italic', 'underline', 'superscript', 'subscript']
|
|
30
33
|
}
|
|
31
34
|
};
|
|
@@ -34,150 +37,228 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
34
37
|
var _this;
|
|
35
38
|
(0, _classCallCheck2["default"])(this, FormElementsEdit);
|
|
36
39
|
_this = _callSuper(this, FormElementsEdit, [props]);
|
|
40
|
+
(0, _defineProperty2["default"])(_this, "validate", function () {
|
|
41
|
+
var draft = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.state.draft;
|
|
42
|
+
var errors = {};
|
|
43
|
+
if (draft.show_custom_name && !String(draft.custom_name || '').trim()) {
|
|
44
|
+
errors.custom_name = 'Custom name is required.';
|
|
45
|
+
}
|
|
46
|
+
return errors;
|
|
47
|
+
});
|
|
48
|
+
// ---------- helpers ----------
|
|
49
|
+
(0, _defineProperty2["default"])(_this, "convertFromHTML", function (content) {
|
|
50
|
+
var newContent = (0, _draftJs.convertFromHTML)(content || '');
|
|
51
|
+
if (!newContent.contentBlocks || !newContent.contentBlocks.length) return _draftJs.EditorState.createEmpty();
|
|
52
|
+
var contentState = _draftJs.ContentState.createFromBlockArray(newContent);
|
|
53
|
+
return _draftJs.EditorState.createWithContent(contentState);
|
|
54
|
+
});
|
|
55
|
+
(0, _defineProperty2["default"])(_this, "toHtml", function (editorState) {
|
|
56
|
+
return (0, _draftjsToHtml["default"])((0, _draftJs.convertToRaw)(editorState.getCurrentContent())).replace(/<p>/g, '').replace(/<\/p>/g, '').replace(/ /g, ' ').replace(/(?:\r\n|\r|\n)/g, ' ');
|
|
57
|
+
});
|
|
58
|
+
(0, _defineProperty2["default"])(_this, "setDraftProp", function (name, value) {
|
|
59
|
+
_this.setState(function (_ref) {
|
|
60
|
+
var draft = _ref.draft;
|
|
61
|
+
var nextDraft = _objectSpread(_objectSpread({}, draft), {}, (0, _defineProperty2["default"])({}, name, value));
|
|
62
|
+
return {
|
|
63
|
+
draft: nextDraft,
|
|
64
|
+
dirty: true,
|
|
65
|
+
errors: _this.validate(nextDraft)
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
(0, _defineProperty2["default"])(_this, "setDraftNested", function (updater) {
|
|
70
|
+
_this.setState(function (_ref2) {
|
|
71
|
+
var draft = _ref2.draft;
|
|
72
|
+
return {
|
|
73
|
+
draft: updater(draft),
|
|
74
|
+
dirty: true
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
// ---------- events originally mutating store; now local only ----------
|
|
79
|
+
(0, _defineProperty2["default"])(_this, "editElementProp", function (elemProperty, targProperty, e) {
|
|
80
|
+
var value = e !== null && e !== void 0 && e.target ? e.target[targProperty] : e; // allow direct values
|
|
81
|
+
_this.setDraftProp(elemProperty, value);
|
|
82
|
+
});
|
|
83
|
+
(0, _defineProperty2["default"])(_this, "onEditorStateChange", function (index, property, editorState) {
|
|
84
|
+
var html = _this.toHtml(editorState);
|
|
85
|
+
_this.setDraftProp(property, html);
|
|
86
|
+
});
|
|
87
|
+
(0, _defineProperty2["default"])(_this, "addOptions", function () {
|
|
88
|
+
var _document$getElementB;
|
|
89
|
+
var optionsApiUrl = (_document$getElementB = document.getElementById('optionsApiUrl')) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.value;
|
|
90
|
+
if (!optionsApiUrl) return;
|
|
91
|
+
(0, _requests.get)(optionsApiUrl).then(function (data) {
|
|
92
|
+
var withIds = (data || []).map(function (x) {
|
|
93
|
+
return _objectSpread(_objectSpread({}, x), {}, {
|
|
94
|
+
key: _UUID["default"].uuid()
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
_this.setDraftProp('options', withIds);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
// ---------- commit / discard ----------
|
|
101
|
+
(0, _defineProperty2["default"])(_this, "save", function () {
|
|
102
|
+
var errors = _this.validate();
|
|
103
|
+
if (Object.keys(errors).length > 0) {
|
|
104
|
+
_this.setState({
|
|
105
|
+
errors: errors
|
|
106
|
+
});
|
|
107
|
+
return; // prevent commit
|
|
108
|
+
}
|
|
109
|
+
if (!_this.state.dirty) {
|
|
110
|
+
// nothing changed; just close
|
|
111
|
+
_this.props.manualEditModeOff && _this.props.manualEditModeOff();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
// Commit to the builder/store (original behavior)
|
|
115
|
+
_this.props.updateElement.call(_this.props.preview, _this.state.draft);
|
|
116
|
+
_this.setState({
|
|
117
|
+
dirty: false
|
|
118
|
+
}, function () {
|
|
119
|
+
_this.props.manualEditModeOff && _this.props.manualEditModeOff();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
(0, _defineProperty2["default"])(_this, "cancel", function () {
|
|
123
|
+
// Discard local changes & close
|
|
124
|
+
_this.setState({
|
|
125
|
+
draft: JSON.parse(JSON.stringify(_this.props.element || {})),
|
|
126
|
+
dirty: false
|
|
127
|
+
});
|
|
128
|
+
_this.props.manualEditModeOff && _this.props.manualEditModeOff();
|
|
129
|
+
});
|
|
37
130
|
_this.state = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
dirty: false
|
|
131
|
+
// start with a deep-ish clone so we don't mutate props.element
|
|
132
|
+
draft: JSON.parse(JSON.stringify(props.element || {})),
|
|
133
|
+
dirty: false,
|
|
134
|
+
errors: {}
|
|
41
135
|
};
|
|
42
136
|
return _this;
|
|
43
137
|
}
|
|
44
138
|
(0, _inherits2["default"])(FormElementsEdit, _React$Component);
|
|
45
139
|
return (0, _createClass2["default"])(FormElementsEdit, [{
|
|
46
|
-
key: "
|
|
47
|
-
value: function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
key: "editElementProp",
|
|
52
|
-
value: function editElementProp(elemProperty, targProperty, e) {
|
|
53
|
-
var _this2 = this;
|
|
54
|
-
// elemProperty could be content or label
|
|
55
|
-
// targProperty could be value or checked
|
|
56
|
-
var this_element = this.state.element;
|
|
57
|
-
this_element[elemProperty] = e.target[targProperty];
|
|
58
|
-
this.setState({
|
|
59
|
-
element: this_element,
|
|
60
|
-
dirty: true
|
|
61
|
-
}, function () {
|
|
62
|
-
if (targProperty === 'checked') {
|
|
63
|
-
_this2.updateElement();
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "onEditorStateChange",
|
|
69
|
-
value: function onEditorStateChange(index, property, editorContent) {
|
|
70
|
-
// const html = draftToHtml(convertToRaw(editorContent.getCurrentContent())).replace(/<p>/g, '<div>').replace(/<\/p>/g, '</div>');
|
|
71
|
-
var html = (0, _draftjsToHtml["default"])((0, _draftJs.convertToRaw)(editorContent.getCurrentContent())).replace(/<p>/g, '').replace(/<\/p>/g, '').replace(/ /g, ' ').replace(/(?:\r\n|\r|\n)/g, ' ');
|
|
72
|
-
var this_element = this.state.element;
|
|
73
|
-
this_element[property] = html;
|
|
74
|
-
this.setState({
|
|
75
|
-
element: this_element,
|
|
76
|
-
dirty: true
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}, {
|
|
80
|
-
key: "updateElement",
|
|
81
|
-
value: function updateElement() {
|
|
82
|
-
var this_element = this.state.element;
|
|
83
|
-
// to prevent ajax calls with no change
|
|
84
|
-
if (this.state.dirty) {
|
|
85
|
-
this.props.updateElement.call(this.props.preview, this_element);
|
|
140
|
+
key: "componentDidUpdate",
|
|
141
|
+
value: function componentDidUpdate(prevProps) {
|
|
142
|
+
var _prevProps$element, _this$props$element;
|
|
143
|
+
// If the user selected a DIFFERENT element, reset the draft
|
|
144
|
+
if (((_prevProps$element = prevProps.element) === null || _prevProps$element === void 0 ? void 0 : _prevProps$element.id) !== ((_this$props$element = this.props.element) === null || _this$props$element === void 0 ? void 0 : _this$props$element.id)) {
|
|
86
145
|
this.setState({
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
}, {
|
|
92
|
-
key: "convertFromHTML",
|
|
93
|
-
value: function convertFromHTML(content) {
|
|
94
|
-
var newContent = (0, _draftJs.convertFromHTML)(content);
|
|
95
|
-
if (!newContent.contentBlocks || !newContent.contentBlocks.length) {
|
|
96
|
-
// to prevent crash when no contents in editor
|
|
97
|
-
return _draftJs.EditorState.createEmpty();
|
|
98
|
-
}
|
|
99
|
-
var contentState = _draftJs.ContentState.createFromBlockArray(newContent);
|
|
100
|
-
return _draftJs.EditorState.createWithContent(contentState);
|
|
101
|
-
}
|
|
102
|
-
}, {
|
|
103
|
-
key: "addOptions",
|
|
104
|
-
value: function addOptions() {
|
|
105
|
-
var _this3 = this;
|
|
106
|
-
var optionsApiUrl = document.getElementById('optionsApiUrl').value;
|
|
107
|
-
if (optionsApiUrl) {
|
|
108
|
-
(0, _requests.get)(optionsApiUrl).then(function (data) {
|
|
109
|
-
_this3.props.element.options = [];
|
|
110
|
-
var options = _this3.props.element.options;
|
|
111
|
-
data.forEach(function (x) {
|
|
112
|
-
// eslint-disable-next-line no-param-reassign
|
|
113
|
-
x.key = _UUID["default"].uuid();
|
|
114
|
-
options.push(x);
|
|
115
|
-
});
|
|
116
|
-
var this_element = _this3.state.element;
|
|
117
|
-
_this3.setState({
|
|
118
|
-
element: this_element,
|
|
119
|
-
dirty: true
|
|
120
|
-
});
|
|
146
|
+
draft: JSON.parse(JSON.stringify(this.props.element || {})),
|
|
147
|
+
dirty: false,
|
|
148
|
+
errors: this.validate(this.props.element || {})
|
|
121
149
|
});
|
|
122
150
|
}
|
|
123
151
|
}
|
|
124
152
|
}, {
|
|
125
153
|
key: "render",
|
|
126
154
|
value: function render() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
var
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
var
|
|
137
|
-
var
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
var
|
|
141
|
-
var
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
var
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
var
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
|
|
155
|
+
var _this2 = this,
|
|
156
|
+
_el$step,
|
|
157
|
+
_el$min_value,
|
|
158
|
+
_el$max_value,
|
|
159
|
+
_el$default_value;
|
|
160
|
+
var _this$state = this.state,
|
|
161
|
+
draft = _this$state.draft,
|
|
162
|
+
dirty = _this$state.dirty,
|
|
163
|
+
errors = _this$state.errors;
|
|
164
|
+
var hasErrors = Object.keys(errors || {}).length > 0;
|
|
165
|
+
var el = draft || {};
|
|
166
|
+
|
|
167
|
+
// booleans
|
|
168
|
+
var this_checked = !!el.required;
|
|
169
|
+
var this_default_checked = !!el.defaultChecked;
|
|
170
|
+
var this_has_popup = !!el.hasPopUp;
|
|
171
|
+
var this_read_only = !!el.readOnly;
|
|
172
|
+
var this_default_today = !!el.defaultToday;
|
|
173
|
+
var this_show_time_select = !!el.showTimeSelect;
|
|
174
|
+
var this_show_time_select_only = !!el.showTimeSelectOnly;
|
|
175
|
+
var this_show_time_input = !!el.showTimeInput;
|
|
176
|
+
var this_checked_inline = !!el.inline;
|
|
177
|
+
var this_checked_bold = !!el.bold;
|
|
178
|
+
var this_checked_italic = !!el.italic;
|
|
179
|
+
var this_checked_center = !!el.center;
|
|
180
|
+
var this_checked_page_break = !!el.pageBreakBefore;
|
|
181
|
+
var this_checked_alternate_form = !!el.alternateForm;
|
|
182
|
+
var canHavePageBreakBefore = el.canHavePageBreakBefore,
|
|
183
|
+
canHaveAlternateForm = el.canHaveAlternateForm,
|
|
184
|
+
canHaveDisplayHorizontal = el.canHaveDisplayHorizontal,
|
|
185
|
+
canHaveOptionCorrect = el.canHaveOptionCorrect,
|
|
186
|
+
canHaveOptionValue = el.canHaveOptionValue;
|
|
187
|
+
var canHaveImageSize = el.element === 'Image' || el.element === 'Camera';
|
|
188
|
+
var files = this.props.files.length ? (0, _toConsumableArray2["default"])(this.props.files) : [];
|
|
189
|
+
if (files.length < 1 || files.length > 0 && files[0].id !== '') {
|
|
190
|
+
files.unshift({
|
|
154
191
|
id: '',
|
|
155
192
|
file_name: ''
|
|
156
193
|
});
|
|
157
194
|
}
|
|
195
|
+
|
|
196
|
+
// editor states from DRAFT (not props.element)
|
|
158
197
|
var editorState;
|
|
159
198
|
var secondaryEditorState;
|
|
160
199
|
var thirdEditorState;
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (
|
|
165
|
-
editorState = this.convertFromHTML(this.props.element.label);
|
|
166
|
-
}
|
|
167
|
-
if (this.props.element.hasOwnProperty('boxLabel')) {
|
|
168
|
-
secondaryEditorState = this.convertFromHTML(this.props.element.boxLabel);
|
|
169
|
-
}
|
|
170
|
-
if (this.props.element.hasOwnProperty('popUpBody')) {
|
|
171
|
-
thirdEditorState = this.convertFromHTML(this.props.element.popUpBody);
|
|
172
|
-
}
|
|
200
|
+
if (el.hasOwnProperty('content')) editorState = this.convertFromHTML(el.content);
|
|
201
|
+
if (el.hasOwnProperty('label')) editorState = this.convertFromHTML(el.label);
|
|
202
|
+
if (el.hasOwnProperty('boxLabel')) secondaryEditorState = this.convertFromHTML(el.boxLabel);
|
|
203
|
+
if (el.hasOwnProperty('popUpBody')) thirdEditorState = this.convertFromHTML(el.popUpBody);
|
|
173
204
|
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
174
205
|
className: "clearfix"
|
|
175
206
|
}, /*#__PURE__*/_react["default"].createElement("h4", {
|
|
176
207
|
className: "float-left"
|
|
177
|
-
},
|
|
178
|
-
className: "
|
|
179
|
-
|
|
180
|
-
|
|
208
|
+
}, el.text), /*#__PURE__*/_react["default"].createElement("div", {
|
|
209
|
+
className: "d-flex justify-content-end mt-3 gap-2"
|
|
210
|
+
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
211
|
+
type: "button",
|
|
212
|
+
className: "btn btn-secondary",
|
|
213
|
+
onClick: this.cancel
|
|
214
|
+
}, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
215
|
+
id: "cancel",
|
|
216
|
+
defaultMessage: "Cancel"
|
|
217
|
+
})), /*#__PURE__*/_react["default"].createElement("button", {
|
|
218
|
+
style: {
|
|
219
|
+
marginLeft: 10
|
|
220
|
+
},
|
|
221
|
+
type: "button",
|
|
222
|
+
className: "btn btn-primary",
|
|
223
|
+
onClick: this.save,
|
|
224
|
+
disabled: !dirty || hasErrors
|
|
225
|
+
}, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
226
|
+
id: "save",
|
|
227
|
+
defaultMessage: "Save"
|
|
228
|
+
})))), el.show_custom_name && /*#__PURE__*/_react["default"].createElement("div", {
|
|
229
|
+
className: "form-group"
|
|
230
|
+
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
231
|
+
className: "control-label",
|
|
232
|
+
htmlFor: "custom_name"
|
|
233
|
+
}, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
234
|
+
id: "custom-name-label"
|
|
235
|
+
}), el.show_custom_name && /*#__PURE__*/_react["default"].createElement("span", {
|
|
236
|
+
style: {
|
|
237
|
+
color: '#d9534f'
|
|
238
|
+
}
|
|
239
|
+
}, " *")), /*#__PURE__*/_react["default"].createElement("input", {
|
|
240
|
+
type: "text",
|
|
241
|
+
className: "form-control".concat(errors.custom_name ? ' is-invalid' : ''),
|
|
242
|
+
"aria-invalid": !!errors.custom_name,
|
|
243
|
+
id: "custom_name",
|
|
244
|
+
value: el.custom_name || '',
|
|
245
|
+
onChange: function onChange(e) {
|
|
246
|
+
return _this2.editElementProp('custom_name', 'value', e);
|
|
247
|
+
},
|
|
248
|
+
onBlur: function onBlur() {
|
|
249
|
+
return _this2.setState(function (_ref3) {
|
|
250
|
+
var draft = _ref3.draft;
|
|
251
|
+
return {
|
|
252
|
+
errors: _this2.validate(draft)
|
|
253
|
+
};
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}), errors.custom_name && /*#__PURE__*/_react["default"].createElement("div", {
|
|
257
|
+
className: "invalid-feedback",
|
|
258
|
+
style: {
|
|
259
|
+
display: 'block'
|
|
260
|
+
}
|
|
261
|
+
}, errors.custom_name)), el.hasOwnProperty('content') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
181
262
|
className: "form-group"
|
|
182
263
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
183
264
|
className: "control-label"
|
|
@@ -186,10 +267,11 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
186
267
|
}), ":"), /*#__PURE__*/_react["default"].createElement(_reactDraftWysiwyg.Editor, {
|
|
187
268
|
toolbar: toolbar,
|
|
188
269
|
defaultEditorState: editorState,
|
|
189
|
-
|
|
190
|
-
|
|
270
|
+
onEditorStateChange: function onEditorStateChange(st) {
|
|
271
|
+
return _this2.onEditorStateChange(0, 'content', st);
|
|
272
|
+
},
|
|
191
273
|
stripPastedStyles: true
|
|
192
|
-
})),
|
|
274
|
+
})), el.hasOwnProperty('file_path') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
193
275
|
className: "form-group"
|
|
194
276
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
195
277
|
className: "control-label",
|
|
@@ -199,118 +281,127 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
199
281
|
}), ":"), /*#__PURE__*/_react["default"].createElement("select", {
|
|
200
282
|
id: "fileSelect",
|
|
201
283
|
className: "form-control",
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
284
|
+
value: el.file_path || '',
|
|
285
|
+
onChange: function onChange(e) {
|
|
286
|
+
return _this2.editElementProp('file_path', 'value', e);
|
|
287
|
+
}
|
|
288
|
+
}, files.map(function (file) {
|
|
206
289
|
var this_key = "file_".concat(file.id);
|
|
207
290
|
return /*#__PURE__*/_react["default"].createElement("option", {
|
|
208
291
|
value: file.id,
|
|
209
292
|
key: this_key
|
|
210
293
|
}, file.file_name);
|
|
211
|
-
}))),
|
|
294
|
+
}))), el.hasOwnProperty('href') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
212
295
|
className: "form-group"
|
|
213
296
|
}, /*#__PURE__*/_react["default"].createElement(_reactTextareaAutosize["default"], {
|
|
214
297
|
type: "text",
|
|
215
298
|
className: "form-control",
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
299
|
+
value: el.href || '',
|
|
300
|
+
onChange: function onChange(e) {
|
|
301
|
+
return _this2.editElementProp('href', 'value', e);
|
|
302
|
+
}
|
|
303
|
+
})), el.hasOwnProperty('label') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
220
304
|
className: "form-group"
|
|
221
|
-
}, !
|
|
305
|
+
}, !el.hide_display_label && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("label", null, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
222
306
|
id: "display-label"
|
|
223
307
|
})), /*#__PURE__*/_react["default"].createElement(_reactDraftWysiwyg.Editor, {
|
|
224
308
|
toolbar: toolbar,
|
|
225
309
|
defaultEditorState: editorState,
|
|
226
|
-
|
|
227
|
-
|
|
310
|
+
onEditorStateChange: function onEditorStateChange(st) {
|
|
311
|
+
return _this2.onEditorStateChange(0, 'label', st);
|
|
312
|
+
},
|
|
228
313
|
stripPastedStyles: true
|
|
229
|
-
})), /*#__PURE__*/_react["default"].createElement("br", null), !
|
|
314
|
+
})), /*#__PURE__*/_react["default"].createElement("br", null), !el.hide_required && /*#__PURE__*/_react["default"].createElement("div", {
|
|
230
315
|
className: "custom-control custom-checkbox"
|
|
231
316
|
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
232
317
|
id: "is-required",
|
|
233
318
|
className: "custom-control-input",
|
|
234
319
|
type: "checkbox",
|
|
235
320
|
checked: this_checked,
|
|
236
|
-
|
|
237
|
-
|
|
321
|
+
onChange: function onChange(e) {
|
|
322
|
+
return _this2.editElementProp('required', 'checked', e);
|
|
323
|
+
}
|
|
238
324
|
}), /*#__PURE__*/_react["default"].createElement("label", {
|
|
239
325
|
className: "custom-control-label",
|
|
240
326
|
htmlFor: "is-required"
|
|
241
327
|
}, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
242
328
|
id: "required"
|
|
243
|
-
}))),
|
|
329
|
+
}))), el.hasOwnProperty('readOnly') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
244
330
|
className: "custom-control custom-checkbox"
|
|
245
331
|
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
246
332
|
id: "is-read-only",
|
|
247
333
|
className: "custom-control-input",
|
|
248
334
|
type: "checkbox",
|
|
249
335
|
checked: this_read_only,
|
|
250
|
-
|
|
251
|
-
|
|
336
|
+
onChange: function onChange(e) {
|
|
337
|
+
return _this2.editElementProp('readOnly', 'checked', e);
|
|
338
|
+
}
|
|
252
339
|
}), /*#__PURE__*/_react["default"].createElement("label", {
|
|
253
340
|
className: "custom-control-label",
|
|
254
341
|
htmlFor: "is-read-only"
|
|
255
342
|
}, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
256
343
|
id: "read-only"
|
|
257
|
-
}))),
|
|
344
|
+
}))), el.hasOwnProperty('defaultToday') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
258
345
|
className: "custom-control custom-checkbox"
|
|
259
346
|
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
260
347
|
id: "is-default-to-today",
|
|
261
348
|
className: "custom-control-input",
|
|
262
349
|
type: "checkbox",
|
|
263
350
|
checked: this_default_today,
|
|
264
|
-
|
|
265
|
-
|
|
351
|
+
onChange: function onChange(e) {
|
|
352
|
+
return _this2.editElementProp('defaultToday', 'checked', e);
|
|
353
|
+
}
|
|
266
354
|
}), /*#__PURE__*/_react["default"].createElement("label", {
|
|
267
355
|
className: "custom-control-label",
|
|
268
356
|
htmlFor: "is-default-to-today"
|
|
269
357
|
}, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
270
358
|
id: "default-to-today"
|
|
271
|
-
}), "?")),
|
|
359
|
+
}), "?")), (el.element === 'Checkboxes' || el.element === 'Checkbox') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
272
360
|
className: "custom-control custom-checkbox"
|
|
273
361
|
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
274
|
-
id: "
|
|
362
|
+
id: "default-checked",
|
|
275
363
|
className: "custom-control-input",
|
|
276
364
|
type: "checkbox",
|
|
277
365
|
checked: this_default_checked,
|
|
278
|
-
|
|
279
|
-
|
|
366
|
+
onChange: function onChange(e) {
|
|
367
|
+
return _this2.editElementProp('defaultChecked', 'checked', e);
|
|
368
|
+
}
|
|
280
369
|
}), /*#__PURE__*/_react["default"].createElement("label", {
|
|
281
370
|
className: "custom-control-label",
|
|
282
|
-
htmlFor: "
|
|
371
|
+
htmlFor: "default-checked"
|
|
283
372
|
}, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
284
373
|
id: "default-checked"
|
|
285
|
-
}))),
|
|
374
|
+
}))), el.element === 'Checkbox' && /*#__PURE__*/_react["default"].createElement("div", {
|
|
286
375
|
className: "custom-control custom-checkbox"
|
|
287
376
|
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
288
377
|
id: "input-has-popup",
|
|
289
378
|
className: "custom-control-input",
|
|
290
379
|
type: "checkbox",
|
|
291
380
|
checked: this_has_popup,
|
|
292
|
-
|
|
293
|
-
|
|
381
|
+
onChange: function onChange(e) {
|
|
382
|
+
return _this2.editElementProp('hasPopUp', 'checked', e);
|
|
383
|
+
}
|
|
294
384
|
}), /*#__PURE__*/_react["default"].createElement("label", {
|
|
295
385
|
className: "custom-control-label",
|
|
296
386
|
htmlFor: "input-has-popup"
|
|
297
387
|
}, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
298
388
|
id: "checkbox-has-popup"
|
|
299
|
-
}))), (
|
|
389
|
+
}))), (el.element === 'RadioButtons' || el.element === 'Checkboxes') && canHaveDisplayHorizontal && /*#__PURE__*/_react["default"].createElement("div", {
|
|
300
390
|
className: "custom-control custom-checkbox"
|
|
301
391
|
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
302
392
|
id: "display-horizontal",
|
|
303
393
|
className: "custom-control-input",
|
|
304
394
|
type: "checkbox",
|
|
305
395
|
checked: this_checked_inline,
|
|
306
|
-
|
|
307
|
-
|
|
396
|
+
onChange: function onChange(e) {
|
|
397
|
+
return _this2.editElementProp('inline', 'checked', e);
|
|
398
|
+
}
|
|
308
399
|
}), /*#__PURE__*/_react["default"].createElement("label", {
|
|
309
400
|
className: "custom-control-label",
|
|
310
401
|
htmlFor: "display-horizontal"
|
|
311
402
|
}, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
312
403
|
id: "display-horizontal"
|
|
313
|
-
})))),
|
|
404
|
+
})))), el.element === 'Checkbox' && /*#__PURE__*/_react["default"].createElement("div", {
|
|
314
405
|
className: "form-group"
|
|
315
406
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
316
407
|
className: "control-label"
|
|
@@ -319,8 +410,9 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
319
410
|
}), ":"), /*#__PURE__*/_react["default"].createElement(_reactDraftWysiwyg.Editor, {
|
|
320
411
|
toolbar: toolbar,
|
|
321
412
|
defaultEditorState: secondaryEditorState,
|
|
322
|
-
|
|
323
|
-
|
|
413
|
+
onEditorStateChange: function onEditorStateChange(st) {
|
|
414
|
+
return _this2.onEditorStateChange(0, 'boxLabel', st);
|
|
415
|
+
},
|
|
324
416
|
stripPastedStyles: true
|
|
325
417
|
})), this_has_popup && /*#__PURE__*/_react["default"].createElement("div", {
|
|
326
418
|
className: "form-group"
|
|
@@ -329,10 +421,11 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
329
421
|
}, "Pop Up:"), /*#__PURE__*/_react["default"].createElement(_reactDraftWysiwyg.Editor, {
|
|
330
422
|
toolbar: toolbar,
|
|
331
423
|
defaultEditorState: thirdEditorState,
|
|
332
|
-
|
|
333
|
-
|
|
424
|
+
onEditorStateChange: function onEditorStateChange(st) {
|
|
425
|
+
return _this2.onEditorStateChange(0, 'popUpBody', st);
|
|
426
|
+
},
|
|
334
427
|
stripPastedStyles: true
|
|
335
|
-
})),
|
|
428
|
+
})), el.hasOwnProperty('src') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
336
429
|
className: "form-group"
|
|
337
430
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
338
431
|
className: "control-label",
|
|
@@ -343,10 +436,11 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
343
436
|
id: "srcInput",
|
|
344
437
|
type: "text",
|
|
345
438
|
className: "form-control",
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
439
|
+
value: el.src || '',
|
|
440
|
+
onChange: function onChange(e) {
|
|
441
|
+
return _this2.editElementProp('src', 'value', e);
|
|
442
|
+
}
|
|
443
|
+
})), canHaveImageSize && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
350
444
|
className: "form-group"
|
|
351
445
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
352
446
|
className: "custom-control custom-checkbox"
|
|
@@ -355,8 +449,9 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
355
449
|
className: "custom-control-input",
|
|
356
450
|
type: "checkbox",
|
|
357
451
|
checked: this_checked_center,
|
|
358
|
-
|
|
359
|
-
|
|
452
|
+
onChange: function onChange(e) {
|
|
453
|
+
return _this2.editElementProp('center', 'checked', e);
|
|
454
|
+
}
|
|
360
455
|
}), /*#__PURE__*/_react["default"].createElement("label", {
|
|
361
456
|
className: "custom-control-label",
|
|
362
457
|
htmlFor: "do-center"
|
|
@@ -375,9 +470,10 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
375
470
|
id: "elementWidth",
|
|
376
471
|
type: "text",
|
|
377
472
|
className: "form-control",
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
473
|
+
value: el.width || '',
|
|
474
|
+
onChange: function onChange(e) {
|
|
475
|
+
return _this2.editElementProp('width', 'value', e);
|
|
476
|
+
}
|
|
381
477
|
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
382
478
|
className: "col-sm-3"
|
|
383
479
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
@@ -389,10 +485,11 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
389
485
|
id: "elementHeight",
|
|
390
486
|
type: "text",
|
|
391
487
|
className: "form-control",
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
488
|
+
value: el.height || '',
|
|
489
|
+
onChange: function onChange(e) {
|
|
490
|
+
return _this2.editElementProp('height', 'value', e);
|
|
491
|
+
}
|
|
492
|
+
})))), el.element === 'FileUpload' && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
396
493
|
className: "form-group"
|
|
397
494
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
398
495
|
className: "control-label",
|
|
@@ -402,8 +499,10 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
402
499
|
}), ":"), /*#__PURE__*/_react["default"].createElement("select", {
|
|
403
500
|
id: "fileType",
|
|
404
501
|
className: "form-control",
|
|
405
|
-
|
|
406
|
-
onChange:
|
|
502
|
+
value: el.fileType || '',
|
|
503
|
+
onChange: function onChange(e) {
|
|
504
|
+
return _this2.editElementProp('fileType', 'value', e);
|
|
505
|
+
}
|
|
407
506
|
}, [{
|
|
408
507
|
type: 'image, application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation, video/mp4,video/x-m4v,video/*',
|
|
409
508
|
typeName: 'All File Type'
|
|
@@ -430,7 +529,7 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
430
529
|
value: file.type,
|
|
431
530
|
key: index
|
|
432
531
|
}, file.typeName);
|
|
433
|
-
})))),
|
|
532
|
+
})))), el.hasOwnProperty('step') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
434
533
|
className: "form-group"
|
|
435
534
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
436
535
|
className: "form-group-range"
|
|
@@ -443,10 +542,11 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
443
542
|
id: "rangeStep",
|
|
444
543
|
type: "number",
|
|
445
544
|
className: "form-control",
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
545
|
+
value: (_el$step = el.step) !== null && _el$step !== void 0 ? _el$step : '',
|
|
546
|
+
onChange: function onChange(e) {
|
|
547
|
+
return _this2.editElementProp('step', 'value', e);
|
|
548
|
+
}
|
|
549
|
+
}))), el.hasOwnProperty('min_value') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
450
550
|
className: "form-group"
|
|
451
551
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
452
552
|
className: "form-group-range"
|
|
@@ -459,16 +559,18 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
459
559
|
id: "rangeMin",
|
|
460
560
|
type: "number",
|
|
461
561
|
className: "form-control",
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
562
|
+
value: (_el$min_value = el.min_value) !== null && _el$min_value !== void 0 ? _el$min_value : '',
|
|
563
|
+
onChange: function onChange(e) {
|
|
564
|
+
return _this2.editElementProp('min_value', 'value', e);
|
|
565
|
+
}
|
|
465
566
|
}), /*#__PURE__*/_react["default"].createElement("input", {
|
|
466
567
|
type: "text",
|
|
467
568
|
className: "form-control",
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
569
|
+
value: el.min_label || '',
|
|
570
|
+
onChange: function onChange(e) {
|
|
571
|
+
return _this2.editElementProp('min_label', 'value', e);
|
|
572
|
+
}
|
|
573
|
+
}))), el.hasOwnProperty('max_value') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
472
574
|
className: "form-group"
|
|
473
575
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
474
576
|
className: "form-group-range"
|
|
@@ -481,16 +583,18 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
481
583
|
id: "rangeMax",
|
|
482
584
|
type: "number",
|
|
483
585
|
className: "form-control",
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
586
|
+
value: (_el$max_value = el.max_value) !== null && _el$max_value !== void 0 ? _el$max_value : '',
|
|
587
|
+
onChange: function onChange(e) {
|
|
588
|
+
return _this2.editElementProp('max_value', 'value', e);
|
|
589
|
+
}
|
|
487
590
|
}), /*#__PURE__*/_react["default"].createElement("input", {
|
|
488
591
|
type: "text",
|
|
489
592
|
className: "form-control",
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
593
|
+
value: el.max_label || '',
|
|
594
|
+
onChange: function onChange(e) {
|
|
595
|
+
return _this2.editElementProp('max_label', 'value', e);
|
|
596
|
+
}
|
|
597
|
+
}))), el.hasOwnProperty('default_value') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
494
598
|
className: "form-group"
|
|
495
599
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
496
600
|
className: "form-group-range"
|
|
@@ -503,10 +607,11 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
503
607
|
id: "defaultSelected",
|
|
504
608
|
type: "number",
|
|
505
609
|
className: "form-control",
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
610
|
+
value: (_el$default_value = el.default_value) !== null && _el$default_value !== void 0 ? _el$default_value : '',
|
|
611
|
+
onChange: function onChange(e) {
|
|
612
|
+
return _this2.editElementProp('default_value', 'value', e);
|
|
613
|
+
}
|
|
614
|
+
}))), el["static"] && /*#__PURE__*/_react["default"].createElement("div", {
|
|
510
615
|
className: "form-group"
|
|
511
616
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
512
617
|
className: "control-label"
|
|
@@ -519,8 +624,9 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
519
624
|
className: "custom-control-input",
|
|
520
625
|
type: "checkbox",
|
|
521
626
|
checked: this_checked_bold,
|
|
522
|
-
|
|
523
|
-
|
|
627
|
+
onChange: function onChange(e) {
|
|
628
|
+
return _this2.editElementProp('bold', 'checked', e);
|
|
629
|
+
}
|
|
524
630
|
}), /*#__PURE__*/_react["default"].createElement("label", {
|
|
525
631
|
className: "custom-control-label",
|
|
526
632
|
htmlFor: "do-bold"
|
|
@@ -533,14 +639,15 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
533
639
|
className: "custom-control-input",
|
|
534
640
|
type: "checkbox",
|
|
535
641
|
checked: this_checked_italic,
|
|
536
|
-
|
|
537
|
-
|
|
642
|
+
onChange: function onChange(e) {
|
|
643
|
+
return _this2.editElementProp('italic', 'checked', e);
|
|
644
|
+
}
|
|
538
645
|
}), /*#__PURE__*/_react["default"].createElement("label", {
|
|
539
646
|
className: "custom-control-label",
|
|
540
647
|
htmlFor: "do-italic"
|
|
541
648
|
}, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
542
649
|
id: "italic"
|
|
543
|
-
})))),
|
|
650
|
+
})))), el.showPlaceholder && /*#__PURE__*/_react["default"].createElement("div", {
|
|
544
651
|
className: "form-group"
|
|
545
652
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
546
653
|
className: "control-label",
|
|
@@ -551,24 +658,11 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
551
658
|
type: "text",
|
|
552
659
|
className: "form-control",
|
|
553
660
|
id: "placeholder",
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
560
|
-
className: "control-label",
|
|
561
|
-
htmlFor: "custom_name"
|
|
562
|
-
}, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
563
|
-
id: "custom-name-label"
|
|
564
|
-
})), /*#__PURE__*/_react["default"].createElement("input", {
|
|
565
|
-
type: "text",
|
|
566
|
-
className: "form-control",
|
|
567
|
-
id: "custom_name",
|
|
568
|
-
defaultValue: this.props.element.custom_name,
|
|
569
|
-
onBlur: this.updateElement.bind(this),
|
|
570
|
-
onChange: this.editElementProp.bind(this, 'custom_name', 'value')
|
|
571
|
-
})), this.props.element.showDescription && /*#__PURE__*/_react["default"].createElement("div", {
|
|
661
|
+
value: el.placeholder || '',
|
|
662
|
+
onChange: function onChange(e) {
|
|
663
|
+
return _this2.editElementProp('placeholder', 'value', e);
|
|
664
|
+
}
|
|
665
|
+
})), el.showDescription && /*#__PURE__*/_react["default"].createElement("div", {
|
|
572
666
|
className: "form-group"
|
|
573
667
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
574
668
|
className: "control-label",
|
|
@@ -579,30 +673,33 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
579
673
|
type: "text",
|
|
580
674
|
className: "form-control",
|
|
581
675
|
id: "questionDescription",
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
676
|
+
value: el.description || '',
|
|
677
|
+
onChange: function onChange(e) {
|
|
678
|
+
return _this2.editElementProp('description', 'value', e);
|
|
679
|
+
}
|
|
680
|
+
})), el.element === 'TextInput' && /*#__PURE__*/_react["default"].createElement("div", {
|
|
586
681
|
className: "form-group"
|
|
587
682
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
588
683
|
className: "control-label"
|
|
589
684
|
}, "Validation Message:"), /*#__PURE__*/_react["default"].createElement("input", {
|
|
590
685
|
type: "text",
|
|
591
686
|
className: "form-control",
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
687
|
+
value: el.validationMessage || '',
|
|
688
|
+
onChange: function onChange(e) {
|
|
689
|
+
return _this2.editElementProp('validationMessage', 'value', e);
|
|
690
|
+
}
|
|
691
|
+
})), el.element === 'TextInput' && /*#__PURE__*/_react["default"].createElement("div", {
|
|
596
692
|
className: "form-group"
|
|
597
693
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
598
694
|
className: "control-label"
|
|
599
695
|
}, "Validation Pattern (Regex):"), /*#__PURE__*/_react["default"].createElement("input", {
|
|
600
696
|
type: "text",
|
|
601
697
|
className: "form-control",
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
698
|
+
value: el.validationPattern || '',
|
|
699
|
+
onChange: function onChange(e) {
|
|
700
|
+
return _this2.editElementProp('validationPattern', 'value', e);
|
|
701
|
+
}
|
|
702
|
+
})), this.props.showCorrectColumn && el.canHaveAnswer && !el.hasOwnProperty('options') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
606
703
|
className: "form-group"
|
|
607
704
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
608
705
|
className: "control-label",
|
|
@@ -613,10 +710,11 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
613
710
|
id: "correctAnswer",
|
|
614
711
|
type: "text",
|
|
615
712
|
className: "form-control",
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
713
|
+
value: el.correct || '',
|
|
714
|
+
onChange: function onChange(e) {
|
|
715
|
+
return _this2.editElementProp('correct', 'value', e);
|
|
716
|
+
}
|
|
717
|
+
})), el.canPopulateFromApi && el.hasOwnProperty('options') && /*#__PURE__*/_react["default"].createElement("div", {
|
|
620
718
|
className: "form-group"
|
|
621
719
|
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
622
720
|
className: "control-label",
|
|
@@ -638,19 +736,39 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
|
|
|
638
736
|
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
639
737
|
className: "col-sm-6"
|
|
640
738
|
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
641
|
-
onClick: this.addOptions
|
|
739
|
+
onClick: this.addOptions,
|
|
642
740
|
className: "btn btn-success"
|
|
643
741
|
}, /*#__PURE__*/_react["default"].createElement(_IntlMessages["default"], {
|
|
644
742
|
id: "populate"
|
|
645
|
-
}))))),
|
|
743
|
+
}))))), el.hasOwnProperty('options') && /*#__PURE__*/_react["default"].createElement(_dynamicOptionList["default"], {
|
|
646
744
|
showCorrectColumn: this.props.showCorrectColumn,
|
|
647
745
|
canHaveOptionCorrect: canHaveOptionCorrect,
|
|
648
746
|
canHaveOptionValue: canHaveOptionValue,
|
|
649
|
-
data: this.props.preview.state.data
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
element:
|
|
653
|
-
|
|
747
|
+
data: this.props.preview.state.data
|
|
748
|
+
// IMPORTANT: feed the DRAFT here so edits stay local
|
|
749
|
+
,
|
|
750
|
+
element: el,
|
|
751
|
+
preview: this.props.preview
|
|
752
|
+
// Wrap updateElement so options edits update the draft only
|
|
753
|
+
,
|
|
754
|
+
updateElement: function updateElement(updated) {
|
|
755
|
+
// Some versions pass the whole element, others only mutate options inside draft
|
|
756
|
+
if (updated && updated.options) {
|
|
757
|
+
_this2.setDraftProp('options', updated.options);
|
|
758
|
+
} else {
|
|
759
|
+
// fallback: clone from current draft in case child mutated it
|
|
760
|
+
_this2.setState(function (_ref4) {
|
|
761
|
+
var draft = _ref4.draft;
|
|
762
|
+
return {
|
|
763
|
+
draft: _objectSpread(_objectSpread({}, draft), {}, {
|
|
764
|
+
options: (0, _toConsumableArray2["default"])(draft.options || [])
|
|
765
|
+
}),
|
|
766
|
+
dirty: true
|
|
767
|
+
};
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
},
|
|
771
|
+
key: el.options && el.options.length || 0
|
|
654
772
|
}));
|
|
655
773
|
}
|
|
656
774
|
}]);
|