@pnp/spfx-controls-react 4.0.0-beta.3798679 → 4.0.0-beta.3809332
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/lib/common/Interfaces.d.ts +1 -1
- package/lib/common/Interfaces.d.ts.map +1 -1
- package/lib/common/SPRestTypes.d.ts +130 -0
- package/lib/common/SPRestTypes.d.ts.map +1 -0
- package/lib/common/SPRestTypes.js +40 -0
- package/lib/common/SPRestTypes.js.map +1 -0
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +1 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/telemetry/version.js +1 -1
- package/lib/common/utilities/SPHelper.d.ts +4 -5
- package/lib/common/utilities/SPHelper.d.ts.map +1 -1
- package/lib/common/utilities/SPHelper.js +40 -53
- package/lib/common/utilities/SPHelper.js.map +1 -1
- package/lib/controls/carousel/Carousel.d.ts.map +1 -1
- package/lib/controls/carousel/Carousel.js +2 -3
- package/lib/controls/carousel/Carousel.js.map +1 -1
- package/lib/controls/dynamicForm/DynamicForm.d.ts +10 -22
- package/lib/controls/dynamicForm/DynamicForm.d.ts.map +1 -1
- package/lib/controls/dynamicForm/DynamicForm.js +460 -453
- package/lib/controls/dynamicForm/DynamicForm.js.map +1 -1
- package/lib/controls/dynamicForm/IDynamicFormProps.d.ts +5 -4
- package/lib/controls/dynamicForm/IDynamicFormProps.d.ts.map +1 -1
- package/lib/controls/dynamicForm/IDynamicFormState.d.ts +1 -1
- package/lib/controls/dynamicForm/IDynamicFormState.d.ts.map +1 -1
- package/lib/controls/dynamicForm/dynamicField/DynamicField.d.ts +0 -2
- package/lib/controls/dynamicForm/dynamicField/DynamicField.d.ts.map +1 -1
- package/lib/controls/dynamicForm/dynamicField/DynamicField.js +3 -8
- package/lib/controls/dynamicForm/dynamicField/DynamicField.js.map +1 -1
- package/lib/controls/dynamicForm/dynamicField/IDynamicFieldProps.d.ts +2 -1
- package/lib/controls/dynamicForm/dynamicField/IDynamicFieldProps.d.ts.map +1 -1
- package/lib/controls/dynamicForm/index.d.ts +2 -0
- package/lib/controls/dynamicForm/index.d.ts.map +1 -1
- package/lib/controls/dynamicForm/index.js +1 -0
- package/lib/controls/dynamicForm/index.js.map +1 -1
- package/lib/controls/folderExplorer/FolderExplorer/IFolderExplorerProps.d.ts +1 -1
- package/lib/controls/folderExplorer/FolderExplorer/IFolderExplorerProps.d.ts.map +1 -1
- package/lib/controls/folderExplorer/FolderExplorer/IFolderExplorerState.d.ts +1 -1
- package/lib/controls/folderExplorer/FolderExplorer/IFolderExplorerState.d.ts.map +1 -1
- package/lib/controls/modernTaxonomyPicker/ModernTaxonomyPicker.d.ts +3 -2
- package/lib/controls/modernTaxonomyPicker/ModernTaxonomyPicker.d.ts.map +1 -1
- package/lib/controls/modernTaxonomyPicker/ModernTaxonomyPicker.js +135 -45
- package/lib/controls/modernTaxonomyPicker/ModernTaxonomyPicker.js.map +1 -1
- package/lib/controls/modernTaxonomyPicker/modernTermPicker/ModernTermPicker.d.ts +1 -1
- package/lib/controls/modernTaxonomyPicker/modernTermPicker/ModernTermPicker.d.ts.map +1 -1
- package/lib/controls/modernTaxonomyPicker/modernTermPicker/ModernTermPicker.types.d.ts +1 -1
- package/lib/controls/modernTaxonomyPicker/modernTermPicker/ModernTermPicker.types.d.ts.map +1 -1
- package/lib/controls/modernTaxonomyPicker/taxonomyPanelContents/TaxonomyPanelContents.d.ts +2 -2
- package/lib/controls/modernTaxonomyPicker/taxonomyPanelContents/TaxonomyPanelContents.d.ts.map +1 -1
- package/lib/controls/modernTaxonomyPicker/taxonomyPanelContents/TaxonomyPanelContents.js.map +1 -1
- package/lib/controls/modernTaxonomyPicker/taxonomyTree/TaxonomyTree.d.ts +2 -3
- package/lib/controls/modernTaxonomyPicker/taxonomyTree/TaxonomyTree.d.ts.map +1 -1
- package/lib/controls/modernTaxonomyPicker/taxonomyTree/TaxonomyTree.js +20 -24
- package/lib/controls/modernTaxonomyPicker/taxonomyTree/TaxonomyTree.js.map +1 -1
- package/lib/controls/modernTaxonomyPicker/termItem/TermItemSuggestion.d.ts +1 -1
- package/lib/controls/modernTaxonomyPicker/termItem/TermItemSuggestion.d.ts.map +1 -1
- package/lib/services/DynamicFormService.d.ts +48 -0
- package/lib/services/DynamicFormService.d.ts.map +1 -0
- package/lib/services/DynamicFormService.js +340 -0
- package/lib/services/DynamicFormService.js.map +1 -0
- package/lib/services/FolderExplorerService.d.ts +4 -5
- package/lib/services/FolderExplorerService.d.ts.map +1 -1
- package/lib/services/FolderExplorerService.js +70 -48
- package/lib/services/FolderExplorerService.js.map +1 -1
- package/lib/services/IFolderExplorerService.d.ts +1 -1
- package/lib/services/IFolderExplorerService.d.ts.map +1 -1
- package/lib/services/PeopleSearchService.d.ts +3 -4
- package/lib/services/PeopleSearchService.d.ts.map +1 -1
- package/lib/services/PeopleSearchService.js +48 -65
- package/lib/services/PeopleSearchService.js.map +1 -1
- package/lib/services/SPRestClient.d.ts +40 -0
- package/lib/services/SPRestClient.d.ts.map +1 -0
- package/lib/services/SPRestClient.js +528 -0
- package/lib/services/SPRestClient.js.map +1 -0
- package/lib/services/SPTaxonomyService.d.ts +11 -7
- package/lib/services/SPTaxonomyService.d.ts.map +1 -1
- package/lib/services/SPTaxonomyService.js +64 -139
- package/lib/services/SPTaxonomyService.js.map +1 -1
- package/lib/services/SPTaxonomyService.types.d.ts +64 -0
- package/lib/services/SPTaxonomyService.types.d.ts.map +1 -0
- package/lib/services/SPTaxonomyService.types.js +2 -0
- package/lib/services/SPTaxonomyService.types.js.map +1 -0
- package/package.json +2 -4
- package/sharepoint/solution/debug/ClientSideAssets.xml +1 -1
- package/sharepoint/solution/debug/ClientSideAssets.xml.config.xml +1 -1
- package/sharepoint/solution/debug/feature_d7493d69-72ce-4892-a4ae-643166acae22.xml.config.xml +1 -1
- package/sharepoint/solution/sp-dev-fx-controls-react.sppkg +0 -0
|
@@ -10,13 +10,8 @@ import { Stack } from "@fluentui/react/lib/Stack";
|
|
|
10
10
|
import { DynamicField } from "./dynamicField";
|
|
11
11
|
import { FilePicker } from "../filePicker";
|
|
12
12
|
import { Guid } from '@microsoft/sp-core-library';
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
import "@pnp/sp/lists";
|
|
16
|
-
import "@pnp/sp/content-types";
|
|
17
|
-
import "@pnp/sp/folders";
|
|
18
|
-
import "@pnp/sp/items";
|
|
19
|
-
import { ChoiceFieldFormatType } from "@pnp/sp/presets/all";
|
|
13
|
+
import { ChoiceFieldFormatType } from "../../common/SPRestTypes";
|
|
14
|
+
import { DynamicFormService, DynamicFormSaveError } from "../../services/DynamicFormService";
|
|
20
15
|
import { cloneDeep, isEqual } from "lodash";
|
|
21
16
|
import SPservice from "../../services/SPService";
|
|
22
17
|
import { FormulaEvaluation } from "../../common/utilities/FormulaEvaluation";
|
|
@@ -30,9 +25,6 @@ var stackTokens = { childrenGap: 20 };
|
|
|
30
25
|
var getstyles = classNamesFunction();
|
|
31
26
|
var getFieldstyles = classNamesFunction();
|
|
32
27
|
var theme = getFluentUIThemeOrDefault();
|
|
33
|
-
var timeout = function (ms) {
|
|
34
|
-
return new Promise(function (resolve) { return setTimeout(resolve, ms); });
|
|
35
|
-
};
|
|
36
28
|
/**
|
|
37
29
|
* DynamicForm Class Control
|
|
38
30
|
*/
|
|
@@ -40,9 +32,10 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
40
32
|
__extends(DynamicFormBase, _super);
|
|
41
33
|
function DynamicFormBase(props) {
|
|
42
34
|
var _this = _super.call(this, props) || this;
|
|
43
|
-
_this.
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
_this._loadVersion = 0;
|
|
36
|
+
_this._operationVersion = 0;
|
|
37
|
+
_this._isLoading = false;
|
|
38
|
+
_this._unmounted = false;
|
|
46
39
|
_this.sortFields = function (fields, customSort) {
|
|
47
40
|
var fMap = new Map();
|
|
48
41
|
for (var _i = 0, fields_1 = fields; _i < fields_1.length; _i++) {
|
|
@@ -77,23 +70,33 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
77
70
|
return fieldOverrides[field.columnInternalName](__assign(__assign({}, field), { disabled: field.disabled || isSaving }));
|
|
78
71
|
}
|
|
79
72
|
// Default render
|
|
80
|
-
return (React.createElement(DynamicField, __assign({ key: field.columnInternalName, styles: styles }, field, { disabled: field.disabled || isSaving, validationErrorMessage: validationErrorMessage, itemsQueryCountLimit: _this.props.itemsQueryCountLimit })));
|
|
73
|
+
return (React.createElement(DynamicField, __assign({ key: field.columnInternalName, styles: styles }, field, { webAbsoluteUrl: _this.webURL, disabled: field.disabled || isSaving, validationErrorMessage: validationErrorMessage, itemsQueryCountLimit: _this.props.itemsQueryCountLimit })));
|
|
81
74
|
};
|
|
82
75
|
/** Triggered when the user submits the form. */
|
|
83
76
|
_this.onSubmitClick = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
84
|
-
var _a, listId, listItemId, onSubmitted, onBeforeSubmit, onSubmitError, enableFileSelection, validationErrorDialogProps,
|
|
85
|
-
var
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
var operationVersion, isCurrent, dataService, spService, webUrl, _a, listId, listItemId, onSubmitted, onBeforeSubmit, onSubmitError, enableFileSelection, validationErrorDialogProps, returnListItemReferenceOnSubmit, useModernTaxonomyPicker, folderPath, contentTypeId, fileSelectRendered, shouldBeReturnBack_1, fields, validationDisabled, validationErrors, objects, _loop_1, this_1, i, len, state_1, isCancelled, apiError, newETag, iur, error_1, error_2, contentTypeIdField, iar, error_3, contentTypeIdField, folderFileName, iur, error_4, updatedExtendedInfo_1, error_5;
|
|
78
|
+
var _this = this;
|
|
79
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
80
|
+
return __generator(this, function (_l) {
|
|
81
|
+
switch (_l.label) {
|
|
88
82
|
case 0:
|
|
89
|
-
|
|
83
|
+
if (this._unmounted || this._isLoading || this.state.isSaving || this._submissionVersion !== undefined)
|
|
84
|
+
return [2 /*return*/];
|
|
85
|
+
operationVersion = this._operationVersion;
|
|
86
|
+
this._submissionVersion = operationVersion;
|
|
87
|
+
isCurrent = function () { return !_this._unmounted && operationVersion === _this._operationVersion; };
|
|
88
|
+
dataService = this._dataService;
|
|
89
|
+
spService = this._spService;
|
|
90
|
+
webUrl = this.webURL;
|
|
91
|
+
_a = this.props, listId = _a.listId, listItemId = _a.listItemId, onSubmitted = _a.onSubmitted, onBeforeSubmit = _a.onBeforeSubmit, onSubmitError = _a.onSubmitError, enableFileSelection = _a.enableFileSelection, validationErrorDialogProps = _a.validationErrorDialogProps, returnListItemReferenceOnSubmit = _a.returnListItemReferenceOnSubmit, useModernTaxonomyPicker = _a.useModernTaxonomyPicker, folderPath = _a.folderPath;
|
|
92
|
+
_l.label = 1;
|
|
93
|
+
case 1:
|
|
94
|
+
_l.trys.push([1, 33, 34, 35]);
|
|
95
|
+
this.setState({ isSaving: true });
|
|
90
96
|
contentTypeId = this.props.contentTypeId;
|
|
91
97
|
if (this.state.contentTypeId !== undefined)
|
|
92
98
|
contentTypeId = this.state.contentTypeId;
|
|
93
|
-
fileSelectRendered = !listItemId && contentTypeId.startsWith("0x0101") && enableFileSelection === true;
|
|
94
|
-
_m.label = 1;
|
|
95
|
-
case 1:
|
|
96
|
-
_m.trys.push([1, 35, , 36]);
|
|
99
|
+
fileSelectRendered = !listItemId && (contentTypeId === null || contentTypeId === void 0 ? void 0 : contentTypeId.startsWith("0x0101")) && enableFileSelection === true;
|
|
97
100
|
shouldBeReturnBack_1 = false;
|
|
98
101
|
fields = (this.state.fieldCollection || []).slice();
|
|
99
102
|
fields.forEach(function (field) {
|
|
@@ -132,11 +135,13 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
132
135
|
if (!!validationDisabled) return [3 /*break*/, 3];
|
|
133
136
|
return [4 /*yield*/, this.evaluateFormulas(this.state.validationFormulas, true, true, this.state.hiddenByFormula)];
|
|
134
137
|
case 2:
|
|
135
|
-
validationErrors = (
|
|
138
|
+
validationErrors = (_l.sent());
|
|
139
|
+
if (!isCurrent())
|
|
140
|
+
return [2 /*return*/];
|
|
136
141
|
if (Object.keys(validationErrors).length > 0) {
|
|
137
142
|
shouldBeReturnBack_1 = true;
|
|
138
143
|
}
|
|
139
|
-
|
|
144
|
+
_l.label = 3;
|
|
140
145
|
case 3:
|
|
141
146
|
// If validation failed, return without saving
|
|
142
147
|
if (shouldBeReturnBack_1) {
|
|
@@ -154,14 +159,11 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
154
159
|
});
|
|
155
160
|
return [2 /*return*/];
|
|
156
161
|
}
|
|
157
|
-
this.setState({
|
|
158
|
-
isSaving: true,
|
|
159
|
-
});
|
|
160
162
|
objects = {};
|
|
161
163
|
_loop_1 = function (i, len) {
|
|
162
164
|
var field, fieldType, additionalData, columnInternalName, hiddenFieldName, fieldcolumnInternalName, value_1, uploadedImage;
|
|
163
|
-
return __generator(this, function (
|
|
164
|
-
switch (
|
|
165
|
+
return __generator(this, function (_m) {
|
|
166
|
+
switch (_m.label) {
|
|
165
167
|
case 0:
|
|
166
168
|
field = fields[i];
|
|
167
169
|
fieldType = field.fieldType, additionalData = field.additionalData, columnInternalName = field.columnInternalName, hiddenFieldName = field.hiddenFieldName;
|
|
@@ -214,8 +216,8 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
214
216
|
if (fieldType === "TaxonomyFieldType") {
|
|
215
217
|
objects[fieldcolumnInternalName] = {
|
|
216
218
|
__metadata: { type: "SP.Taxonomy.TaxonomyFieldValue" },
|
|
217
|
-
Label: (
|
|
218
|
-
TermGuid: (
|
|
219
|
+
Label: (_d = (_c = (_b = value_1[0]) === null || _b === void 0 ? void 0 : _b.labels[0]) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : "",
|
|
220
|
+
TermGuid: (_f = (_e = value_1[0]) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : "11111111-1111-1111-1111-111111111111",
|
|
219
221
|
WssId: "-1",
|
|
220
222
|
};
|
|
221
223
|
}
|
|
@@ -230,8 +232,8 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
230
232
|
if (fieldType === "TaxonomyFieldType") {
|
|
231
233
|
objects[fieldcolumnInternalName] = {
|
|
232
234
|
__metadata: { type: "SP.Taxonomy.TaxonomyFieldValue" },
|
|
233
|
-
Label: (
|
|
234
|
-
TermGuid: (
|
|
235
|
+
Label: (_h = (_g = value_1[0]) === null || _g === void 0 ? void 0 : _g.name) !== null && _h !== void 0 ? _h : "",
|
|
236
|
+
TermGuid: (_k = (_j = value_1[0]) === null || _j === void 0 ? void 0 : _j.key) !== null && _k !== void 0 ? _k : "11111111-1111-1111-1111-111111111111",
|
|
235
237
|
WssId: "-1",
|
|
236
238
|
};
|
|
237
239
|
}
|
|
@@ -247,9 +249,11 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
247
249
|
}
|
|
248
250
|
if (!(fieldType === "Thumbnail")) return [3 /*break*/, 3];
|
|
249
251
|
if (!additionalData) return [3 /*break*/, 2];
|
|
250
|
-
return [4 /*yield*/, this_1.uploadImage(additionalData)];
|
|
252
|
+
return [4 /*yield*/, this_1.uploadImage(additionalData, isCurrent)];
|
|
251
253
|
case 1:
|
|
252
|
-
uploadedImage =
|
|
254
|
+
uploadedImage = _m.sent();
|
|
255
|
+
if (!isCurrent())
|
|
256
|
+
return [2 /*return*/, { value: void 0 }];
|
|
253
257
|
objects[fieldcolumnInternalName] = JSON.stringify({
|
|
254
258
|
type: "thumbnail",
|
|
255
259
|
fileName: uploadedImage.Name,
|
|
@@ -259,20 +263,22 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
259
263
|
return [3 /*break*/, 3];
|
|
260
264
|
case 2:
|
|
261
265
|
objects[fieldcolumnInternalName] = null;
|
|
262
|
-
|
|
266
|
+
_m.label = 3;
|
|
263
267
|
case 3: return [2 /*return*/];
|
|
264
268
|
}
|
|
265
269
|
});
|
|
266
270
|
};
|
|
267
271
|
this_1 = this;
|
|
268
272
|
i = 0, len = fields.length;
|
|
269
|
-
|
|
273
|
+
_l.label = 4;
|
|
270
274
|
case 4:
|
|
271
275
|
if (!(i < len)) return [3 /*break*/, 7];
|
|
272
276
|
return [5 /*yield**/, _loop_1(i, len)];
|
|
273
277
|
case 5:
|
|
274
|
-
|
|
275
|
-
|
|
278
|
+
state_1 = _l.sent();
|
|
279
|
+
if (typeof state_1 === "object")
|
|
280
|
+
return [2 /*return*/, state_1.value];
|
|
281
|
+
_l.label = 6;
|
|
276
282
|
case 6:
|
|
277
283
|
i++;
|
|
278
284
|
return [3 /*break*/, 4];
|
|
@@ -280,219 +286,204 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
280
286
|
if (!onBeforeSubmit) return [3 /*break*/, 9];
|
|
281
287
|
return [4 /*yield*/, onBeforeSubmit(objects)];
|
|
282
288
|
case 8:
|
|
283
|
-
isCancelled =
|
|
289
|
+
isCancelled = _l.sent();
|
|
290
|
+
if (!isCurrent())
|
|
291
|
+
return [2 /*return*/];
|
|
284
292
|
if (isCancelled) {
|
|
285
293
|
this.setState({
|
|
286
294
|
isSaving: false,
|
|
287
295
|
});
|
|
288
296
|
return [2 /*return*/];
|
|
289
297
|
}
|
|
290
|
-
|
|
298
|
+
_l.label = 9;
|
|
291
299
|
case 9:
|
|
300
|
+
if (!isCurrent())
|
|
301
|
+
return [2 /*return*/];
|
|
292
302
|
apiError = void 0;
|
|
293
303
|
newETag = undefined;
|
|
294
|
-
if (!listItemId) return [3 /*break*/,
|
|
295
|
-
|
|
304
|
+
if (!listItemId) return [3 /*break*/, 15];
|
|
305
|
+
_l.label = 10;
|
|
296
306
|
case 10:
|
|
297
|
-
|
|
298
|
-
return [4 /*yield*/,
|
|
299
|
-
.getById(listId)
|
|
300
|
-
.items.getById(listItemId)
|
|
301
|
-
.update(objects, this.state.etag)];
|
|
307
|
+
_l.trys.push([10, 13, , 14]);
|
|
308
|
+
return [4 /*yield*/, dataService.updateItem(listId, listItemId, objects, this.state.etag)];
|
|
302
309
|
case 11:
|
|
303
|
-
iur =
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
: undefined);
|
|
309
|
-
}
|
|
310
|
-
return [3 /*break*/, 13];
|
|
310
|
+
iur = _l.sent();
|
|
311
|
+
if (!isCurrent())
|
|
312
|
+
return [2 /*return*/];
|
|
313
|
+
newETag = iur.reference.etag;
|
|
314
|
+
return [4 /*yield*/, this.notifySubmitted(iur, onSubmitted, returnListItemReferenceOnSubmit)];
|
|
311
315
|
case 12:
|
|
312
|
-
|
|
316
|
+
_l.sent();
|
|
317
|
+
return [3 /*break*/, 14];
|
|
318
|
+
case 13:
|
|
319
|
+
error_1 = _l.sent();
|
|
320
|
+
if (!isCurrent())
|
|
321
|
+
return [2 /*return*/];
|
|
313
322
|
apiError = error_1.message;
|
|
314
323
|
if (onSubmitError) {
|
|
315
324
|
onSubmitError(objects, error_1);
|
|
316
325
|
}
|
|
317
326
|
console.log("Error", error_1);
|
|
318
|
-
return [3 /*break*/,
|
|
319
|
-
case
|
|
320
|
-
case
|
|
327
|
+
return [3 /*break*/, 14];
|
|
328
|
+
case 14: return [3 /*break*/, 30];
|
|
329
|
+
case 15:
|
|
321
330
|
if (!(contentTypeId === undefined ||
|
|
322
331
|
contentTypeId === "" ||
|
|
323
332
|
(!contentTypeId.startsWith("0x0120") &&
|
|
324
|
-
contentTypeId.startsWith("0x01")))) return [3 /*break*/,
|
|
325
|
-
if (!(fileSelectRendered === true)) return [3 /*break*/,
|
|
326
|
-
|
|
327
|
-
case 15:
|
|
328
|
-
_m.sent();
|
|
329
|
-
return [3 /*break*/, 19];
|
|
333
|
+
contentTypeId.startsWith("0x01")))) return [3 /*break*/, 25];
|
|
334
|
+
if (!(fileSelectRendered === true)) return [3 /*break*/, 20];
|
|
335
|
+
_l.label = 16;
|
|
330
336
|
case 16:
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
// check if item contenttype is passed, then update the object with content type id, else, pass the object
|
|
334
|
-
if (contentTypeId !== undefined && contentTypeId.startsWith("0x01"))
|
|
335
|
-
objects[contentTypeIdField] = contentTypeId;
|
|
336
|
-
return [4 /*yield*/, sp.web.lists.getById(listId).items.add(objects)];
|
|
337
|
+
_l.trys.push([16, 18, , 19]);
|
|
338
|
+
return [4 /*yield*/, this.addFileToLibrary(objects, dataService, isCurrent)];
|
|
337
339
|
case 17:
|
|
338
|
-
|
|
339
|
-
if (onSubmitted) {
|
|
340
|
-
onSubmitted(iar.data, this.props.returnListItemInstanceOnSubmit !== false
|
|
341
|
-
? iar.item
|
|
342
|
-
: undefined);
|
|
343
|
-
}
|
|
340
|
+
_l.sent();
|
|
344
341
|
return [3 /*break*/, 19];
|
|
345
342
|
case 18:
|
|
346
|
-
error_2 =
|
|
343
|
+
error_2 = _l.sent();
|
|
344
|
+
if (!isCurrent())
|
|
345
|
+
return [2 /*return*/];
|
|
347
346
|
apiError = error_2.message;
|
|
348
347
|
if (onSubmitError) {
|
|
349
348
|
onSubmitError(objects, error_2);
|
|
350
349
|
}
|
|
351
|
-
console.log("Error", error_2);
|
|
352
350
|
return [3 /*break*/, 19];
|
|
353
|
-
case 19: return [3 /*break*/,
|
|
351
|
+
case 19: return [3 /*break*/, 24];
|
|
354
352
|
case 20:
|
|
355
|
-
|
|
356
|
-
_m.label = 21;
|
|
357
|
-
case 21:
|
|
358
|
-
_m.trys.push([21, 31, , 32]);
|
|
359
|
-
idField = "ID";
|
|
353
|
+
_l.trys.push([20, 23, , 24]);
|
|
360
354
|
contentTypeIdField = "ContentTypeId";
|
|
361
|
-
|
|
355
|
+
// check if item contenttype is passed, then update the object with content type id, else, pass the object
|
|
356
|
+
if (contentTypeId !== undefined && contentTypeId.startsWith("0x01"))
|
|
357
|
+
objects[contentTypeIdField] = contentTypeId;
|
|
358
|
+
return [4 /*yield*/, dataService.addItem(listId, objects)];
|
|
359
|
+
case 21:
|
|
360
|
+
iar = _l.sent();
|
|
361
|
+
if (!isCurrent())
|
|
362
|
+
return [2 /*return*/];
|
|
363
|
+
return [4 /*yield*/, this.notifySubmitted(iar, onSubmitted, returnListItemReferenceOnSubmit)];
|
|
362
364
|
case 22:
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
365
|
+
_l.sent();
|
|
366
|
+
return [3 /*break*/, 24];
|
|
367
|
+
case 23:
|
|
368
|
+
error_3 = _l.sent();
|
|
369
|
+
if (!isCurrent())
|
|
370
|
+
return [2 /*return*/];
|
|
371
|
+
apiError = error_3.message;
|
|
372
|
+
if (onSubmitError) {
|
|
373
|
+
onSubmitError(objects, error_3);
|
|
374
|
+
}
|
|
375
|
+
console.log("Error", error_3);
|
|
376
|
+
return [3 /*break*/, 24];
|
|
377
|
+
case 24: return [3 /*break*/, 30];
|
|
372
378
|
case 25:
|
|
373
|
-
|
|
374
|
-
|
|
379
|
+
if (!contentTypeId.startsWith("0x0120")) return [3 /*break*/, 30];
|
|
380
|
+
_l.label = 26;
|
|
375
381
|
case 26:
|
|
376
|
-
|
|
377
|
-
|
|
382
|
+
_l.trys.push([26, 29, , 30]);
|
|
383
|
+
contentTypeIdField = "ContentTypeId";
|
|
384
|
+
folderFileName = this.getFolderName(objects);
|
|
385
|
+
objects[contentTypeIdField] = contentTypeId;
|
|
386
|
+
return [4 /*yield*/, dataService.addFolder(listId, folderFileName, objects, folderPath)];
|
|
378
387
|
case 27:
|
|
379
|
-
|
|
380
|
-
if (!
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
objects[contentTypeIdField] = contentTypeId; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
384
|
-
return [4 /*yield*/, this.updateListItemRetry(library, folderId, objects)];
|
|
388
|
+
iur = _l.sent();
|
|
389
|
+
if (!isCurrent())
|
|
390
|
+
return [2 /*return*/];
|
|
391
|
+
return [4 /*yield*/, this.notifySubmitted(iur, onSubmitted, returnListItemReferenceOnSubmit)];
|
|
385
392
|
case 28:
|
|
386
|
-
|
|
387
|
-
if (onSubmitted) {
|
|
388
|
-
onSubmitted(iur.data, this.props.returnListItemInstanceOnSubmit !== false
|
|
389
|
-
? iur.item
|
|
390
|
-
: undefined);
|
|
391
|
-
}
|
|
393
|
+
_l.sent();
|
|
392
394
|
return [3 /*break*/, 30];
|
|
393
|
-
case 29:
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
apiError =
|
|
395
|
+
case 29:
|
|
396
|
+
error_4 = _l.sent();
|
|
397
|
+
if (!isCurrent())
|
|
398
|
+
return [2 /*return*/];
|
|
399
|
+
apiError = error_4.message;
|
|
398
400
|
if (onSubmitError) {
|
|
399
|
-
onSubmitError(objects,
|
|
401
|
+
onSubmitError(objects, error_4);
|
|
400
402
|
}
|
|
401
|
-
console.log("Error",
|
|
402
|
-
return [3 /*break*/,
|
|
403
|
-
case
|
|
404
|
-
if (!(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
403
|
+
console.log("Error", error_4);
|
|
404
|
+
return [3 /*break*/, 30];
|
|
405
|
+
case 30:
|
|
406
|
+
if (!isCurrent())
|
|
407
|
+
return [2 /*return*/];
|
|
408
|
+
if (!(listItemId && this.state.fieldCollection.some(function (f) { return f.isAppendOnly; }))) return [3 /*break*/, 32];
|
|
409
|
+
return [4 /*yield*/, spService.getExtendedListFormData(listId, listItemId, webUrl)];
|
|
410
|
+
case 31:
|
|
411
|
+
updatedExtendedInfo_1 = _l.sent();
|
|
412
|
+
if (!isCurrent())
|
|
413
|
+
return [2 /*return*/];
|
|
408
414
|
this.setState(function (prevState) { return ({
|
|
409
415
|
fieldCollection: prevState.fieldCollection.map(function (field) {
|
|
410
416
|
return field.isAppendOnly
|
|
411
417
|
? __assign(__assign({}, field), { notesAppendOnlyHistory: updatedExtendedInfo_1[field.columnInternalName], newValue: '', value: '' }) : field;
|
|
412
418
|
})
|
|
413
419
|
}); });
|
|
414
|
-
|
|
415
|
-
case
|
|
420
|
+
_l.label = 32;
|
|
421
|
+
case 32:
|
|
416
422
|
this.setState({
|
|
417
423
|
isSaving: false,
|
|
418
424
|
etag: newETag,
|
|
419
425
|
infoErrorMessages: apiError ? [{ type: MessageBarType.error, message: apiError }] : [],
|
|
420
426
|
});
|
|
421
|
-
return [3 /*break*/,
|
|
422
|
-
case
|
|
423
|
-
|
|
427
|
+
return [3 /*break*/, 35];
|
|
428
|
+
case 33:
|
|
429
|
+
error_5 = _l.sent();
|
|
430
|
+
if (!isCurrent())
|
|
431
|
+
return [2 /*return*/];
|
|
432
|
+
this.setState({ isSaving: false, infoErrorMessages: [{ type: MessageBarType.error, message: error_5.message }] });
|
|
424
433
|
if (onSubmitError) {
|
|
425
|
-
onSubmitError(null,
|
|
434
|
+
onSubmitError(null, error_5);
|
|
426
435
|
}
|
|
427
|
-
console.
|
|
428
|
-
return [3 /*break*/,
|
|
429
|
-
case
|
|
436
|
+
console.error("Error onSubmit", error_5);
|
|
437
|
+
return [3 /*break*/, 35];
|
|
438
|
+
case 34:
|
|
439
|
+
if (this._submissionVersion === operationVersion) {
|
|
440
|
+
this._submissionVersion = undefined;
|
|
441
|
+
if (isCurrent())
|
|
442
|
+
this.setState({ isSaving: false });
|
|
443
|
+
}
|
|
444
|
+
return [7 /*endfinally*/];
|
|
445
|
+
case 35: return [2 /*return*/];
|
|
430
446
|
}
|
|
431
447
|
});
|
|
432
448
|
}); };
|
|
433
449
|
/**
|
|
434
450
|
* Adds selected file to the library
|
|
435
451
|
*/
|
|
436
|
-
_this.addFileToLibrary = function (objects) { return __awaiter(_this, void 0, void 0, function () {
|
|
437
|
-
var selectedFile, _a, listId, contentTypeId, onSubmitted,
|
|
438
|
-
return __generator(this, function (
|
|
439
|
-
switch (
|
|
452
|
+
_this.addFileToLibrary = function (objects, dataService, isCurrent) { return __awaiter(_this, void 0, void 0, function () {
|
|
453
|
+
var selectedFile, _a, listId, contentTypeId, onSubmitted, returnListItemReferenceOnSubmit, folderPath, contentTypeIdField, itemTitle, content, iur, error_6;
|
|
454
|
+
return __generator(this, function (_b) {
|
|
455
|
+
switch (_b.label) {
|
|
440
456
|
case 0:
|
|
441
457
|
selectedFile = this.state.selectedFile;
|
|
442
|
-
_a = this.props, listId = _a.listId, contentTypeId = _a.contentTypeId, onSubmitted = _a.onSubmitted,
|
|
443
|
-
if (!(selectedFile !== undefined)) return [3 /*break*/,
|
|
444
|
-
|
|
458
|
+
_a = this.props, listId = _a.listId, contentTypeId = _a.contentTypeId, onSubmitted = _a.onSubmitted, returnListItemReferenceOnSubmit = _a.returnListItemReferenceOnSubmit, folderPath = _a.folderPath;
|
|
459
|
+
if (!(selectedFile !== undefined)) return [3 /*break*/, 6];
|
|
460
|
+
_b.label = 1;
|
|
445
461
|
case 1:
|
|
446
|
-
|
|
447
|
-
idField = "ID";
|
|
462
|
+
_b.trys.push([1, 5, , 6]);
|
|
448
463
|
contentTypeIdField = "ContentTypeId";
|
|
449
|
-
return [4 /*yield*/, sp.web.lists.getById(listId)];
|
|
450
|
-
case 2:
|
|
451
|
-
library = _f.sent();
|
|
452
464
|
itemTitle = selectedFile !== undefined && selectedFile.fileName !== undefined && selectedFile.fileName !== ""
|
|
453
465
|
? selectedFile.fileName.replace(/["|*|:|<|>|?|/|\\||]/g, "_").trim() // Replace not allowed chars in folder name and trim empty spaces at the start or end.
|
|
454
466
|
: "";
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
467
|
+
objects[contentTypeIdField] = contentTypeId;
|
|
468
|
+
return [4 /*yield*/, selectedFile.downloadFileContent()];
|
|
469
|
+
case 2:
|
|
470
|
+
content = _b.sent();
|
|
471
|
+
if (!isCurrent())
|
|
472
|
+
return [2 /*return*/];
|
|
473
|
+
return [4 /*yield*/, dataService.addFile(listId, itemTitle, content, objects, folderPath)];
|
|
474
|
+
case 3:
|
|
475
|
+
iur = _b.sent();
|
|
476
|
+
if (!isCurrent())
|
|
477
|
+
return [2 /*return*/];
|
|
478
|
+
return [4 /*yield*/, this.notifySubmitted(iur, onSubmitted, returnListItemReferenceOnSubmit)];
|
|
459
479
|
case 4:
|
|
460
|
-
_b
|
|
461
|
-
|
|
480
|
+
_b.sent();
|
|
481
|
+
return [3 /*break*/, 6];
|
|
462
482
|
case 5:
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
case 6: return [4 /*yield*/, _d.apply(_c, _e.concat([_f.sent()]))];
|
|
468
|
-
case 7:
|
|
469
|
-
fileCreatedResult = _f.sent();
|
|
470
|
-
return [4 /*yield*/, fileCreatedResult.file.listItemAllFields()];
|
|
471
|
-
case 8:
|
|
472
|
-
fields = _f.sent();
|
|
473
|
-
if (!fields[idField]) return [3 /*break*/, 10];
|
|
474
|
-
fileId = fields[idField];
|
|
475
|
-
// Set the content type ID for the target item
|
|
476
|
-
objects[contentTypeIdField] = contentTypeId;
|
|
477
|
-
return [4 /*yield*/, this.updateListItemRetry(library, fileId, objects)];
|
|
478
|
-
case 9:
|
|
479
|
-
iur = _f.sent();
|
|
480
|
-
if (onSubmitted) {
|
|
481
|
-
onSubmitted(iur.data, returnListItemInstanceOnSubmit !== false
|
|
482
|
-
? iur.item
|
|
483
|
-
: undefined);
|
|
484
|
-
}
|
|
485
|
-
return [3 /*break*/, 11];
|
|
486
|
-
case 10: throw new Error("Unable to read the ID of the just created file");
|
|
487
|
-
case 11: return [3 /*break*/, 13];
|
|
488
|
-
case 12:
|
|
489
|
-
error_5 = _f.sent();
|
|
490
|
-
if (onSubmitError) {
|
|
491
|
-
onSubmitError(objects, error_5);
|
|
492
|
-
}
|
|
493
|
-
console.log("Error", error_5);
|
|
494
|
-
return [3 /*break*/, 13];
|
|
495
|
-
case 13: return [2 /*return*/];
|
|
483
|
+
error_6 = _b.sent();
|
|
484
|
+
console.error("Error uploading document", error_6);
|
|
485
|
+
throw error_6;
|
|
486
|
+
case 6: return [2 /*return*/];
|
|
496
487
|
}
|
|
497
488
|
});
|
|
498
489
|
}); };
|
|
@@ -502,11 +493,16 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
502
493
|
_this.onChange = function (internalName,
|
|
503
494
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
504
495
|
newValue, validate, additionalData) { return __awaiter(_this, void 0, void 0, function () {
|
|
505
|
-
var fieldCol, field, useModernTaxonomyPicker, user, result, emails, index, element, user, result, validationErrors;
|
|
496
|
+
var operationVersion, isCurrent, dataService, fieldCol, field, useModernTaxonomyPicker, user, result, emails, index, element, user, result, validationErrors;
|
|
506
497
|
var _this = this;
|
|
507
498
|
return __generator(this, function (_a) {
|
|
508
499
|
switch (_a.label) {
|
|
509
500
|
case 0:
|
|
501
|
+
if (this._unmounted || this._isLoading)
|
|
502
|
+
return [2 /*return*/];
|
|
503
|
+
operationVersion = this._operationVersion;
|
|
504
|
+
isCurrent = function () { return !_this._unmounted && operationVersion === _this._operationVersion; };
|
|
505
|
+
dataService = this._dataService;
|
|
510
506
|
fieldCol = cloneDeep(this.state.fieldCollection || []);
|
|
511
507
|
field = fieldCol.filter(function (element, i) {
|
|
512
508
|
return element.columnInternalName === internalName;
|
|
@@ -549,15 +545,17 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
549
545
|
if (user.indexOf("@") === -1) {
|
|
550
546
|
user = newValue[0].loginName;
|
|
551
547
|
}
|
|
552
|
-
return [4 /*yield*/,
|
|
548
|
+
return [4 /*yield*/, dataService.ensureUser(user)];
|
|
553
549
|
case 1:
|
|
554
550
|
result = _a.sent();
|
|
555
|
-
|
|
551
|
+
if (!isCurrent())
|
|
552
|
+
return [2 /*return*/];
|
|
553
|
+
field.newValue = result.Id;
|
|
556
554
|
field.stringValue = user;
|
|
557
555
|
field.subPropertyValues = {
|
|
558
|
-
id: result.
|
|
559
|
-
title: result.
|
|
560
|
-
email: result.
|
|
556
|
+
id: result.Id,
|
|
557
|
+
title: result.Title,
|
|
558
|
+
email: result.Email,
|
|
561
559
|
};
|
|
562
560
|
return [3 /*break*/, 3];
|
|
563
561
|
case 2:
|
|
@@ -578,10 +576,12 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
578
576
|
if (user.indexOf("@") === -1) {
|
|
579
577
|
user = element.loginName;
|
|
580
578
|
}
|
|
581
|
-
return [4 /*yield*/,
|
|
579
|
+
return [4 /*yield*/, dataService.ensureUser(user)];
|
|
582
580
|
case 5:
|
|
583
581
|
result = _a.sent();
|
|
584
|
-
|
|
582
|
+
if (!isCurrent())
|
|
583
|
+
return [2 /*return*/];
|
|
584
|
+
field.newValue.push(result.Id);
|
|
585
585
|
emails.push(user);
|
|
586
586
|
return [3 /*break*/, 7];
|
|
587
587
|
case 6:
|
|
@@ -597,11 +597,11 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
597
597
|
validationErrors = __assign({}, this.state.validationErrors);
|
|
598
598
|
if (validationErrors[field.columnInternalName])
|
|
599
599
|
delete validationErrors[field.columnInternalName];
|
|
600
|
-
this.setState({
|
|
600
|
+
this.setState(function () { return isCurrent() ? {
|
|
601
601
|
fieldCollection: fieldCol,
|
|
602
602
|
validationErrors: validationErrors
|
|
603
|
-
}, function () {
|
|
604
|
-
if (validate)
|
|
603
|
+
} : null; }, function () {
|
|
604
|
+
if (isCurrent() && validate)
|
|
605
605
|
_this.performValidation();
|
|
606
606
|
});
|
|
607
607
|
return [2 /*return*/];
|
|
@@ -732,25 +732,50 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
732
732
|
* Invoked when component first mounts, loads information about the SharePoint list, fields and list item
|
|
733
733
|
*/
|
|
734
734
|
_this.getListInformation = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
735
|
-
var
|
|
735
|
+
var loadVersion, isCurrent, assertCurrent, props, spService, dataService, webUrl, loadContext, listId, listItemId, disabledFields, respectETag, customIcons, onListItemLoaded, fieldOrder, contentTypeId, listInfo, additionalInfo, numberFields, validationFormulas_1, contentTypeName, clientValidationFormulas_1, headerJSON_1, footerJSON_1, bodySections_1, customFormatInfo, item, isEditingItem, etag_1, extendedInfo, appendOnlyFields, tempFields, sortedFields_1, installedLanguages_1, error_7;
|
|
736
736
|
var _this = this;
|
|
737
|
-
var
|
|
738
|
-
return __generator(this, function (
|
|
739
|
-
switch (
|
|
737
|
+
var _a;
|
|
738
|
+
return __generator(this, function (_b) {
|
|
739
|
+
switch (_b.label) {
|
|
740
740
|
case 0:
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
741
|
+
this._isLoading = true;
|
|
742
|
+
loadVersion = ++this._loadVersion;
|
|
743
|
+
isCurrent = function () { return !_this._unmounted && loadVersion === _this._loadVersion; };
|
|
744
|
+
assertCurrent = function () {
|
|
745
|
+
if (!isCurrent()) {
|
|
746
|
+
var error = new Error('The form load is no longer current.');
|
|
747
|
+
error.name = 'AbortError';
|
|
748
|
+
throw error;
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
props = this.props;
|
|
752
|
+
spService = this._spService;
|
|
753
|
+
dataService = this._dataService;
|
|
754
|
+
webUrl = this.webURL;
|
|
755
|
+
loadContext = {
|
|
756
|
+
props: props,
|
|
757
|
+
spService: spService,
|
|
758
|
+
webUrl: webUrl,
|
|
759
|
+
assertCurrent: assertCurrent,
|
|
760
|
+
taxonomyService: this._taxonomyService,
|
|
761
|
+
installedLanguages: this.state.installedLanguages
|
|
762
|
+
};
|
|
763
|
+
listId = props.listId, listItemId = props.listItemId, disabledFields = props.disabledFields, respectETag = props.respectETag, customIcons = props.customIcons, onListItemLoaded = props.onListItemLoaded, fieldOrder = props.fieldOrder;
|
|
764
|
+
contentTypeId = props.contentTypeId;
|
|
765
|
+
_b.label = 1;
|
|
744
766
|
case 1:
|
|
745
|
-
|
|
746
|
-
|
|
767
|
+
_b.trys.push([1, 12, , 13]);
|
|
768
|
+
assertCurrent();
|
|
769
|
+
return [4 /*yield*/, spService.getListFormRenderInfo(listId, webUrl)];
|
|
747
770
|
case 2:
|
|
748
|
-
listInfo =
|
|
749
|
-
|
|
771
|
+
listInfo = _b.sent();
|
|
772
|
+
assertCurrent();
|
|
773
|
+
return [4 /*yield*/, spService.getAdditionalListFormFieldInfo(listId, webUrl)];
|
|
750
774
|
case 3:
|
|
751
|
-
additionalInfo =
|
|
775
|
+
additionalInfo = _b.sent();
|
|
776
|
+
assertCurrent();
|
|
752
777
|
numberFields = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.filter(function (f) { return f.TypeAsString === "Number" || f.TypeAsString === "Currency"; });
|
|
753
|
-
|
|
778
|
+
validationFormulas_1 = additionalInfo.reduce(function (prev, cur) {
|
|
754
779
|
if (!prev[cur.InternalName] && cur.ValidationFormula) {
|
|
755
780
|
prev[cur.InternalName] = {
|
|
756
781
|
ValidationFormula: cur.ValidationFormula,
|
|
@@ -764,7 +789,7 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
764
789
|
contentTypeId = Object.keys(listInfo.ContentTypeIdToNameMap)[0];
|
|
765
790
|
}
|
|
766
791
|
contentTypeName = listInfo.ContentTypeIdToNameMap[contentTypeId];
|
|
767
|
-
|
|
792
|
+
clientValidationFormulas_1 = listInfo.ClientForms.Edit[contentTypeName].reduce(function (prev, cur) {
|
|
768
793
|
if (cur.ClientValidationFormula) {
|
|
769
794
|
prev[cur.InternalName] = {
|
|
770
795
|
ValidationFormula: cur.ClientValidationFormula,
|
|
@@ -773,147 +798,118 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
773
798
|
}
|
|
774
799
|
return prev;
|
|
775
800
|
}, {});
|
|
776
|
-
headerJSON = void 0, footerJSON = void 0;
|
|
777
|
-
bodySections = void 0;
|
|
778
801
|
if (listInfo.ClientFormCustomFormatter && listInfo.ClientFormCustomFormatter[contentTypeId]) {
|
|
779
802
|
customFormatInfo = JSON.parse(listInfo.ClientFormCustomFormatter[contentTypeId]);
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
803
|
+
bodySections_1 = (_a = customFormatInfo.bodyJSONFormatter) === null || _a === void 0 ? void 0 : _a.sections;
|
|
804
|
+
headerJSON_1 = customFormatInfo.headerJSONFormatter;
|
|
805
|
+
footerJSON_1 = customFormatInfo.footerJSONFormatter;
|
|
783
806
|
}
|
|
784
|
-
spList = sp.web.lists.getById(listId);
|
|
785
807
|
item = null;
|
|
786
808
|
isEditingItem = listItemId !== undefined && listItemId !== null && listItemId !== 0;
|
|
787
|
-
|
|
809
|
+
etag_1 = undefined;
|
|
788
810
|
extendedInfo = undefined;
|
|
789
811
|
if (!isEditingItem) return [3 /*break*/, 8];
|
|
790
|
-
|
|
791
|
-
if (contentTypeId.startsWith("0x0120") || contentTypeId.startsWith("0x0101")) {
|
|
792
|
-
spListItem.select("*", "FileLeafRef"); // Explainer: FileLeafRef is not loaded by default. Load it to show the file/folder name in the field.
|
|
793
|
-
}
|
|
794
|
-
return [4 /*yield*/, spListItem.get().catch(function (err) { return _this.updateFormMessages(MessageBarType.error, err.message); })];
|
|
812
|
+
return [4 /*yield*/, dataService.getItem(listId, listItemId, contentTypeId.startsWith("0x0120") || contentTypeId.startsWith("0x0101"))];
|
|
795
813
|
case 4:
|
|
796
|
-
item =
|
|
814
|
+
item = _b.sent();
|
|
815
|
+
assertCurrent();
|
|
797
816
|
if (!onListItemLoaded) return [3 /*break*/, 6];
|
|
798
817
|
return [4 /*yield*/, onListItemLoaded(item)];
|
|
799
818
|
case 5:
|
|
800
|
-
|
|
801
|
-
|
|
819
|
+
_b.sent();
|
|
820
|
+
assertCurrent();
|
|
821
|
+
_b.label = 6;
|
|
802
822
|
case 6:
|
|
803
823
|
if (respectETag !== false) {
|
|
804
|
-
|
|
824
|
+
etag_1 = typeof item["odata.etag"] === 'string' ? item["odata.etag"] : undefined;
|
|
805
825
|
}
|
|
806
826
|
appendOnlyFields = listInfo.ClientForms.Edit[contentTypeName]
|
|
807
827
|
.filter(function (field) { return field.FieldType === 'Note' && field.AppendOnly; });
|
|
808
828
|
if (!(appendOnlyFields.length > 0)) return [3 /*break*/, 8];
|
|
809
|
-
return [4 /*yield*/,
|
|
829
|
+
return [4 /*yield*/, spService.getExtendedListFormData(listId, listItemId, webUrl)];
|
|
810
830
|
case 7:
|
|
811
|
-
extendedInfo =
|
|
812
|
-
|
|
813
|
-
|
|
831
|
+
extendedInfo = _b.sent();
|
|
832
|
+
assertCurrent();
|
|
833
|
+
_b.label = 8;
|
|
834
|
+
case 8: return [4 /*yield*/, this.buildFieldCollection(listInfo, contentTypeName, item, numberFields, listId, listItemId, disabledFields, customIcons, extendedInfo, loadContext)];
|
|
814
835
|
case 9:
|
|
815
|
-
tempFields =
|
|
816
|
-
|
|
817
|
-
|
|
836
|
+
tempFields = _b.sent();
|
|
837
|
+
assertCurrent();
|
|
838
|
+
sortedFields_1 = (fieldOrder === null || fieldOrder === void 0 ? void 0 : fieldOrder.length) > 0
|
|
839
|
+
? this.sortFields(tempFields, fieldOrder)
|
|
818
840
|
: tempFields;
|
|
819
|
-
installedLanguages = void 0;
|
|
820
841
|
if (!(tempFields.filter(function (f) { return f.fieldType === "Currency"; }).length > 0)) return [3 /*break*/, 11];
|
|
821
|
-
return [4 /*yield*/,
|
|
842
|
+
return [4 /*yield*/, dataService.getInstalledLanguages()];
|
|
822
843
|
case 10:
|
|
823
|
-
|
|
824
|
-
|
|
844
|
+
installedLanguages_1 = _b.sent();
|
|
845
|
+
assertCurrent();
|
|
846
|
+
_b.label = 11;
|
|
825
847
|
case 11:
|
|
826
|
-
this.setState({
|
|
848
|
+
this.setState(function () { return isCurrent() ? {
|
|
827
849
|
contentTypeId: contentTypeId,
|
|
828
|
-
clientValidationFormulas:
|
|
850
|
+
clientValidationFormulas: clientValidationFormulas_1,
|
|
829
851
|
customFormatting: {
|
|
830
|
-
header:
|
|
831
|
-
body:
|
|
832
|
-
footer:
|
|
852
|
+
header: headerJSON_1,
|
|
853
|
+
body: bodySections_1,
|
|
854
|
+
footer: footerJSON_1
|
|
833
855
|
},
|
|
834
|
-
etag:
|
|
835
|
-
fieldCollection:
|
|
836
|
-
installedLanguages:
|
|
837
|
-
validationFormulas:
|
|
838
|
-
}, function () {
|
|
856
|
+
etag: etag_1,
|
|
857
|
+
fieldCollection: sortedFields_1,
|
|
858
|
+
installedLanguages: installedLanguages_1,
|
|
859
|
+
validationFormulas: validationFormulas_1
|
|
860
|
+
} : null; }, function () {
|
|
861
|
+
if (isCurrent()) {
|
|
862
|
+
_this._isLoading = false;
|
|
863
|
+
_this.performValidation(true);
|
|
864
|
+
}
|
|
865
|
+
});
|
|
839
866
|
return [3 /*break*/, 13];
|
|
840
867
|
case 12:
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
868
|
+
error_7 = _b.sent();
|
|
869
|
+
if (!isCurrent())
|
|
870
|
+
return [2 /*return*/];
|
|
871
|
+
this.updateFormMessages(MessageBarType.error, 'An error occurred while loading: ' + error_7.message);
|
|
872
|
+
console.error("An error occurred while loading DynamicForm", error_7);
|
|
844
873
|
return [2 /*return*/, null];
|
|
845
874
|
case 13: return [2 /*return*/];
|
|
846
875
|
}
|
|
847
876
|
});
|
|
848
877
|
}); };
|
|
849
|
-
|
|
850
|
-
_this.getTermsForModernTaxonomyPicker = function (termsetId, terms) { return __awaiter(_this, void 0, void 0, function () {
|
|
851
|
-
var selectedTerms;
|
|
878
|
+
_this.getTermsForModernTaxonomyPicker = function (termsetId, terms, loadContext) { return __awaiter(_this, void 0, void 0, function () {
|
|
852
879
|
var _this = this;
|
|
853
880
|
return __generator(this, function (_a) {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
if (!terms || terms.length === 0) {
|
|
857
|
-
return [2 /*return*/, []];
|
|
858
|
-
}
|
|
859
|
-
return [4 /*yield*/, Promise.all(
|
|
860
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
861
|
-
terms.map(function (fetchedterm) { return __awaiter(_this, void 0, void 0, function () {
|
|
862
|
-
var response, error_7;
|
|
863
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
864
|
-
return __generator(this, function (_v) {
|
|
865
|
-
switch (_v.label) {
|
|
866
|
-
case 0:
|
|
867
|
-
if (!(fetchedterm === null || fetchedterm === void 0 ? void 0 : fetchedterm.TermGuid)) {
|
|
868
|
-
console.error("Error: TermGuid is undefined for term", fetchedterm);
|
|
869
|
-
return [2 /*return*/, null];
|
|
870
|
-
}
|
|
871
|
-
_v.label = 1;
|
|
872
|
-
case 1:
|
|
873
|
-
_v.trys.push([1, 3, , 4]);
|
|
874
|
-
return [4 /*yield*/, this._taxonomyService.getTermById(Guid.parse(termsetId), Guid.parse(fetchedterm.TermGuid))];
|
|
875
|
-
case 2:
|
|
876
|
-
response = _v.sent();
|
|
877
|
-
return [2 /*return*/, {
|
|
878
|
-
id: response.id,
|
|
879
|
-
labels: [
|
|
880
|
-
{
|
|
881
|
-
name: (_c = (_b = (_a = response.labels) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : fetchedterm.Label,
|
|
882
|
-
isDefault: (_f = (_e = (_d = response.labels) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.isDefault) !== null && _f !== void 0 ? _f : true,
|
|
883
|
-
languageTag: (_j = (_h = (_g = response.labels) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.languageTag) !== null && _j !== void 0 ? _j : "en-US",
|
|
884
|
-
},
|
|
885
|
-
],
|
|
886
|
-
childrenCount: (_k = response.childrenCount) !== null && _k !== void 0 ? _k : 0,
|
|
887
|
-
createdDateTime: (_l = response.createdDateTime) !== null && _l !== void 0 ? _l : new Date().toISOString(),
|
|
888
|
-
lastModifiedDateTime: (_m = response.lastModifiedDateTime) !== null && _m !== void 0 ? _m : new Date().toISOString(),
|
|
889
|
-
descriptions: (_o = response.descriptions) !== null && _o !== void 0 ? _o : [],
|
|
890
|
-
customSortOrder: (_p = response.customSortOrder) !== null && _p !== void 0 ? _p : [],
|
|
891
|
-
properties: (_q = response.properties) !== null && _q !== void 0 ? _q : [],
|
|
892
|
-
localProperties: (_r = response.localProperties) !== null && _r !== void 0 ? _r : [],
|
|
893
|
-
isDeprecated: (_s = response.isDeprecated) !== null && _s !== void 0 ? _s : false,
|
|
894
|
-
isAvailableForTagging: (_t = response.isAvailableForTagging) !== null && _t !== void 0 ? _t : [],
|
|
895
|
-
topicRequested: (_u = response.topicRequested) !== null && _u !== void 0 ? _u : false,
|
|
896
|
-
}];
|
|
897
|
-
case 3:
|
|
898
|
-
error_7 = _v.sent();
|
|
899
|
-
console.error("Error fetching term ".concat(fetchedterm.TermGuid, ":"), error_7);
|
|
900
|
-
return [2 /*return*/, null];
|
|
901
|
-
case 4: return [2 /*return*/];
|
|
902
|
-
}
|
|
903
|
-
});
|
|
904
|
-
}); }))];
|
|
905
|
-
case 1:
|
|
906
|
-
selectedTerms = _a.sent();
|
|
907
|
-
return [2 /*return*/, selectedTerms.filter(function (term) { return term !== null; })];
|
|
881
|
+
if (!terms || terms.length === 0) {
|
|
882
|
+
return [2 /*return*/, []];
|
|
908
883
|
}
|
|
884
|
+
return [2 /*return*/, Promise.all(terms.map(function (fetchedterm) { return __awaiter(_this, void 0, void 0, function () {
|
|
885
|
+
var term;
|
|
886
|
+
return __generator(this, function (_a) {
|
|
887
|
+
switch (_a.label) {
|
|
888
|
+
case 0:
|
|
889
|
+
loadContext.assertCurrent();
|
|
890
|
+
if (!(fetchedterm === null || fetchedterm === void 0 ? void 0 : fetchedterm.TermGuid)) {
|
|
891
|
+
throw new Error('A managed metadata value has no term ID.');
|
|
892
|
+
}
|
|
893
|
+
return [4 /*yield*/, loadContext.taxonomyService.getTermById(Guid.parse(termsetId), Guid.parse(fetchedterm.TermGuid))];
|
|
894
|
+
case 1:
|
|
895
|
+
term = _a.sent();
|
|
896
|
+
loadContext.assertCurrent();
|
|
897
|
+
if (!term)
|
|
898
|
+
throw new Error('The taxonomy field contains an empty term ID.');
|
|
899
|
+
return [2 /*return*/, term];
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
}); }))];
|
|
909
903
|
});
|
|
910
904
|
}); };
|
|
911
|
-
_this.uploadImage = function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
912
|
-
var _a, listId, listItemId, fileInstance, buffer;
|
|
905
|
+
_this.uploadImage = function (file, isCurrent) { return __awaiter(_this, void 0, void 0, function () {
|
|
906
|
+
var _a, listId, listItemId, service, webUrl, fileInstance, buffer;
|
|
913
907
|
return __generator(this, function (_b) {
|
|
914
908
|
switch (_b.label) {
|
|
915
909
|
case 0:
|
|
916
910
|
_a = this.props, listId = _a.listId, listItemId = _a.listItemId;
|
|
911
|
+
service = this._spService;
|
|
912
|
+
webUrl = this.webURL;
|
|
917
913
|
if (!file.fileAbsoluteUrl) return [3 /*break*/, 1];
|
|
918
914
|
return [2 /*return*/, {
|
|
919
915
|
Name: file.fileName,
|
|
@@ -923,10 +919,14 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
923
919
|
case 1: return [4 /*yield*/, file.downloadFileContent()];
|
|
924
920
|
case 2:
|
|
925
921
|
fileInstance = _b.sent();
|
|
922
|
+
if (!isCurrent())
|
|
923
|
+
throw new Error('The form target changed before image upload.');
|
|
926
924
|
return [4 /*yield*/, this.getImageArrayBuffer(fileInstance)];
|
|
927
925
|
case 3:
|
|
928
926
|
buffer = _b.sent();
|
|
929
|
-
|
|
927
|
+
if (!isCurrent())
|
|
928
|
+
throw new Error('The form target changed before image upload.');
|
|
929
|
+
return [4 /*yield*/, service.uploadImage(listId, listItemId, file.fileName, buffer, undefined, webUrl)];
|
|
930
930
|
case 4: return [2 /*return*/, _b.sent()];
|
|
931
931
|
}
|
|
932
932
|
});
|
|
@@ -1029,95 +1029,10 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1029
1029
|
folderNameValue = objects[titleField];
|
|
1030
1030
|
return folderNameValue.replace(/["|*|:|<|>|?|/|\\||]/g, "_").trim();
|
|
1031
1031
|
};
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
* The folderPath can be a server relative path, but should be in the same library.
|
|
1035
|
-
* @param folderPath The path to the folder coming from the component properties
|
|
1036
|
-
* @param rootFolder The rootFolder object of the library
|
|
1037
|
-
* @returns
|
|
1038
|
-
*/
|
|
1039
|
-
_this.getFolderByPath = function (folderPath, rootFolder) { return __awaiter(_this, void 0, void 0, function () {
|
|
1040
|
-
var libraryFolder, normalizedFolderPath, serverRelativeLibraryPath, folder;
|
|
1041
|
-
return __generator(this, function (_a) {
|
|
1042
|
-
switch (_a.label) {
|
|
1043
|
-
case 0: return [4 /*yield*/, rootFolder()];
|
|
1044
|
-
case 1:
|
|
1045
|
-
libraryFolder = _a.sent();
|
|
1046
|
-
normalizedFolderPath = decodeURIComponent(folderPath).toLowerCase().replace(/\/$/, "");
|
|
1047
|
-
serverRelativeLibraryPath = libraryFolder.ServerRelativeUrl.toLowerCase().replace(/\/$/, "");
|
|
1048
|
-
// In case of a server relative path in the same library, return the folder
|
|
1049
|
-
if ("".concat(normalizedFolderPath, "/").startsWith("".concat(serverRelativeLibraryPath, "/"))) {
|
|
1050
|
-
return [2 /*return*/, sp.web.getFolderByServerRelativePath(normalizedFolderPath)];
|
|
1051
|
-
}
|
|
1052
|
-
folder = sp.web.getFolderByServerRelativePath("".concat(serverRelativeLibraryPath, "/").concat(normalizedFolderPath));
|
|
1053
|
-
return [2 /*return*/, folder];
|
|
1054
|
-
}
|
|
1055
|
-
});
|
|
1056
|
-
}); };
|
|
1057
|
-
/**
|
|
1058
|
-
* Updates a list item and retries the operation if a 409 (Save Conflict) was thrown.
|
|
1059
|
-
* @param list The list/library on which to execute the operation
|
|
1060
|
-
* @param itemId The item ID
|
|
1061
|
-
* @param objects The values to update the item with
|
|
1062
|
-
* @param retry The retry index
|
|
1063
|
-
* @returns An update result
|
|
1064
|
-
*/
|
|
1065
|
-
_this.updateListItemRetry = function (list_1, itemId_1, objects_1) {
|
|
1066
|
-
var args_1 = [];
|
|
1067
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
1068
|
-
args_1[_i - 3] = arguments[_i];
|
|
1069
|
-
}
|
|
1070
|
-
return __awaiter(_this, __spreadArray([list_1, itemId_1, objects_1], args_1, true), void 0, function (list, itemId, objects, retry) {
|
|
1071
|
-
var error_8;
|
|
1072
|
-
if (retry === void 0) { retry = 0; }
|
|
1073
|
-
return __generator(this, function (_a) {
|
|
1074
|
-
switch (_a.label) {
|
|
1075
|
-
case 0:
|
|
1076
|
-
_a.trys.push([0, 2, , 6]);
|
|
1077
|
-
return [4 /*yield*/, list.items.getById(itemId).update(objects)];
|
|
1078
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
1079
|
-
case 2:
|
|
1080
|
-
error_8 = _a.sent();
|
|
1081
|
-
if (!(error_8.status === 409 && retry < 3)) return [3 /*break*/, 5];
|
|
1082
|
-
return [4 /*yield*/, timeout(100)];
|
|
1083
|
-
case 3:
|
|
1084
|
-
_a.sent();
|
|
1085
|
-
return [4 /*yield*/, this.updateListItemRetry(list, itemId, objects, retry + 1)];
|
|
1086
|
-
case 4: return [2 /*return*/, _a.sent()];
|
|
1087
|
-
case 5: throw error_8;
|
|
1088
|
-
case 6: return [2 /*return*/];
|
|
1089
|
-
}
|
|
1090
|
-
});
|
|
1091
|
-
});
|
|
1092
|
-
};
|
|
1093
|
-
// Initialize pnp sp
|
|
1094
|
-
if (_this.props.webAbsoluteUrl) {
|
|
1095
|
-
sp.setup({
|
|
1096
|
-
sp: {
|
|
1097
|
-
headers: {
|
|
1098
|
-
Accept: "application/json;odata=verbose",
|
|
1099
|
-
},
|
|
1100
|
-
baseUrl: _this.props.webAbsoluteUrl,
|
|
1101
|
-
},
|
|
1102
|
-
});
|
|
1103
|
-
}
|
|
1104
|
-
else {
|
|
1105
|
-
sp.setup({
|
|
1106
|
-
spfxContext: { pageContext: _this.props.context.pageContext },
|
|
1107
|
-
});
|
|
1108
|
-
}
|
|
1109
|
-
// Initialize taxonomy service
|
|
1110
|
-
_this._taxonomyService = new SPTaxonomyService(_this.props.context);
|
|
1032
|
+
_this._dataService = new DynamicFormService(_this.props.context, _this.webURL);
|
|
1033
|
+
_this._taxonomyService = new SPTaxonomyService(_this.props.context, _this.webURL);
|
|
1111
1034
|
// Initialize state
|
|
1112
|
-
_this.state =
|
|
1113
|
-
infoErrorMessages: [],
|
|
1114
|
-
fieldCollection: [],
|
|
1115
|
-
validationFormulas: {},
|
|
1116
|
-
clientValidationFormulas: {},
|
|
1117
|
-
validationErrors: {},
|
|
1118
|
-
hiddenByFormula: [],
|
|
1119
|
-
isValidationErrorDialogOpen: false,
|
|
1120
|
-
};
|
|
1035
|
+
_this.state = _this.emptyTargetState();
|
|
1121
1036
|
// Get SPService Factory
|
|
1122
1037
|
_this._spService = _this.props.webAbsoluteUrl
|
|
1123
1038
|
? new SPservice(_this.props.context, _this.props.webAbsoluteUrl)
|
|
@@ -1128,6 +1043,33 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1128
1043
|
_this._customFormatter = new CustomFormattingHelper(_this._formulaEvaluation);
|
|
1129
1044
|
return _this;
|
|
1130
1045
|
}
|
|
1046
|
+
Object.defineProperty(DynamicFormBase.prototype, "webURL", {
|
|
1047
|
+
get: function () {
|
|
1048
|
+
return this.props.webAbsoluteUrl || this.props.context.pageContext.web.absoluteUrl;
|
|
1049
|
+
},
|
|
1050
|
+
enumerable: false,
|
|
1051
|
+
configurable: true
|
|
1052
|
+
});
|
|
1053
|
+
DynamicFormBase.prototype.emptyTargetState = function () {
|
|
1054
|
+
return {
|
|
1055
|
+
infoErrorMessages: [],
|
|
1056
|
+
fieldCollection: [],
|
|
1057
|
+
validationFormulas: {},
|
|
1058
|
+
clientValidationFormulas: {},
|
|
1059
|
+
validationErrors: {},
|
|
1060
|
+
hiddenByFormula: [],
|
|
1061
|
+
isValidationErrorDialogOpen: false,
|
|
1062
|
+
isSaving: false,
|
|
1063
|
+
selectedFile: undefined,
|
|
1064
|
+
missingSelectedFile: false,
|
|
1065
|
+
contentTypeId: undefined,
|
|
1066
|
+
etag: undefined,
|
|
1067
|
+
installedLanguages: undefined,
|
|
1068
|
+
customFormatting: undefined,
|
|
1069
|
+
headerContent: undefined,
|
|
1070
|
+
footerContent: undefined
|
|
1071
|
+
};
|
|
1072
|
+
};
|
|
1131
1073
|
/**
|
|
1132
1074
|
* Updates the ETag stored in the component's state.
|
|
1133
1075
|
* This is useful when the list item has been modified externally (e.g., by adding/removing attachments)
|
|
@@ -1157,14 +1099,31 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1157
1099
|
};
|
|
1158
1100
|
DynamicFormBase.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
1159
1101
|
var _this = this;
|
|
1160
|
-
|
|
1102
|
+
var targetChanged = prevProps.context !== this.props.context ||
|
|
1103
|
+
prevProps.webAbsoluteUrl !== this.props.webAbsoluteUrl ||
|
|
1104
|
+
prevProps.listId !== this.props.listId || prevProps.listItemId !== this.props.listItemId;
|
|
1105
|
+
if (targetChanged) {
|
|
1106
|
+
this._isLoading = true;
|
|
1107
|
+
this._operationVersion++;
|
|
1108
|
+
this._submissionVersion = undefined;
|
|
1109
|
+
this._loadVersion++;
|
|
1110
|
+
this._dataService.dispose();
|
|
1111
|
+
this._taxonomyService.dispose();
|
|
1112
|
+
this._dataService = new DynamicFormService(this.props.context, this.webURL);
|
|
1113
|
+
this._taxonomyService = new SPTaxonomyService(this.props.context, this.webURL);
|
|
1114
|
+
this._spService = new SPservice(this.props.context, this.webURL);
|
|
1115
|
+
this._formulaEvaluation = new FormulaEvaluation(this.props.context, this.webURL);
|
|
1116
|
+
this._customFormatter = new CustomFormattingHelper(this._formulaEvaluation);
|
|
1117
|
+
}
|
|
1118
|
+
if (targetChanged || !isEqual(prevProps, this.props)) {
|
|
1161
1119
|
// Props have changed due to parent component or workbench config, reset state
|
|
1162
|
-
this.setState({
|
|
1120
|
+
this.setState(targetChanged ? this.emptyTargetState() : {
|
|
1163
1121
|
infoErrorMessages: [], // Reset info/error messages
|
|
1164
|
-
validationErrors: {} // Reset validation errors
|
|
1122
|
+
validationErrors: {}, // Reset validation errors
|
|
1123
|
+
isSaving: this.state.isSaving
|
|
1165
1124
|
}, function () {
|
|
1166
1125
|
// If listId or listItemId have changed, reload list information
|
|
1167
|
-
if (
|
|
1126
|
+
if (targetChanged) {
|
|
1168
1127
|
_this.getListInformation()
|
|
1169
1128
|
.then(function () {
|
|
1170
1129
|
/* no-op; */
|
|
@@ -1183,6 +1142,14 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1183
1142
|
/**
|
|
1184
1143
|
* Default React component render method
|
|
1185
1144
|
*/
|
|
1145
|
+
DynamicFormBase.prototype.componentWillUnmount = function () {
|
|
1146
|
+
this._unmounted = true;
|
|
1147
|
+
this._operationVersion++;
|
|
1148
|
+
this._submissionVersion = undefined;
|
|
1149
|
+
this._loadVersion++;
|
|
1150
|
+
this._dataService.dispose();
|
|
1151
|
+
this._taxonomyService.dispose();
|
|
1152
|
+
};
|
|
1186
1153
|
DynamicFormBase.prototype.render = function () {
|
|
1187
1154
|
var _a;
|
|
1188
1155
|
var _this = this;
|
|
@@ -1260,6 +1227,29 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1260
1227
|
newMessages.push({ type: type, message: message });
|
|
1261
1228
|
this.setState({ infoErrorMessages: newMessages });
|
|
1262
1229
|
};
|
|
1230
|
+
DynamicFormBase.prototype.notifySubmitted = function (result, onSubmitted, returnReference) {
|
|
1231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1232
|
+
var error_8;
|
|
1233
|
+
return __generator(this, function (_a) {
|
|
1234
|
+
switch (_a.label) {
|
|
1235
|
+
case 0:
|
|
1236
|
+
if (!onSubmitted)
|
|
1237
|
+
return [2 /*return*/];
|
|
1238
|
+
_a.label = 1;
|
|
1239
|
+
case 1:
|
|
1240
|
+
_a.trys.push([1, 3, , 4]);
|
|
1241
|
+
return [4 /*yield*/, onSubmitted(result.data, returnReference !== false ? result.reference : undefined)];
|
|
1242
|
+
case 2:
|
|
1243
|
+
_a.sent();
|
|
1244
|
+
return [3 /*break*/, 4];
|
|
1245
|
+
case 3:
|
|
1246
|
+
error_8 = _a.sent();
|
|
1247
|
+
throw new DynamicFormSaveError(result.reference, error_8, 'callback');
|
|
1248
|
+
case 4: return [2 /*return*/];
|
|
1249
|
+
}
|
|
1250
|
+
});
|
|
1251
|
+
});
|
|
1252
|
+
};
|
|
1263
1253
|
/**
|
|
1264
1254
|
* Builds a collection of fields to be rendered in the form
|
|
1265
1255
|
* @param listInfo Data returned by RenderListDataAsStream with RenderOptions = 64 (ClientFormSchema)
|
|
@@ -1272,22 +1262,24 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1272
1262
|
* @returns
|
|
1273
1263
|
*/
|
|
1274
1264
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1275
|
-
DynamicFormBase.prototype.buildFieldCollection = function (listInfo, contentTypeName, item, numberFields, listId, listItemId, disabledFields, customIcons, extendedInfo) {
|
|
1265
|
+
DynamicFormBase.prototype.buildFieldCollection = function (listInfo, contentTypeName, item, numberFields, listId, listItemId, disabledFields, customIcons, extendedInfo, loadContext) {
|
|
1276
1266
|
return __awaiter(this, void 0, void 0, function () {
|
|
1277
|
-
var useModernTaxonomyPicker, tempFields, order, hiddenFields, defaultDayOfWeek, _loop_3, this_2, i, len;
|
|
1267
|
+
var props, spService, taxonomyService, webUrl, assertCurrent, useModernTaxonomyPicker, tempFields, order, hiddenFields, defaultDayOfWeek, _loop_3, this_2, i, len;
|
|
1278
1268
|
return __generator(this, function (_a) {
|
|
1279
1269
|
switch (_a.label) {
|
|
1280
1270
|
case 0:
|
|
1281
|
-
|
|
1271
|
+
props = loadContext.props, spService = loadContext.spService, taxonomyService = loadContext.taxonomyService, webUrl = loadContext.webUrl, assertCurrent = loadContext.assertCurrent;
|
|
1272
|
+
useModernTaxonomyPicker = props.useModernTaxonomyPicker;
|
|
1282
1273
|
tempFields = [];
|
|
1283
1274
|
order = 0;
|
|
1284
|
-
hiddenFields =
|
|
1275
|
+
hiddenFields = props.hiddenFields !== undefined ? props.hiddenFields : [];
|
|
1285
1276
|
defaultDayOfWeek = 0;
|
|
1286
1277
|
_loop_3 = function (i, len) {
|
|
1287
|
-
var field, hiddenName, termSetId, anchorId, lookupListId, lookupField, choices_1, defaultValue, value, stringValue, subPropertyValues, richText, appendOnly, dateFormat, principalType, cultureName, minValue, maxValue, showAsPercentage, selectedTags_1, choiceType, notesAppendOnlyHistory, fieldName, numberField, userEmails,
|
|
1288
|
-
return __generator(this, function (
|
|
1289
|
-
switch (
|
|
1278
|
+
var field, hiddenName, termSetId, anchorId, lookupListId, lookupField, choices_1, defaultValue, value, stringValue, subPropertyValues, richText, appendOnly, dateFormat, principalType, cultureName, minValue, maxValue, showAsPercentage, selectedTags_1, choiceType, notesAppendOnlyHistory, fieldName, numberField, userEmails, userEmail, response, term, termId, term, _selectedTags, _selectedTags, response, regionalSettings;
|
|
1279
|
+
return __generator(this, function (_b) {
|
|
1280
|
+
switch (_b.label) {
|
|
1290
1281
|
case 0:
|
|
1282
|
+
assertCurrent();
|
|
1291
1283
|
field = listInfo.ClientForms.Edit[contentTypeName][i];
|
|
1292
1284
|
if (!(hiddenFields.indexOf(field.InternalName) < 0)) return [3 /*break*/, 32];
|
|
1293
1285
|
if (!(field.Hidden === false)) return [3 /*break*/, 32];
|
|
@@ -1360,16 +1352,17 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1360
1352
|
}
|
|
1361
1353
|
showAsPercentage = field.ShowAsPercentage;
|
|
1362
1354
|
if (field.FieldType === "Currency") {
|
|
1363
|
-
cultureName = this_2.cultureNameLookup(numberField.CurrencyLocaleId);
|
|
1355
|
+
cultureName = this_2.cultureNameLookup(numberField.CurrencyLocaleId, loadContext);
|
|
1364
1356
|
}
|
|
1365
1357
|
}
|
|
1366
1358
|
if (!(field.FieldType === "Lookup" || field.FieldType === "LookupMulti")) return [3 /*break*/, 3];
|
|
1367
1359
|
lookupListId = field.LookupListId;
|
|
1368
1360
|
lookupField = field.LookupFieldName;
|
|
1369
1361
|
if (!(item !== null)) return [3 /*break*/, 2];
|
|
1370
|
-
return [4 /*yield*/,
|
|
1362
|
+
return [4 /*yield*/, spService.getLookupValues(listId, listItemId, field.InternalName, lookupField, webUrl)];
|
|
1371
1363
|
case 1:
|
|
1372
|
-
value =
|
|
1364
|
+
value = _b.sent();
|
|
1365
|
+
assertCurrent();
|
|
1373
1366
|
stringValue = value === null || value === void 0 ? void 0 : value.map(function (dv) { return dv.key + ';#' + dv.name; }).join(';#');
|
|
1374
1367
|
if (item[field.InternalName + "Id"]) {
|
|
1375
1368
|
subPropertyValues.id = item[field.InternalName + "Id"];
|
|
@@ -1379,15 +1372,16 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1379
1372
|
return [3 /*break*/, 3];
|
|
1380
1373
|
case 2:
|
|
1381
1374
|
value = [];
|
|
1382
|
-
|
|
1375
|
+
_b.label = 3;
|
|
1383
1376
|
case 3:
|
|
1384
1377
|
if (!(field.FieldType === "User")) return [3 /*break*/, 7];
|
|
1385
1378
|
if (!(item !== null)) return [3 /*break*/, 5];
|
|
1386
1379
|
userEmails = [];
|
|
1387
|
-
|
|
1388
|
-
return [4 /*yield*/, this_2._spService.getUserUPNFromFieldValue(listId, listItemId, field.InternalName, this_2.webURL)];
|
|
1380
|
+
return [4 /*yield*/, spService.getUserUPNFromFieldValue(listId, listItemId, field.InternalName, webUrl)];
|
|
1389
1381
|
case 4:
|
|
1390
|
-
|
|
1382
|
+
userEmail = _b.sent();
|
|
1383
|
+
assertCurrent();
|
|
1384
|
+
userEmails.push(userEmail + "");
|
|
1391
1385
|
value = userEmails;
|
|
1392
1386
|
stringValue = userEmails === null || userEmails === void 0 ? void 0 : userEmails.map(function (dv) { return dv.split('/').shift(); }).join(';');
|
|
1393
1387
|
if (item[field.InternalName + "Id"]) {
|
|
@@ -1398,44 +1392,49 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1398
1392
|
return [3 /*break*/, 6];
|
|
1399
1393
|
case 5:
|
|
1400
1394
|
value = [];
|
|
1401
|
-
|
|
1395
|
+
_b.label = 6;
|
|
1402
1396
|
case 6:
|
|
1403
1397
|
principalType = field.PrincipalAccountType;
|
|
1404
|
-
|
|
1398
|
+
_b.label = 7;
|
|
1405
1399
|
case 7:
|
|
1406
1400
|
if (!(field.FieldType === "UserMulti")) return [3 /*break*/, 11];
|
|
1407
1401
|
if (!(item !== null)) return [3 /*break*/, 9];
|
|
1408
|
-
return [4 /*yield*/,
|
|
1402
|
+
return [4 /*yield*/, spService.getUsersUPNFromFieldValue(listId, listItemId, field.InternalName, webUrl)];
|
|
1409
1403
|
case 8:
|
|
1410
|
-
value =
|
|
1404
|
+
value = _b.sent();
|
|
1405
|
+
assertCurrent();
|
|
1411
1406
|
stringValue = value === null || value === void 0 ? void 0 : value.map(function (dv) { return dv.split('/').pop(); }).join(';');
|
|
1412
1407
|
return [3 /*break*/, 10];
|
|
1413
1408
|
case 9:
|
|
1414
1409
|
value = [];
|
|
1415
|
-
|
|
1410
|
+
_b.label = 10;
|
|
1416
1411
|
case 10:
|
|
1417
1412
|
principalType = field.PrincipalAccountType;
|
|
1418
|
-
|
|
1413
|
+
_b.label = 11;
|
|
1419
1414
|
case 11:
|
|
1420
1415
|
if (!useModernTaxonomyPicker) return [3 /*break*/, 24];
|
|
1421
1416
|
if (!(field.FieldType === "TaxonomyFieldType")) return [3 /*break*/, 18];
|
|
1422
1417
|
termSetId = field.TermSetId;
|
|
1423
1418
|
anchorId = field.AnchorId !== Guid.empty.toString() ? field.AnchorId : null;
|
|
1424
1419
|
if (!(item !== null)) return [3 /*break*/, 15];
|
|
1425
|
-
return [4 /*yield*/,
|
|
1420
|
+
return [4 /*yield*/, spService.getSingleManagedMetadataLabel(listId, listItemId, field.InternalName, webUrl)];
|
|
1426
1421
|
case 12:
|
|
1427
|
-
response =
|
|
1422
|
+
response = _b.sent();
|
|
1423
|
+
assertCurrent();
|
|
1428
1424
|
if (!response) return [3 /*break*/, 14];
|
|
1429
|
-
return [4 /*yield*/,
|
|
1425
|
+
return [4 /*yield*/, taxonomyService.getTermById(Guid.parse(field.TermSetId), Guid.parse(response.TermID))];
|
|
1430
1426
|
case 13:
|
|
1431
|
-
term =
|
|
1427
|
+
term = _b.sent();
|
|
1428
|
+
assertCurrent();
|
|
1429
|
+
if (!term)
|
|
1430
|
+
throw new Error('The taxonomy field contains an empty term ID.');
|
|
1432
1431
|
selectedTags_1.push({
|
|
1433
1432
|
key: response.TermID,
|
|
1434
1433
|
name: response.Label,
|
|
1435
1434
|
});
|
|
1436
1435
|
value = term; //selectedTags;
|
|
1437
1436
|
stringValue = selectedTags_1 === null || selectedTags_1 === void 0 ? void 0 : selectedTags_1.map(function (dv) { return dv.key + ';#' + dv.name; }).join(';#');
|
|
1438
|
-
|
|
1437
|
+
_b.label = 14;
|
|
1439
1438
|
case 14: return [3 /*break*/, 17];
|
|
1440
1439
|
case 15:
|
|
1441
1440
|
if (!(defaultValue !== "")) return [3 /*break*/, 17];
|
|
@@ -1444,24 +1443,28 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1444
1443
|
key: termId,
|
|
1445
1444
|
name: defaultValue.split("|")[0].split("#")[1],
|
|
1446
1445
|
});
|
|
1447
|
-
return [4 /*yield*/,
|
|
1446
|
+
return [4 /*yield*/, taxonomyService.getTermById(Guid.parse(field.TermSetId), Guid.parse(termId))];
|
|
1448
1447
|
case 16:
|
|
1449
|
-
term =
|
|
1448
|
+
term = _b.sent();
|
|
1449
|
+
assertCurrent();
|
|
1450
|
+
if (!term)
|
|
1451
|
+
throw new Error('The taxonomy field contains an empty term ID.');
|
|
1450
1452
|
value = term; //selectedTags;
|
|
1451
|
-
|
|
1453
|
+
_b.label = 17;
|
|
1452
1454
|
case 17:
|
|
1453
1455
|
if (defaultValue === "")
|
|
1454
1456
|
defaultValue = null;
|
|
1455
|
-
|
|
1457
|
+
_b.label = 18;
|
|
1456
1458
|
case 18:
|
|
1457
1459
|
if (!(field.FieldType === "TaxonomyFieldTypeMulti")) return [3 /*break*/, 23];
|
|
1458
1460
|
hiddenName = field.HiddenListInternalName;
|
|
1459
1461
|
termSetId = field.TermSetId;
|
|
1460
1462
|
anchorId = field.AnchorId !== Guid.empty.toString() ? field.AnchorId : null;
|
|
1461
1463
|
if (!(item && item[field.InternalName])) return [3 /*break*/, 20];
|
|
1462
|
-
return [4 /*yield*/, this_2.getTermsForModernTaxonomyPicker(field.TermSetId, item[field.InternalName])];
|
|
1464
|
+
return [4 /*yield*/, this_2.getTermsForModernTaxonomyPicker(field.TermSetId, item[field.InternalName], loadContext)];
|
|
1463
1465
|
case 19:
|
|
1464
|
-
_selectedTags =
|
|
1466
|
+
_selectedTags = _b.sent();
|
|
1467
|
+
assertCurrent();
|
|
1465
1468
|
// item[field.InternalName].forEach((element) => {
|
|
1466
1469
|
// selectedTags.push({
|
|
1467
1470
|
// key: element.TermGuid,
|
|
@@ -1483,26 +1486,28 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1483
1486
|
return [4 /*yield*/, this_2.getTermsForModernTaxonomyPicker(field.TermSetId, selectedTags_1.map(function (dv) { return ({
|
|
1484
1487
|
Label: dv.name,
|
|
1485
1488
|
TermGuid: dv.key
|
|
1486
|
-
}); }))];
|
|
1489
|
+
}); }), loadContext)];
|
|
1487
1490
|
case 21:
|
|
1488
|
-
_selectedTags =
|
|
1491
|
+
_selectedTags = _b.sent();
|
|
1492
|
+
assertCurrent();
|
|
1489
1493
|
//value = selectedTags;
|
|
1490
1494
|
value = _selectedTags;
|
|
1491
1495
|
stringValue = selectedTags_1 === null || selectedTags_1 === void 0 ? void 0 : selectedTags_1.map(function (dv) { return dv.key + ';#' + dv.name; }).join(';#');
|
|
1492
|
-
|
|
1496
|
+
_b.label = 22;
|
|
1493
1497
|
case 22:
|
|
1494
1498
|
if (defaultValue === "")
|
|
1495
1499
|
defaultValue = null;
|
|
1496
|
-
|
|
1500
|
+
_b.label = 23;
|
|
1497
1501
|
case 23: return [3 /*break*/, 29];
|
|
1498
1502
|
case 24:
|
|
1499
1503
|
if (!(field.FieldType === "TaxonomyFieldType")) return [3 /*break*/, 28];
|
|
1500
1504
|
termSetId = field.TermSetId;
|
|
1501
1505
|
anchorId = field.AnchorId;
|
|
1502
1506
|
if (!(item !== null)) return [3 /*break*/, 26];
|
|
1503
|
-
return [4 /*yield*/,
|
|
1507
|
+
return [4 /*yield*/, spService.getSingleManagedMetadataLabel(listId, listItemId, field.InternalName, webUrl)];
|
|
1504
1508
|
case 25:
|
|
1505
|
-
response =
|
|
1509
|
+
response = _b.sent();
|
|
1510
|
+
assertCurrent();
|
|
1506
1511
|
if (response) {
|
|
1507
1512
|
selectedTags_1.push({
|
|
1508
1513
|
key: response.TermID,
|
|
@@ -1520,11 +1525,11 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1520
1525
|
});
|
|
1521
1526
|
value = selectedTags_1;
|
|
1522
1527
|
}
|
|
1523
|
-
|
|
1528
|
+
_b.label = 27;
|
|
1524
1529
|
case 27:
|
|
1525
1530
|
if (defaultValue === "")
|
|
1526
1531
|
defaultValue = null;
|
|
1527
|
-
|
|
1532
|
+
_b.label = 28;
|
|
1528
1533
|
case 28:
|
|
1529
1534
|
if (field.FieldType === "TaxonomyFieldTypeMulti") {
|
|
1530
1535
|
hiddenName = field.HiddenListInternalName;
|
|
@@ -1567,7 +1572,7 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1567
1572
|
defaultValue = null;
|
|
1568
1573
|
}
|
|
1569
1574
|
}
|
|
1570
|
-
|
|
1575
|
+
_b.label = 29;
|
|
1571
1576
|
case 29:
|
|
1572
1577
|
if (!(field.FieldType === "DateTime")) return [3 /*break*/, 31];
|
|
1573
1578
|
if (item !== null && item[fieldName]) {
|
|
@@ -1581,10 +1586,12 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1581
1586
|
defaultValue = new Date(defaultValue);
|
|
1582
1587
|
}
|
|
1583
1588
|
dateFormat = field.DisplayFormat === 1 ? "DateTime" : "DateOnly";
|
|
1584
|
-
return [4 /*yield*/,
|
|
1589
|
+
return [4 /*yield*/, spService.getRegionalWebSettings(webUrl)];
|
|
1585
1590
|
case 30:
|
|
1586
|
-
|
|
1587
|
-
|
|
1591
|
+
regionalSettings = _b.sent();
|
|
1592
|
+
assertCurrent();
|
|
1593
|
+
defaultDayOfWeek = regionalSettings.FirstDayOfWeek;
|
|
1594
|
+
_b.label = 31;
|
|
1588
1595
|
case 31:
|
|
1589
1596
|
// Setup Thumbnail, Location and Boolean fields
|
|
1590
1597
|
if (field.FieldType === "Thumbnail") {
|
|
@@ -1622,8 +1629,8 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1622
1629
|
fieldType: field.FieldType,
|
|
1623
1630
|
// fieldTitle: field.Title,
|
|
1624
1631
|
defaultValue: defaultValue,
|
|
1625
|
-
context:
|
|
1626
|
-
disabled:
|
|
1632
|
+
context: props.context,
|
|
1633
|
+
disabled: props.disabled ||
|
|
1627
1634
|
(disabledFields &&
|
|
1628
1635
|
disabledFields.indexOf(field.InternalName) > -1),
|
|
1629
1636
|
// listId: this.props.listId,
|
|
@@ -1650,7 +1657,7 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1650
1657
|
});
|
|
1651
1658
|
// This may not be necessary now using RenderListDataAsStream
|
|
1652
1659
|
tempFields.sort(function (a, b) { return a.Order - b.Order; });
|
|
1653
|
-
|
|
1660
|
+
_b.label = 32;
|
|
1654
1661
|
case 32: return [2 /*return*/];
|
|
1655
1662
|
}
|
|
1656
1663
|
});
|
|
@@ -1672,12 +1679,12 @@ var DynamicFormBase = /** @class */ (function (_super) {
|
|
|
1672
1679
|
});
|
|
1673
1680
|
});
|
|
1674
1681
|
};
|
|
1675
|
-
DynamicFormBase.prototype.cultureNameLookup = function (lcid) {
|
|
1676
|
-
var _a, _b;
|
|
1677
|
-
var pageCulture =
|
|
1682
|
+
DynamicFormBase.prototype.cultureNameLookup = function (lcid, loadContext) {
|
|
1683
|
+
var _a, _b, _c;
|
|
1684
|
+
var pageCulture = loadContext.props.context.pageContext.cultureInfo.currentCultureName;
|
|
1678
1685
|
if (!lcid)
|
|
1679
1686
|
return pageCulture;
|
|
1680
|
-
return (_b = (_a =
|
|
1687
|
+
return (_c = (_b = (_a = loadContext.installedLanguages) === null || _a === void 0 ? void 0 : _a.find(function (lang) { return lang.Lcid === lcid; })) === null || _b === void 0 ? void 0 : _b.DisplayName) !== null && _c !== void 0 ? _c : pageCulture;
|
|
1681
1688
|
};
|
|
1682
1689
|
return DynamicFormBase;
|
|
1683
1690
|
}(React.Component));
|