@agilemotion/oui-react-js 1.3.4 → 1.3.5
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/BusinessPortalAppHome.js +21 -7
- package/dist/RestUtils.js +20 -14
- package/dist/Utils.js +0 -2
- package/dist/components/PopupView.js +4 -3
- package/dist/components/SignaturePanel.js +3 -8
- package/dist/components/StepperTitleBar.css +7 -1
- package/dist/components/StepperTitleBar.js +12 -10
- package/dist/components/TemplateDesigner.css +5 -1
- package/dist/components/TemplateDesigner.js +48 -16
- package/dist/components/TemplateItemEventHandler.js +116 -84
- package/dist/components/form/BaseField.js +2 -1
- package/dist/components/form/FieldSet.js +18 -15
- package/dist/components/form/Form.css +1 -0
- package/dist/components/form/Form.js +3 -2
- package/dist/components/form/ImageEditor.js +13 -4
- package/dist/components/layout/Layout.js +0 -1
- package/dist/components/signatures/DocumentContainer.js +4 -4
- package/dist/components/signatures/OLD.js +1138 -0
- package/dist/components/signatures/SignatureInputProps.js +0 -7
- package/dist/components/signatures/SignatureTemplateDesigner.js +197 -487
- package/dist/event/ActionHandlers.js +1 -1
- package/dist/event/LoadDataActionHandler.js +1 -1
- package/dist/event/ServiceCallActionHandler.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,1138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _Utils = _interopRequireDefault(require("../../Utils"));
|
|
11
|
+
|
|
12
|
+
var _reactHtmlRenderer = _interopRequireDefault(require("react-html-renderer"));
|
|
13
|
+
|
|
14
|
+
var _core = require("@material-ui/core");
|
|
15
|
+
|
|
16
|
+
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
17
|
+
|
|
18
|
+
var _ApplicationContext = _interopRequireDefault(require("../../ApplicationContext"));
|
|
19
|
+
|
|
20
|
+
var _reactPromiseTracker = require("react-promise-tracker");
|
|
21
|
+
|
|
22
|
+
var _SignatureInputProps = _interopRequireDefault(require("./SignatureInputProps"));
|
|
23
|
+
|
|
24
|
+
var _Observable = _interopRequireDefault(require("../../event/Observable"));
|
|
25
|
+
|
|
26
|
+
var _Event = _interopRequireDefault(require("../../event/Event"));
|
|
27
|
+
|
|
28
|
+
var _EventType = _interopRequireDefault(require("../../event/EventType"));
|
|
29
|
+
|
|
30
|
+
var Base64 = _interopRequireWildcard(require("js-base64"));
|
|
31
|
+
|
|
32
|
+
var _RestUtils = require("../../RestUtils");
|
|
33
|
+
|
|
34
|
+
var _ServiceCallActionHandler = _interopRequireDefault(require("../../event/ServiceCallActionHandler"));
|
|
35
|
+
|
|
36
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
37
|
+
|
|
38
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
|
+
|
|
40
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
|
+
|
|
42
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
43
|
+
|
|
44
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
45
|
+
|
|
46
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
47
|
+
|
|
48
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
49
|
+
|
|
50
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
51
|
+
|
|
52
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
53
|
+
|
|
54
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
55
|
+
|
|
56
|
+
const INITIAL_ITEM = {
|
|
57
|
+
type: "initial",
|
|
58
|
+
defaultWidth: "100%",
|
|
59
|
+
defaultWidthOnPageDrop: "80px",
|
|
60
|
+
defaultHeightOnPageDrop: "80px"
|
|
61
|
+
};
|
|
62
|
+
const SIGN_ITEM = {
|
|
63
|
+
type: "sign",
|
|
64
|
+
defaultWidth: "100%",
|
|
65
|
+
defaultWidthOnPageDrop: "200px",
|
|
66
|
+
defaultHeightOnPageDrop: "80px"
|
|
67
|
+
};
|
|
68
|
+
const TEXT_ITEM = {
|
|
69
|
+
type: "text",
|
|
70
|
+
defaultWidth: "100%",
|
|
71
|
+
defaultWidthOnPageDrop: "200px",
|
|
72
|
+
defaultHeightOnPageDrop: "80px"
|
|
73
|
+
};
|
|
74
|
+
const DROP_ITEM_MARGIN = 32;
|
|
75
|
+
const types = [INITIAL_ITEM, SIGN_ITEM, TEXT_ITEM];
|
|
76
|
+
const useStyles = (0, _core.makeStyles)(theme => ({
|
|
77
|
+
button: {
|
|
78
|
+
margin: theme.spacing(1)
|
|
79
|
+
},
|
|
80
|
+
input: {
|
|
81
|
+
display: 'none'
|
|
82
|
+
},
|
|
83
|
+
errorMessageDisplay: {
|
|
84
|
+
color: 'red'
|
|
85
|
+
},
|
|
86
|
+
propertyWindow: {
|
|
87
|
+
height: "400px",
|
|
88
|
+
margin: "4px",
|
|
89
|
+
borderRadius: "4px",
|
|
90
|
+
paddingLeft: "24px",
|
|
91
|
+
borderBottom: "1px solid #e1e1e1",
|
|
92
|
+
borderTop: "1px solid #e1e1e1"
|
|
93
|
+
},
|
|
94
|
+
paletteButton: {
|
|
95
|
+
width: "270px",
|
|
96
|
+
height: "40px",
|
|
97
|
+
backgroundColor: "#e1e1e1",
|
|
98
|
+
margin: "4px",
|
|
99
|
+
textAlign: "center",
|
|
100
|
+
padding: "28px 0",
|
|
101
|
+
borderRadius: "4px"
|
|
102
|
+
},
|
|
103
|
+
paletteButtonSelected: {
|
|
104
|
+
'&:hover': {
|
|
105
|
+
backgroundColor: "yellowgreen"
|
|
106
|
+
},
|
|
107
|
+
width: "270px",
|
|
108
|
+
height: "40px",
|
|
109
|
+
backgroundColor: "yellowgreen",
|
|
110
|
+
margin: "4px",
|
|
111
|
+
textAlign: "center",
|
|
112
|
+
padding: "28px 0",
|
|
113
|
+
borderRadius: "4px"
|
|
114
|
+
},
|
|
115
|
+
palette: {
|
|
116
|
+
width: "280px",
|
|
117
|
+
borderRadius: "4px",
|
|
118
|
+
border: "1px solid #e1e1e1"
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
121
|
+
|
|
122
|
+
const status = response => {
|
|
123
|
+
if (response.ok) {
|
|
124
|
+
return Promise.resolve(response);
|
|
125
|
+
} else {
|
|
126
|
+
let error = new Error(response.statusText);
|
|
127
|
+
error.code = response.status;
|
|
128
|
+
return Promise.reject(error);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const json = response => {
|
|
133
|
+
return response.text();
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const VALID_COLOR = "green";
|
|
137
|
+
const INVALID_COLOR = "red";
|
|
138
|
+
const location = window.location.protocol + "//" + window.location.hostname;
|
|
139
|
+
const dragAndDropData = {}; //Global variable as Chrome doesn't allow access to event.dataTransfer in dragover
|
|
140
|
+
|
|
141
|
+
const SignatureTemplateDesigner = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
142
|
+
const _React$useState = _react.default.useState(null),
|
|
143
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
144
|
+
file = _React$useState2[0],
|
|
145
|
+
setFile = _React$useState2[1];
|
|
146
|
+
|
|
147
|
+
const _React$useState3 = _react.default.useState(null),
|
|
148
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
149
|
+
htmlTemplate = _React$useState4[0],
|
|
150
|
+
setHtmlTemplate = _React$useState4[1];
|
|
151
|
+
|
|
152
|
+
const _React$useState5 = _react.default.useState(null),
|
|
153
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
154
|
+
paletteSelectionId = _React$useState6[0],
|
|
155
|
+
setPaletteSelectionId = _React$useState6[1];
|
|
156
|
+
|
|
157
|
+
const paletteSelection = _react.default.useRef(null);
|
|
158
|
+
|
|
159
|
+
const idCounter = _react.default.useRef(0);
|
|
160
|
+
|
|
161
|
+
const _React$useState7 = _react.default.useState(null),
|
|
162
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
163
|
+
value = _React$useState8[0],
|
|
164
|
+
setValue = _React$useState8[1];
|
|
165
|
+
|
|
166
|
+
const _React$useState9 = _react.default.useState(null),
|
|
167
|
+
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
168
|
+
selectedInputBoxValue = _React$useState10[0],
|
|
169
|
+
setSelectedInputBoxValue = _React$useState10[1];
|
|
170
|
+
|
|
171
|
+
const _React$useState11 = _react.default.useState([]),
|
|
172
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
173
|
+
inputBoxValues = _React$useState12[0],
|
|
174
|
+
setInputBoxValues = _React$useState12[1];
|
|
175
|
+
|
|
176
|
+
const classes = useStyles();
|
|
177
|
+
|
|
178
|
+
const _React$useState13 = _react.default.useState(true),
|
|
179
|
+
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
180
|
+
initializing = _React$useState14[0],
|
|
181
|
+
setInitializing = _React$useState14[1];
|
|
182
|
+
|
|
183
|
+
const _React$useState15 = _react.default.useState(true),
|
|
184
|
+
_React$useState16 = _slicedToArray(_React$useState15, 2),
|
|
185
|
+
loading = _React$useState16[0],
|
|
186
|
+
setLoading = _React$useState16[1];
|
|
187
|
+
|
|
188
|
+
const documentName = _react.default.useRef(null);
|
|
189
|
+
|
|
190
|
+
_react.default.useEffect(() => {
|
|
191
|
+
props.handle.api = api();
|
|
192
|
+
|
|
193
|
+
if (initializing) {
|
|
194
|
+
let parsedConfig = _Utils.default.parseConfig(props.config, props.viewId);
|
|
195
|
+
|
|
196
|
+
_Observable.default.addSubscriptions(parsedConfig.eventHandlingConfig, props.handle, props.viewId);
|
|
197
|
+
|
|
198
|
+
_Observable.default.addSystemSubscriptions(parsedConfig);
|
|
199
|
+
|
|
200
|
+
setInitializing(false);
|
|
201
|
+
|
|
202
|
+
if (!_Utils.default.isNull(props.loadCompleteHandler)) {
|
|
203
|
+
props.loadCompleteHandler(props.config.id);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
_react.default.useEffect(() => {
|
|
209
|
+
if (!_Utils.default.isNull(props.valueChangeHandler)) {
|
|
210
|
+
props.valueChangeHandler(value);
|
|
211
|
+
}
|
|
212
|
+
}, [value]);
|
|
213
|
+
|
|
214
|
+
const api = () => {
|
|
215
|
+
return {
|
|
216
|
+
get id() {
|
|
217
|
+
return props.config.id;
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
loadData: actionConfig => {
|
|
221
|
+
setLoading(true);
|
|
222
|
+
let service = !_Utils.default.isNull(props.config.dataService) ? props.config.dataService : !_Utils.default.isNull(actionConfig) !== null ? actionConfig.dataService : null;
|
|
223
|
+
|
|
224
|
+
if (!_Utils.default.isNull(service)) {
|
|
225
|
+
if (service.type === 'remoteObjectProxy') {
|
|
226
|
+
(0, _RestUtils.invokeRpc)(service, props.handle, props.viewId, result => {
|
|
227
|
+
setLoading(false);
|
|
228
|
+
}, e => {
|
|
229
|
+
console.error(e);
|
|
230
|
+
|
|
231
|
+
_Utils.default.publishSystemErrorMessage(props.viewId);
|
|
232
|
+
}, parameter => {
|
|
233
|
+
setLoading(false);
|
|
234
|
+
});
|
|
235
|
+
} else {
|
|
236
|
+
if (_Utils.default.isNull(actionConfig)) {
|
|
237
|
+
actionConfig = {};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
actionConfig.service = service;
|
|
241
|
+
|
|
242
|
+
_ServiceCallActionHandler.default.execute(actionConfig, null, null, props.viewId, data => {
|
|
243
|
+
setHtmlTemplate(data.template);
|
|
244
|
+
setLoading(false);
|
|
245
|
+
}, () => {});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return true;
|
|
249
|
+
} else {
|
|
250
|
+
if (!_Utils.default.isNull(actionConfig) && !_Utils.default.isNull(actionConfig.value)) {
|
|
251
|
+
let value = _ApplicationContext.default.isExpression(actionConfig.value) ? _ApplicationContext.default.resolveExpressionValue(actionConfig.value) : actionConfig.value;
|
|
252
|
+
setValue(value);
|
|
253
|
+
|
|
254
|
+
if (!_Utils.default.isNull(value)) {
|
|
255
|
+
setHtmlTemplate(value.htmlTemplate);
|
|
256
|
+
setInputBoxValues(value.signatureInputs);
|
|
257
|
+
idCounter.current = value.idCounter;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
setLoading(false);
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
get model() {
|
|
266
|
+
return value;
|
|
267
|
+
},
|
|
268
|
+
|
|
269
|
+
get value() {
|
|
270
|
+
return value;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
let mouseOverHandler = function mouseOverHandler(event) {
|
|
277
|
+
if (typeof event.target.className === 'string' && event.target.className.includes("dropTarget") && paletteSelection.current !== null) {
|
|
278
|
+
let originalBorder = event.target.style.border.replace(INVALID_COLOR, VALID_COLOR);
|
|
279
|
+
event.target.setAttribute('originalBorder', originalBorder);
|
|
280
|
+
event.target.style.border = "4px dashed " + VALID_COLOR;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
let mouseOutHandler = function mouseOutHandler(event) {
|
|
285
|
+
if (typeof event.target.className === 'string' && event.target.className.includes("dropTarget")) {
|
|
286
|
+
let originalBorder = event.target.getAttribute("originalBorder");
|
|
287
|
+
|
|
288
|
+
if (_Utils.default.isNull(originalBorder)) {
|
|
289
|
+
originalBorder = "";
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
event.target.style.border = originalBorder;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const resetBorders = item => {
|
|
297
|
+
let elements = document.getElementsByClassName("_draggable_" + item.type);
|
|
298
|
+
|
|
299
|
+
var _iterator = _createForOfIteratorHelper(elements),
|
|
300
|
+
_step;
|
|
301
|
+
|
|
302
|
+
try {
|
|
303
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
304
|
+
const element = _step.value;
|
|
305
|
+
element.style.borderWidth = "2px";
|
|
306
|
+
}
|
|
307
|
+
} catch (err) {
|
|
308
|
+
_iterator.e(err);
|
|
309
|
+
} finally {
|
|
310
|
+
_iterator.f();
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
const getAllInputBoxElements = () => {
|
|
315
|
+
let elements = [];
|
|
316
|
+
|
|
317
|
+
var _iterator2 = _createForOfIteratorHelper(types),
|
|
318
|
+
_step2;
|
|
319
|
+
|
|
320
|
+
try {
|
|
321
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
322
|
+
const type = _step2.value;
|
|
323
|
+
|
|
324
|
+
var _iterator3 = _createForOfIteratorHelper(document.getElementsByClassName("_draggable_" + type.type)),
|
|
325
|
+
_step3;
|
|
326
|
+
|
|
327
|
+
try {
|
|
328
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
329
|
+
const element = _step3.value;
|
|
330
|
+
elements.push(element);
|
|
331
|
+
}
|
|
332
|
+
} catch (err) {
|
|
333
|
+
_iterator3.e(err);
|
|
334
|
+
} finally {
|
|
335
|
+
_iterator3.f();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
} catch (err) {
|
|
339
|
+
_iterator2.e(err);
|
|
340
|
+
} finally {
|
|
341
|
+
_iterator2.f();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return elements;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
const getPageDropOffset = (left, top) => {
|
|
348
|
+
let leftOffset = 0;
|
|
349
|
+
let topOffset = 0;
|
|
350
|
+
let elements = getAllInputBoxElements();
|
|
351
|
+
|
|
352
|
+
var _iterator4 = _createForOfIteratorHelper(elements),
|
|
353
|
+
_step4;
|
|
354
|
+
|
|
355
|
+
try {
|
|
356
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
357
|
+
const element = _step4.value;
|
|
358
|
+
|
|
359
|
+
if (parseFloat(element.style.left.replace('px', '')) === left) {
|
|
360
|
+
leftOffset += 4;
|
|
361
|
+
left = parseFloat(element.style.left.replace('px', '')) + 4;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (parseFloat(element.style.top.replace('px', '')) === top) {
|
|
365
|
+
topOffset += 4;
|
|
366
|
+
top = parseFloat(element.style.top.replace('px', ''));
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
} catch (err) {
|
|
370
|
+
_iterator4.e(err);
|
|
371
|
+
} finally {
|
|
372
|
+
_iterator4.f();
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return {
|
|
376
|
+
leftOffset: leftOffset,
|
|
377
|
+
topOffset: topOffset
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
const convertToPixels = val => {
|
|
382
|
+
if (val.includes("pt")) {
|
|
383
|
+
let numericValue = parseFloat(val.replace('pt', ''));
|
|
384
|
+
return (4 * numericValue / 3).toFixed(0) + "px";
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
return val;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
const resetAllBorder = () => {
|
|
391
|
+
resetBorders(INITIAL_ITEM);
|
|
392
|
+
resetBorders(SIGN_ITEM);
|
|
393
|
+
resetBorders(TEXT_ITEM);
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
let mouseClickHandler = function mouseClickHandler(event) {
|
|
397
|
+
resetAllBorder();
|
|
398
|
+
setSelectedInputBoxValue(null);
|
|
399
|
+
|
|
400
|
+
if (typeof event.target.className === 'string' && event.target.className.includes("dropTarget")) {
|
|
401
|
+
if (paletteSelection.current !== null) {
|
|
402
|
+
let node = document.createElement("div"); // TODO : First check if its an overlay or an adaptive mode
|
|
403
|
+
|
|
404
|
+
node.style.lineHeight = event.target.style.lineHeight;
|
|
405
|
+
node.style.border = "2px dashed " + INVALID_COLOR;
|
|
406
|
+
node.style.position = 'absolute';
|
|
407
|
+
node.style.borderRadius = '2px';
|
|
408
|
+
node.id = idCounter.current++;
|
|
409
|
+
node.className = "__agm_wf_signatureInput__ _draggable_" + paletteSelection.current.type;
|
|
410
|
+
node.setAttribute("draggable", true);
|
|
411
|
+
|
|
412
|
+
if (event.target.className.includes("page")) {
|
|
413
|
+
let top = !_Utils.default.isNull(event.target.style.top) && event.target.style.top.trim().length > 0 ? event.target.style.top.replaceAll('pt', '') : '0';
|
|
414
|
+
let topPos = parseFloat(top) + parseFloat(event.target.style.height.replace('pt', '')) - parseFloat(paletteSelection.current.defaultHeightOnPageDrop.replace('px', '')) * .75 - DROP_ITEM_MARGIN;
|
|
415
|
+
let pageDropOffset = getPageDropOffset(DROP_ITEM_MARGIN, parseFloat(convertToPixels(topPos + "pt").replace('px', '')));
|
|
416
|
+
node.style.top = convertToPixels(topPos - pageDropOffset.topOffset + 'pt');
|
|
417
|
+
node.style.width = paletteSelection.current.defaultWidthOnPageDrop;
|
|
418
|
+
node.style.height = paletteSelection.current.defaultHeightOnPageDrop;
|
|
419
|
+
node.style.padding = '8px';
|
|
420
|
+
node.style.left = DROP_ITEM_MARGIN + pageDropOffset.leftOffset + 'px';
|
|
421
|
+
event.target.appendChild(node);
|
|
422
|
+
} else {
|
|
423
|
+
let lineHeight = event.target.style.lineHeight;
|
|
424
|
+
let hasLineHeight = !_Utils.default.isNull(lineHeight) && lineHeight.trim().length > 0 && lineHeight.toString() !== '0';
|
|
425
|
+
node.style.top = hasLineHeight ? event.target.style.top : convertToPixels(parseFloat(event.target.style.top.replace('pt', '')) - 14.5 + 'pt');
|
|
426
|
+
node.style.left = event.target.style.left;
|
|
427
|
+
node.style.width = convertToPixels(event.target.style.width);
|
|
428
|
+
node.style.height = convertToPixels(hasLineHeight ? event.target.style.lineHeight : '14.5pt');
|
|
429
|
+
node.style.padding = parseFloat(node.style.height.replace('px', '')) > 32 ? '8px' : '0px';
|
|
430
|
+
event.target.parentElement.appendChild(node);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
node.addEventListener('dragstart', dragStart, false);
|
|
434
|
+
let inputValue = {};
|
|
435
|
+
inputValue.id = node.id;
|
|
436
|
+
inputValue.height = node.style.height.replace("px", "");
|
|
437
|
+
inputValue.width = node.style.width.replace("px", "");
|
|
438
|
+
inputValue.type = paletteSelection.current.type === "initial" ? "INITIAL" : paletteSelection.current.type === "sign" ? "SIGN" : "TEXT INPUT";
|
|
439
|
+
inputBoxValues.push(inputValue);
|
|
440
|
+
setValue(null);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
paletteSelection.current = null;
|
|
444
|
+
setPaletteSelectionId(null);
|
|
445
|
+
} else if (event.target.className.includes("_draggable_")) {
|
|
446
|
+
event.target.style.borderWidth = "4px";
|
|
447
|
+
let inputValue = getInputValue(event.target.id);
|
|
448
|
+
setSelectedInputBoxValue(inputValue);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (typeof event.target.className === 'string' && !event.target.className.includes("paletteButton") && !event.target.className.includes("paletteButtonLabel") && !event.target.className.includes("paletteButtonSelected")) {
|
|
452
|
+
paletteSelection.current = null;
|
|
453
|
+
setPaletteSelectionId(null);
|
|
454
|
+
document.getElementsByTagName("body")[0].style.cursor = 'default';
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
_react.default.useEffect(() => {
|
|
459
|
+
return () => {
|
|
460
|
+
destroyEvents();
|
|
461
|
+
};
|
|
462
|
+
}, []);
|
|
463
|
+
|
|
464
|
+
_react.default.useEffect(() => {
|
|
465
|
+
let event = new _Event.default(props.handle, props.viewId, value);
|
|
466
|
+
|
|
467
|
+
_Observable.default.fireEvent(_EventType.default.VALUE_CHANGE, event);
|
|
468
|
+
}, [value]);
|
|
469
|
+
|
|
470
|
+
const initDragAndDrop = className => {
|
|
471
|
+
setTimeout(() => {
|
|
472
|
+
let elements = document.getElementsByClassName(className);
|
|
473
|
+
|
|
474
|
+
var _iterator5 = _createForOfIteratorHelper(elements),
|
|
475
|
+
_step5;
|
|
476
|
+
|
|
477
|
+
try {
|
|
478
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
479
|
+
const element = _step5.value;
|
|
480
|
+
|
|
481
|
+
if (className !== "page") {
|
|
482
|
+
element.addEventListener("dragstart", dragStart, false);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
element.addEventListener("dragover", dragOver, false);
|
|
486
|
+
element.addEventListener("drop", drop, false);
|
|
487
|
+
}
|
|
488
|
+
} catch (err) {
|
|
489
|
+
_iterator5.e(err);
|
|
490
|
+
} finally {
|
|
491
|
+
_iterator5.f();
|
|
492
|
+
}
|
|
493
|
+
}, 2000);
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
const destroyEvents = () => {
|
|
497
|
+
let elements = document.getElementsByClassName("page");
|
|
498
|
+
|
|
499
|
+
var _iterator6 = _createForOfIteratorHelper(elements),
|
|
500
|
+
_step6;
|
|
501
|
+
|
|
502
|
+
try {
|
|
503
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
504
|
+
const element = _step6.value;
|
|
505
|
+
element.removeEventListener("dragover", dragOver);
|
|
506
|
+
element.removeEventListener("drop", drop);
|
|
507
|
+
}
|
|
508
|
+
} catch (err) {
|
|
509
|
+
_iterator6.e(err);
|
|
510
|
+
} finally {
|
|
511
|
+
_iterator6.f();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
let allInputs = getAllInputBoxElements();
|
|
515
|
+
|
|
516
|
+
var _iterator7 = _createForOfIteratorHelper(allInputs),
|
|
517
|
+
_step7;
|
|
518
|
+
|
|
519
|
+
try {
|
|
520
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
521
|
+
const element = _step7.value;
|
|
522
|
+
element.removeEventListener("dragover", dragOver);
|
|
523
|
+
element.removeEventListener("drop", drop);
|
|
524
|
+
element.removeEventListener("dropStart", dragStart);
|
|
525
|
+
}
|
|
526
|
+
} catch (err) {
|
|
527
|
+
_iterator7.e(err);
|
|
528
|
+
} finally {
|
|
529
|
+
_iterator7.f();
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
_react.default.useEffect(() => {
|
|
534
|
+
initDragAndDrop("page");
|
|
535
|
+
|
|
536
|
+
var _iterator8 = _createForOfIteratorHelper(types),
|
|
537
|
+
_step8;
|
|
538
|
+
|
|
539
|
+
try {
|
|
540
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
541
|
+
const type = _step8.value;
|
|
542
|
+
initDragAndDrop("_draggable_" + type.type);
|
|
543
|
+
resetBorders(type);
|
|
544
|
+
}
|
|
545
|
+
} catch (err) {
|
|
546
|
+
_iterator8.e(err);
|
|
547
|
+
} finally {
|
|
548
|
+
_iterator8.f();
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (!loading) {
|
|
552
|
+
setValue(null);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
setSelectedInputBoxValue(null);
|
|
556
|
+
setInputBoxValues([]);
|
|
557
|
+
setPaletteSelectionId(null);
|
|
558
|
+
}, [htmlTemplate]);
|
|
559
|
+
|
|
560
|
+
function getElementPage(elementId) {
|
|
561
|
+
let pages = document.getElementsByClassName("page");
|
|
562
|
+
|
|
563
|
+
var _iterator9 = _createForOfIteratorHelper(pages),
|
|
564
|
+
_step9;
|
|
565
|
+
|
|
566
|
+
try {
|
|
567
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
568
|
+
const page = _step9.value;
|
|
569
|
+
let elements = page.getElementsByClassName("__agm_wf_signatureInput__");
|
|
570
|
+
|
|
571
|
+
var _iterator10 = _createForOfIteratorHelper(elements),
|
|
572
|
+
_step10;
|
|
573
|
+
|
|
574
|
+
try {
|
|
575
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
576
|
+
const element = _step10.value;
|
|
577
|
+
|
|
578
|
+
if (element.id === elementId) {
|
|
579
|
+
return page;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
} catch (err) {
|
|
583
|
+
_iterator10.e(err);
|
|
584
|
+
} finally {
|
|
585
|
+
_iterator10.f();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
} catch (err) {
|
|
589
|
+
_iterator9.e(err);
|
|
590
|
+
} finally {
|
|
591
|
+
_iterator9.f();
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function handleDragDrop(event) {
|
|
598
|
+
let offset;
|
|
599
|
+
offset = dragAndDropData.offset.split(',');
|
|
600
|
+
let dm = document.getElementById(dragAndDropData.id);
|
|
601
|
+
let page = getElementPage(dm.id);
|
|
602
|
+
let itemLeft = event.clientX + parseInt(offset[0], 10);
|
|
603
|
+
let itemTop = event.clientY + parseInt(offset[1], 10);
|
|
604
|
+
let itemWidth = parseFloat(convertToPixels(dm.style.width).replace('px', ''));
|
|
605
|
+
let itemHeight = parseFloat(convertToPixels(dm.style.height).replace('px', ''));
|
|
606
|
+
dm.style.left = itemLeft + 'px';
|
|
607
|
+
dm.style.top = itemTop + 'px';
|
|
608
|
+
let itemRight = itemLeft + itemWidth;
|
|
609
|
+
let itemBottom = itemTop + itemHeight;
|
|
610
|
+
let pageRight = parseFloat(convertToPixels(page.style.width).replace('px', ''));
|
|
611
|
+
let pageBottom = parseFloat(convertToPixels(page.style.height).replace('px', ''));
|
|
612
|
+
|
|
613
|
+
if (itemLeft < DROP_ITEM_MARGIN) {
|
|
614
|
+
dm.style.left = DROP_ITEM_MARGIN + 'px';
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
if (itemRight > pageRight - DROP_ITEM_MARGIN) {
|
|
618
|
+
dm.style.left = pageRight - DROP_ITEM_MARGIN - itemWidth + 'px';
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (itemTop < DROP_ITEM_MARGIN) {
|
|
622
|
+
dm.style.top = DROP_ITEM_MARGIN + 'px';
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
if (itemBottom > pageBottom - DROP_ITEM_MARGIN) {
|
|
626
|
+
dm.style.top = pageBottom - DROP_ITEM_MARGIN - itemHeight + 'px';
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
event.preventDefault();
|
|
630
|
+
return false;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
function dragStart(event) {
|
|
634
|
+
document.body.style.cursor = "move";
|
|
635
|
+
let style = window.getComputedStyle(event.target, null);
|
|
636
|
+
dragAndDropData.offset = parseInt(style.getPropertyValue("left"), 10) - event.clientX + ',' + (parseInt(style.getPropertyValue("top"), 10) - event.clientY);
|
|
637
|
+
dragAndDropData.id = event.target.id;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function dragOver(event) {
|
|
641
|
+
document.body.style.cursor = "move";
|
|
642
|
+
return handleDragDrop(event);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
function drop(event) {
|
|
646
|
+
document.body.style.cursor = "default";
|
|
647
|
+
return handleDragDrop(event);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
const getInputValue = id => {
|
|
651
|
+
let index = 0;
|
|
652
|
+
|
|
653
|
+
var _iterator11 = _createForOfIteratorHelper(inputBoxValues),
|
|
654
|
+
_step11;
|
|
655
|
+
|
|
656
|
+
try {
|
|
657
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
658
|
+
const inputBoxValue = _step11.value;
|
|
659
|
+
|
|
660
|
+
if (inputBoxValue.id === id) {
|
|
661
|
+
inputBoxValue.index = index;
|
|
662
|
+
return inputBoxValue;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
index++;
|
|
666
|
+
}
|
|
667
|
+
} catch (err) {
|
|
668
|
+
_iterator11.e(err);
|
|
669
|
+
} finally {
|
|
670
|
+
_iterator11.f();
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
return null;
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
const handleSubmit = () => event => {
|
|
677
|
+
setHtmlTemplate("");
|
|
678
|
+
const accessToken = sessionStorage.getItem("accessToken");
|
|
679
|
+
const idToken = sessionStorage.getItem("idToken");
|
|
680
|
+
let data = new FormData();
|
|
681
|
+
data.append("sourceType", "PDF");
|
|
682
|
+
data.append("targetType", "HTML");
|
|
683
|
+
data.append("file", file);
|
|
684
|
+
let fetchConfig = {
|
|
685
|
+
method: 'POST',
|
|
686
|
+
headers: {
|
|
687
|
+
'Accept': 'application/json',
|
|
688
|
+
'Authorization': 'Bearer ' + accessToken,
|
|
689
|
+
'idToken': idToken
|
|
690
|
+
},
|
|
691
|
+
body: data
|
|
692
|
+
};
|
|
693
|
+
let url = location + _ApplicationContext.default.getBaseApiUrl() + props.config.documentConverterUrl;
|
|
694
|
+
(0, _reactPromiseTracker.trackPromise)(fetch(encodeURI(url), fetchConfig).then(status).then(json).then(data => {
|
|
695
|
+
setHtmlTemplate(data);
|
|
696
|
+
setFile(null);
|
|
697
|
+
}).catch(e => {
|
|
698
|
+
if (e.code === 401) {
|
|
699
|
+
_ApplicationContext.default.clear();
|
|
700
|
+
|
|
701
|
+
_ApplicationContext.default.getApplicationHistory().push('/login');
|
|
702
|
+
}
|
|
703
|
+
}));
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
const handleChange = () => event => {
|
|
707
|
+
let files = event.target.files;
|
|
708
|
+
documentName.current = files[0].name;
|
|
709
|
+
setFile(files[0]);
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
const deleteInputItem = id => {
|
|
713
|
+
let val = getInputValue(id);
|
|
714
|
+
inputBoxValues.splice(val.index, 1);
|
|
715
|
+
let element = document.getElementById(id);
|
|
716
|
+
element.remove();
|
|
717
|
+
saveValue();
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
const clear = () => {
|
|
721
|
+
var _iterator12 = _createForOfIteratorHelper(inputBoxValues),
|
|
722
|
+
_step12;
|
|
723
|
+
|
|
724
|
+
try {
|
|
725
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
726
|
+
const inputBoxValue = _step12.value;
|
|
727
|
+
document.getElementById(inputBoxValue.id).remove();
|
|
728
|
+
}
|
|
729
|
+
} catch (err) {
|
|
730
|
+
_iterator12.e(err);
|
|
731
|
+
} finally {
|
|
732
|
+
_iterator12.f();
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
inputBoxValues.splice(0, inputBoxValues.length);
|
|
736
|
+
setValue(null);
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
const handleDuplicate = id => {
|
|
740
|
+
let inputValue = getInputValue(id);
|
|
741
|
+
let element = document.getElementById(id);
|
|
742
|
+
let pageElements = document.getElementsByClassName("page");
|
|
743
|
+
let elementPage = null;
|
|
744
|
+
let elementTop = 3 * parseFloat(element.style.top.replace("px", '').replace('pt', '')) / 4;
|
|
745
|
+
let pageElementTop = 0;
|
|
746
|
+
|
|
747
|
+
var _iterator13 = _createForOfIteratorHelper(pageElements),
|
|
748
|
+
_step13;
|
|
749
|
+
|
|
750
|
+
try {
|
|
751
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
752
|
+
const pageElement = _step13.value;
|
|
753
|
+
let pageElementHeight = parseFloat(pageElement.style.height.replace("px", '').replace('pt', ''));
|
|
754
|
+
|
|
755
|
+
if (elementTop >= pageElementTop && elementTop < pageElementTop + pageElementHeight) {
|
|
756
|
+
elementPage = pageElement;
|
|
757
|
+
break;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
pageElementTop += pageElementHeight;
|
|
761
|
+
}
|
|
762
|
+
} catch (err) {
|
|
763
|
+
_iterator13.e(err);
|
|
764
|
+
} finally {
|
|
765
|
+
_iterator13.f();
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
let offset = elementTop - pageElementTop;
|
|
769
|
+
let pageNumber = 0;
|
|
770
|
+
let elementData = getInputValue(id);
|
|
771
|
+
|
|
772
|
+
var _iterator14 = _createForOfIteratorHelper(pageElements),
|
|
773
|
+
_step14;
|
|
774
|
+
|
|
775
|
+
try {
|
|
776
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
777
|
+
const pageElement = _step14.value;
|
|
778
|
+
let pageElementHeight = parseFloat(pageElement.style.height.replace("px", '').replace('pt', ''));
|
|
779
|
+
|
|
780
|
+
if (pageElement !== elementPage) {
|
|
781
|
+
let node = document.createElement("div");
|
|
782
|
+
node.style.lineHeight = element.lineHeight;
|
|
783
|
+
node.style.border = element.style.border;
|
|
784
|
+
node.style.position = 'absolute';
|
|
785
|
+
node.style.borderWidth = '2px';
|
|
786
|
+
node.style.borderRadius = '2px';
|
|
787
|
+
node.style.width = element.style.width;
|
|
788
|
+
node.style.padding = element.style.padding;
|
|
789
|
+
node.style.height = element.style.height;
|
|
790
|
+
node.style.left = element.style.left;
|
|
791
|
+
node.innerText = element.innerText;
|
|
792
|
+
node.style.top = convertToPixels(pageNumber * pageElementHeight + offset + 'pt');
|
|
793
|
+
node.id = idCounter.current++;
|
|
794
|
+
node.className = element.className;
|
|
795
|
+
node.setAttribute("sid", element.getAttribute("sid"));
|
|
796
|
+
node.setAttribute("draggable", true);
|
|
797
|
+
let inputValue = {};
|
|
798
|
+
inputValue.id = node.id;
|
|
799
|
+
inputValue.height = node.style.height.replace("px", "");
|
|
800
|
+
inputValue.width = node.style.width.replace("px", "");
|
|
801
|
+
inputValue.type = elementData.type;
|
|
802
|
+
inputValue.signatory = elementData.signatory;
|
|
803
|
+
inputBoxValues.push(inputValue);
|
|
804
|
+
pageElement.appendChild(node);
|
|
805
|
+
node.addEventListener('dragstart', dragStart, false);
|
|
806
|
+
saveValue();
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
} catch (err) {
|
|
810
|
+
_iterator14.e(err);
|
|
811
|
+
} finally {
|
|
812
|
+
_iterator14.f();
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
|
|
816
|
+
function saveValue() {
|
|
817
|
+
let allValid = true;
|
|
818
|
+
|
|
819
|
+
var _iterator15 = _createForOfIteratorHelper(inputBoxValues),
|
|
820
|
+
_step15;
|
|
821
|
+
|
|
822
|
+
try {
|
|
823
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
824
|
+
const inputBoxValue = _step15.value;
|
|
825
|
+
|
|
826
|
+
if (_Utils.default.isNull(inputBoxValue.signatory)) {
|
|
827
|
+
allValid = false;
|
|
828
|
+
break;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
} catch (err) {
|
|
832
|
+
_iterator15.e(err);
|
|
833
|
+
} finally {
|
|
834
|
+
_iterator15.f();
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
if (allValid) {
|
|
838
|
+
let newValue = {};
|
|
839
|
+
newValue.htmlTemplate = document.getElementById("templateContainer").innerHTML.replace("div name=\"replaced_html\"", "html").replace("div name=\"replaced_body\"", "body");
|
|
840
|
+
newValue.htmlTemplateBase64 = Base64.encode(newValue.htmlTemplate);
|
|
841
|
+
newValue.signatureInputs = inputBoxValues;
|
|
842
|
+
newValue.idCounter = idCounter.current;
|
|
843
|
+
newValue.documentName = documentName.current;
|
|
844
|
+
setValue(newValue);
|
|
845
|
+
} else {
|
|
846
|
+
setValue(null);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
const saveProps = (id, values) => {
|
|
851
|
+
let val = getInputValue(id);
|
|
852
|
+
val.width = values.width;
|
|
853
|
+
val.height = values.height;
|
|
854
|
+
val.signatory = values.signatory;
|
|
855
|
+
val.type = values.type === 'TEXT INPUT' ? 'TEXT_INPUT' : values.type;
|
|
856
|
+
let element = document.getElementById(id);
|
|
857
|
+
element.style.width = values.width + "px";
|
|
858
|
+
element.style.height = values.height + "px";
|
|
859
|
+
element.style.borderColor = VALID_COLOR;
|
|
860
|
+
element.innerText = values.signatory.map.name;
|
|
861
|
+
element.setAttribute("sid", values.signatory.map.emailAddress);
|
|
862
|
+
saveValue();
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
866
|
+
ref: ref,
|
|
867
|
+
style: {
|
|
868
|
+
padding: "0 32px"
|
|
869
|
+
}
|
|
870
|
+
}, !_Utils.default.isNull(props.config) && !loading ? /*#__PURE__*/_react.default.createElement("div", {
|
|
871
|
+
style: {
|
|
872
|
+
width: "100%",
|
|
873
|
+
maxHeight: "70vh"
|
|
874
|
+
}
|
|
875
|
+
}, _Utils.default.isNull(props.showToolbar) || props.showToolbar === true ? /*#__PURE__*/_react.default.createElement("div", {
|
|
876
|
+
style: {
|
|
877
|
+
marginBottom: "32px"
|
|
878
|
+
}
|
|
879
|
+
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
880
|
+
accept: "application/pdf",
|
|
881
|
+
className: classes.input,
|
|
882
|
+
id: "contained-button-file",
|
|
883
|
+
onChange: handleChange(),
|
|
884
|
+
type: "file"
|
|
885
|
+
}), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
886
|
+
className: "row"
|
|
887
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
888
|
+
className: "col-*-*"
|
|
889
|
+
}, /*#__PURE__*/_react.default.createElement("label", {
|
|
890
|
+
htmlFor: "contained-button-file"
|
|
891
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
892
|
+
variant: "contained",
|
|
893
|
+
component: "span",
|
|
894
|
+
className: classes.button
|
|
895
|
+
}, "Upload File"))), /*#__PURE__*/_react.default.createElement("div", {
|
|
896
|
+
className: "col-*-*"
|
|
897
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
898
|
+
variant: "contained",
|
|
899
|
+
component: "span",
|
|
900
|
+
disabled: _Utils.default.isNull(file),
|
|
901
|
+
className: classes.button,
|
|
902
|
+
onClick: handleSubmit()
|
|
903
|
+
}, "Generate Template"))))) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
904
|
+
style: {
|
|
905
|
+
height: "auto"
|
|
906
|
+
}
|
|
907
|
+
}, !_Utils.default.isNull(htmlTemplate) ? /*#__PURE__*/_react.default.createElement("div", {
|
|
908
|
+
className: 'row'
|
|
909
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
910
|
+
className: "".concat(classes.palette, " col-*-*"),
|
|
911
|
+
style: {
|
|
912
|
+
maxHeight: "calc(70vh - 80px)",
|
|
913
|
+
overflow: "auto"
|
|
914
|
+
}
|
|
915
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
916
|
+
className: "col-*-*"
|
|
917
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
918
|
+
variant: "contained",
|
|
919
|
+
component: "span",
|
|
920
|
+
className: paletteSelectionId === 'INITIAL_ITEM' ? classes.paletteButtonSelected : classes.paletteButton,
|
|
921
|
+
onClick: () => {
|
|
922
|
+
document.getElementsByTagName("body")[0].style.cursor = 'grabbing';
|
|
923
|
+
paletteSelection.current = INITIAL_ITEM;
|
|
924
|
+
setPaletteSelectionId('INITIAL_ITEM');
|
|
925
|
+
},
|
|
926
|
+
id: "initialPaletteButton",
|
|
927
|
+
classes: {
|
|
928
|
+
"label": "paletteButtonLabel"
|
|
929
|
+
}
|
|
930
|
+
}, "Initial Pad")), /*#__PURE__*/_react.default.createElement("div", {
|
|
931
|
+
className: "col-*-*"
|
|
932
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
933
|
+
variant: "contained",
|
|
934
|
+
component: "span",
|
|
935
|
+
className: paletteSelectionId === 'SIGN_ITEM' ? classes.paletteButtonSelected : classes.paletteButton,
|
|
936
|
+
onClick: () => {
|
|
937
|
+
document.getElementsByTagName("body")[0].style.cursor = 'grabbing';
|
|
938
|
+
paletteSelection.current = SIGN_ITEM;
|
|
939
|
+
setPaletteSelectionId('SIGN_ITEM');
|
|
940
|
+
},
|
|
941
|
+
id: "signPaletteButton",
|
|
942
|
+
classes: {
|
|
943
|
+
"label": "paletteButtonLabel"
|
|
944
|
+
}
|
|
945
|
+
}, "Signature Pad")), /*#__PURE__*/_react.default.createElement("div", {
|
|
946
|
+
className: "col-*-*"
|
|
947
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
948
|
+
variant: "contained",
|
|
949
|
+
component: "span",
|
|
950
|
+
className: paletteSelectionId === 'TEXT_ITEM' ? classes.paletteButtonSelected : classes.paletteButton,
|
|
951
|
+
onClick: () => {
|
|
952
|
+
document.getElementsByTagName("body")[0].style.cursor = 'grabbing';
|
|
953
|
+
paletteSelection.current = TEXT_ITEM;
|
|
954
|
+
setPaletteSelectionId('TEXT_ITEM');
|
|
955
|
+
},
|
|
956
|
+
id: "signPaletteButton",
|
|
957
|
+
classes: {
|
|
958
|
+
"label": "paletteButtonLabel"
|
|
959
|
+
}
|
|
960
|
+
}, "Text Input")), /*#__PURE__*/_react.default.createElement("div", {
|
|
961
|
+
className: "col-*-*"
|
|
962
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
963
|
+
variant: "contained",
|
|
964
|
+
component: "span",
|
|
965
|
+
className: classes.paletteButton,
|
|
966
|
+
onClick: () => {
|
|
967
|
+
clear();
|
|
968
|
+
},
|
|
969
|
+
id: "clearButton",
|
|
970
|
+
classes: {
|
|
971
|
+
"label": "paletteButtonLabel"
|
|
972
|
+
}
|
|
973
|
+
}, "Clear")), /*#__PURE__*/_react.default.createElement("div", {
|
|
974
|
+
className: "".concat(classes.propertyWindow)
|
|
975
|
+
}, /*#__PURE__*/_react.default.createElement(_SignatureInputProps.default, {
|
|
976
|
+
value: selectedInputBoxValue,
|
|
977
|
+
signatoryUrl: location + _ApplicationContext.default.getBaseApiUrl() + props.config.signatoryUrl,
|
|
978
|
+
saveHandler: (id, values) => saveProps(id, values),
|
|
979
|
+
deleteHandler: (id, values) => deleteInputItem(id, values),
|
|
980
|
+
dublicateHandler: id => handleDuplicate(id)
|
|
981
|
+
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
982
|
+
style: {
|
|
983
|
+
maxHeight: "calc(70vh - 80px)",
|
|
984
|
+
overflow: "auto",
|
|
985
|
+
width: "60%"
|
|
986
|
+
},
|
|
987
|
+
className: 'col-*-*',
|
|
988
|
+
id: "signaturePanel",
|
|
989
|
+
onClick: e => mouseClickHandler(e),
|
|
990
|
+
onMouseOver: e => mouseOverHandler(e),
|
|
991
|
+
onMouseOut: e => mouseOutHandler(e),
|
|
992
|
+
id: "templateContainer"
|
|
993
|
+
}, /*#__PURE__*/_react.default.createElement(_reactHtmlRenderer.default, {
|
|
994
|
+
html: htmlTemplate.replace('<html', "<div name=\"replaced_html\"").replace('</html>', '</div>').replace('<body', "<div name=\"replaced_body\"").replace('</body>', '</div>')
|
|
995
|
+
}))) : null)) : /*#__PURE__*/_react.default.createElement("div", null, "Loading..."));
|
|
996
|
+
}));
|
|
997
|
+
|
|
998
|
+
var _default = SignatureTemplateDesigner;
|
|
999
|
+
exports.default = _default;
|
|
1000
|
+
|
|
1001
|
+
/*#__PURE__*/
|
|
1002
|
+
_react.default.createElement("div", {
|
|
1003
|
+
ref: ref,
|
|
1004
|
+
style: {
|
|
1005
|
+
padding: "0 32px"
|
|
1006
|
+
}
|
|
1007
|
+
}, !_Utils.default.isNull(props.config) && !loading ? /*#__PURE__*/_react.default.createElement("div", {
|
|
1008
|
+
style: {
|
|
1009
|
+
width: "100%",
|
|
1010
|
+
maxHeight: "70vh"
|
|
1011
|
+
}
|
|
1012
|
+
}, _Utils.default.isNull(props.showToolbar) || props.showToolbar === true ? /*#__PURE__*/_react.default.createElement("div", {
|
|
1013
|
+
style: {
|
|
1014
|
+
marginBottom: "32px"
|
|
1015
|
+
}
|
|
1016
|
+
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
1017
|
+
accept: "application/pdf",
|
|
1018
|
+
className: classes.input,
|
|
1019
|
+
id: "contained-button-file",
|
|
1020
|
+
onChange: handleChange(),
|
|
1021
|
+
type: "file"
|
|
1022
|
+
}), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
1023
|
+
className: "row"
|
|
1024
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1025
|
+
className: "col-*-*"
|
|
1026
|
+
}, /*#__PURE__*/_react.default.createElement("label", {
|
|
1027
|
+
htmlFor: "contained-button-file"
|
|
1028
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1029
|
+
variant: "contained",
|
|
1030
|
+
component: "span",
|
|
1031
|
+
className: classes.button
|
|
1032
|
+
}, "Upload File"))), /*#__PURE__*/_react.default.createElement("div", {
|
|
1033
|
+
className: "col-*-*"
|
|
1034
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1035
|
+
variant: "contained",
|
|
1036
|
+
component: "span",
|
|
1037
|
+
disabled: _Utils.default.isNull(file),
|
|
1038
|
+
className: classes.button,
|
|
1039
|
+
onClick: handleSubmit()
|
|
1040
|
+
}, "Generate Template"))))) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
1041
|
+
style: {
|
|
1042
|
+
height: "auto"
|
|
1043
|
+
}
|
|
1044
|
+
}, !_Utils.default.isNull(templateDoc) ? /*#__PURE__*/_react.default.createElement("div", {
|
|
1045
|
+
className: 'row'
|
|
1046
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1047
|
+
className: "".concat(classes.palette, " col-*-*"),
|
|
1048
|
+
style: {
|
|
1049
|
+
maxHeight: "calc(70vh - 80px)",
|
|
1050
|
+
overflow: "auto",
|
|
1051
|
+
width: '280px'
|
|
1052
|
+
}
|
|
1053
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1054
|
+
variant: "contained",
|
|
1055
|
+
component: "span",
|
|
1056
|
+
className: paletteSelectionId === 'INITIAL_ITEM' ? classes.paletteButtonSelected : classes.paletteButton,
|
|
1057
|
+
onClick: () => grabPalleteItem({
|
|
1058
|
+
id: 'INITIAL_ITEM',
|
|
1059
|
+
description: 'Initial',
|
|
1060
|
+
type: 'INITIAL_ITEM',
|
|
1061
|
+
props: INITIAL_ITEM
|
|
1062
|
+
}),
|
|
1063
|
+
id: "initialPaletteButton",
|
|
1064
|
+
classes: {
|
|
1065
|
+
"label": "paletteButtonLabel"
|
|
1066
|
+
}
|
|
1067
|
+
}, "Initial Pad"), /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1068
|
+
variant: "contained",
|
|
1069
|
+
component: "span",
|
|
1070
|
+
className: paletteSelectionId === 'SIGN_ITEM' ? classes.paletteButtonSelected : classes.paletteButton,
|
|
1071
|
+
onClick: () => {
|
|
1072
|
+
document.getElementsByTagName("body")[0].style.cursor = 'grabbing';
|
|
1073
|
+
paletteSelection.current = SIGN_ITEM;
|
|
1074
|
+
setPaletteSelectionId('SIGN_ITEM');
|
|
1075
|
+
},
|
|
1076
|
+
id: "signPaletteButton",
|
|
1077
|
+
classes: {
|
|
1078
|
+
"label": "paletteButtonLabel"
|
|
1079
|
+
}
|
|
1080
|
+
}, "Signature Pad"), /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1081
|
+
variant: "contained",
|
|
1082
|
+
component: "span",
|
|
1083
|
+
className: paletteSelectionId === 'TEXT_ITEM' ? classes.paletteButtonSelected : classes.paletteButton,
|
|
1084
|
+
onClick: () => {
|
|
1085
|
+
document.getElementsByTagName("body")[0].style.cursor = 'grabbing';
|
|
1086
|
+
paletteSelection.current = TEXT_ITEM;
|
|
1087
|
+
setPaletteSelectionId('TEXT_ITEM');
|
|
1088
|
+
},
|
|
1089
|
+
id: "signPaletteButton",
|
|
1090
|
+
classes: {
|
|
1091
|
+
"label": "paletteButtonLabel"
|
|
1092
|
+
}
|
|
1093
|
+
}, "Text Input"), /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1094
|
+
variant: "contained",
|
|
1095
|
+
component: "span",
|
|
1096
|
+
className: classes.paletteButton,
|
|
1097
|
+
onClick: () => {
|
|
1098
|
+
clear();
|
|
1099
|
+
},
|
|
1100
|
+
id: "clearButton",
|
|
1101
|
+
classes: {
|
|
1102
|
+
"label": "paletteButtonLabel"
|
|
1103
|
+
}
|
|
1104
|
+
}, "Clear"), /*#__PURE__*/_react.default.createElement("div", {
|
|
1105
|
+
className: "".concat(classes.propertyWindow)
|
|
1106
|
+
}, /*#__PURE__*/_react.default.createElement(_SignatureInputProps.default, {
|
|
1107
|
+
value: selectedInputBoxValue,
|
|
1108
|
+
signatoryUrl: location + _ApplicationContext.default.getBaseApiUrl() + props.config.signatoryUrl,
|
|
1109
|
+
saveHandler: (id, values) => saveProps(id, values),
|
|
1110
|
+
deleteHandler: (id, values) => deleteInputItem(id, values),
|
|
1111
|
+
dublicateHandler: id => handleDuplicate(id)
|
|
1112
|
+
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
1113
|
+
style: {
|
|
1114
|
+
border: "1px solid #e1e1e1",
|
|
1115
|
+
borderRadius: "4px",
|
|
1116
|
+
marginLeft: "8px",
|
|
1117
|
+
height: "100%",
|
|
1118
|
+
width: "calc(100% - 288px)"
|
|
1119
|
+
},
|
|
1120
|
+
className: 'col-*-*',
|
|
1121
|
+
onClick: e => mouseClickHandler(e)
|
|
1122
|
+
}, templateDoc ? /*#__PURE__*/_react.default.createElement("div", {
|
|
1123
|
+
style: {
|
|
1124
|
+
maxHeight: "calc(70vh - 80px)",
|
|
1125
|
+
overflow: "auto"
|
|
1126
|
+
},
|
|
1127
|
+
className: 'col-*-*',
|
|
1128
|
+
id: "templateContainer"
|
|
1129
|
+
}, /*#__PURE__*/_react.default.createElement(_reactHtmlRenderer.default, {
|
|
1130
|
+
html: templateDoc.replace('<html', "<div name=\"replaced_html\"").replace('</html>', '</div>').replace('<body', "<div name=\"replaced_body\"").replace('</body>', '</div>')
|
|
1131
|
+
})) : /*#__PURE__*/_react.default.createElement("div", {
|
|
1132
|
+
style: {
|
|
1133
|
+
width: '100%',
|
|
1134
|
+
display: 'inline-block',
|
|
1135
|
+
textAlign: 'center',
|
|
1136
|
+
marginTop: '64px'
|
|
1137
|
+
}
|
|
1138
|
+
}, "no template to display"))) : null)) : /*#__PURE__*/_react.default.createElement("div", null, "Loading..."));
|