@pnp/spfx-controls-react 3.15.0-beta.4974097 → 3.15.0-beta.4974233

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.
Files changed (83) hide show
  1. package/CHANGELOG.json +3 -1
  2. package/CHANGELOG.md +2 -1
  3. package/lib/common/telemetry/version.js +1 -1
  4. package/lib/controls/dynamicForm/DynamicForm.d.ts +10 -7
  5. package/lib/controls/dynamicForm/DynamicForm.d.ts.map +1 -1
  6. package/lib/controls/dynamicForm/DynamicForm.js +211 -117
  7. package/lib/controls/dynamicForm/DynamicForm.js.map +1 -1
  8. package/lib/controls/dynamicForm/DynamicForm.module.css +2 -2
  9. package/lib/controls/dynamicForm/DynamicForm.module.scss.d.ts +4 -0
  10. package/lib/controls/dynamicForm/DynamicForm.module.scss.d.ts.map +1 -1
  11. package/lib/controls/dynamicForm/DynamicForm.module.scss.js +20 -16
  12. package/lib/controls/dynamicForm/DynamicForm.module.scss.js.map +1 -1
  13. package/lib/controls/dynamicForm/IDynamicFormProps.d.ts +5 -0
  14. package/lib/controls/dynamicForm/IDynamicFormProps.d.ts.map +1 -1
  15. package/lib/controls/dynamicForm/IDynamicFormState.d.ts +1 -0
  16. package/lib/controls/dynamicForm/IDynamicFormState.d.ts.map +1 -1
  17. package/lib/controls/dynamicForm/IValidationErrorDialogProps.d.ts +15 -0
  18. package/lib/controls/dynamicForm/IValidationErrorDialogProps.d.ts.map +1 -0
  19. package/lib/controls/dynamicForm/IValidationErrorDialogProps.js +2 -0
  20. package/lib/controls/dynamicForm/IValidationErrorDialogProps.js.map +1 -0
  21. package/lib/controls/dynamicForm/dynamicField/DynamicField.js +1 -1
  22. package/lib/controls/dynamicForm/dynamicField/DynamicField.js.map +1 -1
  23. package/lib/loc/bg-bg.js +2 -0
  24. package/lib/loc/bg-bg.js.map +1 -1
  25. package/lib/loc/ca-es.js +2 -0
  26. package/lib/loc/ca-es.js.map +1 -1
  27. package/lib/loc/da-dk.js +2 -0
  28. package/lib/loc/da-dk.js.map +1 -1
  29. package/lib/loc/de-de.js +2 -0
  30. package/lib/loc/de-de.js.map +1 -1
  31. package/lib/loc/el-gr.js +2 -0
  32. package/lib/loc/el-gr.js.map +1 -1
  33. package/lib/loc/en-us.js +2 -0
  34. package/lib/loc/en-us.js.map +1 -1
  35. package/lib/loc/es-es.js +2 -0
  36. package/lib/loc/es-es.js.map +1 -1
  37. package/lib/loc/et-ee.js +2 -0
  38. package/lib/loc/et-ee.js.map +1 -1
  39. package/lib/loc/eu-es.js +8 -0
  40. package/lib/loc/eu-es.js.map +1 -1
  41. package/lib/loc/fi-fi.js +2 -0
  42. package/lib/loc/fi-fi.js.map +1 -1
  43. package/lib/loc/fr-ca.js +2 -0
  44. package/lib/loc/fr-ca.js.map +1 -1
  45. package/lib/loc/fr-fr.js +2 -0
  46. package/lib/loc/fr-fr.js.map +1 -1
  47. package/lib/loc/it-it.js +2 -0
  48. package/lib/loc/it-it.js.map +1 -1
  49. package/lib/loc/ja-jp.js +2 -0
  50. package/lib/loc/ja-jp.js.map +1 -1
  51. package/lib/loc/lt-lt.js +2 -0
  52. package/lib/loc/lt-lt.js.map +1 -1
  53. package/lib/loc/lv-lv.js +2 -0
  54. package/lib/loc/lv-lv.js.map +1 -1
  55. package/lib/loc/nb-no.js +2 -0
  56. package/lib/loc/nb-no.js.map +1 -1
  57. package/lib/loc/nl-nl.js +2 -0
  58. package/lib/loc/nl-nl.js.map +1 -1
  59. package/lib/loc/pl-pl.js +2 -0
  60. package/lib/loc/pl-pl.js.map +1 -1
  61. package/lib/loc/pt-br.js +2 -0
  62. package/lib/loc/pt-br.js.map +1 -1
  63. package/lib/loc/pt-pt.js +2 -0
  64. package/lib/loc/pt-pt.js.map +1 -1
  65. package/lib/loc/ro-ro.js +2 -0
  66. package/lib/loc/ro-ro.js.map +1 -1
  67. package/lib/loc/ru-ru.js +2 -0
  68. package/lib/loc/ru-ru.js.map +1 -1
  69. package/lib/loc/sk-sk.js +2 -0
  70. package/lib/loc/sk-sk.js.map +1 -1
  71. package/lib/loc/sr-latn-rs.js +2 -0
  72. package/lib/loc/sr-latn-rs.js.map +1 -1
  73. package/lib/loc/sv-se.js +2 -0
  74. package/lib/loc/sv-se.js.map +1 -1
  75. package/lib/loc/tr-tr.js +2 -0
  76. package/lib/loc/tr-tr.js.map +1 -1
  77. package/lib/loc/vi-vn.js +2 -0
  78. package/lib/loc/vi-vn.js.map +1 -1
  79. package/lib/loc/zh-cn.js +2 -0
  80. package/lib/loc/zh-cn.js.map +1 -1
  81. package/lib/loc/zh-tw.js +2 -0
  82. package/lib/loc/zh-tw.js.map +1 -1
  83. package/package.json +1 -1
