dattatable 2.10.59 → 2.10.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/build/common/listCfg.d.ts +18 -0
  2. package/build/common/listCfg.js +152 -0
  3. package/dist/dattatable.js +1 -1
  4. package/dist/dattatable.min.js +1 -1
  5. package/docs/assets/navigation.js +1 -1
  6. package/docs/assets/search.js +1 -1
  7. package/docs/classes/Accordion.html +2 -2
  8. package/docs/classes/AuditLog.html +2 -2
  9. package/docs/classes/CanvasForm.html +2 -2
  10. package/docs/classes/Comments.html +2 -2
  11. package/docs/classes/Dashboard.html +4 -4
  12. package/docs/classes/DataTable.html +3 -3
  13. package/docs/classes/Documents.html +6 -6
  14. package/docs/classes/FilterSlideout.html +2 -2
  15. package/docs/classes/Footer.html +2 -2
  16. package/docs/classes/Header.html +2 -2
  17. package/docs/classes/InstallationRequired.html +2 -2
  18. package/docs/classes/ItemForm.html +4 -4
  19. package/docs/classes/List.html +4 -4
  20. package/docs/classes/ListConfig.html +5 -3
  21. package/docs/classes/ListSecurity.html +2 -2
  22. package/docs/classes/LoadingDialog.html +2 -2
  23. package/docs/classes/Modal.html +2 -2
  24. package/docs/classes/Navigation.html +3 -3
  25. package/docs/classes/Tiles.html +2 -2
  26. package/docs/classes/Timeout.html +2 -2
  27. package/docs/enums/ActionButtonTypes.html +2 -2
  28. package/docs/functions/formatBytes.html +1 -1
  29. package/docs/functions/formatDateValue.html +1 -1
  30. package/docs/functions/formatTimeValue.html +1 -1
  31. package/docs/functions/getContextInfo.html +1 -1
  32. package/docs/functions/getFileExt.html +1 -1
  33. package/docs/functions/waitForTheme.html +1 -1
  34. package/docs/interfaces/IAccordion.html +2 -2
  35. package/docs/interfaces/IAccordionProps.html +2 -2
  36. package/docs/interfaces/IAuditLogItem.html +2 -2
  37. package/docs/interfaces/IAuditLogItemCreation.html +2 -2
  38. package/docs/interfaces/IAuditLogProps.html +2 -2
  39. package/docs/interfaces/IAuditLogViewProps.html +2 -2
  40. package/docs/interfaces/ICommentsItem.html +2 -2
  41. package/docs/interfaces/ICreateLookupData.html +4 -0
  42. package/docs/interfaces/IDashboardProps.html +2 -2
  43. package/docs/interfaces/IDataTable.html +2 -2
  44. package/docs/interfaces/IDataTableProps.html +2 -2
  45. package/docs/interfaces/IDocumentsProps.html +2 -2
  46. package/docs/interfaces/IFilterItem.html +2 -2
  47. package/docs/interfaces/IFilterProps.html +2 -2
  48. package/docs/interfaces/IFooterProps.html +2 -2
  49. package/docs/interfaces/IGenerateLookupDataProps.html +5 -0
  50. package/docs/interfaces/IHeaderProps.html +2 -2
  51. package/docs/interfaces/IInstallProps.html +2 -2
  52. package/docs/interfaces/IItemFormCreateProps.html +2 -2
  53. package/docs/interfaces/IItemFormEditProps.html +2 -2
  54. package/docs/interfaces/IItemFormTab.html +2 -2
  55. package/docs/interfaces/IItemFormTabInfo.html +2 -2
  56. package/docs/interfaces/IItemFormViewProps.html +2 -2
  57. package/docs/interfaces/IListConfig.html +2 -2
  58. package/docs/interfaces/IListConfigProps.html +2 -2
  59. package/docs/interfaces/IListProps.html +2 -2
  60. package/docs/interfaces/IListSecurity.html +2 -2
  61. package/docs/interfaces/IListSecurityItem.html +2 -2
  62. package/docs/interfaces/ILookupData.html +4 -0
  63. package/docs/interfaces/IShowDialogProps.html +2 -2
  64. package/docs/interfaces/ITiles.html +2 -2
  65. package/docs/interfaces/ITilesProps.html +2 -2
  66. package/docs/interfaces/IValidateLookupsProps.html +2 -2
  67. package/docs/modules.html +3 -0
  68. package/docs/variables/DattaTable.html +1 -1
  69. package/docs/variables/ListSecurityDefaultGroups.html +1 -1
  70. package/package.json +1 -1
