@agilemotion/oui-react-js 1.3.4 → 1.3.6

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.
@@ -69,10 +69,15 @@ const BusinessPortalAppHome = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_re
69
69
  loadingColor = _React$useState6[0],
70
70
  setLoadingColor = _React$useState6[1];
71
71
 
72
- const _React$useState7 = _react.default.useState(location + props.contextRoot + props.implConfig.authUrl + "/user/avatar?" + "access_token=" + sessionStorage.getItem("accessToken") + "&idToken=" + sessionStorage.getItem("idToken")),
72
+ const _React$useState7 = _react.default.useState(false),
73
73
  _React$useState8 = _slicedToArray(_React$useState7, 2),
74
- avatarUrl = _React$useState8[0],
75
- setAvatarUrl = _React$useState8[1];
74
+ hasClientError = _React$useState8[0],
75
+ setHasClientError = _React$useState8[1];
76
+
77
+ const _React$useState9 = _react.default.useState(location + props.contextRoot + props.implConfig.authUrl + "/user/avatar?" + "access_token=" + sessionStorage.getItem("accessToken") + "&idToken=" + sessionStorage.getItem("idToken")),
78
+ _React$useState10 = _slicedToArray(_React$useState9, 2),
79
+ avatarUrl = _React$useState10[0],
80
+ setAvatarUrl = _React$useState10[1];
76
81
 
77
82
  const history = (0, _reactRouter.useHistory)();
78
83
 
@@ -90,8 +95,13 @@ const BusinessPortalAppHome = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_re
90
95
 
91
96
  _ApplicationContext.default.setFilesApiPath(props.implConfig.filesApiPath);
92
97
 
93
- let implId = sessionStorage.getItem("implId");
94
- (0, _reactPromiseTracker.trackPromise)(fetch(encodeURI(location + props.contextRoot + props.implConfig.baseApiUrl + "/ui/setup/" + (implId ? implId : "default")), {
98
+ let cid = sessionStorage.getItem("cid");
99
+
100
+ if (window.location.host.startsWith("localhost") && !cid) {
101
+ cid = 'default';
102
+ }
103
+
104
+ (0, _reactPromiseTracker.trackPromise)(fetch(encodeURI(location + props.contextRoot + props.implConfig.baseApiUrl + "/ui/setup/" + cid), {
95
105
  method: 'GET',
96
106
  headers: {
97
107
  'Accept': 'application/json',
@@ -106,6 +116,8 @@ const BusinessPortalAppHome = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_re
106
116
 
107
117
  _ApplicationContext.default.getApplicationHistory().push('/login');
108
118
  }
119
+
120
+ setHasClientError(true);
109
121
  }));
110
122
  }
111
123
  });
@@ -143,7 +155,7 @@ const BusinessPortalAppHome = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_re
143
155
  className: "main w-100 h-100 d-inline-block"
144
156
  }, /*#__PURE__*/_react.default.createElement("div", {
145
157
  className: "w-100 h-100"
146
- }, dashboardSettings !== null ? /*#__PURE__*/_react.default.createElement(_BusinessPortalAppDashboard.default, {
158
+ }, dashboardSettings !== null && !hasClientError ? /*#__PURE__*/_react.default.createElement(_BusinessPortalAppDashboard.default, {
147
159
  logoutCallBack: () => {
148
160
  logout();
149
161
  },
@@ -151,7 +163,9 @@ const BusinessPortalAppHome = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_re
151
163
  avatar: !_Utils.default.isNull(avatarUrl) ? avatarUrl : null,
152
164
  logo: dashboardSettings.logo,
153
165
  appLogoPath: props.implConfig.appLogo
154
- }) : null), /*#__PURE__*/_react.default.createElement(_LoadingIndicator.default, {
166
+ }) : hasClientError ? /*#__PURE__*/_react.default.createElement("div", {
167
+ style: "margin: 128px; color: red; font-size: 24px"
168
+ }, "System error - Unknown client") : null), /*#__PURE__*/_react.default.createElement(_LoadingIndicator.default, {
155
169
  color: loadingColor
156
170
  })));
157
171
  }));