@@ -61,20 +61,21 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
61
61
  }
62
62
  };
63
63
  /* eslint-disable @microsoft/spfx/no-async-await */
64
- import { SPHttpClient } from '@microsoft/sp-http';
65
- import { sp } from '@pnp/sp/presets/all';
66
- import * as strings from 'ControlStrings';
67
- import { DefaultButton, PrimaryButton } from 'office-ui-fabric-react/lib/Button';
68
- import { ProgressIndicator } from 'office-ui-fabric-react/lib/ProgressIndicator';
69
- import { Stack } from 'office-ui-fabric-react/lib/Stack';
70
- import * as React from 'react';
71
- import SPservice from '../../services/SPService';
72
- import { DynamicField } from './dynamicField';
73
- import styles from './DynamicForm.module.scss';
74
- import '@pnp/sp/lists';
75
- import '@pnp/sp/content-types';
76
- import '@pnp/sp/folders';
77
- import '@pnp/sp/items';
64
+ import { SPHttpClient } from "@microsoft/sp-http";
65
+ import { sp } from "@pnp/sp/presets/all";
66
+ import * as strings from "ControlStrings";
67
+ import { DefaultButton, PrimaryButton, } from "office-ui-fabric-react/lib/Button";
68
+ import { ProgressIndicator } from "office-ui-fabric-react/lib/ProgressIndicator";
69
+ import { Stack } from "office-ui-fabric-react/lib/Stack";
70
+ import * as React from "react";
71
+ import SPservice from "../../services/SPService";
72
+ import { DynamicField } from "./dynamicField";
73
+ import styles from "./DynamicForm.module.scss";
74
+ import { Dialog, DialogFooter, DialogType, } from "office-ui-fabric-react/lib/Dialog";
75
+ import "@pnp/sp/lists";
76
+ import "@pnp/sp/content-types";
77
+ import "@pnp/sp/folders";
78
+ import "@pnp/sp/items";
78
79
  var stackTokens = { childrenGap: 20 };
