gd-sprest 9.7.2 → 9.7.4

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 (100) hide show
  1. package/@types/utils/base.d.ts +0 -3
  2. package/build/helper/executor.js +10 -20
  3. package/build/helper/fieldSchemaXML.js +85 -89
  4. package/build/helper/index.js +12 -28
  5. package/build/helper/jslink.js +124 -128
  6. package/build/helper/listForm.js +109 -118
  7. package/build/helper/listFormField.js +62 -65
  8. package/build/helper/methods/addContentEditorWebPart.js +9 -17
  9. package/build/helper/methods/addPermissionLevel.js +12 -16
  10. package/build/helper/methods/addScriptEditorWebPart.js +9 -17
  11. package/build/helper/methods/copyPermissionLevel.js +22 -26
  12. package/build/helper/methods/createContentType.js +96 -19
  13. package/build/helper/methods/createDocSet.js +10 -14
  14. package/build/helper/methods/getCurrentTheme.js +26 -31
  15. package/build/helper/methods/hasPermissions.js +8 -13
  16. package/build/helper/methods/index.js +16 -32
  17. package/build/helper/methods/loadSPCore.js +13 -17
  18. package/build/helper/methods/parse.js +5 -9
  19. package/build/helper/methods/request.js +4 -8
  20. package/build/helper/methods/setContentTypeFields.js +71 -79
  21. package/build/helper/methods/setGroupOwner.js +6 -10
  22. package/build/helper/methods/setWebProperty.js +26 -30
  23. package/build/helper/methods/stringify.js +3 -7
  24. package/build/helper/methods/webWorker.js +40 -20
  25. package/build/helper/ribbonLink.js +10 -14
  26. package/build/helper/sbLink.js +11 -15
  27. package/build/helper/sp/calloutManager.js +22 -25
  28. package/build/helper/sp/index.js +13 -16
  29. package/build/helper/sp/modalDialog.js +32 -35
  30. package/build/helper/sp/notify.js +9 -12
  31. package/build/helper/sp/ribbon.js +1 -4
  32. package/build/helper/sp/sod.js +9 -18
  33. package/build/helper/sp/status.js +18 -21
  34. package/build/helper/spCfg.js +232 -259
  35. package/build/helper/spCfgTypes.js +2 -5
  36. package/build/helper/taxonomy.js +144 -182
  37. package/build/helper/webpart.js +110 -94
  38. package/build/index.js +6 -23
  39. package/build/lib/apps.js +4 -7
  40. package/build/lib/contextInfo.js +217 -781
  41. package/build/lib/directorySession.js +4 -7
  42. package/build/lib/graph.js +16 -19
  43. package/build/lib/groupService.js +4 -7
  44. package/build/lib/groupSiteManager.js +4 -7
  45. package/build/lib/hubSites.js +11 -25
  46. package/build/lib/hubSitesUtility.js +4 -7
  47. package/build/lib/index.js +27 -43
  48. package/build/lib/list.js +49 -53
  49. package/build/lib/navigation.js +4 -7
  50. package/build/lib/peopleManager.js +4 -7
  51. package/build/lib/peoplePicker.js +4 -7
  52. package/build/lib/profileLoader.js +4 -7
  53. package/build/lib/search.js +30 -33
  54. package/build/lib/sensitivityLabels.js +6 -9
  55. package/build/lib/site.js +20 -35
  56. package/build/lib/siteIconManager.js +4 -7
  57. package/build/lib/siteManager.js +4 -7
  58. package/build/lib/sitePages.js +37 -51
  59. package/build/lib/socialFeed.js +13 -16
  60. package/build/lib/themeManager.js +4 -7
  61. package/build/lib/userProfile.js +4 -7
  62. package/build/lib/utility.js +12 -17
  63. package/build/lib/web.js +34 -49
  64. package/build/lib/webTemplateExtensions.js +4 -7
  65. package/build/lib/wfInstanceService.js +4 -7
  66. package/build/lib/wfSubscriptionService.js +4 -7
  67. package/build/mapper/custom/audit.js +3 -6
  68. package/build/mapper/custom/graph.js +13 -16
  69. package/build/mapper/custom/index.js +8 -24
  70. package/build/mapper/custom/odata.js +3 -6
  71. package/build/mapper/custom/old.js +42 -45
  72. package/build/mapper/custom/peoplePicker.js +4 -7
  73. package/build/mapper/custom/propertyValues.js +3 -6
  74. package/build/mapper/custom/utility.js +17 -20
  75. package/build/mapper/custom/webTemplateExtensions.js +19 -22
  76. package/build/mapper/def.js +1032 -989
  77. package/build/mapper/index.js +4 -9
  78. package/build/mapper/v2.js +2629 -2632
  79. package/build/rest.js +16 -19
  80. package/build/sptypes/graphtypes.js +694 -710
  81. package/build/sptypes/index.js +3 -7
  82. package/build/sptypes/sptypes.js +49 -52
  83. package/build/utils/base.js +20 -37
  84. package/build/utils/batch.js +53 -63
  85. package/build/utils/helper.js +79 -83
  86. package/build/utils/index.js +9 -25
  87. package/build/utils/methodInfo.js +88 -141
  88. package/build/utils/oData.js +62 -112
  89. package/build/utils/request.js +137 -155
  90. package/build/utils/requestType.js +1 -4
  91. package/build/utils/targetInfo.js +39 -52
  92. package/build/utils/xhrRequest.js +59 -107
  93. package/build/v2/drive.js +9 -13
  94. package/build/v2/drives.js +8 -12
  95. package/build/v2/index.js +3 -19
  96. package/build/v2/sites.js +61 -65
  97. package/dist/gd-sprest.d.ts +0 -3
  98. package/dist/gd-sprest.js +1 -1
  99. package/dist/gd-sprest.min.js +1 -1
  100. package/package.json +2 -2