@@ -1,4 +1,9 @@
1
1
  import { Helper, Types } from "gd-sprest-bs";
2
+ export interface ICreateLookupData {
3
+ lookupData: ILookupData[];
4
+ showDialog?: boolean;
5
+ webUrl: string;
6
+ }
2
7
  export interface IListConfig {
3
8
  cfg: Helper.ISPConfigProps;
4
9
  lookupFields: Types.SP.FieldLookup[];
@@ -8,6 +13,17 @@ export interface IListConfigProps {
8
13
  srcList: Types.SP.List;
9
14
  srcWebUrl: string;
10
15
  }
16
+ export interface ILookupData {
17
+ field: string;
18
+ list: string;
19
+ items: string;
20
+ }
21
+ export interface IGenerateLookupDataProps {
22
+ lookupFields: Types.SP.FieldLookup[];
23
+ showDialog?: boolean;
24
+ srcList: Types.SP.List;
25
+ srcWebUrl: string;
26
+ }
11
27
  export interface IValidateLookupsProps {
12
28
  cfg: Helper.ISPConfigProps;
13
29
  dstUrl: string;
@@ -21,6 +37,8 @@ export interface IValidateLookupsProps {
21
37
  */
22
38
  export declare class ListConfig {
23
39
  private static InternalFields;
40
+ static createLookupListData(props: ICreateLookupData): PromiseLike<void>;
24
41
  static generate(props: IListConfigProps): PromiseLike<IListConfig>;
42
+ static generateLookupListData(props: IGenerateLookupDataProps): PromiseLike<ILookupData[]>;
25
43
  static validateLookups(props: IValidateLookupsProps): PromiseLike<Helper.ISPConfigProps>;
26
44
  }
@@ -10,6 +10,98 @@ var list_1 = require("./list");
10
10
  var ListConfig = /** @class */ (function () {
11
11
  function ListConfig() {
12
12
  }
13
+ // Generates the lookup list data
14
+ ListConfig.createLookupListData = function (props) {
15
+ // See if we are showing a loading dialog
16
+ if (props.showDialog) {
17
+ // Show a loading dialog
18
+ loadingDialog_1.LoadingDialog.setHeader("Lookup List Data");
19
+ loadingDialog_1.LoadingDialog.setBody("Updating the lookup list data...");
20
+ loadingDialog_1.LoadingDialog.show();
21
+ }
22
+ // Return a promise
23
+ return new Promise(function (resolve, reject) {
24
+ // Ensure data exists
25
+ if (props.lookupData == null) {
26
+ // Hide the dialog
27
+ props.showDialog ? loadingDialog_1.LoadingDialog.hide() : null;
28
+ resolve(null);
29
+ return;
30
+ }
31
+ // Update the dialog
32
+ props.showDialog ? loadingDialog_1.LoadingDialog.setBody("Getting the web context information...") : null;
33
+ // Get the web context info
34
+ gd_sprest_bs_1.ContextInfo.getWeb(props.webUrl).execute(function (contextInfo) {
35
+ // Parse the lookup list data
36
+ gd_sprest_bs_1.Helper.Executor(props.lookupData, function (lookupData) {
37
+ // Update the dialog
38
+ props.showDialog ? loadingDialog_1.LoadingDialog.setBody("Getting the list: " + lookupData.list) : null;
39
+ // Get the items
40
+ var items = null;
41
+ try {
42
+ items = gd_sprest_bs_1.Helper.parse(lookupData.items).results;
43
+ }
44
+ catch (_a) {
45
+ // Unable to parse the data
46
+ console.error("List data corrupt for: " + lookupData.list);
47
+ return;
48
+ }
49
+ // Return a promise
50
+ return new Promise(function (resolve) {
51
+ // Update the dialog
52
+ props.showDialog ? loadingDialog_1.LoadingDialog.setBody("Getting the current list data for: " + lookupData.list) : null;
53
+ // Get the current list items
54
+ (0, gd_sprest_bs_1.Web)(props.webUrl).Lists(lookupData.list).Items().query({ Top: 5000, GetAllItems: true }).execute(function (currItems) {
55
+ var dstList = (0, gd_sprest_bs_1.Web)(props.webUrl, { requestDigest: contextInfo.GetContextWebInformation.FormDigestValue }).Lists(lookupData.list);
56
+ // Update the dialog
57
+ props.showDialog ? loadingDialog_1.LoadingDialog.setBody("Importing the list data: " + lookupData.list) : null;
58
+ var _loop_1 = function (i) {
59
+ var addItem = true;
60
+ var item = items[i];
61
+ // See if the items exists
62
+ currItems.results.find(function (a) {
63
+ // See if the item exists
64
+ if (a[lookupData.field] == item[lookupData.field]) {
65
+ // Set the flag
66
+ addItem = false;
67
+ }
68
+ });
69
+ // See if we are adding the item
70
+ if (addItem) {
71
+ var dstItem = {};
72
+ dstItem["Title"] = item["Title"];
73
+ dstItem[lookupData.field] = item[lookupData.field];
74
+ dstList.Items().add(dstItem).batch(function (item) {
75
+ // Log
76
+ console.log("[" + lookupData.list + "] Item added: " + item[lookupData.field]);
77
+ });
78
+ }
79
+ };
80
+ // Parse the list items
81
+ for (var i = 0; i < items.length; i++) {
82
+ _loop_1(i);
83
+ }
84
+ // Execute the batch job
85
+ dstList.done(function () {
86
+ // Check the next list
87
+ resolve(null);
88
+ });
89
+ }, function () {
90
+ // Error getting the list data
91
+ console.error("Error getting the destination list: " + lookupData.list);
92
+ // Check the next lookup field
93
+ resolve(null);
94
+ });
95
+ });
96
+ }).then(function () {
97
+ // Hide the dialog
98
+ props.showDialog ? loadingDialog_1.LoadingDialog.hide() : null;
99
+ // Resolve the request
100
+ resolve();
101
+ }, reject);
102
+ });
103
+ });
104
+ };
13
105
  // Generates the list configuration
14
106
  ListConfig.generate = function (props) {
15
107
  var _this = this;
@@ -236,6 +328,66 @@ var ListConfig = /** @class */ (function () {
236
328
  });
237
329
  });
238
330
  };
331
+ // Generates the lookup list data
332
+ ListConfig.generateLookupListData = function (props) {
333
+ var lookupListData = [];
334
+ // See if we are showing a loading dialog
335
+ if (props.showDialog) {
336
+ // Show a loading dialog
337
+ loadingDialog_1.LoadingDialog.setHeader("Analyzing Lookup Lists");
338
+ loadingDialog_1.LoadingDialog.setBody("Getting the lookup lists data...");
339
+ loadingDialog_1.LoadingDialog.show();
340
+ }
341
+ // Keep track of the lookup lists we are searching for
342
+ var lookupLists = {};
343
+ // Return a promise
344
+ return new Promise(function (resolve, reject) {
345
+ // Parse the lookup fields
346
+ gd_sprest_bs_1.Helper.Executor(props.lookupFields, function (lookupField) {
347
+ var _a;
348
+ // Ensure this lookup isn't to the source list
349
+ if (((_a = lookupField.LookupList) === null || _a === void 0 ? void 0 : _a.indexOf(props.srcList.Id)) >= 0) {
350
+ return;
351
+ }
352
+ // See if we have already checked this list
353
+ var listId = (lookupField.LookupList || "").replace(/{|}/g, '');
354
+ if (lookupLists[listId]) {
355
+ return;
356
+ }
357
+ // Updated the loading dialog
358
+ props.showDialog ? loadingDialog_1.LoadingDialog.setBody("Getting the lookup list for: " + lookupField.InternalName) : null;
359
+ // Return a promise
360
+ return new Promise(function (resolve) {
361
+ // Get the source list
362
+ (0, gd_sprest_bs_1.Web)(props.srcWebUrl).Lists().getById(lookupField.LookupList).execute(function (list) {
363
+ // Get the list items
364
+ list.Items().query({
365
+ GetAllItems: true,
366
+ Top: 5000,
367
+ OrderBy: ["Id"]
368
+ }).execute(function (items) {
369
+ // Save the item data
370
+ lookupListData.push({
371
+ field: lookupField.LookupField,
372
+ items: gd_sprest_bs_1.Helper.stringify(items),
373
+ list: list.Title
374
+ });
375
+ // Set the flag
376
+ lookupLists[listId] = true;
377
+ // Check the next list
378
+ resolve(null);
379
+ });
380
+ }, function () {
381
+ // Check the next list
382
+ resolve(null);
383
+ });
384
+ });
385
+ }).then(function () {
386
+ // Resolve the request
387
+ resolve(lookupListData);
388
+ }, reject);
389
+ });
390
+ };
239
391
  // Validates the lookup fields
240
392
  ListConfig.validateLookups = function (props) {
241
393
  var _this = this;
@@ -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.11.82/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 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.Title,\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 // 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 Title: props.srcList.Title,\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 // Parse the content type fields\r\n var fieldRefs = [];\r\n for (var j = 0; j < ct.FieldLinks.results.length; j++) {\r\n var fldInfo = list.getField(ct.FieldLinks.results[j].Name);\r\n // See if this is a lookup field\r\n if (fldInfo.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Lookup) {\r\n // Ensure this isn't an associated lookup field\r\n if (fldInfo.IsDependentLookup != true) {\r\n // Append the field ref\r\n fieldRefs.push(fldInfo.InternalName);\r\n }\r\n }\r\n else {\r\n // Append the field ref\r\n fieldRefs.push(fldInfo.InternalName);\r\n }\r\n // Skip internal fields\r\n if (_this.InternalFields.indexOf(fldInfo.InternalName) >= 0) {\r\n continue;\r\n }\r\n // See if this is a calculated field\r\n if (fldInfo.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Calculated) {\r\n // Add the field and continue the loop\r\n calcFields.push(fldInfo);\r\n }\r\n // Else, see if this is a lookup field\r\n else if (fldInfo.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Lookup) {\r\n // Add the field\r\n lookupFields.push(fldInfo);\r\n }\r\n // Else, ensure the field hasn't been added\r\n else if (fields[fldInfo.InternalName] == null) {\r\n // Add the field information\r\n fields[fldInfo.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n name: fldInfo.InternalName,\r\n schemaXml: fldInfo.SchemaXml\r\n });\r\n }\r\n }\r\n // Add the list content type\r\n cfgProps.ListCfg[0].ContentTypes.push({\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 {\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 // Add the view\r\n cfgProps.ListCfg[0].ViewInformation.push({\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 // 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 // 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.srcList.Id)) >= 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(\"Checking the destination web for: \" + list.Title) : null;\r\n // Ensure the list exists in the destination\r\n (0, gd_sprest_bs_1.Web)(props.dstUrl).Lists(list.Title).execute(function () {\r\n // Set the flag\r\n lookupLists[list.Id] = true;\r\n // Check the next list\r\n resolve(null);\r\n }, function () {\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,\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 });\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 ];\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.11.82/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 // Get the items\r\n var items = null;\r\n try {\r\n items = gd_sprest_bs_1.Helper.parse(lookupData.items).results;\r\n }\r\n catch (_a) {\r\n // Unable to parse the data\r\n console.error(\"List data corrupt for: \" + lookupData.list);\r\n return;\r\n }\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 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 var _loop_1 = function (i) {\r\n var addItem = true;\r\n var item = items[i];\r\n // See if the items exists\r\n currItems.results.find(function (a) {\r\n // See if the item exists\r\n if (a[lookupData.field] == item[lookupData.field]) {\r\n // Set the flag\r\n addItem = false;\r\n }\r\n });\r\n // See if we are adding the item\r\n if (addItem) {\r\n var dstItem = {};\r\n dstItem[\"Title\"] = item[\"Title\"];\r\n dstItem[lookupData.field] = item[lookupData.field];\r\n dstList.Items().add(dstItem).batch(function (item) {\r\n // Log\r\n console.log(\"[\" + lookupData.list + \"] Item added: \" + item[lookupData.field]);\r\n });\r\n }\r\n };\r\n // Parse the list items\r\n for (var i = 0; i < items.length; i++) {\r\n _loop_1(i);\r\n }\r\n // Execute the batch job\r\n dstList.done(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 });\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 // 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.Title,\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 // 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 Title: props.srcList.Title,\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 // Parse the content type fields\r\n var fieldRefs = [];\r\n for (var j = 0; j < ct.FieldLinks.results.length; j++) {\r\n var fldInfo = list.getField(ct.FieldLinks.results[j].Name);\r\n // See if this is a lookup field\r\n if (fldInfo.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Lookup) {\r\n // Ensure this isn't an associated lookup field\r\n if (fldInfo.IsDependentLookup != true) {\r\n // Append the field ref\r\n fieldRefs.push(fldInfo.InternalName);\r\n }\r\n }\r\n else {\r\n // Append the field ref\r\n fieldRefs.push(fldInfo.InternalName);\r\n }\r\n // Skip internal fields\r\n if (_this.InternalFields.indexOf(fldInfo.InternalName) >= 0) {\r\n continue;\r\n }\r\n // See if this is a calculated field\r\n if (fldInfo.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Calculated) {\r\n // Add the field and continue the loop\r\n calcFields.push(fldInfo);\r\n }\r\n // Else, see if this is a lookup field\r\n else if (fldInfo.FieldTypeKind == gd_sprest_bs_1.SPTypes.FieldType.Lookup) {\r\n // Add the field\r\n lookupFields.push(fldInfo);\r\n }\r\n // Else, ensure the field hasn't been added\r\n else if (fields[fldInfo.InternalName] == null) {\r\n // Add the field information\r\n fields[fldInfo.InternalName] = true;\r\n cfgProps.ListCfg[0].CustomFields.push({\r\n name: fldInfo.InternalName,\r\n schemaXml: fldInfo.SchemaXml\r\n });\r\n }\r\n }\r\n // Add the list content type\r\n cfgProps.ListCfg[0].ContentTypes.push({\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 {\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 // Add the view\r\n cfgProps.ListCfg[0].ViewInformation.push({\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 // 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 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.srcList.Id)) >= 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 // 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 // Save the item data\r\n lookupListData.push({\r\n field: lookupField.LookupField,\r\n items: gd_sprest_bs_1.Helper.stringify(items),\r\n list: list.Title\r\n });\r\n // Set the flag\r\n lookupLists[listId] = true;\r\n // Check the next list\r\n resolve(null);\r\n });\r\n }, function () {\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 // 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.srcList.Id)) >= 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(\"Checking the destination web for: \" + list.Title) : null;\r\n // Ensure the list exists in the destination\r\n (0, gd_sprest_bs_1.Web)(props.dstUrl).Lists(list.Title).execute(function () {\r\n // Set the flag\r\n lookupLists[list.Id] = true;\r\n // Check the next list\r\n resolve(null);\r\n }, function () {\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,\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 });\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 ];\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