79
80
  /**
80
81
  * DynamicForm Class Control
@@ -83,32 +84,38 @@ var DynamicForm = /** @class */ (function (_super) {
83
84
  __extends(DynamicForm, _super);
84
85
  function DynamicForm(props) {
85
86
  var _this = _super.call(this, props) || this;
86
- _this.webURL = _this.props.webAbsoluteUrl ? _this.props.webAbsoluteUrl : _this.props.context.pageContext.web.absoluteUrl;
87
+ _this.webURL = _this.props.webAbsoluteUrl
88
+ ? _this.props.webAbsoluteUrl
89
+ : _this.props.context.pageContext.web.absoluteUrl;
87
90
  //trigger when the user submits the form.
88
91
  _this.onSubmitClick = function () { return __awaiter(_this, void 0, void 0, function () {
89
92
  var _a, listId, listItemId, contentTypeId, onSubmitted, onBeforeSubmit, onSubmitError, shouldBeReturnBack_1, fields, objects, _loop_1, this_1, i, len, isCancelled, newETag, iur, error_1, iar, error_2, idField, titleField, contentTypeIdField, library, folderTitle, newFolder, fields_1, folderId, iur, error_3, error_4;
90
- return __generator(this, function (_b) {
91
- switch (_b.label) {
93
+ var _b;
94
+ return __generator(this, function (_c) {
95
+ switch (_c.label) {
92
96
  case 0:
93
97
  _a = this.props, listId = _a.listId, listItemId = _a.listItemId, contentTypeId = _a.contentTypeId, onSubmitted = _a.onSubmitted, onBeforeSubmit = _a.onBeforeSubmit, onSubmitError = _a.onSubmitError;
94
- _b.label = 1;
98
+ _c.label = 1;
95
99
  case 1:
96
- _b.trys.push([1, 27, , 28]);
100
+ _c.trys.push([1, 27, , 28]);
97
101
  shouldBeReturnBack_1 = false;
98
102
  fields = (this.state.fieldCollection || []).slice();
99
103
  fields.forEach(function (val) {
100
104
  if (val.required) {
101
105
  if (val.newValue === null) {
102
- if (val.fieldDefaultValue === null || val.fieldDefaultValue === '' || val.fieldDefaultValue.length === 0) {
106
+ if (val.fieldDefaultValue === null ||
107
+ val.fieldDefaultValue === "" ||
108
+ val.fieldDefaultValue.length === 0 ||
109
+ val.fieldDefaultValue === undefined) {
103
110
  if (val.fieldType === "DateTime")
104
111
  val.fieldDefaultValue = null;
105
112
  else
106
- val.fieldDefaultValue = '';
113
+ val.fieldDefaultValue = "";
107
114
  shouldBeReturnBack_1 = true;
108
115
  }
109
116
  }
110
- else if (val.newValue === '') {
111
- val.fieldDefaultValue = '';
117
+ else if (val.newValue === "") {
118
+ val.fieldDefaultValue = "";
112
119
  shouldBeReturnBack_1 = true;
113
120
  }
114
121
  else if (Array.isArray(val.newValue) && val.newValue.length === 0) {
@@ -118,17 +125,20 @@ var DynamicForm = /** @class */ (function (_super) {
118
125
  }
119
126
  });
120
127
  if (shouldBeReturnBack_1) {
121
- this.setState({ fieldCollection: fields });
128
+ this.setState({
129
+ fieldCollection: fields,
130
+ isValidationErrorDialogOpen: ((_b = this.props.validationErrorDialogProps) === null || _b === void 0 ? void 0 : _b.showDialogOnValidationError) === true,
131
+ });
122
132
  return [2 /*return*/];
123
133
  }
124
134
  this.setState({
125
- isSaving: true
135
+ isSaving: true,
126
136
  });
127
137
  objects = {};
128
138
  _loop_1 = function (i, len) {
129
139
  var val, fieldType, additionalData, columnInternalName, hiddenFieldName, value_1, uploadedImage;
130
- return __generator(this, function (_c) {
131
- switch (_c.label) {
140
+ return __generator(this, function (_d) {
141
+ switch (_d.label) {
132
142
  case 0:
133
143
  val = fields[i];
134
144
  fieldType = val.fieldType, additionalData = val.additionalData, columnInternalName = val.columnInternalName, hiddenFieldName = val.hiddenFieldName;
@@ -148,20 +158,24 @@ var DynamicForm = /** @class */ (function (_super) {
148
158
  val.newValue.forEach(function (element) {
149
159
  value_1.push(element.key);
150
160
  });
151
- objects["".concat(columnInternalName, "Id")] = { results: value_1.length === 0 ? null : value_1 };
161
+ objects["".concat(columnInternalName, "Id")] = {
162
+ results: value_1.length === 0 ? null : value_1,
163
+ };
152
164
  return [3 /*break*/, 14];
153
165
  case 2:
154
166
  if (!(fieldType === "TaxonomyFieldType")) return [3 /*break*/, 3];
155
167
  objects[columnInternalName] = {
156
- '__metadata': { 'type': 'SP.Taxonomy.TaxonomyFieldValue' },
157
- 'Label': value_1[0].name,
158
- 'TermGuid': value_1[0].key,
159
- 'WssId': '-1'
168
+ __metadata: { type: "SP.Taxonomy.TaxonomyFieldValue" },
169
+ Label: value_1[0].name,
170
+ TermGuid: value_1[0].key,
171
+ WssId: "-1",
160
172
  };
161
173
  return [3 /*break*/, 14];
162
174
  case 3:
163
175
  if (!(fieldType === "TaxonomyFieldTypeMulti")) return [3 /*break*/, 4];
164
- objects[hiddenFieldName] = val.newValue.map(function (term) { return "-1#;".concat(term.name, "|").concat(term.key, ";"); }).join('#');
176
+ objects[hiddenFieldName] = val.newValue
177
+ .map(function (term) { return "-1#;".concat(term.name, "|").concat(term.key, ";"); })
178
+ .join("#");
165
179
  return [3 /*break*/, 14];
166
180
  case 4:
167
181
  if (!(fieldType === "User")) return [3 /*break*/, 5];
@@ -181,41 +195,43 @@ var DynamicForm = /** @class */ (function (_super) {
181
195
  return [3 /*break*/, 14];
182
196
  case 8:
183
197
  if (!(fieldType === "UserMulti")) return [3 /*break*/, 9];
184
- objects["".concat(columnInternalName, "Id")] = { results: val.newValue.lenght === 0 ? null : val.newValue };
198
+ objects["".concat(columnInternalName, "Id")] = {
199
+ results: val.newValue.lenght === 0 ? null : val.newValue,
200
+ };
185
201
  return [3 /*break*/, 14];
186
202
  case 9:
187
- if (!(fieldType === 'Thumbnail')) return [3 /*break*/, 13];
203
+ if (!(fieldType === "Thumbnail")) return [3 /*break*/, 13];
188
204
  if (!additionalData) return [3 /*break*/, 11];
189
205
  return [4 /*yield*/, this_1.uploadImage(additionalData)];
190
206
  case 10:
191
- uploadedImage = _c.sent();
207
+ uploadedImage = _d.sent();
192
208
  objects[columnInternalName] = JSON.stringify({
193
- type: 'thumbnail',
209
+ type: "thumbnail",
194
210
  fileName: uploadedImage.Name,
195
211
  serverRelativeUrl: uploadedImage.ServerRelativeUrl,
196
- id: uploadedImage.UniqueId
212
+ id: uploadedImage.UniqueId,
197
213
  });
198
214
  return [3 /*break*/, 12];
199
215
  case 11:
200
216
  objects[columnInternalName] = null;
201
- _c.label = 12;
217
+ _d.label = 12;
202
218
  case 12: return [3 /*break*/, 14];
203
219
  case 13:
204
220
  objects[columnInternalName] = val.newValue;
205
- _c.label = 14;
221
+ _d.label = 14;
206
222
  case 14: return [2 /*return*/];
207
223
  }
208
224
  });
209
225
  };
210
226
  this_1 = this;
211
227
  i = 0, len = fields.length;
212
- _b.label = 2;
228
+ _c.label = 2;
213
229
  case 2:
214
230
  if (!(i < len)) return [3 /*break*/, 5];
215
231
  return [5 /*yield**/, _loop_1(i, len)];
216
232
  case 3:
217
- _b.sent();
218
- _b.label = 4;
233
+ _c.sent();
234
+ _c.label = 4;
219
235
  case 4:
220
236
  i++;
221
237
  return [3 /*break*/, 2];
@@ -223,30 +239,35 @@ var DynamicForm = /** @class */ (function (_super) {
223
239
  if (!onBeforeSubmit) return [3 /*break*/, 7];
224
240
  return [4 /*yield*/, onBeforeSubmit(objects)];
225
241
  case 6:
226
- isCancelled = _b.sent();
242
+ isCancelled = _c.sent();
227
243
  if (isCancelled) {
228
244
  this.setState({
229
- isSaving: false
245
+ isSaving: false,
230
246
  });
231
247
  return [2 /*return*/];
232
248
  }
233
- _b.label = 7;
249
+ _c.label = 7;
234
250
  case 7:
235
251
  newETag = undefined;
236
252
  if (!listItemId) return [3 /*break*/, 12];
237
- _b.label = 8;
253
+ _c.label = 8;
238
254
  case 8:
239
- _b.trys.push([8, 10, , 11]);
240
- return [4 /*yield*/, sp.web.lists.getById(listId).items.getById(listItemId).update(objects, this.state.etag)];
255
+ _c.trys.push([8, 10, , 11]);
256
+ return [4 /*yield*/, sp.web.lists
257
+ .getById(listId)
258
+ .items.getById(listItemId)
259
+ .update(objects, this.state.etag)];
241
260
  case 9:
242
- iur = _b.sent();
243
- newETag = iur.data['odata.etag'];
261
+ iur = _c.sent();
262
+ newETag = iur.data["odata.etag"];
244
263
  if (onSubmitted) {
245
- onSubmitted(iur.data, this.props.returnListItemInstanceOnSubmit !== false ? iur.item : undefined);
264
+ onSubmitted(iur.data, this.props.returnListItemInstanceOnSubmit !== false
265
+ ? iur.item
266
+ : undefined);
246
267
  }
247
268
  return [3 /*break*/, 11];
248
269
  case 10:
249
- error_1 = _b.sent();
270
+ error_1 = _c.sent();
250
271
  if (onSubmitError) {
251
272
  onSubmitError(objects, error_1);
252
273
  }
@@ -254,19 +275,23 @@ var DynamicForm = /** @class */ (function (_super) {
254
275
  return [3 /*break*/, 11];
255
276
  case 11: return [3 /*break*/, 26];
256
277
  case 12:
257
- if (!(contentTypeId === undefined || contentTypeId === '' || !contentTypeId.startsWith('0x0120'))) return [3 /*break*/, 17];
258
- _b.label = 13;
278
+ if (!(contentTypeId === undefined ||
279
+ contentTypeId === "" ||
280
+ !contentTypeId.startsWith("0x0120"))) return [3 /*break*/, 17];
281
+ _c.label = 13;
259
282
  case 13:
260
- _b.trys.push([13, 15, , 16]);
283
+ _c.trys.push([13, 15, , 16]);
261
284
  return [4 /*yield*/, sp.web.lists.getById(listId).items.add(objects)];
262
285
  case 14:
263
- iar = _b.sent();
286
+ iar = _c.sent();
264
287
  if (onSubmitted) {
265
- onSubmitted(iar.data, this.props.returnListItemInstanceOnSubmit !== false ? iar.item : undefined);
288
+ onSubmitted(iar.data, this.props.returnListItemInstanceOnSubmit !== false
289
+ ? iar.item
290
+ : undefined);
266
291
  }
267
292
  return [3 /*break*/, 16];
268
293
  case 15:
269
- error_2 = _b.sent();
294
+ error_2 = _c.sent();
270
295
  if (onSubmitError) {
271
296
  onSubmitError(objects, error_2);
272
297
  }
@@ -274,40 +299,42 @@ var DynamicForm = /** @class */ (function (_super) {
274
299
  return [3 /*break*/, 16];
275
300
  case 16: return [3 /*break*/, 26];
276
301
  case 17:
277
- if (!contentTypeId.startsWith('0x0120')) return [3 /*break*/, 26];
278
- _b.label = 18;
302
+ if (!contentTypeId.startsWith("0x0120")) return [3 /*break*/, 26];
303
+ _c.label = 18;
279
304
  case 18:
280
- _b.trys.push([18, 25, , 26]);
281
- idField = 'ID';
282
- titleField = 'Title';
283
- contentTypeIdField = 'ContentTypeId';
305
+ _c.trys.push([18, 25, , 26]);
306
+ idField = "ID";
307
+ titleField = "Title";
308
+ contentTypeIdField = "ContentTypeId";
284
309
  return [4 /*yield*/, sp.web.lists.getById(listId)];
285
310
  case 19:
286
- library = _b.sent();
287
- folderTitle = (objects[titleField] !== undefined && objects[titleField] !== '') ?
288
- objects[titleField].replace(/["|*|:|<|>|?|/|\\||]/g, "_") : // Replace not allowed chars in folder name
289
- '';
311
+ library = _c.sent();
312
+ folderTitle = objects[titleField] !== undefined && objects[titleField] !== ""
313
+ ? objects[titleField].replace(/["|*|:|<|>|?|/|\\||]/g, "_") // Replace not allowed chars in folder name
314
+ : "";
290
315
  return [4 /*yield*/, library.rootFolder.addSubFolderUsingPath(folderTitle)];
291
316
  case 20:
292
- newFolder = _b.sent();
317
+ newFolder = _c.sent();
293
318
  return [4 /*yield*/, newFolder.listItemAllFields()];
294
319
  case 21:
295
- fields_1 = _b.sent();
320
+ fields_1 = _c.sent();
296
321
  if (!fields_1[idField]) return [3 /*break*/, 23];
297
322
  folderId = fields_1[idField];
298
323
  // Set the content type ID for the target item
299
324
  objects[contentTypeIdField] = contentTypeId;
300
325
  return [4 /*yield*/, library.items.getById(folderId).update(objects)];
301
326
  case 22:
302
- iur = _b.sent();
327
+ iur = _c.sent();
303
328
  if (onSubmitted) {
304
- onSubmitted(iur.data, this.props.returnListItemInstanceOnSubmit !== false ? iur.item : undefined);
329
+ onSubmitted(iur.data, this.props.returnListItemInstanceOnSubmit !== false
330
+ ? iur.item
331
+ : undefined);
305
332
  }
306
333
  return [3 /*break*/, 24];
307
- case 23: throw new Error('Unable to read the ID of the just created folder or Document Set');
334
+ case 23: throw new Error("Unable to read the ID of the just created folder or Document Set");
308
335
  case 24: return [3 /*break*/, 26];
309
336
  case 25:
310
- error_3 = _b.sent();
337
+ error_3 = _c.sent();
311
338
  if (onSubmitError) {
312
339
  onSubmitError(objects, error_3);
313
340
  }
@@ -316,11 +343,11 @@ var DynamicForm = /** @class */ (function (_super) {
316
343
  case 26:
317
344
  this.setState({
318
345
  isSaving: false,
319
- etag: newETag
346
+ etag: newETag,
320
347
  });
321
348
  return [3 /*break*/, 28];
322
349
  case 27:
323
- error_4 = _b.sent();
350
+ error_4 = _c.sent();
324
351
  if (onSubmitError) {
325
352
  onSubmitError(null, error_4);
326
353
  }
@@ -337,13 +364,16 @@ var DynamicForm = /** @class */ (function (_super) {
337
364
  switch (_a.label) {
338
365
  case 0:
339
366
  fieldCol = (this.state.fieldCollection || []).slice();
340
- field = fieldCol.filter(function (element, i) { return element.columnInternalName === internalName; })[0];
367
+ field = fieldCol.filter(function (element, i) {
368
+ return element.columnInternalName === internalName;
369
+ })[0];
341
370
  field.newValue = newValue;
342
371
  field.additionalData = additionalData;
343
372
  if (!(field.fieldType === "User" && newValue.length !== 0)) return [3 /*break*/, 4];
344
- if (!(newValue[0].id === undefined || parseInt(newValue[0].id, 10).toString() === "NaN")) return [3 /*break*/, 2];
373
+ if (!(newValue[0].id === undefined ||
374
+ parseInt(newValue[0].id, 10).toString() === "NaN")) return [3 /*break*/, 2];
345
375
  user = newValue[0].secondaryText;
346
- if (user.indexOf('@') === -1) {
376
+ if (user.indexOf("@") === -1) {
347
377
  user = newValue[0].loginName;
348
378
  }
349
379
  return [4 /*yield*/, sp.web.ensureUser(user)];
@@ -363,9 +393,10 @@ var DynamicForm = /** @class */ (function (_super) {
363
393
  case 5:
364
394
  if (!(index < newValue.length)) return [3 /*break*/, 9];
365
395
  element = newValue[index];
366
- if (!(element.id === undefined || parseInt(element.id, 10).toString() === "NaN")) return [3 /*break*/, 7];
396
+ if (!(element.id === undefined ||
397
+ parseInt(element.id, 10).toString() === "NaN")) return [3 /*break*/, 7];
367
398
  user = element.secondaryText;
368
- if (user.indexOf('@') === -1) {
399
+ if (user.indexOf("@") === -1) {
369
400
  user = element.loginName;
370
401
  }
371
402
  return [4 /*yield*/, sp.web.ensureUser(user)];
@@ -381,7 +412,7 @@ var DynamicForm = /** @class */ (function (_super) {
381
412
  return [3 /*break*/, 5];
382
413
  case 9:
383
414
  this.setState({
384
- fieldCollection: fieldCol
415
+ fieldCollection: fieldCol,
385
416
  });
386
417
  return [2 /*return*/];
387
418
  }
@@ -414,12 +445,14 @@ var DynamicForm = /** @class */ (function (_super) {
414
445
  _b.label = 5;
415
446
  case 5:
416
447
  if (respectETag !== false) {
417
- etag = item['odata.etag'];
448
+ etag = item["odata.etag"];
418
449
  }
419
450
  _b.label = 6;
420
451
  case 6:
421
- if (!(contentTypeId === undefined || contentTypeId === '')) return [3 /*break*/, 8];
422
- return [4 /*yield*/, spList.contentTypes.select("Id", "Name").get()];
452
+ if (!(contentTypeId === undefined || contentTypeId === "")) return [3 /*break*/, 8];
453
+ return [4 /*yield*/, spList.contentTypes
454
+ .select("Id", "Name")
455
+ .get()];
423
456
  case 7:
424
457
  defaultContentType = _b.sent();
425
458
  contentTypeId = defaultContentType[0].Id.StringValue;
@@ -459,7 +492,7 @@ var DynamicForm = /** @class */ (function (_super) {
459
492
  else {
460
493
  defaultValue = field.DefaultValue;
461
494
  }
462
- if (!(fieldType === 'Choice' || fieldType === 'MultiChoice')) return [3 /*break*/, 1];
495
+ if (!(fieldType === "Choice" || fieldType === "MultiChoice")) return [3 /*break*/, 1];
463
496
  field.Choices.forEach(function (element) {
464
497
  choices_1.push({ key: element, text: element });
465
498
  });
@@ -504,15 +537,21 @@ var DynamicForm = /** @class */ (function (_super) {
504
537
  anchorId = field.AnchorId;
505
538
  if (item !== null) {
506
539
  item[field.InternalName].forEach(function (element) {
507
- selectedTags_1.push({ key: element.TermGuid, name: element.Label });
540
+ selectedTags_1.push({
541
+ key: element.TermGuid,
542
+ name: element.Label,
543
+ });
508
544
  });
509
545
  defaultValue = selectedTags_1;
510
546
  }
511
547
  else {
512
548
  if (defaultValue !== null && defaultValue !== "") {
513
549
  defaultValue.split(/#|;/).forEach(function (element) {
514
- if (element.indexOf('|') !== -1)
515
- selectedTags_1.push({ key: element.split('|')[1], name: element.split('|')[0] });
550
+ if (element.indexOf("|") !== -1)
551
+ selectedTags_1.push({
552
+ key: element.split("|")[1],
553
+ name: element.split("|")[0],
554
+ });
516
555
  });
517
556
  defaultValue = selectedTags_1;
518
557
  }
@@ -529,13 +568,19 @@ var DynamicForm = /** @class */ (function (_super) {
529
568
  case 13:
530
569
  response = _e.sent();
531
570
  if (response) {
532
- selectedTags_1.push({ key: response.TermID, name: response.Label });
571
+ selectedTags_1.push({
572
+ key: response.TermID,
573
+ name: response.Label,
574
+ });
533
575
  defaultValue = selectedTags_1;
534
576
  }
535
577
  return [3 /*break*/, 15];
536
578
  case 14:
537
579
  if (defaultValue !== "") {
538
- selectedTags_1.push({ key: defaultValue.split('|')[1], name: defaultValue.split('|')[0].split('#')[1] });
580
+ selectedTags_1.push({
581
+ key: defaultValue.split("|")[1],
582
+ name: defaultValue.split("|")[0].split("#")[1],
583
+ });
539
584
  defaultValue = selectedTags_1;
540
585
  }
541
586
  _e.label = 15;
@@ -547,15 +592,19 @@ var DynamicForm = /** @class */ (function (_super) {
547
592
  if (!(fieldType === "DateTime")) return [3 /*break*/, 18];
548
593
  if (item !== null && item[field.InternalName])
549
594
  defaultValue = new Date(item[field.InternalName]);
550
- else if (defaultValue === '[today]') {
595
+ else if (defaultValue === "[today]") {
551
596
  defaultValue = new Date();
552
597
  }
553
598
  schemaXml = field.SchemaXml;
554
- dateFormatRegEx = /\s+Format="([^"]+)"/gmi.exec(schemaXml);
555
- dateFormat = dateFormatRegEx && dateFormatRegEx.length ? dateFormatRegEx[1] : 'DateOnly';
599
+ dateFormatRegEx = /\s+Format="([^"]+)"/gim.exec(schemaXml);
600
+ dateFormat =
601
+ dateFormatRegEx && dateFormatRegEx.length
602
+ ? dateFormatRegEx[1]
603
+ : "DateOnly";
556
604
  return [4 /*yield*/, this_2._spService.getRegionalWebSettings()];
557
605
  case 17:
558
- defaultDayOfWeek = (_e.sent()).FirstDayOfWeek;
606
+ defaultDayOfWeek = (_e.sent())
607
+ .FirstDayOfWeek;
559
608
  return [3 /*break*/, 28];
560
609
  case 18:
561
610
  if (!(fieldType === "UserMulti")) return [3 /*break*/, 22];
@@ -584,7 +633,7 @@ var DynamicForm = /** @class */ (function (_super) {
584
633
  _d = (_c = userEmails).push;
585
634
  return [4 /*yield*/, this_2._spService.getUserUPNFromFieldValue(listId, listItemId, field.InternalName, this_2.webURL)];
586
635
  case 24:
587
- _d.apply(_c, [(_e.sent()) + '']);
636
+ _d.apply(_c, [(_e.sent()) + ""]);
588
637
  defaultValue = userEmails;
589
638
  return [3 /*break*/, 26];
590
639
  case 25:
@@ -615,7 +664,9 @@ var DynamicForm = /** @class */ (function (_super) {
615
664
  fieldTitle: field.Title,
616
665
  fieldDefaultValue: defaultValue,
617
666
  context: this_2.props.context,
618
- disabled: this_2.props.disabled || (disabledFields && disabledFields.indexOf(field.InternalName) > -1),
667
+ disabled: this_2.props.disabled ||
668
+ (disabledFields &&
669
+ disabledFields.indexOf(field.InternalName) > -1),
619
670
  listId: this_2.props.listId,
620
671
  columnInternalName: field.EntityPropertyName,
621
672
  label: field.Title,
@@ -628,7 +679,7 @@ var DynamicForm = /** @class */ (function (_super) {
628
679
  firstDayOfWeek: defaultDayOfWeek,
629
680
  listItemId: listItemId,
630
681
  principalType: principalType,
631
- description: field.Description
682
+ description: field.Description,
632
683
  });
633
684
  tempFields.sort(function (a, b) { return a.Order - b.Order; });
634
685
  _e.label = 29;
@@ -669,7 +720,7 @@ var DynamicForm = /** @class */ (function (_super) {
669
720
  return [2 /*return*/, {
670
721
  Name: file.fileName,
671
722
  ServerRelativeUrl: file.fileAbsoluteUrl,
672
- UniqueId: ''
723
+ UniqueId: "",
673
724
  }];
674
725
  case 1: return [4 /*yield*/, file.downloadFileContent()];
675
726
  case 2:
@@ -699,9 +750,9 @@ var DynamicForm = /** @class */ (function (_super) {
699
750
  _a.trys.push([0, 4, , 5]);
700
751
  context = this.props.context;
701
752
  webAbsoluteUrl = !webUrl ? this.webURL : webUrl;
702
- apiUrl = '';
703
- if (contentTypeId !== undefined && contentTypeId !== '') {
704
- if (contentTypeId.startsWith('0x0120')) {
753
+ apiUrl = "";
754
+ if (contentTypeId !== undefined && contentTypeId !== "") {
755
+ if (contentTypeId.startsWith("0x0120")) {
705
756
  apiUrl = "".concat(webAbsoluteUrl, "/_api/web/lists(@listId)/contenttypes('").concat(contentTypeId, "')/fields?@listId=guid'").concat(encodeURIComponent(listId), "'&$filter=ReadOnlyField eq false and (Hidden eq false or StaticName eq 'Title') and (FromBaseType eq false or StaticName eq 'Title')");
706
757
  }
707
758
  else {
@@ -731,6 +782,27 @@ var DynamicForm = /** @class */ (function (_super) {
731
782
  }
732
783
  });
733
784
  }); };
785
+ _this.closeValidationErrorDialog = function () {
786
+ _this.setState({
787
+ isValidationErrorDialogOpen: false,
788
+ });
789
+ };
790
+ _this.getValidationErrorTitle = function () {
791
+ var errorTitle = strings.DynamicFormDialogValidationErrorTitle;
792
+ var validationDialogProps = _this.props.validationErrorDialogProps;
793
+ if (validationDialogProps === null || validationDialogProps === void 0 ? void 0 : validationDialogProps.customTitle) {
794
+ errorTitle = validationDialogProps.customTitle;
795
+ }
796
+ return errorTitle;
797
+ };
798
+ _this.getValidationErrorMessage = function () {
799
+ var errorMessage = strings.DynamicFormDialogValidationErrorMessage;
800
+ var validationDialogProps = _this.props.validationErrorDialogProps;
801
+ if (validationDialogProps === null || validationDialogProps === void 0 ? void 0 : validationDialogProps.customMessage) {
802
+ errorMessage = validationDialogProps.customMessage;
803
+ }
804
+ return errorMessage;
805
+ };
734
806
  // Initialize pnp sp
735
807
  if (_this.props.webAbsoluteUrl) {
736
808
  sp.setup({
@@ -738,28 +810,37 @@ var DynamicForm = /** @class */ (function (_super) {
738
810
  headers: {
739
811
  Accept: "application/json;odata=verbose",
740
812
  },
741
- baseUrl: _this.props.webAbsoluteUrl
813
+ baseUrl: _this.props.webAbsoluteUrl,
742
814
  },
743
815
  });
744
816
  }
745
817
  else {
746
818
  sp.setup({
747
- spfxContext: { pageContext: _this.props.context.pageContext }
819
+ spfxContext: { pageContext: _this.props.context.pageContext },
748
820
  });
749
821
  }
750
822
  // Initialize state
751
823
  _this.state = {
752
- fieldCollection: []
824
+ fieldCollection: [],
825
+ isValidationErrorDialogOpen: false,
753
826
  };
754
827
  // Get SPService Factory
755
- _this._spService = _this.props.webAbsoluteUrl ? new SPservice(_this.props.context, _this.props.webAbsoluteUrl) : new SPservice(_this.props.context);
828
+ _this._spService = _this.props.webAbsoluteUrl
829
+ ? new SPservice(_this.props.context, _this.props.webAbsoluteUrl)
830
+ : new SPservice(_this.props.context);
756
831
  return _this;
757
832
  }
758
833
  /**
759
834
  * Lifecycle hook when component is mounted
760
835
  */
761
836
  DynamicForm.prototype.componentDidMount = function () {
762
- this.getFieldInformations().then(function () { }).catch(function () { });
837
+ this.getFieldInformations()
838
+ .then(function () {
839
+ /* no-op; */
840
+ })
841
+ .catch(function () {
842
+ /* no-op; */
843
+ });
763
844
  };
764
845
  /**
765
846
  * Default React component render method
@@ -768,20 +849,33 @@ var DynamicForm = /** @class */ (function (_super) {
768
849
  var _this = this;
769
850
  var _a = this.state, fieldCollection = _a.fieldCollection, isSaving = _a.isSaving;
770
851
  var fieldOverrides = this.props.fieldOverrides;
771
- return (React.createElement("div", null, fieldCollection.length === 0 ? React.createElement("div", null,
772
- React.createElement(ProgressIndicator, { label: strings.DynamicFormLoading, description: strings.DynamicFormPleaseWait })) :
773
- React.createElement("div", null,
852
+ return (React.createElement("div", null,
853
+ fieldCollection.length === 0 ? (React.createElement("div", null,
854
+ React.createElement(ProgressIndicator, { label: strings.DynamicFormLoading, description: strings.DynamicFormPleaseWait }))) : (React.createElement("div", null,
774
855
  fieldCollection.map(function (v, i) {
775
- if (fieldOverrides && Object.prototype.hasOwnProperty.call(fieldOverrides, v.columnInternalName)) {
856
+ if (fieldOverrides &&
857
+ Object.prototype.hasOwnProperty.call(fieldOverrides, v.columnInternalName)) {
776
858
  v.disabled = v.disabled || isSaving;
777
859
  return fieldOverrides[v.columnInternalName](v);
778
860
  }
779
- return React.createElement(DynamicField, __assign({ key: v.columnInternalName }, v, { disabled: v.disabled || isSaving }));
861
+ return (React.createElement(DynamicField, __assign({ key: v.columnInternalName }, v, { disabled: v.disabled || isSaving })));
780
862
  }),
781
- !this.props.disabled &&
782
- React.createElement(Stack, { className: styles.buttons, horizontal: true, tokens: stackTokens },
783
- React.createElement(PrimaryButton, { disabled: isSaving, text: strings.Save, onClick: function () { return _this.onSubmitClick(); } }),
784
- React.createElement(DefaultButton, { disabled: isSaving, text: strings.Cancel, onClick: this.props.onCancelled })))));
863
+ !this.props.disabled && (React.createElement(Stack, { className: styles.buttons, horizontal: true, tokens: stackTokens },
864
+ React.createElement(PrimaryButton, { disabled: isSaving, text: strings.Save, onClick: function () { return _this.onSubmitClick(); } }),
865
+ React.createElement(DefaultButton, { disabled: isSaving, text: strings.Cancel, onClick: this.props.onCancelled }))))),
866
+ React.createElement(Dialog, { hidden: !this.state.isValidationErrorDialogOpen, onDismiss: this.closeValidationErrorDialog, dialogContentProps: {
867
+ type: DialogType.normal,
868
+ title: this.getValidationErrorTitle(),
869
+ showCloseButton: true,
870
+ }, modalProps: {
871
+ className: styles.validationErrorDialog,
872
+ isBlocking: true,
873
+ containerClassName: "ms-dialogMainOverride",
874
+ } },
875
+ this.getValidationErrorMessage(),
876
+ React.createElement(DialogFooter, { className: styles.actions },
877
+ React.createElement("div", { className: "ms-Dialog-actionsRight ".concat(styles.actionsRight) },
878
+ React.createElement(DefaultButton, { className: styles.action, onClick: this.closeValidationErrorDialog, text: strings.CloseButton }))))));
785
879
  };
786
880
  return DynamicForm;
787
881
  }(React.Component));