dattatable 2.11.30 → 2.11.32
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/build/common/list.js +2 -2
- package/build/common/listCfg.js +43 -5
- package/dist/dattatable.js +2 -2
- package/dist/dattatable.min.js +1 -1
- package/docs/classes/Accordion.html +2 -2
- package/docs/classes/AuditLog.html +2 -2
- package/docs/classes/CanvasForm.html +2 -2
- package/docs/classes/Comments.html +2 -2
- package/docs/classes/Dashboard.html +4 -4
- package/docs/classes/DataTable.html +3 -3
- package/docs/classes/Documents.html +6 -6
- package/docs/classes/FilterSlideout.html +2 -2
- package/docs/classes/Footer.html +2 -2
- package/docs/classes/Header.html +2 -2
- package/docs/classes/InstallationRequired.html +2 -2
- package/docs/classes/ItemForm.html +4 -4
- package/docs/classes/List.html +4 -4
- package/docs/classes/ListConfig.html +2 -2
- package/docs/classes/ListSecurity.html +2 -2
- package/docs/classes/LoadingDialog.html +2 -2
- package/docs/classes/Modal.html +2 -2
- package/docs/classes/Navigation.html +3 -3
- package/docs/classes/Tiles.html +2 -2
- package/docs/classes/Timeout.html +2 -2
- package/docs/enums/ActionButtonTypes.html +2 -2
- package/docs/functions/formatBytes.html +1 -1
- package/docs/functions/formatDateValue.html +1 -1
- package/docs/functions/formatTimeValue.html +1 -1
- package/docs/functions/getContextInfo.html +1 -1
- package/docs/functions/getFileExt.html +1 -1
- package/docs/functions/waitForTheme.html +1 -1
- package/docs/interfaces/IAccordion.html +2 -2
- package/docs/interfaces/IAccordionProps.html +2 -2
- package/docs/interfaces/IAuditLogItem.html +2 -2
- package/docs/interfaces/IAuditLogItemCreation.html +2 -2
- package/docs/interfaces/IAuditLogProps.html +2 -2
- package/docs/interfaces/IAuditLogViewProps.html +2 -2
- package/docs/interfaces/ICommentsItem.html +2 -2
- package/docs/interfaces/ICreateLookupData.html +2 -2
- package/docs/interfaces/IDashboardProps.html +2 -2
- package/docs/interfaces/IDataTable.html +2 -2
- package/docs/interfaces/IDataTableProps.html +2 -2
- package/docs/interfaces/IDocumentsProps.html +2 -2
- package/docs/interfaces/IFilterItem.html +2 -2
- package/docs/interfaces/IFilterProps.html +2 -2
- package/docs/interfaces/IFooterProps.html +2 -2
- package/docs/interfaces/IGenerateLookupDataProps.html +2 -2
- package/docs/interfaces/IHeaderProps.html +2 -2
- package/docs/interfaces/IInstallProps.html +2 -2
- package/docs/interfaces/IItemFormCreateProps.html +2 -2
- package/docs/interfaces/IItemFormEditProps.html +2 -2
- package/docs/interfaces/IItemFormSaveProps.html +2 -2
- package/docs/interfaces/IItemFormTab.html +2 -2
- package/docs/interfaces/IItemFormTabInfo.html +2 -2
- package/docs/interfaces/IItemFormViewProps.html +2 -2
- package/docs/interfaces/IListConfig.html +2 -2
- package/docs/interfaces/IListConfigProps.html +2 -2
- package/docs/interfaces/IListProps.html +2 -2
- package/docs/interfaces/IListSecurity.html +2 -2
- package/docs/interfaces/IListSecurityItem.html +2 -2
- package/docs/interfaces/ILookupData.html +2 -2
- package/docs/interfaces/IShowDialogProps.html +2 -2
- package/docs/interfaces/ITiles.html +2 -2
- package/docs/interfaces/ITilesProps.html +2 -2
- package/docs/interfaces/IValidateLookupsProps.html +2 -2
- package/docs/variables/DattaTable.html +1 -1
- package/docs/variables/ListSecurityDefaultGroups.html +1 -1
- package/package.json +54 -54
package/build/common/list.js
CHANGED
|
@@ -289,7 +289,7 @@ var List = /** @class */ (function () {
|
|
|
289
289
|
// Get the versions for this item
|
|
290
290
|
item["Versions"]().execute(function (versions) {
|
|
291
291
|
// Parse the versions
|
|
292
|
-
for (var i = 0; i < versions.results.length
|
|
292
|
+
for (var i = 0; i < versions.results.length; i++) {
|
|
293
293
|
var version = versions.results[i];
|
|
294
294
|
var prevVersion = versions.results[i + 1];
|
|
295
295
|
var versionId = version.VersionLabel;
|
|
@@ -305,7 +305,7 @@ var List = /** @class */ (function () {
|
|
|
305
305
|
for (var j = 0; j < _this.ListFields.length; j++) {
|
|
306
306
|
var field = _this.ListFields[j];
|
|
307
307
|
var value = version[field.InternalName] || version[field.InternalName + "Id"];
|
|
308
|
-
var prevValue = prevVersion[field.InternalName] || prevVersion[field.InternalName + "Id"];
|
|
308
|
+
var prevValue = prevVersion ? prevVersion[field.InternalName] || prevVersion[field.InternalName + "Id"] : null;
|
|
309
309
|
// Skip the default properties
|
|
310
310
|
if (defaultFields.indexOf(field.InternalName) >= 0) {
|
|
311
311
|
continue;
|
package/build/common/listCfg.js
CHANGED
|
@@ -111,8 +111,8 @@ var ListConfig = /** @class */ (function () {
|
|
|
111
111
|
loadingDialog_1.LoadingDialog.setHeader("Validating Custom Formatters");
|
|
112
112
|
loadingDialog_1.LoadingDialog.setBody("Getting the list '" + listName + "' information...");
|
|
113
113
|
loadingDialog_1.LoadingDialog.show();
|
|
114
|
-
// Load the list
|
|
115
|
-
(0, gd_sprest_bs_1.Web)(webUrl).Lists(listName).query({ Expand: ["ContentTypes", "Views"], Select: ["Id"] }).execute(function (list) {
|
|
114
|
+
// Load the list information
|
|
115
|
+
(0, gd_sprest_bs_1.Web)(webUrl).Lists(listName).query({ Expand: ["ContentTypes", "Fields", "Views"], Select: ["Id"] }).execute(function (list) {
|
|
116
116
|
// Parse the content types
|
|
117
117
|
gd_sprest_bs_1.Helper.Executor(list.ContentTypes.results, function (ct) {
|
|
118
118
|
// See if the custom formatter exists and needs the list id
|
|
@@ -130,7 +130,7 @@ var ListConfig = /** @class */ (function () {
|
|
|
130
130
|
}).execute(resolve, function () {
|
|
131
131
|
// Log the error
|
|
132
132
|
console.error("Error updating the custom formatter for the content type: " + ct.Name);
|
|
133
|
-
// Check the next
|
|
133
|
+
// Check the next content type
|
|
134
134
|
resolve(null);
|
|
135
135
|
});
|
|
136
136
|
});
|
|
@@ -153,12 +153,36 @@ var ListConfig = /** @class */ (function () {
|
|
|
153
153
|
}).execute(resolve, function () {
|
|
154
154
|
// Log the error
|
|
155
155
|
console.error("Error updating the custom formatter for the view: " + view.Title);
|
|
156
|
-
// Check the next
|
|
156
|
+
// Check the next view
|
|
157
157
|
resolve(null);
|
|
158
158
|
});
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
}).then(
|
|
161
|
+
}).then(function () {
|
|
162
|
+
// Parse the views
|
|
163
|
+
gd_sprest_bs_1.Helper.Executor(list.Fields.results, function (field) {
|
|
164
|
+
// See if the custom formatter exists and needs the list id
|
|
165
|
+
if (field.SchemaXml && field.SchemaXml.indexOf("[[ListId]]") >= 0) {
|
|
166
|
+
// Return a promise
|
|
167
|
+
return new Promise(function (resolve) {
|
|
168
|
+
var schemaXml = field.SchemaXml;
|
|
169
|
+
// Replace the list id
|
|
170
|
+
while (schemaXml.indexOf("[[ListId]]") >= 0) {
|
|
171
|
+
schemaXml = schemaXml.replace("[[ListId]]", list.Id);
|
|
172
|
+
}
|
|
173
|
+
// Update the content type
|
|
174
|
+
field.update({
|
|
175
|
+
SchemaXml: schemaXml
|
|
176
|
+
}).execute(resolve, function () {
|
|
177
|
+
// Log the error
|
|
178
|
+
console.error("Error updating the custom formatter for the field: " + field.InternalName);
|
|
179
|
+
// Check the next field
|
|
180
|
+
resolve(null);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}).then(resolve, reject);
|
|
185
|
+
}, reject);
|
|
162
186
|
}, reject);
|
|
163
187
|
}, reject);
|
|
164
188
|
});
|
|
@@ -315,6 +339,13 @@ var ListConfig = /** @class */ (function () {
|
|
|
315
339
|
}
|
|
316
340
|
// Else, ensure the field hasn't been added
|
|
317
341
|
else if (fields[field.InternalName] == null) {
|
|
342
|
+
// Replace the source list id in the JSON config
|
|
343
|
+
var schemaXml = field.SchemaXml;
|
|
344
|
+
if (schemaXml) {
|
|
345
|
+
while (schemaXml.indexOf(list.ListId) >= 0) {
|
|
346
|
+
schemaXml = schemaXml.replace(list.ListId, "[[ListId]]");
|
|
347
|
+
}
|
|
348
|
+
}
|
|
318
349
|
// Add the field information
|
|
319
350
|
fields[field.InternalName] = true;
|
|
320
351
|
cfgProps.ListCfg[0].CustomFields.push({
|
|
@@ -367,6 +398,13 @@ var ListConfig = /** @class */ (function () {
|
|
|
367
398
|
mmsFields[field.InternalName] = field;
|
|
368
399
|
}
|
|
369
400
|
else {
|
|
401
|
+
// Replace the source list id in the JSON config
|
|
402
|
+
var schemaXml = field.SchemaXml;
|
|
403
|
+
if (schemaXml) {
|
|
404
|
+
while (schemaXml.indexOf(list.ListId) >= 0) {
|
|
405
|
+
schemaXml = schemaXml.replace(list.ListId, "[[ListId]]");
|
|
406
|
+
}
|
|
407
|
+
}
|
|
370
408
|
// Append the field
|
|
371
409
|
fields[field.InternalName] = true;
|
|
372
410
|
cfgProps.ListCfg[0].CustomFields.push({
|
package/dist/dattatable.js
CHANGED
|
@@ -104,7 +104,7 @@ eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assig
|
|
|
104
104
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
105
105
|
|
|
106
106
|
"use strict";
|
|
107
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.List = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.12.70/node_modules/gd-sprest-bs/build/index.js\");\r\nvar _1 = __webpack_require__(/*! . */ \"./build/common/index.js\");\r\n/**\r\n * List\r\n */\r\nvar List = /** @class */ (function () {\r\n // Constructor\r\n function List(props) {\r\n var _this = this;\r\n /** Public Properties */\r\n // CAML query\r\n this._camlQuery = null;\r\n // List Content Types Information\r\n this._listContentTypes = null;\r\n // List Fields Information\r\n this._listFields = null;\r\n // List Information\r\n this._listInfo = null;\r\n // List Url\r\n this._listUrl = null;\r\n // List Views Information\r\n this._listViews = null;\r\n // Items\r\n this._items = null;\r\n // List Id\r\n this._listId = null;\r\n // List Name\r\n this._listName = null;\r\n // OData query\r\n this._odata = null;\r\n // View name\r\n this._viewName = null;\r\n // View Xml\r\n this._viewXml = null;\r\n // Web Url\r\n this._webUrl = null;\r\n /** Private Properties */\r\n // Base Permissions\r\n this._basePermissions = null;\r\n // Error event when loading the items fail\r\n this._onInitError = null;\r\n // Event triggered when the component is initialized\r\n this._onInitialized = null;\r\n // Items loading event\r\n this._onItemLoading = null;\r\n // Items loaded event\r\n this._onItemsLoaded = null;\r\n // Error event when loading a form\r\n this._onLoadFormError = null;\r\n // Refresh event when refreshing the items\r\n this._onRefreshItems = null;\r\n // Event triggered when the form is reset\r\n this._onResetForm = null;\r\n // The request digest value of the target site\r\n this._requestDigest = null;\r\n // Save the properties\r\n this._camlQuery = props.camlQuery;\r\n this._listId = props.listId;\r\n this._listName = props.listName;\r\n this._odata = props.itemQuery;\r\n this._onInitError = props.onInitError;\r\n this._onInitialized = props.onInitialized;\r\n this._onItemLoading = props.onItemLoading;\r\n this._onItemsLoaded = props.onItemsLoaded;\r\n this._onLoadFormError = props.onLoadFormError;\r\n this._onRefreshItems = props.onRefreshItems;\r\n this._onResetForm = props.onResetForm;\r\n this._viewName = props.viewName;\r\n this._webUrl = props.webUrl || gd_sprest_bs_1.ContextInfo.webServerRelativeUrl;\r\n // Set the context information\r\n (0, _1.getContextInfo)(props.webUrl).then(function (requestDigest) {\r\n _this._requestDigest = requestDigest;\r\n // Load the list information\r\n _this.init().then(function () {\r\n // Load the items\r\n _this.loadItems().then(function () {\r\n // Call the event\r\n _this._onInitialized ? _this._onInitialized() : null;\r\n // Call the items loaded event\r\n _this._onItemsLoaded ? _this._onItemsLoaded(_this.Items) : null;\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }\r\n Object.defineProperty(List.prototype, \"CAMLQuery\", {\r\n get: function () { return this._camlQuery; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"CanAddEditItems\", {\r\n // Flag to determine if the user can add/edit items to the list\r\n get: function () {\r\n return this.hasPermissions([\r\n gd_sprest_bs_1.SPTypes.BasePermissionTypes.AddListItems,\r\n gd_sprest_bs_1.SPTypes.BasePermissionTypes.EditListItems\r\n ]);\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"CanDeleteItems\", {\r\n // Flag to determine if the user can delete items to the list\r\n get: function () {\r\n return this.hasPermissions(gd_sprest_bs_1.SPTypes.BasePermissionTypes.DeleteListItems);\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"CanViewItems\", {\r\n // Flag to determine if the user can view items to the list \r\n get: function () {\r\n return this.hasPermissions(gd_sprest_bs_1.SPTypes.BasePermissionTypes.ViewListItems);\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"EditForm\", {\r\n // Reference to the edit form\r\n get: function () { return _1.ItemForm.EditForm; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"EditForms\", {\r\n // Reference to the edit forms, if tabs are used\r\n get: function () { return _1.ItemForm.EditForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListContentTypes\", {\r\n get: function () { return this._listContentTypes; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListFields\", {\r\n get: function () { return this._listFields; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListInfo\", {\r\n get: function () { return this._listInfo; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListSettingsUrl\", {\r\n // List Settings Url\r\n get: function () { return \"\".concat(this.WebUrl, \"/\").concat(gd_sprest_bs_1.ContextInfo.layoutsUrl, \"/listedit.aspx?List=\").concat(this.ListInfo.Id); },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListUrl\", {\r\n get: function () { return this._listUrl; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListViews\", {\r\n get: function () { return this._listViews; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"Items\", {\r\n get: function () { return this._items; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListId\", {\r\n get: function () { return this._listId; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListName\", {\r\n get: function () { return this._listName; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"OData\", {\r\n get: function () { return this._odata; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewForm\", {\r\n // Reference to the display form\r\n get: function () { return _1.ItemForm.DisplayForm; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewForms\", {\r\n // Reference to the display forms, if tabs are used\r\n get: function () { return _1.ItemForm.DisplayForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewName\", {\r\n get: function () { return this._viewName; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewXml\", {\r\n get: function () { return this._viewXml; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"WebUrl\", {\r\n get: function () { return this._webUrl; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Clears the modal or canvas\r\n List.prototype.clear = function (props) {\r\n // Ensure we are not rendering to a specified element\r\n if (props.elForm == null) {\r\n // Clear the modal/form\r\n var useModal = typeof (props.useModal) === \"boolean\" ? props.useModal : _1.ItemForm.UseModal;\r\n useModal ? _1.Modal.clear() : _1.CanvasForm.clear();\r\n }\r\n // Set the list name\r\n _1.ItemForm.ListName = this.ListName;\r\n // Call the event\r\n this._onResetForm ? this._onResetForm() : null;\r\n };\r\n // Reference to the create item method\r\n List.prototype.createItem = function (values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Create the item\r\n _this.ListInfo.Items().add(values).execute(resolve, reject);\r\n });\r\n };\r\n // Deletes the item and removes it from the internal items array\r\n List.prototype.deleteItem = function (itemId) {\r\n var _this = this;\r\n // Parse the items\r\n for (var i = 0; i < this.Items.length; i++) {\r\n var item = this.Items[i];\r\n // See if this is the target item\r\n if (item[\"Id\"] == itemId || item[\"ID\"] == itemId) {\r\n // Remove the item\r\n this.Items.splice(i, 1);\r\n break;\r\n }\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Delete the item\r\n _this.ListInfo.Items(itemId).delete().execute(resolve, reject);\r\n });\r\n };\r\n // Displays the edit form\r\n List.prototype.editForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear(props);\r\n // Display the form\r\n _1.ItemForm.edit(props).then(null, this._onLoadFormError);\r\n };\r\n // Gets the changes for a list item's version history\r\n List.prototype.getChanges = function (id, defaultFields) {\r\n var _this = this;\r\n if (defaultFields === void 0) { defaultFields = []; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var changes = {};\r\n // Get the item\r\n var item = _this.getItem(id);\r\n if (item) {\r\n // Get the versions for this item\r\n item[\"Versions\"]().execute(function (versions) {\r\n // Parse the versions\r\n for (var i = 0; i < versions.results.length - 1; i++) {\r\n var version = versions.results[i];\r\n var prevVersion = versions.results[i + 1];\r\n var versionId = version.VersionLabel;\r\n // Set the change object\r\n changes[versionId] = {};\r\n // Set the default properties\r\n for (var i_1 = 0; i_1 < defaultFields.length; i_1++) {\r\n var defaultField = defaultFields[i_1];\r\n // Set the default value\r\n changes[versionId][defaultField] = version[defaultField];\r\n }\r\n // Parse the list fields\r\n for (var j = 0; j < _this.ListFields.length; j++) {\r\n var field = _this.ListFields[j];\r\n var value = version[field.InternalName] || version[field.InternalName + \"Id\"];\r\n var prevValue = prevVersion[field.InternalName] || prevVersion[field.InternalName + \"Id\"];\r\n // Skip the default properties\r\n if (defaultFields.indexOf(field.InternalName) >= 0) {\r\n continue;\r\n }\r\n // Skip functions\r\n if (typeof (value) === \"function\") {\r\n continue;\r\n }\r\n // Try to convert the values to a string\r\n try {\r\n if (JSON.stringify(value) != JSON.stringify(prevValue)) {\r\n // Append the change\r\n changes[versionId][field.InternalName] = value;\r\n }\r\n }\r\n // Skip this property on error\r\n catch (_a) { }\r\n }\r\n }\r\n // Resolve the request\r\n resolve(changes);\r\n }, reject);\r\n }\r\n });\r\n };\r\n // Gets a list field by internal or title\r\n List.prototype.getField = function (name) {\r\n var titleField = null;\r\n // Parse the fields\r\n for (var i = 0; i < this.ListFields.length; i++) {\r\n var field = this.ListFields[i];\r\n // Try to find the field by internal name first\r\n if (field.InternalName == name) {\r\n // Return the field if we match by internal\r\n return field;\r\n }\r\n // Else, see if the title field matches and save a reference\r\n else if (field.Title == name) {\r\n // Save the field reference\r\n titleField = field;\r\n }\r\n }\r\n // Return the title field if it was found\r\n return titleField;\r\n };\r\n // Gets a list field by internal or title\r\n List.prototype.getFieldById = function (id) {\r\n if (id === void 0) { id = \"\"; }\r\n var fieldId = id.replace(/{|}/g, '');\r\n // Parse the fields\r\n for (var i = 0; i < this.ListFields.length; i++) {\r\n var field = this.ListFields[i];\r\n // See if this is the target field\r\n if (field.Id == fieldId) {\r\n // Return the field if we match by internal\r\n return field;\r\n }\r\n }\r\n // Not found\r\n return null;\r\n };\r\n // Gets a list item by id\r\n List.prototype.getItem = function (id) {\r\n // Parse the items\r\n for (var i = 0; i < this.Items.length; i++) {\r\n var item = this.Items[i];\r\n // See if this is the target item\r\n if (item[\"Id\"] == id || item[\"ID\"] == id) {\r\n // Return the item\r\n return item;\r\n }\r\n }\r\n // Not found\r\n return null;\r\n };\r\n // Determines if the user has permissions to the list\r\n List.prototype.hasPermissions = function (permissions) {\r\n // See if the user has permissions\r\n return gd_sprest_bs_1.Helper.hasPermissions(this._basePermissions, permissions);\r\n };\r\n // Initializes the list component\r\n List.prototype.init = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Set the web\r\n var web = (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n });\r\n // Get the list\r\n var list = _this.ListId ? web.Lists().getById(_this.ListId) : web.Lists(_this.ListName);\r\n // Query the list content types\r\n list.execute(function (list) {\r\n // Set the list id/name\r\n _this._listId = list.Id;\r\n _this._listName = list.Title;\r\n // Save the list information\r\n _this._listInfo = list;\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n });\r\n // Get the user permissions for this list\r\n list.query({ Expand: [\"EffectiveBasePermissions\"] }).execute(function (list) {\r\n _this._basePermissions = list.EffectiveBasePermissions;\r\n });\r\n // Get the root folder\r\n list.RootFolder().execute(function (folder) {\r\n // Set the url\r\n _this._listUrl = folder.ServerRelativeUrl;\r\n }, true);\r\n // Query the content types\r\n list.ContentTypes().query({\r\n Expand: [\"FieldLinks\", \"Fields\", \"Parent\"]\r\n }).execute(function (cts) {\r\n // Save the content types\r\n _this._listContentTypes = cts.results;\r\n }, true);\r\n // Query the list fields\r\n list.Fields().execute(function (fields) {\r\n // Save the fields\r\n _this._listFields = fields.results;\r\n }, true);\r\n // Query the list views\r\n list.Views().query({\r\n Expand: [\"ViewFields\"]\r\n }).execute(function (views) {\r\n // Save the views\r\n _this._listViews = views.results;\r\n }, true);\r\n // Wait for the requests to complete\r\n list.done(function () {\r\n // See if the view name is specified\r\n if (_this.ViewName) {\r\n // Parse the views\r\n for (var i = 0; i < _this.ListViews.length; i++) {\r\n var view = _this.ListViews[i];\r\n if (view.Title.toLowerCase() == _this.ViewName.toLowerCase()) {\r\n // Set the view xml\r\n _this._viewXml = view.ListViewXml;\r\n }\r\n }\r\n }\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Loads the items\r\n List.prototype.loadItem = function (itemId, query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n }).Lists(_this.ListName).Items(itemId).query({\r\n Custom: query ? query.Custom : null,\r\n Expand: query ? query.Expand : null,\r\n Select: query ? query.Select : null\r\n }).execute(function (newItem) {\r\n var itemFound = false;\r\n // Parse the items\r\n for (var i = 0; i < _this._items.length; i++) {\r\n var item = _this._items[i];\r\n // See if this is the item\r\n if (itemId == item.Id) {\r\n // Call the event\r\n _this._onItemLoading ? _this._onItemLoading(newItem) : null;\r\n // Replace the item\r\n _this._items[i] = newItem;\r\n // Set the flag and break from the loop\r\n itemFound = true;\r\n break;\r\n }\r\n }\r\n // See if the item wasn't found\r\n if (!itemFound) {\r\n // Append the item\r\n _this._items.push(newItem);\r\n }\r\n // Resolve the request\r\n resolve(newItem);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items\r\n List.prototype.loadItems = function (query) {\r\n // See if the caml query exists\r\n if (this.CAMLQuery) {\r\n return this.loadItemsByCAMLQuery();\r\n }\r\n // Else, see if the view xml exists\r\n else if (this.ViewXml) {\r\n // Get the items by the view name\r\n return this.loadItemsByView();\r\n }\r\n else {\r\n // Get the items by odata\r\n return this.loadItemsByQuery(query);\r\n }\r\n };\r\n // Loads the items by CAML query\r\n List.prototype.loadItemsByCAMLQuery = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items already exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n }).Lists(_this.ListName).getItemsByQuery(_this.CAMLQuery).execute(function (items) {\r\n // See if the event exists\r\n if (_this._onItemLoading) {\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n // Call the event\r\n _this._onItemLoading(items.results[i]);\r\n }\r\n }\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items by odata query\r\n List.prototype.loadItemsByQuery = function (query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName).Items().query(query).execute(function (items) {\r\n // See if the event exists\r\n if (_this._onItemLoading) {\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n // Call the event\r\n _this._onItemLoading(items.results[i]);\r\n }\r\n }\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items by view name\r\n List.prototype.loadItemsByView = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items already exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n }).Lists(_this.ListName).getItems(_this.ViewXml).execute(function (items) {\r\n // See if the event exists\r\n if (_this._onItemLoading) {\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n // Call the event\r\n _this._onItemLoading(items.results[i]);\r\n }\r\n }\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Displays the new form\r\n List.prototype.newForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear(props);\r\n // Display the form\r\n _1.ItemForm.create(props).then(null, this._onLoadFormError);\r\n };\r\n // Refresh the data\r\n List.prototype.refresh = function (query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Clear the items\r\n this._items = null;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Refresh the context information\r\n _this.refreshContextInfo().then(function () {\r\n // Load the data\r\n _this.loadItems(query).then(function (items) {\r\n // Call the event\r\n var callback = _this._onRefreshItems ? _this._onRefreshItems(items) : null;\r\n if (callback && typeof (callback.then) === \"function\") {\r\n // Wait for the request to complete\r\n callback.then(resolve, reject);\r\n }\r\n else {\r\n // Resolve the request\r\n resolve(items);\r\n }\r\n }, reject);\r\n }, reject);\r\n });\r\n };\r\n // Refreshes the context information\r\n List.prototype.refreshContextInfo = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the request digest is set\r\n if (_this._requestDigest) {\r\n // Get the context information\r\n (0, _1.getContextInfo)(_this.WebUrl).then(function (requestDigest) {\r\n // Save the value and resolve the request\r\n _this._requestDigest = requestDigest;\r\n resolve();\r\n }, reject);\r\n }\r\n else {\r\n // Resolve the request\r\n resolve();\r\n }\r\n });\r\n };\r\n // Refresh the data\r\n List.prototype.refreshItem = function (itemId, query) {\r\n if (query === void 0) { query = this.OData; }\r\n // Load the item\r\n return this.loadItem(itemId, query);\r\n };\r\n // Saves the item with an option to bypass validation\r\n List.prototype.save = function (bypassValidation) {\r\n // Save the item\r\n return _1.ItemForm.save({ bypassValidation: bypassValidation });\r\n };\r\n // Updates an item\r\n List.prototype.updateItem = function (itemId, values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Create the item\r\n _this.ListInfo.Items(itemId).update(values).execute(resolve, reject);\r\n });\r\n };\r\n // Displays the view form\r\n List.prototype.viewForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear(props);\r\n // Display the form\r\n _1.ItemForm.view(props).then(null, this._onLoadFormError);\r\n };\r\n return List;\r\n}());\r\nexports.List = List;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/list.js?");
|
|
107
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.List = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.12.70/node_modules/gd-sprest-bs/build/index.js\");\r\nvar _1 = __webpack_require__(/*! . */ \"./build/common/index.js\");\r\n/**\r\n * List\r\n */\r\nvar List = /** @class */ (function () {\r\n // Constructor\r\n function List(props) {\r\n var _this = this;\r\n /** Public Properties */\r\n // CAML query\r\n this._camlQuery = null;\r\n // List Content Types Information\r\n this._listContentTypes = null;\r\n // List Fields Information\r\n this._listFields = null;\r\n // List Information\r\n this._listInfo = null;\r\n // List Url\r\n this._listUrl = null;\r\n // List Views Information\r\n this._listViews = null;\r\n // Items\r\n this._items = null;\r\n // List Id\r\n this._listId = null;\r\n // List Name\r\n this._listName = null;\r\n // OData query\r\n this._odata = null;\r\n // View name\r\n this._viewName = null;\r\n // View Xml\r\n this._viewXml = null;\r\n // Web Url\r\n this._webUrl = null;\r\n /** Private Properties */\r\n // Base Permissions\r\n this._basePermissions = null;\r\n // Error event when loading the items fail\r\n this._onInitError = null;\r\n // Event triggered when the component is initialized\r\n this._onInitialized = null;\r\n // Items loading event\r\n this._onItemLoading = null;\r\n // Items loaded event\r\n this._onItemsLoaded = null;\r\n // Error event when loading a form\r\n this._onLoadFormError = null;\r\n // Refresh event when refreshing the items\r\n this._onRefreshItems = null;\r\n // Event triggered when the form is reset\r\n this._onResetForm = null;\r\n // The request digest value of the target site\r\n this._requestDigest = null;\r\n // Save the properties\r\n this._camlQuery = props.camlQuery;\r\n this._listId = props.listId;\r\n this._listName = props.listName;\r\n this._odata = props.itemQuery;\r\n this._onInitError = props.onInitError;\r\n this._onInitialized = props.onInitialized;\r\n this._onItemLoading = props.onItemLoading;\r\n this._onItemsLoaded = props.onItemsLoaded;\r\n this._onLoadFormError = props.onLoadFormError;\r\n this._onRefreshItems = props.onRefreshItems;\r\n this._onResetForm = props.onResetForm;\r\n this._viewName = props.viewName;\r\n this._webUrl = props.webUrl || gd_sprest_bs_1.ContextInfo.webServerRelativeUrl;\r\n // Set the context information\r\n (0, _1.getContextInfo)(props.webUrl).then(function (requestDigest) {\r\n _this._requestDigest = requestDigest;\r\n // Load the list information\r\n _this.init().then(function () {\r\n // Load the items\r\n _this.loadItems().then(function () {\r\n // Call the event\r\n _this._onInitialized ? _this._onInitialized() : null;\r\n // Call the items loaded event\r\n _this._onItemsLoaded ? _this._onItemsLoaded(_this.Items) : null;\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }\r\n Object.defineProperty(List.prototype, \"CAMLQuery\", {\r\n get: function () { return this._camlQuery; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"CanAddEditItems\", {\r\n // Flag to determine if the user can add/edit items to the list\r\n get: function () {\r\n return this.hasPermissions([\r\n gd_sprest_bs_1.SPTypes.BasePermissionTypes.AddListItems,\r\n gd_sprest_bs_1.SPTypes.BasePermissionTypes.EditListItems\r\n ]);\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"CanDeleteItems\", {\r\n // Flag to determine if the user can delete items to the list\r\n get: function () {\r\n return this.hasPermissions(gd_sprest_bs_1.SPTypes.BasePermissionTypes.DeleteListItems);\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"CanViewItems\", {\r\n // Flag to determine if the user can view items to the list \r\n get: function () {\r\n return this.hasPermissions(gd_sprest_bs_1.SPTypes.BasePermissionTypes.ViewListItems);\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"EditForm\", {\r\n // Reference to the edit form\r\n get: function () { return _1.ItemForm.EditForm; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"EditForms\", {\r\n // Reference to the edit forms, if tabs are used\r\n get: function () { return _1.ItemForm.EditForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListContentTypes\", {\r\n get: function () { return this._listContentTypes; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListFields\", {\r\n get: function () { return this._listFields; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListInfo\", {\r\n get: function () { return this._listInfo; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListSettingsUrl\", {\r\n // List Settings Url\r\n get: function () { return \"\".concat(this.WebUrl, \"/\").concat(gd_sprest_bs_1.ContextInfo.layoutsUrl, \"/listedit.aspx?List=\").concat(this.ListInfo.Id); },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListUrl\", {\r\n get: function () { return this._listUrl; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListViews\", {\r\n get: function () { return this._listViews; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"Items\", {\r\n get: function () { return this._items; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListId\", {\r\n get: function () { return this._listId; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListName\", {\r\n get: function () { return this._listName; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"OData\", {\r\n get: function () { return this._odata; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewForm\", {\r\n // Reference to the display form\r\n get: function () { return _1.ItemForm.DisplayForm; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewForms\", {\r\n // Reference to the display forms, if tabs are used\r\n get: function () { return _1.ItemForm.DisplayForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewName\", {\r\n get: function () { return this._viewName; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewXml\", {\r\n get: function () { return this._viewXml; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"WebUrl\", {\r\n get: function () { return this._webUrl; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Clears the modal or canvas\r\n List.prototype.clear = function (props) {\r\n // Ensure we are not rendering to a specified element\r\n if (props.elForm == null) {\r\n // Clear the modal/form\r\n var useModal = typeof (props.useModal) === \"boolean\" ? props.useModal : _1.ItemForm.UseModal;\r\n useModal ? _1.Modal.clear() : _1.CanvasForm.clear();\r\n }\r\n // Set the list name\r\n _1.ItemForm.ListName = this.ListName;\r\n // Call the event\r\n this._onResetForm ? this._onResetForm() : null;\r\n };\r\n // Reference to the create item method\r\n List.prototype.createItem = function (values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Create the item\r\n _this.ListInfo.Items().add(values).execute(resolve, reject);\r\n });\r\n };\r\n // Deletes the item and removes it from the internal items array\r\n List.prototype.deleteItem = function (itemId) {\r\n var _this = this;\r\n // Parse the items\r\n for (var i = 0; i < this.Items.length; i++) {\r\n var item = this.Items[i];\r\n // See if this is the target item\r\n if (item[\"Id\"] == itemId || item[\"ID\"] == itemId) {\r\n // Remove the item\r\n this.Items.splice(i, 1);\r\n break;\r\n }\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Delete the item\r\n _this.ListInfo.Items(itemId).delete().execute(resolve, reject);\r\n });\r\n };\r\n // Displays the edit form\r\n List.prototype.editForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear(props);\r\n // Display the form\r\n _1.ItemForm.edit(props).then(null, this._onLoadFormError);\r\n };\r\n // Gets the changes for a list item's version history\r\n List.prototype.getChanges = function (id, defaultFields) {\r\n var _this = this;\r\n if (defaultFields === void 0) { defaultFields = []; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var changes = {};\r\n // Get the item\r\n var item = _this.getItem(id);\r\n if (item) {\r\n // Get the versions for this item\r\n item[\"Versions\"]().execute(function (versions) {\r\n // Parse the versions\r\n for (var i = 0; i < versions.results.length; i++) {\r\n var version = versions.results[i];\r\n var prevVersion = versions.results[i + 1];\r\n var versionId = version.VersionLabel;\r\n // Set the change object\r\n changes[versionId] = {};\r\n // Set the default properties\r\n for (var i_1 = 0; i_1 < defaultFields.length; i_1++) {\r\n var defaultField = defaultFields[i_1];\r\n // Set the default value\r\n changes[versionId][defaultField] = version[defaultField];\r\n }\r\n // Parse the list fields\r\n for (var j = 0; j < _this.ListFields.length; j++) {\r\n var field = _this.ListFields[j];\r\n var value = version[field.InternalName] || version[field.InternalName + \"Id\"];\r\n var prevValue = prevVersion ? prevVersion[field.InternalName] || prevVersion[field.InternalName + \"Id\"] : null;\r\n // Skip the default properties\r\n if (defaultFields.indexOf(field.InternalName) >= 0) {\r\n continue;\r\n }\r\n // Skip functions\r\n if (typeof (value) === \"function\") {\r\n continue;\r\n }\r\n // Try to convert the values to a string\r\n try {\r\n if (JSON.stringify(value) != JSON.stringify(prevValue)) {\r\n // Append the change\r\n changes[versionId][field.InternalName] = value;\r\n }\r\n }\r\n // Skip this property on error\r\n catch (_a) { }\r\n }\r\n }\r\n // Resolve the request\r\n resolve(changes);\r\n }, reject);\r\n }\r\n });\r\n };\r\n // Gets a list field by internal or title\r\n List.prototype.getField = function (name) {\r\n var titleField = null;\r\n // Parse the fields\r\n for (var i = 0; i < this.ListFields.length; i++) {\r\n var field = this.ListFields[i];\r\n // Try to find the field by internal name first\r\n if (field.InternalName == name) {\r\n // Return the field if we match by internal\r\n return field;\r\n }\r\n // Else, see if the title field matches and save a reference\r\n else if (field.Title == name) {\r\n // Save the field reference\r\n titleField = field;\r\n }\r\n }\r\n // Return the title field if it was found\r\n return titleField;\r\n };\r\n // Gets a list field by internal or title\r\n List.prototype.getFieldById = function (id) {\r\n if (id === void 0) { id = \"\"; }\r\n var fieldId = id.replace(/{|}/g, '');\r\n // Parse the fields\r\n for (var i = 0; i < this.ListFields.length; i++) {\r\n var field = this.ListFields[i];\r\n // See if this is the target field\r\n if (field.Id == fieldId) {\r\n // Return the field if we match by internal\r\n return field;\r\n }\r\n }\r\n // Not found\r\n return null;\r\n };\r\n // Gets a list item by id\r\n List.prototype.getItem = function (id) {\r\n // Parse the items\r\n for (var i = 0; i < this.Items.length; i++) {\r\n var item = this.Items[i];\r\n // See if this is the target item\r\n if (item[\"Id\"] == id || item[\"ID\"] == id) {\r\n // Return the item\r\n return item;\r\n }\r\n }\r\n // Not found\r\n return null;\r\n };\r\n // Determines if the user has permissions to the list\r\n List.prototype.hasPermissions = function (permissions) {\r\n // See if the user has permissions\r\n return gd_sprest_bs_1.Helper.hasPermissions(this._basePermissions, permissions);\r\n };\r\n // Initializes the list component\r\n List.prototype.init = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Set the web\r\n var web = (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n });\r\n // Get the list\r\n var list = _this.ListId ? web.Lists().getById(_this.ListId) : web.Lists(_this.ListName);\r\n // Query the list content types\r\n list.execute(function (list) {\r\n // Set the list id/name\r\n _this._listId = list.Id;\r\n _this._listName = list.Title;\r\n // Save the list information\r\n _this._listInfo = list;\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n });\r\n // Get the user permissions for this list\r\n list.query({ Expand: [\"EffectiveBasePermissions\"] }).execute(function (list) {\r\n _this._basePermissions = list.EffectiveBasePermissions;\r\n });\r\n // Get the root folder\r\n list.RootFolder().execute(function (folder) {\r\n // Set the url\r\n _this._listUrl = folder.ServerRelativeUrl;\r\n }, true);\r\n // Query the content types\r\n list.ContentTypes().query({\r\n Expand: [\"FieldLinks\", \"Fields\", \"Parent\"]\r\n }).execute(function (cts) {\r\n // Save the content types\r\n _this._listContentTypes = cts.results;\r\n }, true);\r\n // Query the list fields\r\n list.Fields().execute(function (fields) {\r\n // Save the fields\r\n _this._listFields = fields.results;\r\n }, true);\r\n // Query the list views\r\n list.Views().query({\r\n Expand: [\"ViewFields\"]\r\n }).execute(function (views) {\r\n // Save the views\r\n _this._listViews = views.results;\r\n }, true);\r\n // Wait for the requests to complete\r\n list.done(function () {\r\n // See if the view name is specified\r\n if (_this.ViewName) {\r\n // Parse the views\r\n for (var i = 0; i < _this.ListViews.length; i++) {\r\n var view = _this.ListViews[i];\r\n if (view.Title.toLowerCase() == _this.ViewName.toLowerCase()) {\r\n // Set the view xml\r\n _this._viewXml = view.ListViewXml;\r\n }\r\n }\r\n }\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Loads the items\r\n List.prototype.loadItem = function (itemId, query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n }).Lists(_this.ListName).Items(itemId).query({\r\n Custom: query ? query.Custom : null,\r\n Expand: query ? query.Expand : null,\r\n Select: query ? query.Select : null\r\n }).execute(function (newItem) {\r\n var itemFound = false;\r\n // Parse the items\r\n for (var i = 0; i < _this._items.length; i++) {\r\n var item = _this._items[i];\r\n // See if this is the item\r\n if (itemId == item.Id) {\r\n // Call the event\r\n _this._onItemLoading ? _this._onItemLoading(newItem) : null;\r\n // Replace the item\r\n _this._items[i] = newItem;\r\n // Set the flag and break from the loop\r\n itemFound = true;\r\n break;\r\n }\r\n }\r\n // See if the item wasn't found\r\n if (!itemFound) {\r\n // Append the item\r\n _this._items.push(newItem);\r\n }\r\n // Resolve the request\r\n resolve(newItem);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items\r\n List.prototype.loadItems = function (query) {\r\n // See if the caml query exists\r\n if (this.CAMLQuery) {\r\n return this.loadItemsByCAMLQuery();\r\n }\r\n // Else, see if the view xml exists\r\n else if (this.ViewXml) {\r\n // Get the items by the view name\r\n return this.loadItemsByView();\r\n }\r\n else {\r\n // Get the items by odata\r\n return this.loadItemsByQuery(query);\r\n }\r\n };\r\n // Loads the items by CAML query\r\n List.prototype.loadItemsByCAMLQuery = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items already exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n }).Lists(_this.ListName).getItemsByQuery(_this.CAMLQuery).execute(function (items) {\r\n // See if the event exists\r\n if (_this._onItemLoading) {\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n // Call the event\r\n _this._onItemLoading(items.results[i]);\r\n }\r\n }\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items by odata query\r\n List.prototype.loadItemsByQuery = function (query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName).Items().query(query).execute(function (items) {\r\n // See if the event exists\r\n if (_this._onItemLoading) {\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n // Call the event\r\n _this._onItemLoading(items.results[i]);\r\n }\r\n }\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items by view name\r\n List.prototype.loadItemsByView = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items already exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n }).Lists(_this.ListName).getItems(_this.ViewXml).execute(function (items) {\r\n // See if the event exists\r\n if (_this._onItemLoading) {\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n // Call the event\r\n _this._onItemLoading(items.results[i]);\r\n }\r\n }\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Displays the new form\r\n List.prototype.newForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear(props);\r\n // Display the form\r\n _1.ItemForm.create(props).then(null, this._onLoadFormError);\r\n };\r\n // Refresh the data\r\n List.prototype.refresh = function (query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Clear the items\r\n this._items = null;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Refresh the context information\r\n _this.refreshContextInfo().then(function () {\r\n // Load the data\r\n _this.loadItems(query).then(function (items) {\r\n // Call the event\r\n var callback = _this._onRefreshItems ? _this._onRefreshItems(items) : null;\r\n if (callback && typeof (callback.then) === \"function\") {\r\n // Wait for the request to complete\r\n callback.then(resolve, reject);\r\n }\r\n else {\r\n // Resolve the request\r\n resolve(items);\r\n }\r\n }, reject);\r\n }, reject);\r\n });\r\n };\r\n // Refreshes the context information\r\n List.prototype.refreshContextInfo = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the request digest is set\r\n if (_this._requestDigest) {\r\n // Get the context information\r\n (0, _1.getContextInfo)(_this.WebUrl).then(function (requestDigest) {\r\n // Save the value and resolve the request\r\n _this._requestDigest = requestDigest;\r\n resolve();\r\n }, reject);\r\n }\r\n else {\r\n // Resolve the request\r\n resolve();\r\n }\r\n });\r\n };\r\n // Refresh the data\r\n List.prototype.refreshItem = function (itemId, query) {\r\n if (query === void 0) { query = this.OData; }\r\n // Load the item\r\n return this.loadItem(itemId, query);\r\n };\r\n // Saves the item with an option to bypass validation\r\n List.prototype.save = function (bypassValidation) {\r\n // Save the item\r\n return _1.ItemForm.save({ bypassValidation: bypassValidation });\r\n };\r\n // Updates an item\r\n List.prototype.updateItem = function (itemId, values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Create the item\r\n _this.ListInfo.Items(itemId).update(values).execute(resolve, reject);\r\n });\r\n };\r\n // Displays the view form\r\n List.prototype.viewForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear(props);\r\n // Display the form\r\n _1.ItemForm.view(props).then(null, this._onLoadFormError);\r\n };\r\n return List;\r\n}());\r\nexports.List = List;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/list.js?");
|
|
108
108
|
|
|
109
109
|
/***/ }),
|
|
110
110
|
|
|
@@ -115,7 +115,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
115
115
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
116
116
|
|
|
117
117
|
"use strict";
|
|
118
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ListConfig = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.12.70/node_modules/gd-sprest-bs/build/index.js\");\r\nvar loadingDialog_1 = __webpack_require__(/*! ./loadingDialog */ \"./build/common/loadingDialog.js\");\r\nvar list_1 = __webpack_require__(/*! ./list */ \"./build/common/list.js\");\r\n/**\r\n * List Configuration Generator\r\n */\r\nvar ListConfig = /** @class */ (function () {\r\n function ListConfig() {\r\n }\r\n // Generates the lookup list data\r\n ListConfig.createLookupListData = function (props) {\r\n // See if we are showing a loading dialog\r\n if (props.showDialog) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Lookup List Data\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Updating the lookup list data...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Ensure data exists\r\n if (props.lookupData == null) {\r\n // Hide the dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.hide() : null;\r\n resolve(null);\r\n return;\r\n }\r\n // Update the dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Getting the web context information...\") : null;\r\n // Get the web context info\r\n gd_sprest_bs_1.ContextInfo.getWeb(props.webUrl).execute(function (contextInfo) {\r\n // Parse the lookup list data\r\n gd_sprest_bs_1.Helper.Executor(props.lookupData, function (lookupData) {\r\n // Update the dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Getting the list: \" + lookupData.list) : null;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Update the dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Getting the current list data for: \" + lookupData.list) : null;\r\n // Get the current list\r\n (0, gd_sprest_bs_1.Web)(props.webUrl).Lists(lookupData.list).execute(function (list) {\r\n // Get the current list items\r\n (0, gd_sprest_bs_1.Web)(props.webUrl).Lists(lookupData.list).Items().query({ Top: 5000, GetAllItems: true }).execute(function (currItems) {\r\n var dstList = (0, gd_sprest_bs_1.Web)(props.webUrl, { requestDigest: contextInfo.GetContextWebInformation.FormDigestValue }).Lists(lookupData.list);\r\n // Update the dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Importing the list data: \" + lookupData.list) : null;\r\n // Parse the list items\r\n for (var i = 0; i < lookupData.items.length; i++) {\r\n var lookupItem = lookupData.items[i];\r\n // Set the metadata type\r\n lookupItem[\"__metadata\"] = { type: list.ListItemEntityTypeFullName };\r\n // See if the item exists\r\n var createFl = true;\r\n for (var j = 0; j < currItems.results.length; j++) {\r\n var currItem = currItems.results[j];\r\n // See if the item already exists\r\n if (currItem[lookupData.field] == lookupItem[lookupData.field]) {\r\n // Set the flag\r\n createFl = false;\r\n break;\r\n }\r\n }\r\n // See if we are creating the item\r\n if (createFl) {\r\n // Create the item\r\n dstList.Items().add(lookupItem).batch(function (item) {\r\n // Log\r\n console.log(\"[\" + lookupData.list + \"] Item added: \" + item[lookupData.field]);\r\n });\r\n }\r\n else {\r\n // Log\r\n console.log(\"[\" + lookupData.list + \"] Item already exists: \" + lookupItem[lookupData.field]);\r\n }\r\n }\r\n // Execute the batch job\r\n dstList.execute(function () {\r\n // Check the next list\r\n resolve(null);\r\n });\r\n }, function () {\r\n // Error getting the list data\r\n console.error(\"Error getting the destination list: \" + lookupData.list);\r\n // Check the next lookup field\r\n resolve(null);\r\n });\r\n }, function () {\r\n // Error getting the list data\r\n console.error(\"Error getting the destination list: \" + lookupData.list);\r\n // Check the next lookup field\r\n resolve(null);\r\n });\r\n });\r\n }).then(function () {\r\n // Hide the dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.hide() : null;\r\n // Resolve the request\r\n resolve();\r\n }, reject);\r\n });\r\n });\r\n };\r\n // Fixes the custom formatter list id values\r\n ListConfig.fixCustomFormatters = function (webUrl, listName) {\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Validating Custom Formatters\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Getting the list '\" + listName + \"' information...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Load the list fields\r\n (0, gd_sprest_bs_1.Web)(webUrl).Lists(listName).query({ Expand: [\"ContentTypes\", \"Views\"], Select: [\"Id\"] }).execute(function (list) {\r\n // Parse the content types\r\n gd_sprest_bs_1.Helper.Executor(list.ContentTypes.results, function (ct) {\r\n // See if the custom formatter exists and needs the list id\r\n if (ct.ClientFormCustomFormatter && ct.ClientFormCustomFormatter.indexOf(\"[[ListId]]\") >= 0) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n var customFormatter = ct.ClientFormCustomFormatter;\r\n // Replace the list id\r\n while (customFormatter.indexOf(\"[[ListId]]\") >= 0) {\r\n customFormatter = customFormatter.replace(\"[[ListId]]\", list.Id);\r\n }\r\n // Update the content type\r\n ct.update({\r\n ClientFormCustomFormatter: customFormatter\r\n }).execute(resolve, function () {\r\n // Log the error\r\n console.error(\"Error updating the custom formatter for the content type: \" + ct.Name);\r\n // Check the next field\r\n resolve(null);\r\n });\r\n });\r\n }\r\n }).then(function () {\r\n // Parse the views\r\n gd_sprest_bs_1.Helper.Executor(list.Views.results, function (view) {\r\n // See if the custom formatter exists and needs the list id\r\n if (view.CustomFormatter && view.CustomFormatter.indexOf(\"[[ListId]]\") >= 0) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n var customFormatter = view.CustomFormatter;\r\n // Replace the list id\r\n while (customFormatter.indexOf(\"[[ListId]]\") >= 0) {\r\n customFormatter = customFormatter.replace(\"[[ListId]]\", list.Id);\r\n }\r\n // Update the content type\r\n view.update({\r\n CustomFormatter: customFormatter\r\n }).execute(resolve, function () {\r\n // Log the error\r\n console.error(\"Error updating the custom formatter for the view: \" + view.Title);\r\n // Check the next field\r\n resolve(null);\r\n });\r\n });\r\n }\r\n }).then(resolve, reject);\r\n }, reject);\r\n }, reject);\r\n });\r\n };\r\n // Fixes the fields to ensure the list property is configured correctly\r\n ListConfig.fixMMSFields = function (webUrl, listName) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Validating MMS Fields\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Getting the list '\" + listName + \"' fields...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Get the hidden list\r\n _this.getMMSLookupListId(webUrl).then(function (listId) {\r\n var mmsListId = \"{\" + listId + \"}\";\r\n // Load the list fields\r\n (0, gd_sprest_bs_1.Web)(webUrl).Lists(listName).Fields().execute(function (fields) {\r\n // Parse the fields\r\n gd_sprest_bs_1.Helper.Executor(fields.results, function (field) {\r\n // See if this is not a MMS field\r\n if (field.TypeDisplayName != \"Managed Metadata\") {\r\n return;\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Get the schema for this field\r\n var parser = new DOMParser();\r\n var schemaXml = parser.parseFromString(field.SchemaXml, \"application/xml\");\r\n var xmlField = schemaXml.querySelector(\"Field\");\r\n // See if the list property is correct\r\n if (xmlField.getAttribute(\"List\") == mmsListId) {\r\n // Check the next field\r\n resolve(null);\r\n }\r\n else {\r\n // Update the list property\r\n xmlField.setAttribute(\"List\", mmsListId);\r\n // Update the schema value and check the next field\r\n field.update({ SchemaXml: xmlField.outerHTML }).execute(resolve, function () {\r\n // Log the error\r\n console.error(\"Error updating the MMS list property for field: \" + field.InternalName);\r\n // Check the next field\r\n resolve(null);\r\n });\r\n }\r\n });\r\n }).then(resolve, reject);\r\n }, reject);\r\n }, function () {\r\n // Error getting the list data\r\n console.error(\"Error getting the taxonomy hidden list.\");\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Generates the list configuration\r\n ListConfig.generate = function (props) {\r\n var _this = this;\r\n // See if we are showing a loading dialog\r\n if (props.showDialog) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Loading List\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Getting the source list configuration...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Get the list information\r\n var list = new list_1.List({\r\n listName: props.srcList,\r\n webUrl: props.srcWebUrl,\r\n itemQuery: { Filter: \"Id eq 0\" },\r\n onInitError: function () {\r\n // Reject the request\r\n reject(\"Error loading the list information. Please check your permission to the source list.\");\r\n },\r\n onInitialized: function () {\r\n var calcFields = [];\r\n var fields = {};\r\n var lookupFields = [];\r\n var mmsFields = {};\r\n // Update the loading dialog\r\n loadingDialog_1.LoadingDialog.setBody(\"Analyzing the list information...\");\r\n // Create the configuration\r\n var cfgProps = {\r\n ListCfg: [{\r\n ListInformation: {\r\n AllowContentTypes: list.ListInfo.AllowContentTypes,\r\n BaseTemplate: list.ListInfo.BaseTemplate,\r\n ContentTypesEnabled: list.ListInfo.ContentTypesEnabled,\r\n EnableAttachments: list.ListInfo.EnableAttachments,\r\n Title: props.srcList,\r\n Hidden: list.ListInfo.Hidden,\r\n NoCrawl: list.ListInfo.NoCrawl\r\n },\r\n ContentTypes: [],\r\n CustomFields: [],\r\n ViewInformation: []\r\n }]\r\n };\r\n // Parse the content types\r\n for (var i = 0; i < list.ListContentTypes.length; i++) {\r\n var ct = list.ListContentTypes[i];\r\n // Skip sealed content types\r\n if (ct.Sealed) {\r\n continue;\r\n }\r\n // Skip the folder content type\r\n if (ct.Name == \"Folder\") {\r\n continue;\r\n }\r\n // Parse the content type fields\r\n var fieldRefs = [];\r\n for (var j = 0; j < ct.FieldLinks.results.length; j++) {\r\n var fieldLink = ct.FieldLinks.results[j];\r\n // Ignore the Taxonomy fields, they will get added automatically\r\n if (fieldLink.Name == \"TaxCatchAll\" || fieldLink.Name == \"TaxCatchAllLabel\") {\r\n continue;\r\n }\r\n // Get the field\r\n var field = list.getField(fieldLink.Name);\r\n // See if this is a lookup field\r\n if (field.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Lookup) {\r\n // Ensure this isn't an associated lookup field\r\n if (field.IsDependentLookup != true) {\r\n // Append the field ref\r\n fieldRefs.push(field.InternalName);\r\n }\r\n }\r\n else {\r\n // Append the field ref\r\n fieldRefs.push(field.InternalName);\r\n }\r\n // Skip internal fields\r\n if (_this.InternalFields.indexOf(field.InternalName) >= 0) {\r\n continue;\r\n }\r\n // See if this is a calculated field\r\n if (field.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Calculated) {\r\n // Add the field and continue the loop\r\n calcFields.push(field);\r\n }\r\n // Else, see if this is a lookup field\r\n else if (field.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Lookup) {\r\n // Add the field\r\n lookupFields.push(field);\r\n }\r\n // Else, see if this is a MMS field\r\n else if (field.TypeDisplayName == \"Managed Metadata\") {\r\n // Add the field\r\n mmsFields[field.InternalName] = field;\r\n }\r\n // Else, ensure the field hasn't been added\r\n else if (fields[field.InternalName] == null) {\r\n // Add the field information\r\n fields[field.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n name: field.InternalName,\r\n schemaXml: field.SchemaXml\r\n });\r\n }\r\n }\r\n // Replace the source list id in the JSON config\r\n var customFormatter = ct.ClientFormCustomFormatter;\r\n if (customFormatter) {\r\n while (customFormatter.indexOf(list.ListId) >= 0) {\r\n customFormatter = customFormatter.replace(list.ListId, \"[[ListId]]\");\r\n }\r\n }\r\n // Add the list content type\r\n cfgProps.ListCfg[0].ContentTypes.push({\r\n ClientFormCustomFormatter: customFormatter,\r\n Name: ct.Name,\r\n Description: ct.Description,\r\n ParentName: ct.Parent.Name,\r\n FieldRefs: fieldRefs\r\n });\r\n }\r\n // Parse the views\r\n for (var i = 0; i < list.ListViews.length; i++) {\r\n var viewInfo = list.ListViews[i];\r\n // Skip hidden views\r\n if (viewInfo.Hidden) {\r\n continue;\r\n }\r\n // Parse the fields\r\n for (var j = 0; j < viewInfo.ViewFields.Items.results.length; j++) {\r\n var field = list.getField(viewInfo.ViewFields.Items.results[j]);\r\n // Ensure the field exists\r\n if (fields[field.InternalName] == null) {\r\n // See if this is a calculated field\r\n if (field.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Calculated) {\r\n // Add the field and continue the loop\r\n calcFields.push(field);\r\n }\r\n // Else, see if this is a lookup field\r\n else if (field.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Lookup) {\r\n // Add the field\r\n lookupFields.push(field);\r\n }\r\n // Else, see if this is a MMS field\r\n else if (field.TypeDisplayName == \"Managed Metadata\") {\r\n // Add the field\r\n mmsFields[field.InternalName] = field;\r\n }\r\n else {\r\n // Append the field\r\n fields[field.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n name: field.InternalName,\r\n schemaXml: field.SchemaXml\r\n });\r\n }\r\n }\r\n }\r\n // Replace the source list id in the JSON config\r\n var customFormatter = viewInfo.CustomFormatter;\r\n if (customFormatter) {\r\n while (customFormatter.indexOf(list.ListId) >= 0) {\r\n customFormatter = customFormatter.replace(list.ListId, \"[[ListId]]\");\r\n }\r\n }\r\n // Add the view\r\n cfgProps.ListCfg[0].ViewInformation.push({\r\n CustomFormatter: customFormatter,\r\n Default: viewInfo.DefaultView,\r\n Hidden: viewInfo.Hidden,\r\n JSLink: viewInfo.JSLink,\r\n MobileDefaultView: viewInfo.MobileDefaultView,\r\n MobileView: viewInfo.MobileView,\r\n RowLimit: viewInfo.RowLimit,\r\n Tabular: viewInfo.TabularView,\r\n ViewName: viewInfo.Title,\r\n ViewFields: viewInfo.ViewFields.Items.results,\r\n ViewQuery: viewInfo.ViewQuery\r\n });\r\n }\r\n // Update the loading dialog\r\n loadingDialog_1.LoadingDialog.setBody(\"Analyzing the lookup fields...\");\r\n // Parse the lookup fields\r\n gd_sprest_bs_1.Helper.Executor(lookupFields, function (lookupField) {\r\n // Skip the field, if it was already added\r\n if (fields[lookupField.InternalName]) {\r\n return;\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Get the lookup list\r\n (0, gd_sprest_bs_1.Web)(props.srcWebUrl).Lists().getById(lookupField.LookupList).execute(function (list) {\r\n // Add the lookup list field\r\n fields[lookupField.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n description: lookupField.Description,\r\n fieldRef: lookupField.PrimaryFieldId,\r\n hidden: lookupField.Hidden,\r\n id: lookupField.Id,\r\n indexed: lookupField.Indexed,\r\n listName: list.Title,\r\n multi: lookupField.AllowMultipleValues,\r\n name: lookupField.InternalName,\r\n readOnly: lookupField.ReadOnlyField,\r\n relationshipBehavior: lookupField.RelationshipDeleteBehavior,\r\n required: lookupField.Required,\r\n showField: lookupField.LookupField,\r\n title: lookupField.Title,\r\n type: gd_sprest_bs_1.Helper.SPCfgFieldType.Lookup\r\n });\r\n // Check the next field\r\n resolve(null);\r\n }, function (err) {\r\n // Broken lookup field, don't add it\r\n console.log(\"Error trying to find lookup list for field '\" + lookupField.InternalName + \"' with id: \" + lookupField.LookupList);\r\n resolve(null);\r\n });\r\n });\r\n }).then(function () {\r\n // Update the loading dialog\r\n loadingDialog_1.LoadingDialog.setBody(\"Analyzing the calculated fields...\");\r\n // Parse the calculated fields\r\n for (var i = 0; i < calcFields.length; i++) {\r\n var calcField = calcFields[i];\r\n if (fields[calcField.InternalName] == null) {\r\n var parser = new DOMParser();\r\n var schemaXml = parser.parseFromString(calcField.SchemaXml, \"application/xml\");\r\n // Get the formula\r\n var formula = schemaXml.querySelector(\"Formula\");\r\n // Parse the field refs\r\n var fieldRefs = schemaXml.querySelectorAll(\"FieldRef\");\r\n for (var j = 0; j < fieldRefs.length; j++) {\r\n var fieldRef = fieldRefs[j].getAttribute(\"Name\");\r\n // Ensure the field exists\r\n var field = list.getField(fieldRef);\r\n if (field) {\r\n // Calculated formulas are supposed to contain the display name\r\n // Replace any instance of the internal field w/ the correct format\r\n var regexp = new RegExp(fieldRef, \"g\");\r\n formula.innerHTML = formula.innerHTML.replace(regexp, \"[\" + field.Title + \"]\");\r\n }\r\n }\r\n // Append the field\r\n fields[calcField.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n name: calcField.InternalName,\r\n schemaXml: schemaXml.querySelector(\"Field\").outerHTML\r\n });\r\n }\r\n }\r\n // Parse the MMS fields\r\n for (var fieldName in mmsFields) {\r\n var mmsField = mmsFields[fieldName];\r\n // Get the schema xml\r\n var parser = new DOMParser();\r\n var schemaXml = parser.parseFromString(mmsField.SchemaXml, \"application/xml\");\r\n // Remove all properties, except for the TextField property\r\n var removeProps = [];\r\n var props_1 = schemaXml.querySelector(\"ArrayOfProperty\");\r\n var _loop_1 = function (j) {\r\n // See if this isn't the text field property\r\n var prop = props_1.children[j];\r\n if (prop.querySelector(\"Name\").innerHTML == \"TextField\") {\r\n // Find the hidden text field for this MMS field\r\n var field_1 = list.getFieldById(prop.querySelector(\"Value\").innerHTML);\r\n if (field_1) {\r\n // Ensure we haven't already added it\r\n if (fields[field_1.InternalName] != true) {\r\n // Append the field\r\n fields[field_1.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n name: field_1.InternalName,\r\n schemaXml: field_1.SchemaXml\r\n });\r\n }\r\n // Parse the content types\r\n gd_sprest_bs_1.Helper.Executor(cfgProps.ListCfg[0].ContentTypes, function (ct) {\r\n // Parse the field links\r\n for (var i = 0; i < ct.FieldRefs.length; i++) {\r\n // See if this is the target field\r\n if (ct.FieldRefs[i] == field_1.InternalName) {\r\n // Remove this from the content types\r\n ct.FieldRefs.splice(i, 1);\r\n break;\r\n }\r\n }\r\n });\r\n }\r\n }\r\n else {\r\n // Remove it\r\n removeProps.push(prop);\r\n }\r\n };\r\n for (var j = props_1.children.length - 1; j >= 0; j--) {\r\n _loop_1(j);\r\n }\r\n // Remove the properties\r\n for (var i = 0; i < removeProps.length; i++) {\r\n // Remove the property\r\n props_1.removeChild(removeProps[i]);\r\n }\r\n // Append the field\r\n fields[mmsField.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n name: mmsField.InternalName,\r\n schemaXml: schemaXml.querySelector(\"Field\").outerHTML\r\n });\r\n }\r\n // Hide the loading dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.hide() : null;\r\n // Resolve the request\r\n resolve({\r\n cfg: cfgProps,\r\n lookupFields: lookupFields\r\n });\r\n });\r\n }\r\n });\r\n });\r\n };\r\n // Generates the lookup list data\r\n ListConfig.generateLookupListData = function (props) {\r\n var _this = this;\r\n var lookupListData = [];\r\n // See if we are showing a loading dialog\r\n if (props.showDialog) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Analyzing Lookup Lists\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Getting the lookup lists data...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n }\r\n // Keep track of the lookup lists we are searching for\r\n var lookupLists = {};\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Parse the lookup fields\r\n gd_sprest_bs_1.Helper.Executor(props.lookupFields, function (lookupField) {\r\n var _a;\r\n // Ensure this lookup isn't to the source list\r\n if (((_a = lookupField.LookupList) === null || _a === void 0 ? void 0 : _a.indexOf(props.srcListId)) >= 0) {\r\n return;\r\n }\r\n // See if we have already checked this list\r\n var listId = (lookupField.LookupList || \"\").replace(/{|}/g, '');\r\n if (lookupLists[listId]) {\r\n return;\r\n }\r\n // Updated the loading dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Getting the lookup list for: \" + lookupField.InternalName) : null;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Get the source list\r\n (0, gd_sprest_bs_1.Web)(props.srcWebUrl).Lists().getById(lookupField.LookupList).execute(function (list) {\r\n // Read the list\r\n _this.readList(props.srcWebUrl, list.Title, lookupField.LookupField).then(function (data) {\r\n // Set the flag\r\n lookupLists[listId] = true;\r\n // Save the item data\r\n lookupListData.push(data);\r\n // Check the next list\r\n resolve(null);\r\n }, resolve);\r\n }, function () {\r\n // Log\r\n console.error(\"Error: List with id '\".concat(lookupField.LookupList, \"' does not exist in web '\").concat(props.srcWebUrl, \"'.\"));\r\n // Check the next list\r\n resolve(null);\r\n });\r\n });\r\n }).then(function () {\r\n // Resolve the request\r\n resolve(lookupListData);\r\n }, reject);\r\n });\r\n };\r\n // Gets the taxonomy hidden list\r\n ListConfig.getMMSLookupListId = function (webUrl) {\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Query the web for the hidden list\r\n (0, gd_sprest_bs_1.Web)(webUrl).Lists(\"TaxonomyHiddenList\").execute(function (list) {\r\n // Resolve the request\r\n resolve(list.Id);\r\n }, reject);\r\n });\r\n };\r\n // Generates the lookup list data\r\n ListConfig.readList = function (webUrl, listName, lookupField) {\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Get the source list\r\n (0, gd_sprest_bs_1.Web)(webUrl).Lists(listName).execute(function (list) {\r\n var fields = [];\r\n // Get the list content type fields\r\n list.ContentTypes().query({ Expand: [\"Fields\"] }).execute(function (cts) {\r\n // Parse the content type fields\r\n for (var i = 0; i < cts.results[0].Fields.results.length; i++) {\r\n var field = cts.results[0].Fields.results[i];\r\n // Add the field link\r\n fields.push(field);\r\n }\r\n });\r\n // Get the list items\r\n list.Items().query({\r\n GetAllItems: true,\r\n Top: 5000,\r\n OrderBy: [\"Id\"]\r\n }).execute(function (items) {\r\n var lookupItems = [];\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n var lookupItem = {};\r\n // Parse the field links\r\n for (var j = 0; j < fields.length; j++) {\r\n var field = fields[j];\r\n var value = items.results[i][field.InternalName];\r\n // Ensure a value exists\r\n if (value == null) {\r\n continue;\r\n }\r\n // See if this is a collection\r\n if (value.results) {\r\n // Set the results\r\n value = { results: value.results };\r\n }\r\n // Add the value, based on the type\r\n switch (field.FieldTypeKind) {\r\n case gd_sprest_bs_1.SPTypes.FieldType.URL:\r\n lookupItem[field.InternalName] = {\r\n Description: value.Description,\r\n Url: value.Url\r\n };\r\n break;\r\n default:\r\n // Set the value\r\n lookupItem[field.InternalName] = value;\r\n break;\r\n }\r\n }\r\n // Add the lookup item\r\n lookupItems.push(lookupItem);\r\n }\r\n // Resolve the request\r\n resolve({\r\n field: lookupField,\r\n items: lookupItems,\r\n list: list.Title\r\n });\r\n }, true); // Set the flag to run this after the previous request completes\r\n }, reject);\r\n });\r\n };\r\n // Validates the lookup fields\r\n ListConfig.validateLookups = function (props) {\r\n var _this = this;\r\n // See if we are showing a loading dialog\r\n if (props.showDialog) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Validating Lookup Lists\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Validating the required lookup lists have been added...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n }\r\n // Keep track of the lookup lists we are searching for\r\n var lookupLists = {};\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Parse the lookup fields\r\n gd_sprest_bs_1.Helper.Executor(props.lookupFields, function (lookupField) {\r\n var _a;\r\n // Ensure this lookup isn't to the source list\r\n if (((_a = lookupField.LookupList) === null || _a === void 0 ? void 0 : _a.indexOf(props.srcListId)) >= 0) {\r\n return;\r\n }\r\n // See if we have already checked this list\r\n var listId = (lookupField.LookupList || \"\").replace(/{|}/g, '');\r\n if (lookupLists[listId]) {\r\n return;\r\n }\r\n // Updated the loading dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Getting the lookup list for: \" + lookupField.InternalName) : null;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Get the source list\r\n (0, gd_sprest_bs_1.Web)(props.srcWebUrl).Lists().getById(lookupField.LookupList).execute(function (list) {\r\n // Updated the loading dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Generating the configuration for: \" + list.Title) : null;\r\n // Generate the lookup list configuration\r\n _this.generate({\r\n srcList: list.Title,\r\n srcWebUrl: props.srcWebUrl,\r\n showDialog: false\r\n }).then(\r\n // Success\r\n function (cfg) {\r\n // Set the flag\r\n lookupLists[list.Id] = true;\r\n // Prepend the list configuration\r\n props.cfg.ListCfg.splice(props.cfg.ListCfg.length - 1, 0, cfg.cfg.ListCfg[0]);\r\n // Check the next list\r\n resolve(null);\r\n }, \r\n // Error\r\n function () {\r\n // Reject the reqeust\r\n reject(\"Lookup list '\" + list.Title + \"' for field '\" + lookupField.InternalName + \"' does not exist in the configuration. Please add the lists in the appropriate order.\");\r\n });\r\n }, function () {\r\n // Reject the reqeust\r\n reject(\"Lookup list for field '\" + lookupField.InternalName + \"' does not exist in the source web. Please review the source list for any issues.\");\r\n });\r\n });\r\n }).then(function () {\r\n // Resolve the request\r\n resolve(props.cfg);\r\n }, reject);\r\n });\r\n };\r\n // Internal Fields\r\n ListConfig.InternalFields = [\r\n \"ContentType\", \"TaxCatchAll\", \"TaxCatchAllLabel\", \"Title\",\r\n \"ItemChildCount\", \"FolderChildCount\", \"FileLeafRef\", \"FileRef\"\r\n ];\r\n return ListConfig;\r\n}());\r\nexports.ListConfig = ListConfig;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/listCfg.js?");
|
|
118
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ListConfig = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.12.70/node_modules/gd-sprest-bs/build/index.js\");\r\nvar loadingDialog_1 = __webpack_require__(/*! ./loadingDialog */ \"./build/common/loadingDialog.js\");\r\nvar list_1 = __webpack_require__(/*! ./list */ \"./build/common/list.js\");\r\n/**\r\n * List Configuration Generator\r\n */\r\nvar ListConfig = /** @class */ (function () {\r\n function ListConfig() {\r\n }\r\n // Generates the lookup list data\r\n ListConfig.createLookupListData = function (props) {\r\n // See if we are showing a loading dialog\r\n if (props.showDialog) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Lookup List Data\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Updating the lookup list data...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Ensure data exists\r\n if (props.lookupData == null) {\r\n // Hide the dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.hide() : null;\r\n resolve(null);\r\n return;\r\n }\r\n // Update the dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Getting the web context information...\") : null;\r\n // Get the web context info\r\n gd_sprest_bs_1.ContextInfo.getWeb(props.webUrl).execute(function (contextInfo) {\r\n // Parse the lookup list data\r\n gd_sprest_bs_1.Helper.Executor(props.lookupData, function (lookupData) {\r\n // Update the dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Getting the list: \" + lookupData.list) : null;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Update the dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Getting the current list data for: \" + lookupData.list) : null;\r\n // Get the current list\r\n (0, gd_sprest_bs_1.Web)(props.webUrl).Lists(lookupData.list).execute(function (list) {\r\n // Get the current list items\r\n (0, gd_sprest_bs_1.Web)(props.webUrl).Lists(lookupData.list).Items().query({ Top: 5000, GetAllItems: true }).execute(function (currItems) {\r\n var dstList = (0, gd_sprest_bs_1.Web)(props.webUrl, { requestDigest: contextInfo.GetContextWebInformation.FormDigestValue }).Lists(lookupData.list);\r\n // Update the dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Importing the list data: \" + lookupData.list) : null;\r\n // Parse the list items\r\n for (var i = 0; i < lookupData.items.length; i++) {\r\n var lookupItem = lookupData.items[i];\r\n // Set the metadata type\r\n lookupItem[\"__metadata\"] = { type: list.ListItemEntityTypeFullName };\r\n // See if the item exists\r\n var createFl = true;\r\n for (var j = 0; j < currItems.results.length; j++) {\r\n var currItem = currItems.results[j];\r\n // See if the item already exists\r\n if (currItem[lookupData.field] == lookupItem[lookupData.field]) {\r\n // Set the flag\r\n createFl = false;\r\n break;\r\n }\r\n }\r\n // See if we are creating the item\r\n if (createFl) {\r\n // Create the item\r\n dstList.Items().add(lookupItem).batch(function (item) {\r\n // Log\r\n console.log(\"[\" + lookupData.list + \"] Item added: \" + item[lookupData.field]);\r\n });\r\n }\r\n else {\r\n // Log\r\n console.log(\"[\" + lookupData.list + \"] Item already exists: \" + lookupItem[lookupData.field]);\r\n }\r\n }\r\n // Execute the batch job\r\n dstList.execute(function () {\r\n // Check the next list\r\n resolve(null);\r\n });\r\n }, function () {\r\n // Error getting the list data\r\n console.error(\"Error getting the destination list: \" + lookupData.list);\r\n // Check the next lookup field\r\n resolve(null);\r\n });\r\n }, function () {\r\n // Error getting the list data\r\n console.error(\"Error getting the destination list: \" + lookupData.list);\r\n // Check the next lookup field\r\n resolve(null);\r\n });\r\n });\r\n }).then(function () {\r\n // Hide the dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.hide() : null;\r\n // Resolve the request\r\n resolve();\r\n }, reject);\r\n });\r\n });\r\n };\r\n // Fixes the custom formatter list id values\r\n ListConfig.fixCustomFormatters = function (webUrl, listName) {\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Validating Custom Formatters\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Getting the list '\" + listName + \"' information...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Load the list information\r\n (0, gd_sprest_bs_1.Web)(webUrl).Lists(listName).query({ Expand: [\"ContentTypes\", \"Fields\", \"Views\"], Select: [\"Id\"] }).execute(function (list) {\r\n // Parse the content types\r\n gd_sprest_bs_1.Helper.Executor(list.ContentTypes.results, function (ct) {\r\n // See if the custom formatter exists and needs the list id\r\n if (ct.ClientFormCustomFormatter && ct.ClientFormCustomFormatter.indexOf(\"[[ListId]]\") >= 0) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n var customFormatter = ct.ClientFormCustomFormatter;\r\n // Replace the list id\r\n while (customFormatter.indexOf(\"[[ListId]]\") >= 0) {\r\n customFormatter = customFormatter.replace(\"[[ListId]]\", list.Id);\r\n }\r\n // Update the content type\r\n ct.update({\r\n ClientFormCustomFormatter: customFormatter\r\n }).execute(resolve, function () {\r\n // Log the error\r\n console.error(\"Error updating the custom formatter for the content type: \" + ct.Name);\r\n // Check the next content type\r\n resolve(null);\r\n });\r\n });\r\n }\r\n }).then(function () {\r\n // Parse the views\r\n gd_sprest_bs_1.Helper.Executor(list.Views.results, function (view) {\r\n // See if the custom formatter exists and needs the list id\r\n if (view.CustomFormatter && view.CustomFormatter.indexOf(\"[[ListId]]\") >= 0) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n var customFormatter = view.CustomFormatter;\r\n // Replace the list id\r\n while (customFormatter.indexOf(\"[[ListId]]\") >= 0) {\r\n customFormatter = customFormatter.replace(\"[[ListId]]\", list.Id);\r\n }\r\n // Update the content type\r\n view.update({\r\n CustomFormatter: customFormatter\r\n }).execute(resolve, function () {\r\n // Log the error\r\n console.error(\"Error updating the custom formatter for the view: \" + view.Title);\r\n // Check the next view\r\n resolve(null);\r\n });\r\n });\r\n }\r\n }).then(function () {\r\n // Parse the views\r\n gd_sprest_bs_1.Helper.Executor(list.Fields.results, function (field) {\r\n // See if the custom formatter exists and needs the list id\r\n if (field.SchemaXml && field.SchemaXml.indexOf(\"[[ListId]]\") >= 0) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n var schemaXml = field.SchemaXml;\r\n // Replace the list id\r\n while (schemaXml.indexOf(\"[[ListId]]\") >= 0) {\r\n schemaXml = schemaXml.replace(\"[[ListId]]\", list.Id);\r\n }\r\n // Update the content type\r\n field.update({\r\n SchemaXml: schemaXml\r\n }).execute(resolve, function () {\r\n // Log the error\r\n console.error(\"Error updating the custom formatter for the field: \" + field.InternalName);\r\n // Check the next field\r\n resolve(null);\r\n });\r\n });\r\n }\r\n }).then(resolve, reject);\r\n }, reject);\r\n }, reject);\r\n }, reject);\r\n });\r\n };\r\n // Fixes the fields to ensure the list property is configured correctly\r\n ListConfig.fixMMSFields = function (webUrl, listName) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Validating MMS Fields\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Getting the list '\" + listName + \"' fields...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Get the hidden list\r\n _this.getMMSLookupListId(webUrl).then(function (listId) {\r\n var mmsListId = \"{\" + listId + \"}\";\r\n // Load the list fields\r\n (0, gd_sprest_bs_1.Web)(webUrl).Lists(listName).Fields().execute(function (fields) {\r\n // Parse the fields\r\n gd_sprest_bs_1.Helper.Executor(fields.results, function (field) {\r\n // See if this is not a MMS field\r\n if (field.TypeDisplayName != \"Managed Metadata\") {\r\n return;\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Get the schema for this field\r\n var parser = new DOMParser();\r\n var schemaXml = parser.parseFromString(field.SchemaXml, \"application/xml\");\r\n var xmlField = schemaXml.querySelector(\"Field\");\r\n // See if the list property is correct\r\n if (xmlField.getAttribute(\"List\") == mmsListId) {\r\n // Check the next field\r\n resolve(null);\r\n }\r\n else {\r\n // Update the list property\r\n xmlField.setAttribute(\"List\", mmsListId);\r\n // Update the schema value and check the next field\r\n field.update({ SchemaXml: xmlField.outerHTML }).execute(resolve, function () {\r\n // Log the error\r\n console.error(\"Error updating the MMS list property for field: \" + field.InternalName);\r\n // Check the next field\r\n resolve(null);\r\n });\r\n }\r\n });\r\n }).then(resolve, reject);\r\n }, reject);\r\n }, function () {\r\n // Error getting the list data\r\n console.error(\"Error getting the taxonomy hidden list.\");\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Generates the list configuration\r\n ListConfig.generate = function (props) {\r\n var _this = this;\r\n // See if we are showing a loading dialog\r\n if (props.showDialog) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Loading List\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Getting the source list configuration...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Get the list information\r\n var list = new list_1.List({\r\n listName: props.srcList,\r\n webUrl: props.srcWebUrl,\r\n itemQuery: { Filter: \"Id eq 0\" },\r\n onInitError: function () {\r\n // Reject the request\r\n reject(\"Error loading the list information. Please check your permission to the source list.\");\r\n },\r\n onInitialized: function () {\r\n var calcFields = [];\r\n var fields = {};\r\n var lookupFields = [];\r\n var mmsFields = {};\r\n // Update the loading dialog\r\n loadingDialog_1.LoadingDialog.setBody(\"Analyzing the list information...\");\r\n // Create the configuration\r\n var cfgProps = {\r\n ListCfg: [{\r\n ListInformation: {\r\n AllowContentTypes: list.ListInfo.AllowContentTypes,\r\n BaseTemplate: list.ListInfo.BaseTemplate,\r\n ContentTypesEnabled: list.ListInfo.ContentTypesEnabled,\r\n EnableAttachments: list.ListInfo.EnableAttachments,\r\n Title: props.srcList,\r\n Hidden: list.ListInfo.Hidden,\r\n NoCrawl: list.ListInfo.NoCrawl\r\n },\r\n ContentTypes: [],\r\n CustomFields: [],\r\n ViewInformation: []\r\n }]\r\n };\r\n // Parse the content types\r\n for (var i = 0; i < list.ListContentTypes.length; i++) {\r\n var ct = list.ListContentTypes[i];\r\n // Skip sealed content types\r\n if (ct.Sealed) {\r\n continue;\r\n }\r\n // Skip the folder content type\r\n if (ct.Name == \"Folder\") {\r\n continue;\r\n }\r\n // Parse the content type fields\r\n var fieldRefs = [];\r\n for (var j = 0; j < ct.FieldLinks.results.length; j++) {\r\n var fieldLink = ct.FieldLinks.results[j];\r\n // Ignore the Taxonomy fields, they will get added automatically\r\n if (fieldLink.Name == \"TaxCatchAll\" || fieldLink.Name == \"TaxCatchAllLabel\") {\r\n continue;\r\n }\r\n // Get the field\r\n var field = list.getField(fieldLink.Name);\r\n // See if this is a lookup field\r\n if (field.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Lookup) {\r\n // Ensure this isn't an associated lookup field\r\n if (field.IsDependentLookup != true) {\r\n // Append the field ref\r\n fieldRefs.push(field.InternalName);\r\n }\r\n }\r\n else {\r\n // Append the field ref\r\n fieldRefs.push(field.InternalName);\r\n }\r\n // Skip internal fields\r\n if (_this.InternalFields.indexOf(field.InternalName) >= 0) {\r\n continue;\r\n }\r\n // See if this is a calculated field\r\n if (field.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Calculated) {\r\n // Add the field and continue the loop\r\n calcFields.push(field);\r\n }\r\n // Else, see if this is a lookup field\r\n else if (field.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Lookup) {\r\n // Add the field\r\n lookupFields.push(field);\r\n }\r\n // Else, see if this is a MMS field\r\n else if (field.TypeDisplayName == \"Managed Metadata\") {\r\n // Add the field\r\n mmsFields[field.InternalName] = field;\r\n }\r\n // Else, ensure the field hasn't been added\r\n else if (fields[field.InternalName] == null) {\r\n // Replace the source list id in the JSON config\r\n var schemaXml = field.SchemaXml;\r\n if (schemaXml) {\r\n while (schemaXml.indexOf(list.ListId) >= 0) {\r\n schemaXml = schemaXml.replace(list.ListId, \"[[ListId]]\");\r\n }\r\n }\r\n // Add the field information\r\n fields[field.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n name: field.InternalName,\r\n schemaXml: field.SchemaXml\r\n });\r\n }\r\n }\r\n // Replace the source list id in the JSON config\r\n var customFormatter = ct.ClientFormCustomFormatter;\r\n if (customFormatter) {\r\n while (customFormatter.indexOf(list.ListId) >= 0) {\r\n customFormatter = customFormatter.replace(list.ListId, \"[[ListId]]\");\r\n }\r\n }\r\n // Add the list content type\r\n cfgProps.ListCfg[0].ContentTypes.push({\r\n ClientFormCustomFormatter: customFormatter,\r\n Name: ct.Name,\r\n Description: ct.Description,\r\n ParentName: ct.Parent.Name,\r\n FieldRefs: fieldRefs\r\n });\r\n }\r\n // Parse the views\r\n for (var i = 0; i < list.ListViews.length; i++) {\r\n var viewInfo = list.ListViews[i];\r\n // Skip hidden views\r\n if (viewInfo.Hidden) {\r\n continue;\r\n }\r\n // Parse the fields\r\n for (var j = 0; j < viewInfo.ViewFields.Items.results.length; j++) {\r\n var field = list.getField(viewInfo.ViewFields.Items.results[j]);\r\n // Ensure the field exists\r\n if (fields[field.InternalName] == null) {\r\n // See if this is a calculated field\r\n if (field.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Calculated) {\r\n // Add the field and continue the loop\r\n calcFields.push(field);\r\n }\r\n // Else, see if this is a lookup field\r\n else if (field.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Lookup) {\r\n // Add the field\r\n lookupFields.push(field);\r\n }\r\n // Else, see if this is a MMS field\r\n else if (field.TypeDisplayName == \"Managed Metadata\") {\r\n // Add the field\r\n mmsFields[field.InternalName] = field;\r\n }\r\n else {\r\n // Replace the source list id in the JSON config\r\n var schemaXml = field.SchemaXml;\r\n if (schemaXml) {\r\n while (schemaXml.indexOf(list.ListId) >= 0) {\r\n schemaXml = schemaXml.replace(list.ListId, \"[[ListId]]\");\r\n }\r\n }\r\n // Append the field\r\n fields[field.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n name: field.InternalName,\r\n schemaXml: field.SchemaXml\r\n });\r\n }\r\n }\r\n }\r\n // Replace the source list id in the JSON config\r\n var customFormatter = viewInfo.CustomFormatter;\r\n if (customFormatter) {\r\n while (customFormatter.indexOf(list.ListId) >= 0) {\r\n customFormatter = customFormatter.replace(list.ListId, \"[[ListId]]\");\r\n }\r\n }\r\n // Add the view\r\n cfgProps.ListCfg[0].ViewInformation.push({\r\n CustomFormatter: customFormatter,\r\n Default: viewInfo.DefaultView,\r\n Hidden: viewInfo.Hidden,\r\n JSLink: viewInfo.JSLink,\r\n MobileDefaultView: viewInfo.MobileDefaultView,\r\n MobileView: viewInfo.MobileView,\r\n RowLimit: viewInfo.RowLimit,\r\n Tabular: viewInfo.TabularView,\r\n ViewName: viewInfo.Title,\r\n ViewFields: viewInfo.ViewFields.Items.results,\r\n ViewQuery: viewInfo.ViewQuery\r\n });\r\n }\r\n // Update the loading dialog\r\n loadingDialog_1.LoadingDialog.setBody(\"Analyzing the lookup fields...\");\r\n // Parse the lookup fields\r\n gd_sprest_bs_1.Helper.Executor(lookupFields, function (lookupField) {\r\n // Skip the field, if it was already added\r\n if (fields[lookupField.InternalName]) {\r\n return;\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Get the lookup list\r\n (0, gd_sprest_bs_1.Web)(props.srcWebUrl).Lists().getById(lookupField.LookupList).execute(function (list) {\r\n // Add the lookup list field\r\n fields[lookupField.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n description: lookupField.Description,\r\n fieldRef: lookupField.PrimaryFieldId,\r\n hidden: lookupField.Hidden,\r\n id: lookupField.Id,\r\n indexed: lookupField.Indexed,\r\n listName: list.Title,\r\n multi: lookupField.AllowMultipleValues,\r\n name: lookupField.InternalName,\r\n readOnly: lookupField.ReadOnlyField,\r\n relationshipBehavior: lookupField.RelationshipDeleteBehavior,\r\n required: lookupField.Required,\r\n showField: lookupField.LookupField,\r\n title: lookupField.Title,\r\n type: gd_sprest_bs_1.Helper.SPCfgFieldType.Lookup\r\n });\r\n // Check the next field\r\n resolve(null);\r\n }, function (err) {\r\n // Broken lookup field, don't add it\r\n console.log(\"Error trying to find lookup list for field '\" + lookupField.InternalName + \"' with id: \" + lookupField.LookupList);\r\n resolve(null);\r\n });\r\n });\r\n }).then(function () {\r\n // Update the loading dialog\r\n loadingDialog_1.LoadingDialog.setBody(\"Analyzing the calculated fields...\");\r\n // Parse the calculated fields\r\n for (var i = 0; i < calcFields.length; i++) {\r\n var calcField = calcFields[i];\r\n if (fields[calcField.InternalName] == null) {\r\n var parser = new DOMParser();\r\n var schemaXml = parser.parseFromString(calcField.SchemaXml, \"application/xml\");\r\n // Get the formula\r\n var formula = schemaXml.querySelector(\"Formula\");\r\n // Parse the field refs\r\n var fieldRefs = schemaXml.querySelectorAll(\"FieldRef\");\r\n for (var j = 0; j < fieldRefs.length; j++) {\r\n var fieldRef = fieldRefs[j].getAttribute(\"Name\");\r\n // Ensure the field exists\r\n var field = list.getField(fieldRef);\r\n if (field) {\r\n // Calculated formulas are supposed to contain the display name\r\n // Replace any instance of the internal field w/ the correct format\r\n var regexp = new RegExp(fieldRef, \"g\");\r\n formula.innerHTML = formula.innerHTML.replace(regexp, \"[\" + field.Title + \"]\");\r\n }\r\n }\r\n // Append the field\r\n fields[calcField.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n name: calcField.InternalName,\r\n schemaXml: schemaXml.querySelector(\"Field\").outerHTML\r\n });\r\n }\r\n }\r\n // Parse the MMS fields\r\n for (var fieldName in mmsFields) {\r\n var mmsField = mmsFields[fieldName];\r\n // Get the schema xml\r\n var parser = new DOMParser();\r\n var schemaXml = parser.parseFromString(mmsField.SchemaXml, \"application/xml\");\r\n // Remove all properties, except for the TextField property\r\n var removeProps = [];\r\n var props_1 = schemaXml.querySelector(\"ArrayOfProperty\");\r\n var _loop_1 = function (j) {\r\n // See if this isn't the text field property\r\n var prop = props_1.children[j];\r\n if (prop.querySelector(\"Name\").innerHTML == \"TextField\") {\r\n // Find the hidden text field for this MMS field\r\n var field_1 = list.getFieldById(prop.querySelector(\"Value\").innerHTML);\r\n if (field_1) {\r\n // Ensure we haven't already added it\r\n if (fields[field_1.InternalName] != true) {\r\n // Append the field\r\n fields[field_1.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n name: field_1.InternalName,\r\n schemaXml: field_1.SchemaXml\r\n });\r\n }\r\n // Parse the content types\r\n gd_sprest_bs_1.Helper.Executor(cfgProps.ListCfg[0].ContentTypes, function (ct) {\r\n // Parse the field links\r\n for (var i = 0; i < ct.FieldRefs.length; i++) {\r\n // See if this is the target field\r\n if (ct.FieldRefs[i] == field_1.InternalName) {\r\n // Remove this from the content types\r\n ct.FieldRefs.splice(i, 1);\r\n break;\r\n }\r\n }\r\n });\r\n }\r\n }\r\n else {\r\n // Remove it\r\n removeProps.push(prop);\r\n }\r\n };\r\n for (var j = props_1.children.length - 1; j >= 0; j--) {\r\n _loop_1(j);\r\n }\r\n // Remove the properties\r\n for (var i = 0; i < removeProps.length; i++) {\r\n // Remove the property\r\n props_1.removeChild(removeProps[i]);\r\n }\r\n // Append the field\r\n fields[mmsField.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n name: mmsField.InternalName,\r\n schemaXml: schemaXml.querySelector(\"Field\").outerHTML\r\n });\r\n }\r\n // Hide the loading dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.hide() : null;\r\n // Resolve the request\r\n resolve({\r\n cfg: cfgProps,\r\n lookupFields: lookupFields\r\n });\r\n });\r\n }\r\n });\r\n });\r\n };\r\n // Generates the lookup list data\r\n ListConfig.generateLookupListData = function (props) {\r\n var _this = this;\r\n var lookupListData = [];\r\n // See if we are showing a loading dialog\r\n if (props.showDialog) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Analyzing Lookup Lists\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Getting the lookup lists data...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n }\r\n // Keep track of the lookup lists we are searching for\r\n var lookupLists = {};\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Parse the lookup fields\r\n gd_sprest_bs_1.Helper.Executor(props.lookupFields, function (lookupField) {\r\n var _a;\r\n // Ensure this lookup isn't to the source list\r\n if (((_a = lookupField.LookupList) === null || _a === void 0 ? void 0 : _a.indexOf(props.srcListId)) >= 0) {\r\n return;\r\n }\r\n // See if we have already checked this list\r\n var listId = (lookupField.LookupList || \"\").replace(/{|}/g, '');\r\n if (lookupLists[listId]) {\r\n return;\r\n }\r\n // Updated the loading dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Getting the lookup list for: \" + lookupField.InternalName) : null;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Get the source list\r\n (0, gd_sprest_bs_1.Web)(props.srcWebUrl).Lists().getById(lookupField.LookupList).execute(function (list) {\r\n // Read the list\r\n _this.readList(props.srcWebUrl, list.Title, lookupField.LookupField).then(function (data) {\r\n // Set the flag\r\n lookupLists[listId] = true;\r\n // Save the item data\r\n lookupListData.push(data);\r\n // Check the next list\r\n resolve(null);\r\n }, resolve);\r\n }, function () {\r\n // Log\r\n console.error(\"Error: List with id '\".concat(lookupField.LookupList, \"' does not exist in web '\").concat(props.srcWebUrl, \"'.\"));\r\n // Check the next list\r\n resolve(null);\r\n });\r\n });\r\n }).then(function () {\r\n // Resolve the request\r\n resolve(lookupListData);\r\n }, reject);\r\n });\r\n };\r\n // Gets the taxonomy hidden list\r\n ListConfig.getMMSLookupListId = function (webUrl) {\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Query the web for the hidden list\r\n (0, gd_sprest_bs_1.Web)(webUrl).Lists(\"TaxonomyHiddenList\").execute(function (list) {\r\n // Resolve the request\r\n resolve(list.Id);\r\n }, reject);\r\n });\r\n };\r\n // Generates the lookup list data\r\n ListConfig.readList = function (webUrl, listName, lookupField) {\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Get the source list\r\n (0, gd_sprest_bs_1.Web)(webUrl).Lists(listName).execute(function (list) {\r\n var fields = [];\r\n // Get the list content type fields\r\n list.ContentTypes().query({ Expand: [\"Fields\"] }).execute(function (cts) {\r\n // Parse the content type fields\r\n for (var i = 0; i < cts.results[0].Fields.results.length; i++) {\r\n var field = cts.results[0].Fields.results[i];\r\n // Add the field link\r\n fields.push(field);\r\n }\r\n });\r\n // Get the list items\r\n list.Items().query({\r\n GetAllItems: true,\r\n Top: 5000,\r\n OrderBy: [\"Id\"]\r\n }).execute(function (items) {\r\n var lookupItems = [];\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n var lookupItem = {};\r\n // Parse the field links\r\n for (var j = 0; j < fields.length; j++) {\r\n var field = fields[j];\r\n var value = items.results[i][field.InternalName];\r\n // Ensure a value exists\r\n if (value == null) {\r\n continue;\r\n }\r\n // See if this is a collection\r\n if (value.results) {\r\n // Set the results\r\n value = { results: value.results };\r\n }\r\n // Add the value, based on the type\r\n switch (field.FieldTypeKind) {\r\n case gd_sprest_bs_1.SPTypes.FieldType.URL:\r\n lookupItem[field.InternalName] = {\r\n Description: value.Description,\r\n Url: value.Url\r\n };\r\n break;\r\n default:\r\n // Set the value\r\n lookupItem[field.InternalName] = value;\r\n break;\r\n }\r\n }\r\n // Add the lookup item\r\n lookupItems.push(lookupItem);\r\n }\r\n // Resolve the request\r\n resolve({\r\n field: lookupField,\r\n items: lookupItems,\r\n list: list.Title\r\n });\r\n }, true); // Set the flag to run this after the previous request completes\r\n }, reject);\r\n });\r\n };\r\n // Validates the lookup fields\r\n ListConfig.validateLookups = function (props) {\r\n var _this = this;\r\n // See if we are showing a loading dialog\r\n if (props.showDialog) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Validating Lookup Lists\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Validating the required lookup lists have been added...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n }\r\n // Keep track of the lookup lists we are searching for\r\n var lookupLists = {};\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Parse the lookup fields\r\n gd_sprest_bs_1.Helper.Executor(props.lookupFields, function (lookupField) {\r\n var _a;\r\n // Ensure this lookup isn't to the source list\r\n if (((_a = lookupField.LookupList) === null || _a === void 0 ? void 0 : _a.indexOf(props.srcListId)) >= 0) {\r\n return;\r\n }\r\n // See if we have already checked this list\r\n var listId = (lookupField.LookupList || \"\").replace(/{|}/g, '');\r\n if (lookupLists[listId]) {\r\n return;\r\n }\r\n // Updated the loading dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Getting the lookup list for: \" + lookupField.InternalName) : null;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Get the source list\r\n (0, gd_sprest_bs_1.Web)(props.srcWebUrl).Lists().getById(lookupField.LookupList).execute(function (list) {\r\n // Updated the loading dialog\r\n props.showDialog ? loadingDialog_1.LoadingDialog.setBody(\"Generating the configuration for: \" + list.Title) : null;\r\n // Generate the lookup list configuration\r\n _this.generate({\r\n srcList: list.Title,\r\n srcWebUrl: props.srcWebUrl,\r\n showDialog: false\r\n }).then(\r\n // Success\r\n function (cfg) {\r\n // Set the flag\r\n lookupLists[list.Id] = true;\r\n // Prepend the list configuration\r\n props.cfg.ListCfg.splice(props.cfg.ListCfg.length - 1, 0, cfg.cfg.ListCfg[0]);\r\n // Check the next list\r\n resolve(null);\r\n }, \r\n // Error\r\n function () {\r\n // Reject the reqeust\r\n reject(\"Lookup list '\" + list.Title + \"' for field '\" + lookupField.InternalName + \"' does not exist in the configuration. Please add the lists in the appropriate order.\");\r\n });\r\n }, function () {\r\n // Reject the reqeust\r\n reject(\"Lookup list for field '\" + lookupField.InternalName + \"' does not exist in the source web. Please review the source list for any issues.\");\r\n });\r\n });\r\n }).then(function () {\r\n // Resolve the request\r\n resolve(props.cfg);\r\n }, reject);\r\n });\r\n };\r\n // Internal Fields\r\n ListConfig.InternalFields = [\r\n \"ContentType\", \"TaxCatchAll\", \"TaxCatchAllLabel\", \"Title\",\r\n \"ItemChildCount\", \"FolderChildCount\", \"FileLeafRef\", \"FileRef\"\r\n ];\r\n return ListConfig;\r\n}());\r\nexports.ListConfig = ListConfig;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/listCfg.js?");
|
|
119
119
|
|
|
120
120
|
/***/ }),
|
|
121
121
|
|