package/dist/RestUtils.js CHANGED
@@ -42,7 +42,15 @@ const json = response => {
42
42
  };
43
43
 
44
44
  class RestUtils {
45
- invokeRest(service, component, viewId, successCallback, errorCallback, invalidParamCallback, returnValueBinding, successMessage) {
45
+ isParamValueNull(paramValue) {
46
+ if (_Utils.default.isNull(paramValue)) {
47
+ return true;
48
+ }
49
+
50
+ return paramValue.hasOwnProperty('value') ? _Utils.default.isNull(paramValue.value) : false;
51
+ }
52
+
53
+ invokeRest(service, component, viewId, successCallback, errorCallback, invalidParamCallback, returnValueBinding, successMessage, event = null) {
46
54
  let url = service.url.startsWith('http://') || service.url.startsWith('https://') ? service.url : location + "".concat(_ApplicationContext.default.getContextRoot() + service.url);
47
55
  let requestBody = null;
48
56
 
@@ -58,11 +66,9 @@ class RestUtils {
58
66
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
59
67
  const parameter = _step.value;
60
68
 
61
- let parameterValue = _ApplicationContext.default.resolveParameterValue(parameter);
62
-
63
- if (!_Utils.default.isNull(parameter.validator) && !_Utils.default.evaluateBooleanExpression(parameter.validator.nullable, parameter.name) && (_Utils.default.isNull(parameterValue) || _Utils.default.isNull(parameterValue.value))) {
64
- console.debug('Invalid parameter value ' + parameter.name);
69
+ let parameterValue = _ApplicationContext.default.resolveParameterValue(parameter, event ? event.data : null);
65
70
 
71
+ if (!_Utils.default.isNull(parameter.validator) && !_Utils.default.evaluateBooleanExpression(parameter.validator.nullable, parameter.name) && this.isParamValueNull(parameterValue)) {
66
72
  if (!_Utils.default.isNull(invalidParamCallback)) {
67
73
  invalidParamCallback(parameter);
68
74
  }
@@ -97,7 +103,7 @@ class RestUtils {
97
103
 
98
104
  if (httpParameterType === 'PATH_VARIABLE') {
99
105
  if (!_Utils.default.isNull(parameterValue)) {
100
- pathParameters += '/' + (typeof parameterValue.value === 'object' ? JSON.stringify(parameterValue.value) : parameterValue.value);
106
+ pathParameters += '/' + (typeof parameterValue.value === 'object' ? JSON.stringify(parameterValue.value) : parameterValue.instanceType === 'TypedValue' ? parameterValue.value : parameterValue);
101
107
  }
102
108
  }
103
109
 
@@ -106,7 +112,7 @@ class RestUtils {
106
112
  console.error("Only one request body is permitted");
107
113
  return;
108
114
  } else {
109
- if (!_Utils.default.isNull(parameterValue)) {
115
+ if (!this.isParamValueNull(parameterValue)) {
110
116
  requestBody = parameterValue.instanceType === 'TypedValue' ? parameterValue.value : parameterValue;
111
117
 
112
118
  if (parameterValue.type === 'MapObject') {
@@ -152,7 +158,7 @@ class RestUtils {
152
158
  postData(url, response => {
153
159
  let responseData = !_Utils.default.isNull(response) ? response.data : null;
154
160
 
155
- if (!_Utils.default.isNull(responseData) && responseData.type === 'MessageDto' && responseData.messageType === "ERROR") {
161
+ if (!_Utils.default.isNull(responseData) && response.dataType === 'message' && responseData.messageType === "ERROR") {
156
162
  this.fireEvent(viewId, component, _EventType.default.SERVICE_CALL_FAILURE);
157
163
  } else {
158
164
  if (!_Utils.default.isNull(successCallback)) {
@@ -203,7 +209,7 @@ class RestUtils {
203
209
  }
204
210
  }
205
211
 
206
- invokeRpc(rpcDetails, component, viewId, successCallback, errorCallback, invalidParamCallback, returnValueBinding, successMessage) {
212
+ invokeRpc(rpcDetails, component, viewId, successCallback, errorCallback, invalidParamCallback, returnValueBinding, successMessage, event = null) {
207
213
  let request = {};
208
214
  request.id = viewId;
209
215
  request.service = rpcDetails.serviceId;
@@ -218,7 +224,7 @@ class RestUtils {
218
224
  parameter.name = parameterConfig.name;
219
225
  parameter.index = parameterConfig.index;
220
226
 
221
- let val = _ApplicationContext.default.resolveParameterValue(parameterConfig);
227
+ let val = _ApplicationContext.default.resolveParameterValue(parameterConfig, event ? event.data : null);
222
228
 
223
229
  if (!_Utils.default.isNull(val)) {
224
230
  parameter.value = val.value; // TODO : Make the default object type a library setting
@@ -238,7 +244,7 @@ class RestUtils {
238
244
  parameter.type = 'String';
239
245
  }
240
246
 
241
- if (!_Utils.default.isNull(parameterConfig.validator) && _Utils.default.evaluateBooleanExpression(parameterConfig.validator.nullable, parameterConfig.name) === false && _Utils.default.isNull(parameter.value)) {
247
+ if (!_Utils.default.isNull(parameterConfig.validator) && _Utils.default.evaluateBooleanExpression(parameterConfig.validator.nullable, parameterConfig.name) === false && this.isParamValueNull(parameter)) {
242
248
  if (!_Utils.default.isNull(invalidParamCallback)) {
243
249
  invalidParamCallback(parameter);
244
250
  }
@@ -264,7 +270,7 @@ class RestUtils {
264
270
 
265
271
  let responseData = !_Utils.default.isNull(response) ? response.data : null;
266
272
 
267
- if (!_Utils.default.isNull(responseData) && responseData.type === 'MessageDto' && responseData.messageType === "ERROR") {
273
+ if (!_Utils.default.isNull(responseData) && response.dataType === 'message' && responseData.messageType === "ERROR") {
268
274
  this.fireEvent(viewId, component, _EventType.default.SERVICE_CALL_FAILURE);
269
275
  } else {
270
276
  this.fireEvent(viewId, component, _EventType.default.SERVICE_CALL_SUCCESS, response.data);
@@ -398,7 +404,7 @@ class RestUtils {
398
404
  if (successCallback !== null) {
399
405
  let responseData = !_Utils.default.isNull(response) ? response.data : null;
400
406
 
401
- if (!_Utils.default.isNull(responseData) && responseData.type === 'MessageDto') {
407
+ if (!_Utils.default.isNull(responseData) && response.dataType === 'message') {
402
408
  let event = new _Event.default(_ApplicationContext.default, viewId, responseData);
403
409
 
404
410
  _Observable.default.fireEvent(_EventType.default.MESSAGE_ARRIVED, event);
@@ -456,14 +462,14 @@ const download = (url, successCallback, errorCallback, secure) => {
456
462
 
457
463
  exports.download = download;
458
464
 
459
- const invokeRpc = (rpcDetails, component, viewId, successCallback, errorCallback, invalidParamCallback, returnValueBinding, successMessage) => {
460
- instance.invokeRpc(rpcDetails, component, viewId, successCallback, errorCallback, invalidParamCallback, returnValueBinding, successMessage);
465
+ const invokeRpc = (rpcDetails, component, viewId, successCallback, errorCallback, invalidParamCallback, returnValueBinding, successMessage, event = null) => {
466
+ instance.invokeRpc(rpcDetails, component, viewId, successCallback, errorCallback, invalidParamCallback, returnValueBinding, successMessage, event);
461
467
  };
462
468
 
463
469
  exports.invokeRpc = invokeRpc;
464
470
 
465
- const invokeRest = (serviceConfig, component, viewId, successCallback, errorCallback, invalidParamCallback, returnValueBinding, successMessage) => {
466
- instance.invokeRest(serviceConfig, component, viewId, successCallback, errorCallback, invalidParamCallback, returnValueBinding, successMessage);
471
+ const invokeRest = (serviceConfig, component, viewId, successCallback, errorCallback, invalidParamCallback, returnValueBinding, successMessage, event = null) => {
472
+ instance.invokeRest(serviceConfig, component, viewId, successCallback, errorCallback, invalidParamCallback, returnValueBinding, successMessage, event);
467
473
  };
468
474
 
469
475
  exports.invokeRest = invokeRest;
package/dist/Utils.js CHANGED
@@ -190,7 +190,7 @@ class Utils {
190
190
 
191
191
  static getFieldGrid(attributes, fields) {
192
192
  let fieldGrid = {};
193
- let maxColspan = !Utils.isNull(attributes) ? attributes.layoutColumns : 1;
193
+ let maxColspan = !Utils.isNull(attributes) && !Utils.isNull(attributes.layoutColumns) ? attributes.layoutColumns : 1;
194
194
  fieldGrid.maxColPerRow = maxColspan;
195
195
  fieldGrid.rows = [];
196
196
  let currRow = this.createRow();
@@ -374,8 +374,6 @@ _defineProperty(Utils, "getPropertyChainPath", expression => {
374
374
 
375
375
  _defineProperty(Utils, "mergeStyles", (defaultStyle, config) => {
376
376
  let configStyle = Utils.getComponentAttribute(config, 'style', null);
377
- console.log(config.id);
378
- console.log(configStyle);
379
377
 
380
378
  if (configStyle) {
381
379
  let properties = Object.getOwnPropertyNames(configStyle);
@@ -41,9 +41,9 @@ function PopupViewDialog(props) {
41
41
  title = _React$useState2[0],
42
42
  setTitle = _React$useState2[1];
43
43
 
44
- const height = _Utils.default.getComponentAttribute(props.view.config, 'height', '28vh');
44
+ const height = _Utils.default.getComponentStyleAttribute(props.view.config, 'height', '28vh');
45
45
 
46
- const width = _Utils.default.getComponentAttribute(props.view.config, 'width', '40vw');
46
+ const width = _Utils.default.getComponentStyleAttribute(props.view.config, 'width', '40vw');
47
47
 
48
48
  const useStyles = (0, _styles.makeStyles)(theme => ({
49
49
  dialogPaper: {
@@ -70,7 +70,8 @@ function PopupViewDialog(props) {
70
70
  id: "alert-dialog-title"
71
71
  }, title), /*#__PURE__*/_react.default.createElement(_DialogContent.default, {
72
72
  style: {
73
- overflow: "hidden"
73
+ overflow: "hidden",
74
+ padding: "0"
74
75
  }
75
76
  }, /*#__PURE__*/_react.default.createElement(_View.View, {
76
77
  config: props.view.config,
@@ -15,8 +15,6 @@ var _RestUtils = require("../RestUtils");
15
15
 
16
16
  var _ServiceCallActionHandler = _interopRequireDefault(require("../event/ServiceCallActionHandler"));
17
17
 
18
- var _DocumentContainer = _interopRequireDefault(require("@agilemotion/signi-vault-ui/dist/DocumentContainer"));
19
-
20
18
  var _AgilitySignaturePanel = _interopRequireDefault(require("./signatures/AgilitySignaturePanel"));
21
19
 
22
20
  var _Event = _interopRequireDefault(require("../event/Event"));
@@ -95,14 +93,14 @@ const SignaturePanel = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.def
95
93
  return value;
96
94
  },
97
95
 
98
- loadData: actionConfig => {
96
+ loadData: (actionConfig, event) => {
99
97
  let service = !_Utils.default.isNull(props.config.dataService) ? props.config.dataService : actionConfig !== null ? actionConfig.dataService : null;
100
98
 
101
99
  if (!_Utils.default.isNull(service)) {
102
100
  if (service.type === 'remoteObjectProxy') {
103
101
  (0, _RestUtils.invokeRpc)(service, props.handle, props.viewId, result => {
104
102
  setConfig(result);
105
- }, e => {}, parameter => {});
103
+ }, e => {}, parameter => {}, null, null, event);
106
104
  } else {
107
105
  if (_Utils.default.isNull(actionConfig)) {
108
106
  actionConfig = {};
@@ -110,7 +108,7 @@ const SignaturePanel = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.def
110
108
 
111
109
  actionConfig.service = service;
112
110
 
113
- _ServiceCallActionHandler.default.execute(actionConfig, null, null, props.viewId, data => {
111
+ _ServiceCallActionHandler.default.execute(actionConfig, event, null, props.viewId, data => {
114
112
  setConfig(data);
115
113
  }, () => {});
116
114
  }
@@ -129,9 +127,6 @@ const SignaturePanel = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.def
129
127
  config: config,
130
128
  imageProcessingUrl: props.config.imageProcessingUrl,
131
129
  signatureImageUrl: props.config.signatureImageUrl
132
- }) : props.config.provider === 'SIGNIVAULT' ? /*#__PURE__*/_react.default.createElement(_DocumentContainer.default, {
133
- handle: handle,
134
- config: config
135
130
  }) : /*#__PURE__*/_react.default.createElement("div", null, "Unsupported provider") : /*#__PURE__*/_react.default.createElement("div", {
136
131
  style: {
137
132
  padding: '32px 0 32px 48px'
@@ -26,6 +26,9 @@
26
26
  border: none;
27
27
  }
28
28
 
29
+ .stepActive .box {
30
+ }
31
+
29
32
  .dot {
30
33
  width: 30px;
31
34
  height: 30px;
@@ -57,6 +60,10 @@
57
60
  width: calc(50% - 15px);
58
61
  }
59
62
 
63
+ .stepVisited .rightLine {
64
+ width: calc(100% - 15px) !important;
65
+ }
66
+
60
67
  .step .lastLine {
61
68
  width: calc(50% - 15px);
62
69
  }
@@ -76,7 +83,6 @@
76
83
  color: #ffffff;
77
84
  font-size: 16px;
78
85
  height: 30px;
79
- float: right;
80
86
  border-top-right-radius: 100px;
81
87
  border-bottom-right-radius: 100px;
82
88
  padding: 2px 8px;
@@ -57,8 +57,8 @@ const StepperTitleBar = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.de
57
57
 
58
58
  const _React$useState5 = _react.default.useState(null),
59
59
  _React$useState6 = _slicedToArray(_React$useState5, 2),
60
- segmentPercentage = _React$useState6[0],
61
- setSegmentPercentage = _React$useState6[1];
60
+ activeSegmentPercentage = _React$useState6[0],
61
+ setActiveSegmentPercentage = _React$useState6[1];
62
62
 
63
63
  const currentIndex = _react.default.useRef(null);
64
64
 
@@ -133,7 +133,7 @@ const StepperTitleBar = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.de
133
133
 
134
134
  setSteps(steps);
135
135
  currentIndex.current = _ApplicationContext.default.graphs[0].getCurrentNodeIndex();
136
- setSegmentPercentage(100 / steps.length);
136
+ setActiveSegmentPercentage(100 - 10 * (steps.length - 1));
137
137
  }
138
138
 
139
139
  };
@@ -145,14 +145,16 @@ const StepperTitleBar = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.de
145
145
  }, graphicsCounter > 0 ? /*#__PURE__*/_react.default.createElement("div", {
146
146
  className: (graphicsCounter <= currentIndex.current ? "".concat(classes.themeBorder, " ") : '') + 'leftLine' + (graphicsCounter === steps.length - 1 ? ' lastLine' : '')
147
147
  }) : null, /*#__PURE__*/_react.default.createElement("div", {
148
- className: (graphicsCounter <= currentIndex.current ? "".concat(classes.theme, " box") : 'box') + (graphicsCounter === 0 ? ' firstBox' : ''),
148
+ className: (graphicsCounter <= currentIndex.current ? "".concat(classes.theme, " box row") : 'box') + (graphicsCounter === 0 ? ' firstBox' : ''),
149
149
  style: {
150
- display: "table-cell"
151
- }
150
+ marginLeft: 'unset',
151
+ marginRight: 'unset'
152
+ },
153
+ id: 'step-' + graphicsCounter
152
154
  }, /*#__PURE__*/_react.default.createElement("div", {
153
- className: 'dot'
155
+ className: 'dot col-*-*'
154
156
  }, step.index + 1), graphicsCounter === currentIndex.current ? /*#__PURE__*/_react.default.createElement("div", {
155
- className: "title",
157
+ className: "title col-*-*",
156
158
  id: "titleDiv"
157
159
  }, step.title) : null), graphicsCounter < steps.length - 1 ? /*#__PURE__*/_react.default.createElement("div", {
158
160
  className: (graphicsCounter < currentIndex.current ? "".concat(classes.themeBorder, " ") : '') + 'rightLine' + (graphicsCounter === 0 ? ' firstLine' : '')
@@ -178,7 +180,7 @@ const StepperTitleBar = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.de
178
180
  whiteSpace: "nowrap",
179
181
  paddingTop: '8px',
180
182
  maxHeight: '8px',
181
- width: segmentPercentage + '%'
183
+ width: (graphicsCounter === currentIndex.current ? activeSegmentPercentage : 10) + '%'
182
184
  },
183
185
  id: 'step-container-' + counter++
184
186
  }, renderStep(step)))))));
@@ -191,10 +193,9 @@ const StepperTitleBar = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.de
191
193
  fontSize: '24px',
192
194
  color: '#202124',
193
195
  padding: "16px 0",
194
- margin: "0",
195
- width: "70%"
196
+ margin: "0"
196
197
  }, props.config)
197
- }, !_Utils.default.isNull(steps) && !_Utils.default.isNull(segmentPercentage) && !_Utils.default.isNull(currentIndex.current) ? render() : null) : null);
198
+ }, !_Utils.default.isNull(steps) && !_Utils.default.isNull(activeSegmentPercentage) && !_Utils.default.isNull(currentIndex.current) ? render() : null) : null);
198
199
  }));
199
200
 
200
201
  var _default = StepperTitleBar;
@@ -1,3 +1,7 @@
1
+ .dropTarget {
2
+ border: 2px dashed #a1a1a1;
3
+ }
4
+
1
5
  ._draggable_ {
2
6
  position: absolute;
3
7
  border-radius: 2px;
@@ -10,4 +14,4 @@
10
14
  white-space: nowrap;
11
15
  overflow: hidden;
12
16
  text-overflow: ellipsis;
13
- }
17
+ }
@@ -203,9 +203,9 @@ const TemplateDesigner = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.d
203
203
  setSelectedItem = _React$useState18[1];
204
204
 
205
205
  _react.default.useEffect(() => {
206
- props.handle.api = api();
207
-
208
206
  if (initializing) {
207
+ props.handle.api = api();
208
+
209
209
  let parsedConfig = _Utils.default.parseConfig(props.config, props.viewId);
210
210
 
211
211
  _Observable.default.addSubscriptions(parsedConfig.eventHandlingConfig, props.handle, props.viewId);
@@ -222,24 +222,40 @@ const TemplateDesigner = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.d
222
222
  }
223
223
  });
224
224
 
225
- _react.default.useEffect(() => {
226
- props.handle.api = api();
225
+ const setup = () => {
226
+ let container = document.getElementById('templateContainer');
227
227
 
228
- if (templateDoc) {
229
- templateItemEventHandler.initDragAndDrop();
228
+ if (!_Utils.default.isNull(templateDoc) && !_Utils.default.isNull(container)) {
229
+ templateItemEventHandler.initDragAndDrop((id, node) => {
230
+ setSelectedItem(id);
231
+ }, container);
230
232
  }
233
+ };
234
+
235
+ _react.default.useEffect(() => {
236
+ setup();
237
+ });
238
+
239
+ _react.default.useEffect(() => {
240
+ setup();
231
241
  }, [templateDoc]);
232
242
 
233
- function getFetchConfig(data, method) {
243
+ function getFetchConfig(data, method, contentType = null) {
234
244
  const accessToken = sessionStorage.getItem("accessToken");
235
245
  const idToken = sessionStorage.getItem("idToken");
246
+ let headers = {
247
+ 'Accept': 'application/json',
248
+ 'Authorization': 'Bearer ' + accessToken,
249
+ 'idToken': idToken
250
+ };
251
+
252
+ if (contentType) {
253
+ headers['Content-Type'] = contentType;
254
+ }
255
+
236
256
  return {
237
257
  method: method,
238
- headers: {
239
- 'Accept': 'application/json',
240
- 'Authorization': 'Bearer ' + accessToken,
241
- 'idToken': idToken
242
- },
258
+ headers: headers,
243
259
  body: data
244
260
  };
245
261
  }
@@ -277,14 +293,29 @@ const TemplateDesigner = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.d
277
293
  };
278
294
 
279
295
  const handleSave = () => {
280
- alert('SAVE FIREEEE');
296
+ let payload = document.getElementById("templateContainer").innerHTML.replace("<div name=\"replaced_html\", '<html'").replace('</div>', '</html>').replace("<div name=\"replaced_body\"", '<body').replace('</div>', '</body>').replace('2px dashed green', 'none');
297
+ let templateData = {};
298
+ templateData.templateType = templateType;
299
+ templateData.payloadBase64 = btoa(payload);
300
+ let fetchConfig = getFetchConfig(JSON.stringify(templateData), 'POST', 'application/json');
301
+ let url = location + _ApplicationContext.default.getBaseApiUrl() + props.config.templateStorageUrl;
302
+ (0, _reactPromiseTracker.trackPromise)(fetch(encodeURI(url), fetchConfig).then(status).then(json).then(data => {//alert('SAVE RESULT : ' + JSON.stringify(data));
303
+ }).catch(e => {
304
+ if (e.code === 401) {
305
+ _ApplicationContext.default.clear();
306
+
307
+ _ApplicationContext.default.getApplicationHistory().push('/login');
308
+ }
309
+ }));
281
310
  };
282
311
 
283
312
  const handleOk = () => {
284
313
  let fetchConfig = getFetchConfig(null, 'GET');
285
314
  setFileDialogOpen(false);
286
315
  (0, _reactPromiseTracker.trackPromise)(fetch(encodeURI(location + _ApplicationContext.default.getBaseApiUrl() + props.config.metaDataUrl + '/' + templateType.id), fetchConfig).then(status).then(json).then(data => {
287
- setDesignData(JSON.parse(data));
316
+ let designData = JSON.parse(data);
317
+ setDesignData(designData);
318
+ setTemplateDoc(atob(designData.template.payloadBase64));
288
319
  }).catch(e => {
289
320
  if (e.code === 401) {
290
321
  _ApplicationContext.default.clear();
@@ -299,6 +330,7 @@ const TemplateDesigner = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.d
299
330
  };
300
331
 
301
332
  const loadDoc = file => {
333
+ setTemplateDoc(null);
302
334
  let data = new FormData();
303
335
  data.append("sourceType", "PDF");
304
336
  data.append("targetType", "HTML");
@@ -318,6 +350,7 @@ const TemplateDesigner = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.d
318
350
 
319
351
  let mouseClickHandler = function mouseClickHandler(event) {
320
352
  if (grabbedItem) {
353
+ setSelectedItem(grabbedItem.id);
321
354
  templateItemEventHandler.handleGrabRelease(event, {
322
355
  id: grabbedItem.id,
323
356
  width: 200,
@@ -385,7 +418,7 @@ const TemplateDesigner = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.d
385
418
  id: 'DELETE'
386
419
  })), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
387
420
  component: "span",
388
- disabled: selectedItem === null,
421
+ disabled: !templateDoc,
389
422
  variant: 'contained',
390
423
  size: "large",
391
424
  onClick: handleSave
@@ -432,7 +465,6 @@ const TemplateDesigner = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.d
432
465
  overflow: "auto"
433
466
  },
434
467
  className: 'col-*-*',
435
- id: "signaturePanel",
436
468
  id: "templateContainer"
437
469
  }, /*#__PURE__*/_react.default.createElement(_reactHtmlRenderer.default, {
438
470
  html: templateDoc.replace('<html', "<div name=\"replaced_html\"").replace('</html>', '</div>').replace('<body', "<div name=\"replaced_body\"").replace('</body>', '</div>')