@@ -1,22 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ListForm = void 0;
4
- var __1 = require("..");
1
+ import { ContextInfo, SPTypes, Web } from "..";
5
2
  /**
6
3
  * List Form
7
4
  */
8
- exports.ListForm = {
5
+ export const ListForm = {
9
6
  // Method to create an instance of the list form
10
- create: function (props) {
11
- var _info = null;
12
- var _props = null;
13
- var _reject = null;
14
- var _resolve = null;
7
+ create: (props) => {
8
+ let _info = null;
9
+ let _props = null;
10
+ let _reject = null;
11
+ let _resolve = null;
15
12
  // Save the properties
16
13
  _props = props || {};
17
14
  _props.fields = _props.fields;
18
15
  // Method to load the list data
19
- var load = function () {
16
+ let load = () => {
20
17
  // Clear the information
21
18
  _info = {
22
19
  item: _props.item,
@@ -26,7 +23,7 @@ exports.ListForm = {
26
23
  // Load the list data
27
24
  loadListData().then(
28
25
  // Success
29
- function () {
26
+ () => {
30
27
  // See if the fields have been defined
31
28
  if (_props.fields) {
32
29
  // Process the fields
@@ -43,7 +40,7 @@ exports.ListForm = {
43
40
  _reject);
44
41
  };
45
42
  // Method to load a content type for the associated fields
46
- var loadContentType = function () {
43
+ let loadContentType = () => {
47
44
  // Load the content types
48
45
  _info.list.ContentTypes()
49
46
  // Query for the default content type and expand the field links
@@ -54,21 +51,21 @@ exports.ListForm = {
54
51
  Top: 1
55
52
  })
56
53
  // Execute the request, but wait for the previous one to be completed
57
- .execute(function (ct) {
54
+ .execute(ct => {
58
55
  // Resolve the promise
59
56
  loadDefaultFields(ct.results[0]);
60
57
  }, _reject);
61
58
  };
62
59
  // Method to load the default fields
63
- var loadDefaultFields = function (ct) {
64
- var fields = ct ? ct.FieldLinks.results : [];
65
- var formFields = {};
66
- var formLinks = {};
60
+ let loadDefaultFields = (ct) => {
61
+ let fields = ct ? ct.FieldLinks.results : [];
62
+ let formFields = {};
63
+ let formLinks = {};
67
64
  // Parse the field links
68
- for (var i = 0; i < fields.length; i++) {
69
- var fieldLink = fields[i];
65
+ for (let i = 0; i < fields.length; i++) {
66
+ let fieldLink = fields[i];
70
67
  // Get the field
71
- var field = _info.fields[fieldLink.Name];
68
+ let field = _info.fields[fieldLink.Name];
72
69
  if (field) {
73
70
  // Skip the content type field
74
71
  if (field.InternalName == "ContentType") {
@@ -91,17 +88,17 @@ exports.ListForm = {
91
88
  loadItem();
92
89
  };
93
90
  // Method to load the field data
94
- var loadFieldData = function (fields) {
91
+ let loadFieldData = (fields) => {
95
92
  // Clear the fields
96
93
  _info.fields = {};
97
94
  // Parse the fields
98
- for (var i = 0; i < fields.results.length; i++) {
99
- var field = fields.results[i];
95
+ for (let i = 0; i < fields.results.length; i++) {
96
+ let field = fields.results[i];
100
97
  // See if the exclude fields is defined
101
98
  if (_props.excludeFields) {
102
- var excludeField = false;
99
+ let excludeField = false;
103
100
  // Parse the fields to exclude
104
- for (var j = 0; j < _props.excludeFields.length; j++) {
101
+ for (let j = 0; j < _props.excludeFields.length; j++) {
105
102
  // See if we are excluding this field
106
103
  if (_props.excludeFields[j] == field.InternalName) {
107
104
  // Set the flag
@@ -119,19 +116,19 @@ exports.ListForm = {
119
116
  }
120
117
  };
121
118
  // Method to load the item
122
- var loadItem = function () {
123
- var reloadItem = false;
119
+ let loadItem = () => {
120
+ let reloadItem = false;
124
121
  // See if the item already exist
125
122
  if (_info.item) {
126
123
  // Parse the fields
127
- for (var fieldName in _info.fields) {
128
- var field = _info.fields[fieldName];
124
+ for (let fieldName in _info.fields) {
125
+ let field = _info.fields[fieldName];
129
126
  // See what type of field this is
130
127
  switch (field.FieldTypeKind) {
131
128
  // Lookup or User Field
132
- case __1.SPTypes.FieldType.Lookup:
133
- case __1.SPTypes.FieldType.User:
134
- var fieldValue = _info.item[fieldName + "Id"];
129
+ case SPTypes.FieldType.Lookup:
130
+ case SPTypes.FieldType.User:
131
+ let fieldValue = _info.item[fieldName + "Id"];
135
132
  // Ensure the value exists
136
133
  if (fieldValue) {
137
134
  // See if a value exists
@@ -148,14 +145,14 @@ exports.ListForm = {
148
145
  default:
149
146
  // See if this is an taxonomy field
150
147
  if (field.TypeAsString.indexOf("TaxonomyFieldType") == 0) {
151
- var fieldValue_1 = _info.item[fieldName + "Id"];
148
+ let fieldValue = _info.item[fieldName + "Id"];
152
149
  // Ensure the value exists
153
- if (fieldValue_1) {
150
+ if (fieldValue) {
154
151
  // See if a field value exists
155
- if (fieldValue_1.results ? fieldValue_1.results.length > 0 : fieldValue_1 != null) {
152
+ if (fieldValue.results ? fieldValue.results.length > 0 : fieldValue != null) {
156
153
  // Parse the fields
157
- for (var fieldName_1 in _info.fields) {
158
- var valueField = _info.fields[fieldName_1];
154
+ for (let fieldName in _info.fields) {
155
+ let valueField = _info.fields[fieldName];
159
156
  // See if this is the value field
160
157
  if (valueField.InternalName == field.InternalName + "_0" || valueField.Title == field.InternalName + "_0") {
161
158
  // Ensure the value field is loaded
@@ -182,7 +179,7 @@ exports.ListForm = {
182
179
  // See if we are loading attachments
183
180
  if (_props.loadAttachments && _info.attachments == null) {
184
181
  // Load the attachments
185
- exports.ListForm.loadAttachments(_props).then(function (attachments) {
182
+ ListForm.loadAttachments(_props).then(attachments => {
186
183
  // Set the attachments
187
184
  _info.attachments = attachments;
188
185
  // Resolve the promise
@@ -197,19 +194,19 @@ exports.ListForm = {
197
194
  // Else, see if we are loading the list item
198
195
  else if (reloadItem || _props.itemId > 0) {
199
196
  // Update the item query
200
- _info.query = exports.ListForm.generateODataQuery(_info, _props.loadAttachments);
197
+ _info.query = ListForm.generateODataQuery(_info, _props.loadAttachments);
201
198
  // Get the list item
202
199
  _info.list.Items(reloadItem ? _props.item.Id : _props.itemId)
203
200
  // Set the query
204
201
  .query(_info.query)
205
202
  // Execute the request
206
- .execute(function (item) {
203
+ .execute(item => {
207
204
  // Save the attachments
208
205
  _info.attachments = item.AttachmentFiles.results;
209
206
  // Save the item
210
207
  _info.item = item;
211
208
  // Refresh the item
212
- exports.ListForm.refreshItem(_info).then(function (info) {
209
+ ListForm.refreshItem(_info).then(info => {
213
210
  // Update the info
214
211
  _info = info;
215
212
  // Resolve the promise
@@ -226,9 +223,9 @@ exports.ListForm = {
226
223
  }
227
224
  };
228
225
  // Method to load the list data
229
- var loadListData = function () {
226
+ let loadListData = () => {
230
227
  // Return a promise
231
- return new Promise(function (resolve, reject) {
228
+ return new Promise((resolve, reject) => {
232
229
  // See if the list & fields already exist
233
230
  if (_info.list && _info.fields) {
234
231
  // Resolve the promise
@@ -236,11 +233,11 @@ exports.ListForm = {
236
233
  return;
237
234
  }
238
235
  // Get the web
239
- (0, __1.Web)(_props.webUrl, { disableCache: true, requestDigest: _props.requestDigest })
236
+ Web(_props.webUrl, { disableCache: true, requestDigest: _props.requestDigest })
240
237
  // Get the list
241
238
  .Lists(_props.listName)
242
239
  // Execute the request
243
- .execute(function (list) {
240
+ .execute(list => {
244
241
  // Save the list and web url
245
242
  _info.list = list;
246
243
  _info.webUrl = _props.webUrl;
@@ -248,7 +245,7 @@ exports.ListForm = {
248
245
  // Load the fields
249
246
  .Fields()
250
247
  // Execute the request
251
- .execute(function (fields) {
248
+ .execute(fields => {
252
249
  // Load the field data
253
250
  loadFieldData(fields);
254
251
  // Resolve the promise
@@ -257,11 +254,11 @@ exports.ListForm = {
257
254
  });
258
255
  };
259
256
  // Method to process the fields
260
- var processFields = function () {
261
- var formFields = {};
257
+ let processFields = () => {
258
+ let formFields = {};
262
259
  // Parse the fields provided
263
- for (var i = 0; i < _props.fields.length; i++) {
264
- var field = _info.fields[_props.fields[i]];
260
+ for (let i = 0; i < _props.fields.length; i++) {
261
+ let field = _info.fields[_props.fields[i]];
265
262
  // Ensure the field exists
266
263
  if (field) {
267
264
  // Save the field
@@ -269,8 +266,8 @@ exports.ListForm = {
269
266
  // See if this is a taxonomy field
270
267
  if (field.TypeAsString.indexOf("TaxonomyFieldType") == 0) {
271
268
  // Parse the list fields
272
- for (var fieldName in _info.fields) {
273
- var valueField = _info.fields[fieldName];
269
+ for (let fieldName in _info.fields) {
270
+ let valueField = _info.fields[fieldName];
274
271
  // See if this is a value field
275
272
  if (valueField.InternalName == field.InternalName + "_0" || valueField.Title == field.InternalName + "_0") {
276
273
  // Include this field
@@ -285,7 +282,7 @@ exports.ListForm = {
285
282
  _info.fields = formFields;
286
283
  };
287
284
  // Return a promise
288
- return new Promise(function (resolve, reject) {
285
+ return new Promise((resolve, reject) => {
289
286
  // Save the methods
290
287
  _reject = reject;
291
288
  _resolve = resolve;
@@ -294,9 +291,8 @@ exports.ListForm = {
294
291
  });
295
292
  },
296
293
  // Method to generate the odata query
297
- generateODataQuery: function (info, loadAttachments) {
298
- if (loadAttachments === void 0) { loadAttachments = false; }
299
- var query = info.query || {};
294
+ generateODataQuery: (info, loadAttachments = false) => {
295
+ let query = info.query || {};
300
296
  // Default the select query to get all the fields by default
301
297
  query.Select = query.Select || ["*"];
302
298
  query.Expand = query.Expand || [];
@@ -309,8 +305,8 @@ exports.ListForm = {
309
305
  query.Select.push("AttachmentFiles");
310
306
  }
311
307
  // Parse the fields
312
- for (var fieldName in info.fields) {
313
- var field = info.fields[fieldName];
308
+ for (let fieldName in info.fields) {
309
+ let field = info.fields[fieldName];
314
310
  // Skip the attachments field
315
311
  if (fieldName == "Attachments") {
316
312
  continue;
@@ -324,13 +320,13 @@ exports.ListForm = {
324
320
  // Update the query, based on the type
325
321
  switch (field.FieldTypeKind) {
326
322
  // Lookup Field
327
- case __1.SPTypes.FieldType.Lookup:
328
- var lookupField = field;
323
+ case SPTypes.FieldType.Lookup:
324
+ let lookupField = field;
329
325
  // See if this is an associated lookup field
330
326
  if (lookupField.PrimaryFieldId) {
331
327
  // Parse the form fields to find the parent field
332
- for (var parentFieldName in info.fields) {
333
- var parentField = info.fields[parentFieldName];
328
+ for (let parentFieldName in info.fields) {
329
+ let parentField = info.fields[parentFieldName];
334
330
  // See if the parent field is being loaded
335
331
  if (parentField.Id == lookupField.PrimaryFieldId) {
336
332
  // Select the field
@@ -348,7 +344,7 @@ exports.ListForm = {
348
344
  }
349
345
  break;
350
346
  // User Field
351
- case __1.SPTypes.FieldType.User:
347
+ case SPTypes.FieldType.User:
352
348
  // Expand the field
353
349
  query.Expand.push(field.InternalName);
354
350
  // Select the fields
@@ -360,8 +356,8 @@ exports.ListForm = {
360
356
  // See if this is an taxonomy field
361
357
  if (field.TypeAsString.indexOf("TaxonomyFieldType") == 0) {
362
358
  // Parse the fields
363
- for (var fieldName_2 in info.fields) {
364
- var valueField = info.fields[fieldName_2];
359
+ for (let fieldName in info.fields) {
360
+ let valueField = info.fields[fieldName];
365
361
  // See if this is the value field
366
362
  if (valueField.InternalName == field.InternalName + "_0" || valueField.Title == field.InternalName + "_0") {
367
363
  // Include the value field
@@ -377,14 +373,14 @@ exports.ListForm = {
377
373
  return query;
378
374
  },
379
375
  // Method to load the item attachments
380
- loadAttachments: function (info) {
376
+ loadAttachments: (info) => {
381
377
  // Return a promise
382
- return new Promise(function (resolve, reject) {
378
+ return new Promise((resolve, reject) => {
383
379
  // Ensure the item id exists
384
- var itemId = info.item ? info.item.Id : info.itemId;
380
+ let itemId = info.item ? info.item.Id : info.itemId;
385
381
  if (itemId > 0) {
386
382
  // Get the web
387
- (0, __1.Web)(info.webUrl, { requestDigest: info.requestDigest })
383
+ Web(info.webUrl, { requestDigest: info.requestDigest })
388
384
  // Get the list
389
385
  .Lists(info.listName)
390
386
  // Get the item
@@ -392,7 +388,7 @@ exports.ListForm = {
392
388
  // Get the attachment files
393
389
  .AttachmentFiles()
394
390
  // Execute the request
395
- .execute(function (attachments) {
391
+ .execute(attachments => {
396
392
  // Ensure the attachments exist
397
393
  if (!attachments.existsFl) {
398
394
  // Reject the promise
@@ -410,26 +406,26 @@ exports.ListForm = {
410
406
  });
411
407
  },
412
408
  // Method to refresh an item
413
- refreshItem: function (info) {
409
+ refreshItem: (info) => {
414
410
  // Return a promise
415
- return new Promise(function (resolve, reject) {
411
+ return new Promise((resolve, reject) => {
416
412
  // Update the query
417
- info.query = exports.ListForm.generateODataQuery(info, info.attachments ? true : false);
413
+ info.query = ListForm.generateODataQuery(info, info.attachments ? true : false);
418
414
  // Get the item
419
- info.list.Items(info.item.Id).query(info.query).execute(function (item) {
415
+ info.list.Items(info.item.Id).query(info.query).execute(item => {
420
416
  // Update the item
421
417
  info.item = item;
422
418
  // Get the item values
423
419
  info.list.Items(item.Id).query({
424
420
  Expand: ["FieldValuesAsText", "Folder"]
425
- }).execute(function (item) {
421
+ }).execute(item => {
426
422
  // Set the values
427
423
  info.itemFolder = item.Folder;
428
424
  info.fieldValuesAsText = item.FieldValuesAsText;
429
425
  });
430
426
  // Get the html values for this item
431
427
  // This is needed for complex field values
432
- info.list.Items(item.Id).FieldValuesAsHtml().execute(function (values) {
428
+ info.list.Items(item.Id).FieldValuesAsHtml().execute(values => {
433
429
  // Set the values
434
430
  info.fieldValuesAsHtml = values;
435
431
  // Resolve the promise
@@ -439,11 +435,11 @@ exports.ListForm = {
439
435
  });
440
436
  },
441
437
  // Method to refresh the request digest value
442
- refreshRequestDigest: function (info) {
438
+ refreshRequestDigest: (info) => {
443
439
  // Return a promise
444
- return new Promise(function (resolve, reject) {
440
+ return new Promise((resolve, reject) => {
445
441
  // Get the context info
446
- __1.ContextInfo.getWeb(info.webUrl).execute(function (context) {
442
+ ContextInfo.getWeb(info.webUrl).execute(context => {
447
443
  // Update the request digest value
448
444
  info.item.updateRequestDigest(context.GetContextWebInformation.FormDigestValue);
449
445
  info.list.updateRequestDigest(context.GetContextWebInformation.FormDigestValue);
@@ -453,24 +449,24 @@ exports.ListForm = {
453
449
  });
454
450
  },
455
451
  // Method to remove attachments from an item
456
- removeAttachment: function (info, fileName) {
452
+ removeAttachment: (info, fileName) => {
457
453
  // Return a promise
458
- return new Promise(function (resolve, reject) {
454
+ return new Promise((resolve, reject) => {
459
455
  // Ensure attachments exist
460
456
  if (info.attachments) {
461
457
  // Parse the attachments
462
- for (var i = 0; i < info.attachments.length; i++) {
458
+ for (let i = 0; i < info.attachments.length; i++) {
463
459
  // See if this is the target attachment
464
- var attachment = info.attachments[i];
460
+ let attachment = info.attachments[i];
465
461
  if (attachment.FileName == fileName) {
466
462
  // Get the web
467
- (0, __1.Web)(info.webUrl, { requestDigest: info.requestDigest })
463
+ Web(info.webUrl, { requestDigest: info.requestDigest })
468
464
  // Get the file
469
465
  .getFileByServerRelativeUrl(attachment.ServerRelativeUrl)
470
466
  // Delete the file
471
467
  .delete()
472
468
  // Execute the request
473
- .execute(function () {
469
+ .execute(() => {
474
470
  // Resolve the promise
475
471
  resolve(info);
476
472
  }, reject);
@@ -488,13 +484,13 @@ exports.ListForm = {
488
484
  });
489
485
  },
490
486
  // Method to save attachments to an existing item
491
- saveAttachments: function (info, attachmentInfo) {
487
+ saveAttachments: (info, attachmentInfo) => {
492
488
  // Return a promise
493
- return new Promise(function (resolve, reject) {
494
- var itemId = info.item ? info.item.Id : info.itemId;
489
+ return new Promise((resolve, reject) => {
490
+ let itemId = info.item ? info.item.Id : info.itemId;
495
491
  if (itemId > 0) {
496
492
  // Get the web
497
- var attachments = (0, __1.Web)(info.webUrl, { requestDigest: info.requestDigest })
493
+ let attachments = Web(info.webUrl, { requestDigest: info.requestDigest })
498
494
  // Get the lists
499
495
  .Lists(info.listName)
500
496
  // Get the item
@@ -502,17 +498,13 @@ exports.ListForm = {
502
498
  // Get the attachment files
503
499
  .AttachmentFiles();
504
500
  // Parse the attachment information
505
- for (var i = 0; i < attachmentInfo.length; i++) {
506
- var attachment = attachmentInfo[i];
501
+ for (let i = 0; i < attachmentInfo.length; i++) {
502
+ let attachment = attachmentInfo[i];
507
503
  // Add the attachment
508
504
  attachments.add(attachment.name, attachment.data).execute(true);
509
505
  }
510
506
  // Wait for the requests to complete
511
- attachments.done(function () {
512
- var args = [];
513
- for (var _i = 0; _i < arguments.length; _i++) {
514
- args[_i] = arguments[_i];
515
- }
507
+ attachments.done((...args) => {
516
508
  // Resolve the promise
517
509
  resolve.apply(args);
518
510
  });
@@ -524,16 +516,15 @@ exports.ListForm = {
524
516
  });
525
517
  },
526
518
  // Method to save a new or existing item
527
- saveItem: function (info, formValues, checkItemVersion) {
528
- if (formValues === void 0) { formValues = {}; }
519
+ saveItem: (info, formValues = {}, checkItemVersion) => {
529
520
  // Return a promise
530
- return new Promise(function (resolve, reject) {
521
+ return new Promise((resolve, reject) => {
531
522
  // Set the metadata type
532
523
  formValues["__metadata"] = formValues["__metadata"] || { type: info.list.ListItemEntityTypeFullName };
533
524
  // See if this is an existing item
534
525
  if (info.item && info.item.update) {
535
526
  // Set the request properties if we are checking the item version
536
- var requestProps = {
527
+ let requestProps = {
537
528
  requestDigest: info.item.getRequestDigest()
538
529
  };
539
530
  // See if we are checking the item versions
@@ -542,9 +533,9 @@ exports.ListForm = {
542
533
  requestProps.requestHeader = { "IF-MATCH": info.item.etag };
543
534
  }
544
535
  // Update the item
545
- (0, __1.Web)(info.webUrl, requestProps).Lists(info.list.Title).Items(info.item.Id).update(formValues).execute(function (response) {
536
+ Web(info.webUrl, requestProps).Lists(info.list.Title).Items(info.item.Id).update(formValues).execute(response => {
546
537
  // Refresh the item
547
- exports.ListForm.refreshItem(info).then(function (info) {
538
+ ListForm.refreshItem(info).then(info => {
548
539
  // Resolve the promise
549
540
  resolve(info);
550
541
  }, reject);
@@ -552,11 +543,11 @@ exports.ListForm = {
552
543
  }
553
544
  else {
554
545
  // Add the item
555
- info.list.Items().add(formValues).execute(function (item) {
546
+ info.list.Items().add(formValues).execute(item => {
556
547
  // Update the info
557
548
  info.item = item;
558
549
  // Refresh the item
559
- exports.ListForm.refreshItem(info).then(function (info) {
550
+ ListForm.refreshItem(info).then(info => {
560
551
  // Resolve the promise
561
552
  resolve(info);
562
553
  }, reject);
@@ -565,13 +556,13 @@ exports.ListForm = {
565
556
  });
566
557
  },
567
558
  // Method to show a file dialog
568
- showFileDialog: function (accept, info, onSave) {
559
+ showFileDialog: (accept, info, onSave) => {
569
560
  // Return a promise
570
- return new Promise(function (resolve, reject) {
561
+ return new Promise((resolve, reject) => {
571
562
  // Method to add an attachment
572
- var addAttachment = function (name, data, src) {
563
+ let addAttachment = (name, data, src) => {
573
564
  // Call the save event
574
- onSave ? onSave({ name: name, data: data, src: src }) : null;
565
+ onSave ? onSave({ name, data, src }) : null;
575
566
  // Get the list
576
567
  info.list
577
568
  // Get the item
@@ -581,9 +572,9 @@ exports.ListForm = {
581
572
  // Add the file
582
573
  .add(name, data)
583
574
  // Execute the request
584
- .execute(function () {
575
+ .execute(() => {
585
576
  // Refresh the item
586
- exports.ListForm.refreshItem(info).then(function (info) {
577
+ ListForm.refreshItem(info).then(info => {
587
578
  // Remove the element
588
579
  document.body.removeChild(el);
589
580
  // Resolve the promise
@@ -592,14 +583,14 @@ exports.ListForm = {
592
583
  }, reject);
593
584
  };
594
585
  // Method to read the file
595
- var readFile = function (ev) {
586
+ let readFile = (ev) => {
596
587
  // Get the source file
597
- var srcFile = ev.target["files"][0];
588
+ let srcFile = ev.target["files"][0];
598
589
  if (srcFile) {
599
- var reader = new FileReader();
590
+ let reader = new FileReader();
600
591
  // Set the file loaded event
601
- reader.onloadend = function (ev) {
602
- var ext = srcFile.name.split(".");
592
+ reader.onloadend = (ev) => {
593
+ let ext = srcFile.name.split(".");
603
594
  ext = ext[ext.length - 1].toLowerCase();
604
595
  // See if the info exists
605
596
  if (info) {
@@ -618,7 +609,7 @@ exports.ListForm = {
618
609
  }
619
610
  };
620
611
  // Set the error
621
- reader.onerror = function (ev) {
612
+ reader.onerror = (ev) => {
622
613
  // Remove the element
623
614
  document.body.removeChild(el);
624
615
  // Reject the promise
@@ -629,7 +620,7 @@ exports.ListForm = {
629
620
  }
630
621
  };
631
622
  // Create the file element
632
- var el = document.body.querySelector("#listform-attachment");
623
+ let el = document.body.querySelector("#listform-attachment");
633
624
  if (el == null) {
634
625
  el = document.createElement("input");
635
626
  // Set the properties