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.
- package/@types/utils/base.d.ts +0 -3
- package/build/helper/executor.js +10 -20
- package/build/helper/fieldSchemaXML.js +85 -89
- package/build/helper/index.js +12 -28
- package/build/helper/jslink.js +124 -128
- package/build/helper/listForm.js +109 -118
- package/build/helper/listFormField.js +62 -65
- package/build/helper/methods/addContentEditorWebPart.js +9 -17
- package/build/helper/methods/addPermissionLevel.js +12 -16
- package/build/helper/methods/addScriptEditorWebPart.js +9 -17
- package/build/helper/methods/copyPermissionLevel.js +22 -26
- package/build/helper/methods/createContentType.js +96 -19
- package/build/helper/methods/createDocSet.js +10 -14
- package/build/helper/methods/getCurrentTheme.js +26 -31
- package/build/helper/methods/hasPermissions.js +8 -13
- package/build/helper/methods/index.js +16 -32
- package/build/helper/methods/loadSPCore.js +13 -17
- package/build/helper/methods/parse.js +5 -9
- package/build/helper/methods/request.js +4 -8
- package/build/helper/methods/setContentTypeFields.js +71 -79
- package/build/helper/methods/setGroupOwner.js +6 -10
- package/build/helper/methods/setWebProperty.js +26 -30
- package/build/helper/methods/stringify.js +3 -7
- package/build/helper/methods/webWorker.js +40 -20
- package/build/helper/ribbonLink.js +10 -14
- package/build/helper/sbLink.js +11 -15
- package/build/helper/sp/calloutManager.js +22 -25
- package/build/helper/sp/index.js +13 -16
- package/build/helper/sp/modalDialog.js +32 -35
- package/build/helper/sp/notify.js +9 -12
- package/build/helper/sp/ribbon.js +1 -4
- package/build/helper/sp/sod.js +9 -18
- package/build/helper/sp/status.js +18 -21
- package/build/helper/spCfg.js +232 -259
- package/build/helper/spCfgTypes.js +2 -5
- package/build/helper/taxonomy.js +144 -182
- package/build/helper/webpart.js +110 -94
- package/build/index.js +6 -23
- package/build/lib/apps.js +4 -7
- package/build/lib/contextInfo.js +217 -781
- package/build/lib/directorySession.js +4 -7
- package/build/lib/graph.js +16 -19
- package/build/lib/groupService.js +4 -7
- package/build/lib/groupSiteManager.js +4 -7
- package/build/lib/hubSites.js +11 -25
- package/build/lib/hubSitesUtility.js +4 -7
- package/build/lib/index.js +27 -43
- package/build/lib/list.js +49 -53
- package/build/lib/navigation.js +4 -7
- package/build/lib/peopleManager.js +4 -7
- package/build/lib/peoplePicker.js +4 -7
- package/build/lib/profileLoader.js +4 -7
- package/build/lib/search.js +30 -33
- package/build/lib/sensitivityLabels.js +6 -9
- package/build/lib/site.js +20 -35
- package/build/lib/siteIconManager.js +4 -7
- package/build/lib/siteManager.js +4 -7
- package/build/lib/sitePages.js +37 -51
- package/build/lib/socialFeed.js +13 -16
- package/build/lib/themeManager.js +4 -7
- package/build/lib/userProfile.js +4 -7
- package/build/lib/utility.js +12 -17
- package/build/lib/web.js +34 -49
- package/build/lib/webTemplateExtensions.js +4 -7
- package/build/lib/wfInstanceService.js +4 -7
- package/build/lib/wfSubscriptionService.js +4 -7
- package/build/mapper/custom/audit.js +3 -6
- package/build/mapper/custom/graph.js +13 -16
- package/build/mapper/custom/index.js +8 -24
- package/build/mapper/custom/odata.js +3 -6
- package/build/mapper/custom/old.js +42 -45
- package/build/mapper/custom/peoplePicker.js +4 -7
- package/build/mapper/custom/propertyValues.js +3 -6
- package/build/mapper/custom/utility.js +17 -20
- package/build/mapper/custom/webTemplateExtensions.js +19 -22
- package/build/mapper/def.js +1032 -989
- package/build/mapper/index.js +4 -9
- package/build/mapper/v2.js +2629 -2632
- package/build/rest.js +16 -19
- package/build/sptypes/graphtypes.js +694 -710
- package/build/sptypes/index.js +3 -7
- package/build/sptypes/sptypes.js +49 -52
- package/build/utils/base.js +20 -37
- package/build/utils/batch.js +53 -63
- package/build/utils/helper.js +79 -83
- package/build/utils/index.js +9 -25
- package/build/utils/methodInfo.js +88 -141
- package/build/utils/oData.js +62 -112
- package/build/utils/request.js +137 -155
- package/build/utils/requestType.js +1 -4
- package/build/utils/targetInfo.js +39 -52
- package/build/utils/xhrRequest.js +59 -107
- package/build/v2/drive.js +9 -13
- package/build/v2/drives.js +8 -12
- package/build/v2/index.js +3 -19
- package/build/v2/sites.js +61 -65
- package/dist/gd-sprest.d.ts +0 -3
- package/dist/gd-sprest.js +1 -1
- package/dist/gd-sprest.min.js +1 -1
- package/package.json +2 -2
package/build/helper/spCfg.js
CHANGED
|
@@ -1,39 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SPConfig = void 0;
|
|
18
|
-
var lib_1 = require("../lib");
|
|
19
|
-
var __1 = require("..");
|
|
20
|
-
var _1 = require(".");
|
|
21
|
-
__exportStar(require("./spCfgTypes"), exports);
|
|
1
|
+
import { ContextInfo, Site, Web } from "../lib";
|
|
2
|
+
import { SPTypes } from "..";
|
|
3
|
+
import { createContentType, setContentTypeFields, Executor, FieldSchemaXML, loadSPCore, SPCfgType, SPCfgFieldType } from ".";
|
|
4
|
+
export * from "./spCfgTypes";
|
|
22
5
|
/**
|
|
23
6
|
* SharePoint Configuration
|
|
24
7
|
*/
|
|
25
|
-
|
|
8
|
+
export const SPConfig = (cfg, webUrl) => {
|
|
26
9
|
// The selected configuration type to install
|
|
27
|
-
|
|
10
|
+
let _cfgType;
|
|
28
11
|
// The request digest
|
|
29
|
-
|
|
12
|
+
let _requestDigest = null;
|
|
30
13
|
// The target name to install/uninstall
|
|
31
|
-
|
|
14
|
+
let _targetName;
|
|
32
15
|
/**
|
|
33
16
|
* Logging
|
|
34
17
|
*/
|
|
35
|
-
|
|
36
|
-
if (isError === void 0) { isError = false; }
|
|
18
|
+
let logMessage = (message, isError = false) => {
|
|
37
19
|
// See if this is an error
|
|
38
20
|
if (isError) {
|
|
39
21
|
// Log the error
|
|
@@ -49,9 +31,9 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
49
31
|
* Methods
|
|
50
32
|
*/
|
|
51
33
|
// Method to create the content types
|
|
52
|
-
|
|
34
|
+
let createContentTypes = (contentTypes, cfgContentTypes, list) => {
|
|
53
35
|
// Return a promise
|
|
54
|
-
return new Promise(
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
55
37
|
// Ensure fields exist
|
|
56
38
|
if (cfgContentTypes == null || cfgContentTypes.length == 0) {
|
|
57
39
|
// Resolve the promise
|
|
@@ -59,11 +41,11 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
59
41
|
return;
|
|
60
42
|
}
|
|
61
43
|
// Method to get the parent content type
|
|
62
|
-
|
|
44
|
+
let getParentCT = (ctName, url) => {
|
|
63
45
|
// Return a promise
|
|
64
|
-
return new Promise(
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
65
47
|
// Get the web containing the parent content type
|
|
66
|
-
|
|
48
|
+
Web(url, { disableCache: true })
|
|
67
49
|
// Get the content types
|
|
68
50
|
.ContentTypes()
|
|
69
51
|
// Filter for the parent name
|
|
@@ -71,16 +53,16 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
71
53
|
Filter: "Name eq '" + ctName + "'"
|
|
72
54
|
})
|
|
73
55
|
// Execute the request
|
|
74
|
-
.execute(
|
|
56
|
+
.execute(cts => {
|
|
75
57
|
// See if the parent exists
|
|
76
58
|
if (cts.results[0]) {
|
|
77
59
|
// Resolve the promise
|
|
78
60
|
resolve({ Id: cts.results[0].Id.StringValue, Url: url });
|
|
79
61
|
}
|
|
80
62
|
// Else, ensure this isn't the root web
|
|
81
|
-
else if (url !=
|
|
63
|
+
else if (url != ContextInfo.siteServerRelativeUrl) {
|
|
82
64
|
// Check the root web for the parent content type
|
|
83
|
-
getParentCT(ctName,
|
|
65
|
+
getParentCT(ctName, ContextInfo.siteServerRelativeUrl).then(resolve, reject);
|
|
84
66
|
}
|
|
85
67
|
else {
|
|
86
68
|
// Reject the promise
|
|
@@ -90,11 +72,11 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
90
72
|
});
|
|
91
73
|
};
|
|
92
74
|
// Parse the configuration
|
|
93
|
-
|
|
75
|
+
Executor(cfgContentTypes, cfg => {
|
|
94
76
|
// Return a promise
|
|
95
|
-
return new Promise(
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
96
78
|
// See if this content type already exists
|
|
97
|
-
|
|
79
|
+
let ct = isInCollection("Name", cfg.Name, contentTypes.results);
|
|
98
80
|
if (ct) {
|
|
99
81
|
// Log
|
|
100
82
|
logMessage("[gd-sprest]" + (list ? "[" + list.Title + " List]" : "") + "[Content Type] The content type '" + cfg.Name + "' already exists.");
|
|
@@ -110,17 +92,17 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
110
92
|
if (cfg.ParentName) {
|
|
111
93
|
getParentCT(cfg.ParentName, cfg.ParentWebUrl || webUrl).then(
|
|
112
94
|
// Success
|
|
113
|
-
|
|
95
|
+
parentInfo => {
|
|
114
96
|
// Add the content type
|
|
115
|
-
|
|
97
|
+
createContentType({
|
|
116
98
|
ctInfo: cfg,
|
|
117
99
|
listName: list ? list.Title : null,
|
|
118
100
|
parentContentTypeId: parentInfo.Id,
|
|
119
101
|
parentContentTypeUrl: parentInfo.Url,
|
|
120
|
-
webUrl
|
|
102
|
+
webUrl
|
|
121
103
|
}).then(
|
|
122
104
|
// Success
|
|
123
|
-
|
|
105
|
+
ct => {
|
|
124
106
|
// Log
|
|
125
107
|
logMessage("[gd-sprest]" + (list ? "[" + list.Title + " List]" : "") + "[Content Type] The content type '" + cfg.Name + "' was created successfully.");
|
|
126
108
|
// Update the configuration
|
|
@@ -131,7 +113,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
131
113
|
resolve(cfg);
|
|
132
114
|
},
|
|
133
115
|
// Error
|
|
134
|
-
|
|
116
|
+
error => {
|
|
135
117
|
// Log
|
|
136
118
|
logMessage("[gd-sprest]" + (list ? "[" + list.Title + " List]" : "") + "[Content Type] The content type '" + cfg.Name + "' failed to be created.", error);
|
|
137
119
|
// Reject the promise
|
|
@@ -139,7 +121,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
139
121
|
});
|
|
140
122
|
},
|
|
141
123
|
// Error
|
|
142
|
-
|
|
124
|
+
() => {
|
|
143
125
|
// Log
|
|
144
126
|
logMessage("[gd-sprest]" + (list ? "[" + list.Title + " List]" : "") + "[Content Type] The parent content type '" + cfg.ParentName + "' was not found.");
|
|
145
127
|
// Reject the promise
|
|
@@ -148,14 +130,14 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
148
130
|
}
|
|
149
131
|
else {
|
|
150
132
|
// Create the content type
|
|
151
|
-
|
|
133
|
+
createContentType({
|
|
152
134
|
ctInfo: cfg,
|
|
153
135
|
listName: list ? list.Title : null,
|
|
154
136
|
parentContentTypeId: cfg.Id,
|
|
155
|
-
webUrl
|
|
137
|
+
webUrl
|
|
156
138
|
}).then(
|
|
157
139
|
// Success
|
|
158
|
-
|
|
140
|
+
(ct) => {
|
|
159
141
|
// Log
|
|
160
142
|
logMessage("[gd-sprest]" + (list ? "[" + list.Title + " List]" : "") + "[Content Type] The content type '" + cfg.Name + "' was created successfully.");
|
|
161
143
|
// Update the configuration
|
|
@@ -166,7 +148,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
166
148
|
resolve(cfg);
|
|
167
149
|
},
|
|
168
150
|
// Error
|
|
169
|
-
|
|
151
|
+
error => {
|
|
170
152
|
// Log
|
|
171
153
|
logMessage("[gd-sprest]" + (list ? "[" + list.Title + " List]" : "") + "[Content Type] The content type '" + cfg.Name + "' failed to be created.");
|
|
172
154
|
logMessage("[gd-sprest]" + (list ? "[" + list.Title + " List]" : "") + "[Content Type] Error: " + error.response, true);
|
|
@@ -175,13 +157,13 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
175
157
|
});
|
|
176
158
|
}
|
|
177
159
|
});
|
|
178
|
-
}).then(
|
|
160
|
+
}).then(() => {
|
|
179
161
|
// Parse the configuration
|
|
180
|
-
|
|
162
|
+
Executor(cfgContentTypes, cfgContentType => {
|
|
181
163
|
// Return a promise
|
|
182
|
-
return new Promise(
|
|
183
|
-
|
|
184
|
-
|
|
164
|
+
return new Promise((resolve, reject) => {
|
|
165
|
+
let cfgUpdate = {};
|
|
166
|
+
let updateFl = false;
|
|
185
167
|
// Ensure the content type exists
|
|
186
168
|
if (cfgContentType.ContentType == null) {
|
|
187
169
|
// Skip this content type
|
|
@@ -191,12 +173,12 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
191
173
|
// Log
|
|
192
174
|
logMessage("[gd-sprest]" + (list ? "[" + list.Title + " List]" : "") + "[Content Type] Updating the field references for: " + cfgContentType.Name);
|
|
193
175
|
// Create the field refs
|
|
194
|
-
|
|
176
|
+
setContentTypeFields({
|
|
195
177
|
fields: cfgContentType.FieldRefs,
|
|
196
178
|
id: cfgContentType.ContentType.Id.StringValue,
|
|
197
179
|
listName: list ? list.Title : null,
|
|
198
|
-
webUrl
|
|
199
|
-
}).then(
|
|
180
|
+
webUrl
|
|
181
|
+
}).then(() => {
|
|
200
182
|
/**
|
|
201
183
|
* See if we need to update the properties
|
|
202
184
|
*/
|
|
@@ -240,7 +222,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
240
222
|
// Log
|
|
241
223
|
logMessage("[gd-sprest]" + (list ? "[" + list.Title + " List]" : "") + "[Content Type][" + cfgContentType.ContentType.Name + "] Updating the content type.");
|
|
242
224
|
// Update the content type
|
|
243
|
-
cfgContentType.ContentType.update(cfgUpdate).execute(
|
|
225
|
+
cfgContentType.ContentType.update(cfgUpdate).execute(() => {
|
|
244
226
|
// Log
|
|
245
227
|
logMessage("[gd-sprest]" + (list ? "[" + list.Title + " List]" : "") + "[Content Type][" + cfgContentType.ContentType.Name + "] Update request completed.");
|
|
246
228
|
// Trigger the event
|
|
@@ -262,10 +244,10 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
262
244
|
});
|
|
263
245
|
};
|
|
264
246
|
// Method to create the fields
|
|
265
|
-
|
|
247
|
+
let createFields = (fields, cfgFields, list) => {
|
|
266
248
|
// Return a promise
|
|
267
|
-
return new Promise(
|
|
268
|
-
|
|
249
|
+
return new Promise((resolve, reject) => {
|
|
250
|
+
let newFields = [];
|
|
269
251
|
// Ensure fields exist
|
|
270
252
|
if (cfgFields == null || cfgFields.length == 0) {
|
|
271
253
|
// Resolve the promise
|
|
@@ -273,10 +255,10 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
273
255
|
return;
|
|
274
256
|
}
|
|
275
257
|
// Parse the configuration
|
|
276
|
-
|
|
277
|
-
return new Promise(
|
|
258
|
+
Executor(cfgFields, cfg => {
|
|
259
|
+
return new Promise((resolve) => {
|
|
278
260
|
// See if this field already exists
|
|
279
|
-
|
|
261
|
+
let field = isInCollection("InternalName", cfg.name, fields.results);
|
|
280
262
|
if (field) {
|
|
281
263
|
// Log
|
|
282
264
|
logMessage("[gd-sprest][Field] The field '" + cfg.name + "' already exists.");
|
|
@@ -289,10 +271,10 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
289
271
|
// Log
|
|
290
272
|
logMessage("[gd-sprest][Field] Creating the '" + cfg.name + "' field.");
|
|
291
273
|
// See if this is an associated lookup field
|
|
292
|
-
|
|
293
|
-
if (cfgLookup.type ==
|
|
274
|
+
let cfgLookup = cfg;
|
|
275
|
+
if (cfgLookup.type == SPCfgFieldType.Lookup && cfgLookup.fieldRef) {
|
|
294
276
|
// Get the field reference
|
|
295
|
-
|
|
277
|
+
let fieldRef = isInCollection("InternalName", cfgLookup.fieldRef, fields.results) ||
|
|
296
278
|
isInCollection("InternalName", cfgLookup.fieldRef, newFields);
|
|
297
279
|
if (fieldRef) {
|
|
298
280
|
// Update the value to be the guid
|
|
@@ -300,12 +282,12 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
300
282
|
}
|
|
301
283
|
}
|
|
302
284
|
// Compute the schema xml
|
|
303
|
-
|
|
304
|
-
|
|
285
|
+
FieldSchemaXML(cfg, webUrl).then(response => {
|
|
286
|
+
let schemas = typeof (response) === "string" ? [response] : response;
|
|
305
287
|
// Parse the fields to add
|
|
306
|
-
for (
|
|
288
|
+
for (let i = 0; i < schemas.length; i++) {
|
|
307
289
|
// Add the field
|
|
308
|
-
fields.createFieldAsXml(schemas[i]).execute(
|
|
290
|
+
fields.createFieldAsXml(schemas[i]).execute((field) => {
|
|
309
291
|
// See if it was successful
|
|
310
292
|
if (field.InternalName) {
|
|
311
293
|
// Log
|
|
@@ -333,13 +315,13 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
333
315
|
});
|
|
334
316
|
};
|
|
335
317
|
// Method to create the lists
|
|
336
|
-
|
|
318
|
+
let createLists = (lists, cfgLists) => {
|
|
337
319
|
// Return a promise
|
|
338
|
-
return new Promise(
|
|
320
|
+
return new Promise((resolve, reject) => {
|
|
339
321
|
// Execute code against each list configuration
|
|
340
|
-
|
|
322
|
+
Executor(cfgLists, cfgList => {
|
|
341
323
|
// Return a promise
|
|
342
|
-
return new Promise(
|
|
324
|
+
return new Promise((resolve) => {
|
|
343
325
|
// See if the target name exists and matches this list
|
|
344
326
|
if (_cfgType && _targetName) {
|
|
345
327
|
// Ensure it's for this list
|
|
@@ -350,7 +332,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
350
332
|
}
|
|
351
333
|
}
|
|
352
334
|
// See if this list already exists
|
|
353
|
-
|
|
335
|
+
let list = isInCollection("Title", cfgList.ListInformation.Title, lists.results);
|
|
354
336
|
if (list) {
|
|
355
337
|
// Log
|
|
356
338
|
logMessage("[gd-sprest][List] The list '" + cfgList.ListInformation.Title + "' already exists.");
|
|
@@ -361,13 +343,13 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
361
343
|
// Log
|
|
362
344
|
logMessage("[gd-sprest][List] Creating the '" + cfgList.ListInformation.Title + "' list.");
|
|
363
345
|
// Update the list name and remove spaces
|
|
364
|
-
|
|
365
|
-
|
|
346
|
+
let listInfo = cfgList.ListInformation;
|
|
347
|
+
let listName = listInfo.Title;
|
|
366
348
|
listInfo.Title = cfgList.ListUrlName || listName.replace(/ /g, "");
|
|
367
349
|
// Add the list
|
|
368
350
|
lists.add(listInfo)
|
|
369
351
|
// Execute the request
|
|
370
|
-
.execute(
|
|
352
|
+
.execute((list) => {
|
|
371
353
|
cfgList["_list"] = list;
|
|
372
354
|
// Restore the list name in the configuration
|
|
373
355
|
listInfo.Title = listName;
|
|
@@ -376,7 +358,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
376
358
|
// See if we need to update the list
|
|
377
359
|
if (list.Title != listName) {
|
|
378
360
|
// Update the list
|
|
379
|
-
list.update({ Title: listName }).execute(
|
|
361
|
+
list.update({ Title: listName }).execute(() => {
|
|
380
362
|
// Log
|
|
381
363
|
logMessage("[gd-sprest][List] The list '" + list.Title + "' was created successfully.");
|
|
382
364
|
// Resolve the promise
|
|
@@ -401,12 +383,12 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
401
383
|
}
|
|
402
384
|
}, reject);
|
|
403
385
|
});
|
|
404
|
-
}).then(
|
|
386
|
+
}).then(() => {
|
|
405
387
|
// Update the lists
|
|
406
|
-
updateLists(cfgLists).then(
|
|
388
|
+
updateLists(cfgLists).then(() => {
|
|
407
389
|
// Parse the lists
|
|
408
|
-
for (
|
|
409
|
-
|
|
390
|
+
for (let i = 0; i < cfgLists.length; i++) {
|
|
391
|
+
let cfgList = cfgLists[i];
|
|
410
392
|
// Trigger the event
|
|
411
393
|
cfgList.onCreated ? cfgList.onCreated(cfgList["_list"]) : null;
|
|
412
394
|
}
|
|
@@ -417,13 +399,13 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
417
399
|
});
|
|
418
400
|
};
|
|
419
401
|
// Method to create the user custom actions
|
|
420
|
-
|
|
402
|
+
let createUserCustomActions = (customActions, cfgCustomActions) => {
|
|
421
403
|
// Return a promise
|
|
422
|
-
return new Promise(
|
|
404
|
+
return new Promise((resolve, reject) => {
|
|
423
405
|
// See if the configuration type exists
|
|
424
406
|
if (_cfgType) {
|
|
425
407
|
// Ensure it's for this type
|
|
426
|
-
if (_cfgType !=
|
|
408
|
+
if (_cfgType != SPCfgType.SiteUserCustomActions || _cfgType != SPCfgType.WebUserCustomActions) {
|
|
427
409
|
// Resolve the promise
|
|
428
410
|
resolve();
|
|
429
411
|
return;
|
|
@@ -436,7 +418,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
436
418
|
return;
|
|
437
419
|
}
|
|
438
420
|
// Parse the configuration
|
|
439
|
-
|
|
421
|
+
Executor(cfgCustomActions, cfg => {
|
|
440
422
|
// See if the target name exists
|
|
441
423
|
if (_cfgType && _targetName) {
|
|
442
424
|
// Ensure it's for this custom action
|
|
@@ -458,7 +440,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
458
440
|
cfg.Rights = updateBasePermissions(cfg.Rights);
|
|
459
441
|
}
|
|
460
442
|
// Add the custom action
|
|
461
|
-
customActions.add(cfg).execute(
|
|
443
|
+
customActions.add(cfg).execute((ca) => {
|
|
462
444
|
// Ensure it exists
|
|
463
445
|
if (ca.existsFl) {
|
|
464
446
|
// Log
|
|
@@ -475,9 +457,9 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
475
457
|
});
|
|
476
458
|
};
|
|
477
459
|
// Method to create the list views
|
|
478
|
-
|
|
460
|
+
let createViews = (list, views, cfgViews) => {
|
|
479
461
|
// Return a promise
|
|
480
|
-
return new Promise(
|
|
462
|
+
return new Promise((resolve, reject) => {
|
|
481
463
|
// Ensure the list views exist
|
|
482
464
|
if (cfgViews == null || cfgViews.length == 0) {
|
|
483
465
|
// Resolve the promise and return it
|
|
@@ -485,9 +467,9 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
485
467
|
return;
|
|
486
468
|
}
|
|
487
469
|
// Parse the configuration
|
|
488
|
-
|
|
470
|
+
Executor(cfgViews, cfg => {
|
|
489
471
|
// See if this view exists
|
|
490
|
-
|
|
472
|
+
let view = isInCollection("Title", cfg.ViewName, views.results);
|
|
491
473
|
if (view) {
|
|
492
474
|
// Log
|
|
493
475
|
logMessage("[gd-sprest][View] The view '" + cfg.ViewName + "' already exists.");
|
|
@@ -503,7 +485,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
503
485
|
Title: cfg.ViewName,
|
|
504
486
|
RowLimit: cfg.RowLimit,
|
|
505
487
|
ViewQuery: cfg.ViewQuery
|
|
506
|
-
}).execute(
|
|
488
|
+
}).execute((view) => {
|
|
507
489
|
// Ensure it exists
|
|
508
490
|
if (view.existsFl) {
|
|
509
491
|
// Log
|
|
@@ -518,9 +500,9 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
518
500
|
}
|
|
519
501
|
}, reject, true);
|
|
520
502
|
}
|
|
521
|
-
}).then(
|
|
503
|
+
}).then(() => {
|
|
522
504
|
// Update the views
|
|
523
|
-
updateViews(list, views, cfgViews).then(
|
|
505
|
+
updateViews(list, views, cfgViews).then(() => {
|
|
524
506
|
// Resolve the promise
|
|
525
507
|
resolve();
|
|
526
508
|
});
|
|
@@ -528,10 +510,10 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
528
510
|
});
|
|
529
511
|
};
|
|
530
512
|
// Method to create the web parts
|
|
531
|
-
|
|
513
|
+
let createWebParts = () => {
|
|
532
514
|
// Return a promise
|
|
533
|
-
return new Promise(
|
|
534
|
-
|
|
515
|
+
return new Promise((resolve, reject) => {
|
|
516
|
+
let cfgWebParts = cfg.WebPartCfg;
|
|
535
517
|
// Ensure fields exist
|
|
536
518
|
if (cfgWebParts == null || cfgWebParts.length == 0) {
|
|
537
519
|
// Resolve the promise
|
|
@@ -541,9 +523,9 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
541
523
|
// Log
|
|
542
524
|
logMessage("[gd-sprest][WebPart] Creating the web parts.");
|
|
543
525
|
// Get the web
|
|
544
|
-
|
|
526
|
+
Web(webUrl, { disableCache: true, requestDigest: _requestDigest })
|
|
545
527
|
// Get the web part catalog
|
|
546
|
-
.getCatalog(
|
|
528
|
+
.getCatalog(SPTypes.ListTemplateType.WebPartCatalog)
|
|
547
529
|
// Get the root folder
|
|
548
530
|
.RootFolder()
|
|
549
531
|
// Expand the files and items
|
|
@@ -551,19 +533,21 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
551
533
|
Expand: ["Files"]
|
|
552
534
|
})
|
|
553
535
|
// Execute the request
|
|
554
|
-
.execute(
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
536
|
+
.execute(folder => {
|
|
537
|
+
let ctr = 0;
|
|
538
|
+
// Parse the configuration
|
|
539
|
+
for (let i = 0; i < cfgWebParts.length; i++) {
|
|
540
|
+
let cfgWebPart = cfgWebParts[i];
|
|
558
541
|
// See if the target name exists
|
|
559
542
|
if (_cfgType && _targetName) {
|
|
560
543
|
// Ensure it's for this list
|
|
561
544
|
if (cfgWebPart.FileName.toLowerCase() != _targetName) {
|
|
562
|
-
|
|
545
|
+
// Skip this list
|
|
546
|
+
continue;
|
|
563
547
|
}
|
|
564
548
|
}
|
|
565
549
|
// The post execute method
|
|
566
|
-
|
|
550
|
+
let postExecute = () => {
|
|
567
551
|
// Increment the counter
|
|
568
552
|
if (++ctr >= cfgWebParts.length) {
|
|
569
553
|
// Resolve the promise
|
|
@@ -571,7 +555,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
571
555
|
}
|
|
572
556
|
};
|
|
573
557
|
// See if this webpart exists
|
|
574
|
-
|
|
558
|
+
let file = isInCollection("Name", cfgWebPart.FileName, folder.Files.results);
|
|
575
559
|
if (file.Name) {
|
|
576
560
|
// Log
|
|
577
561
|
logMessage("[gd-sprest][WebPart] The webpart '" + cfgWebPart.FileName + "' already exists.");
|
|
@@ -582,23 +566,23 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
582
566
|
}
|
|
583
567
|
else {
|
|
584
568
|
// Trim the xml
|
|
585
|
-
|
|
569
|
+
let xml = cfgWebPart.XML.trim();
|
|
586
570
|
// Convert the string to an array buffer
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
for (
|
|
571
|
+
let buffer = new ArrayBuffer(xml.length * 2);
|
|
572
|
+
let bufferView = new Uint16Array(buffer);
|
|
573
|
+
for (let j = 0; j < xml.length; j++) {
|
|
590
574
|
bufferView[j] = xml.charCodeAt(j);
|
|
591
575
|
}
|
|
592
576
|
// Create the webpart, but execute the requests one at a time
|
|
593
577
|
folder.Files.add(cfgWebPart.FileName, true, buffer).execute(
|
|
594
578
|
// Success
|
|
595
|
-
|
|
579
|
+
(file) => {
|
|
596
580
|
// See if group exists
|
|
597
581
|
if (cfgWebPart.Group) {
|
|
598
582
|
// Set the target to the root web
|
|
599
|
-
|
|
583
|
+
Web(ContextInfo.siteServerRelativeUrl, { disableCache: true })
|
|
600
584
|
// Get the web part catalog
|
|
601
|
-
.getCatalog(
|
|
585
|
+
.getCatalog(SPTypes.ListTemplateType.WebPartCatalog)
|
|
602
586
|
// Get the Items
|
|
603
587
|
.Items()
|
|
604
588
|
// Query for this webpart
|
|
@@ -606,7 +590,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
606
590
|
Filter: "FileLeafRef eq '" + cfgWebPart.FileName + "'"
|
|
607
591
|
})
|
|
608
592
|
// Execute the request
|
|
609
|
-
.execute(
|
|
593
|
+
.execute((items) => {
|
|
610
594
|
// Update the item
|
|
611
595
|
items.results[0].update({
|
|
612
596
|
Group: cfgWebPart.Group
|
|
@@ -619,29 +603,25 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
619
603
|
cfgWebPart.onCreated ? cfgWebPart.onCreated(file) : null;
|
|
620
604
|
},
|
|
621
605
|
// Error
|
|
622
|
-
|
|
606
|
+
() => {
|
|
623
607
|
// Log
|
|
624
608
|
logMessage("[gd-sprest][WebPart] The '" + file.Name + "' webpart file upload failed.");
|
|
625
609
|
// Skip this webpart
|
|
626
610
|
resolve();
|
|
627
611
|
});
|
|
628
612
|
}
|
|
629
|
-
};
|
|
630
|
-
// Parse the configuration
|
|
631
|
-
for (var i = 0; i < cfgWebParts.length; i++) {
|
|
632
|
-
_loop_1(i);
|
|
633
613
|
}
|
|
634
614
|
}, reject);
|
|
635
615
|
});
|
|
636
616
|
};
|
|
637
617
|
// Method to see if an object exists in a collection
|
|
638
|
-
|
|
618
|
+
let isInCollection = (key, value, collection) => {
|
|
639
619
|
// Ensure a value exists
|
|
640
620
|
if (value) {
|
|
641
|
-
|
|
621
|
+
let valueLower = value ? value.toLowerCase() : "";
|
|
642
622
|
// Parse the collection
|
|
643
|
-
for (
|
|
644
|
-
|
|
623
|
+
for (let i = 0; i < collection.length; i++) {
|
|
624
|
+
let keyValue = collection[i][key];
|
|
645
625
|
keyValue = keyValue ? keyValue.toLowerCase() : "";
|
|
646
626
|
// See if the item exists
|
|
647
627
|
if (valueLower == keyValue) {
|
|
@@ -654,9 +634,9 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
654
634
|
return false;
|
|
655
635
|
};
|
|
656
636
|
// Method to remove the content type
|
|
657
|
-
|
|
637
|
+
let removeContentTypes = (contentTypes, cfgContentTypes) => {
|
|
658
638
|
// Return a promise
|
|
659
|
-
return new Promise(
|
|
639
|
+
return new Promise((resolve, reject) => {
|
|
660
640
|
// Ensure the content types exist
|
|
661
641
|
if (cfgContentTypes == null || cfgContentTypes.length == 0) {
|
|
662
642
|
// Resolve the promise and return it
|
|
@@ -664,12 +644,12 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
664
644
|
return;
|
|
665
645
|
}
|
|
666
646
|
// Parse the configuration
|
|
667
|
-
|
|
647
|
+
Executor(cfgContentTypes, cfg => {
|
|
668
648
|
// Get the field
|
|
669
|
-
|
|
649
|
+
let ct = isInCollection("Name", cfg.Name, contentTypes.results);
|
|
670
650
|
if (ct) {
|
|
671
651
|
// Remove the field
|
|
672
|
-
ct.delete().execute(
|
|
652
|
+
ct.delete().execute(() => {
|
|
673
653
|
// Log
|
|
674
654
|
logMessage("[gd-sprest][Content Type] The content type '" + ct.Name + "' was removed.");
|
|
675
655
|
}, reject, true);
|
|
@@ -678,9 +658,9 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
678
658
|
});
|
|
679
659
|
};
|
|
680
660
|
// Method to remove the fields
|
|
681
|
-
|
|
661
|
+
let removeFields = (fields, cfgFields) => {
|
|
682
662
|
// Return a promise
|
|
683
|
-
return new Promise(
|
|
663
|
+
return new Promise((resolve, reject) => {
|
|
684
664
|
// Ensure the fields exist
|
|
685
665
|
if (cfgFields == null || cfgFields.length == 0) {
|
|
686
666
|
// Resolve the promise and return it
|
|
@@ -688,12 +668,12 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
688
668
|
return;
|
|
689
669
|
}
|
|
690
670
|
// Parse the configuration
|
|
691
|
-
|
|
671
|
+
Executor(cfgFields, cfg => {
|
|
692
672
|
// Get the field
|
|
693
|
-
|
|
673
|
+
let field = isInCollection("InternalName", cfg.name, fields.results);
|
|
694
674
|
if (field) {
|
|
695
675
|
// Remove the field
|
|
696
|
-
field.delete().execute(
|
|
676
|
+
field.delete().execute(() => {
|
|
697
677
|
// Log
|
|
698
678
|
logMessage("[gd-sprest][Field] The field '" + field.InternalName + "' was removed.");
|
|
699
679
|
}, reject, true);
|
|
@@ -702,13 +682,13 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
702
682
|
});
|
|
703
683
|
};
|
|
704
684
|
// Method to remove the lists
|
|
705
|
-
|
|
685
|
+
let removeLists = (lists, cfgLists) => {
|
|
706
686
|
// Return a promise
|
|
707
|
-
return new Promise(
|
|
687
|
+
return new Promise((resolve, reject) => {
|
|
708
688
|
// See if the configuration type exists
|
|
709
689
|
if (_cfgType) {
|
|
710
690
|
// Ensure it's for this type
|
|
711
|
-
if (_cfgType !=
|
|
691
|
+
if (_cfgType != SPCfgType.Lists) {
|
|
712
692
|
// Resolve the promise
|
|
713
693
|
resolve();
|
|
714
694
|
return;
|
|
@@ -721,7 +701,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
721
701
|
return;
|
|
722
702
|
}
|
|
723
703
|
// Parse the configuration
|
|
724
|
-
|
|
704
|
+
Executor(cfgLists, cfg => {
|
|
725
705
|
// See if the target name exists
|
|
726
706
|
if (_cfgType && _targetName) {
|
|
727
707
|
// Ensure it's for this list
|
|
@@ -731,10 +711,10 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
731
711
|
}
|
|
732
712
|
}
|
|
733
713
|
// Get the list
|
|
734
|
-
|
|
714
|
+
let list = isInCollection("Title", cfg.ListInformation.Title, lists.results);
|
|
735
715
|
if (list) {
|
|
736
716
|
// Remove the list
|
|
737
|
-
list.delete().execute(
|
|
717
|
+
list.delete().execute(() => {
|
|
738
718
|
// Log
|
|
739
719
|
logMessage("[gd-sprest][List] The list '" + list.Title + "' was removed.");
|
|
740
720
|
}, reject, true);
|
|
@@ -743,13 +723,13 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
743
723
|
});
|
|
744
724
|
};
|
|
745
725
|
// Method to remove the user custom actions
|
|
746
|
-
|
|
726
|
+
let removeUserCustomActions = (customActions, cfgCustomActions) => {
|
|
747
727
|
// Return a promise
|
|
748
|
-
return new Promise(
|
|
728
|
+
return new Promise((resolve, reject) => {
|
|
749
729
|
// See if the configuration type exists
|
|
750
730
|
if (_cfgType) {
|
|
751
731
|
// Ensure it's for this type
|
|
752
|
-
if (_cfgType !=
|
|
732
|
+
if (_cfgType != SPCfgType.SiteUserCustomActions || _cfgType != SPCfgType.WebUserCustomActions) {
|
|
753
733
|
// Resolve the promise
|
|
754
734
|
resolve();
|
|
755
735
|
return;
|
|
@@ -762,7 +742,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
762
742
|
return;
|
|
763
743
|
}
|
|
764
744
|
// Parse the configuration
|
|
765
|
-
|
|
745
|
+
Executor(cfgCustomActions, cfg => {
|
|
766
746
|
// See if the target name exists
|
|
767
747
|
if (_cfgType && _targetName) {
|
|
768
748
|
// Ensure it's for this custom action
|
|
@@ -773,10 +753,10 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
773
753
|
}
|
|
774
754
|
}
|
|
775
755
|
// Get the custom action
|
|
776
|
-
|
|
756
|
+
let ca = isInCollection("Name", cfg.Name, customActions.results);
|
|
777
757
|
if (ca) {
|
|
778
758
|
// Remove the custom action
|
|
779
|
-
ca.delete().execute(
|
|
759
|
+
ca.delete().execute(() => {
|
|
780
760
|
// Log
|
|
781
761
|
logMessage("[gd-sprest][Custom Action] The custom action '" + ca.Name + "' was removed.");
|
|
782
762
|
}, reject, true);
|
|
@@ -785,14 +765,14 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
785
765
|
});
|
|
786
766
|
};
|
|
787
767
|
// Method to remove the web parts
|
|
788
|
-
|
|
789
|
-
|
|
768
|
+
let removeWebParts = (site) => {
|
|
769
|
+
let cfgWebParts = cfg.WebPartCfg;
|
|
790
770
|
// Return a promise
|
|
791
|
-
return new Promise(
|
|
771
|
+
return new Promise((resolve, reject) => {
|
|
792
772
|
// See if the configuration type exists
|
|
793
773
|
if (_cfgType) {
|
|
794
774
|
// Ensure it's for this type
|
|
795
|
-
if (_cfgType !=
|
|
775
|
+
if (_cfgType != SPCfgType.WebParts) {
|
|
796
776
|
// Resolve the promise
|
|
797
777
|
resolve();
|
|
798
778
|
return;
|
|
@@ -807,35 +787,33 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
807
787
|
// Log
|
|
808
788
|
logMessage("[gd-sprest][WebPart] Removing the web parts.");
|
|
809
789
|
// Get the webpart gallery from the root web
|
|
810
|
-
site.RootWeb().getCatalog(
|
|
790
|
+
site.RootWeb().getCatalog(SPTypes.ListTemplateType.WebPartCatalog)
|
|
811
791
|
// Get the root folder
|
|
812
792
|
.RootFolder()
|
|
813
793
|
// Expand the files
|
|
814
794
|
.Files()
|
|
815
795
|
// Execute the request
|
|
816
|
-
.execute(
|
|
817
|
-
|
|
818
|
-
|
|
796
|
+
.execute(files => {
|
|
797
|
+
// Parse the configuration
|
|
798
|
+
for (let i = 0; i < cfgWebParts.length; i++) {
|
|
799
|
+
let cfgWebPart = cfgWebParts[i];
|
|
819
800
|
// See if the target name exists
|
|
820
801
|
if (_cfgType && _targetName) {
|
|
821
802
|
// Ensure it's for this webpart
|
|
822
803
|
if (cfgWebPart.FileName.toLowerCase() != _targetName) {
|
|
823
|
-
|
|
804
|
+
// Skip this webpart
|
|
805
|
+
continue;
|
|
824
806
|
}
|
|
825
807
|
}
|
|
826
808
|
// Get the file
|
|
827
|
-
|
|
809
|
+
let file = isInCollection("Name", cfgWebPart.FileName, files.results);
|
|
828
810
|
if (file) {
|
|
829
811
|
// Remove the file
|
|
830
|
-
file.delete().execute(
|
|
812
|
+
file.delete().execute(() => {
|
|
831
813
|
// Log
|
|
832
814
|
logMessage("[gd-sprest][WebPart] The webpart '" + file.Name + "' file was removed.");
|
|
833
815
|
}, true);
|
|
834
816
|
}
|
|
835
|
-
};
|
|
836
|
-
// Parse the configuration
|
|
837
|
-
for (var i = 0; i < cfgWebParts.length; i++) {
|
|
838
|
-
_loop_2(i);
|
|
839
817
|
}
|
|
840
818
|
// Resolve the promise
|
|
841
819
|
resolve();
|
|
@@ -843,12 +821,12 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
843
821
|
});
|
|
844
822
|
};
|
|
845
823
|
// Method to get the web information
|
|
846
|
-
|
|
824
|
+
let setRequestDigest = () => {
|
|
847
825
|
// Return a promise
|
|
848
|
-
return new Promise(
|
|
826
|
+
return new Promise((resolve, reject) => {
|
|
849
827
|
if (webUrl) {
|
|
850
828
|
// Get the web context information
|
|
851
|
-
|
|
829
|
+
ContextInfo.getWeb(webUrl).execute(webInfo => {
|
|
852
830
|
_requestDigest = webInfo.GetContextWebInformation.FormDigestValue;
|
|
853
831
|
// Resolve the promise
|
|
854
832
|
resolve();
|
|
@@ -861,12 +839,12 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
861
839
|
});
|
|
862
840
|
};
|
|
863
841
|
// Method to update the base permissions
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
842
|
+
let updateBasePermissions = (values) => {
|
|
843
|
+
let high = values.High;
|
|
844
|
+
let low = values.Low;
|
|
867
845
|
// See if this is an array
|
|
868
|
-
for (
|
|
869
|
-
|
|
846
|
+
for (let i = 0; i < values["length"]; i++) {
|
|
847
|
+
let value = values[i];
|
|
870
848
|
// See if this is the full mask
|
|
871
849
|
if (value == 65) {
|
|
872
850
|
// Set the values
|
|
@@ -883,8 +861,8 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
883
861
|
}
|
|
884
862
|
// Else, update the base permission
|
|
885
863
|
else {
|
|
886
|
-
|
|
887
|
-
|
|
864
|
+
let bit = value - 1;
|
|
865
|
+
let bitValue = 1;
|
|
888
866
|
// Validate the bit
|
|
889
867
|
if (bit < 0) {
|
|
890
868
|
continue;
|
|
@@ -912,12 +890,12 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
912
890
|
};
|
|
913
891
|
};
|
|
914
892
|
// Method to update the lists
|
|
915
|
-
|
|
893
|
+
let updateLists = (cfgLists) => {
|
|
916
894
|
// Return a promise
|
|
917
|
-
return new Promise(
|
|
918
|
-
|
|
895
|
+
return new Promise((resolve, reject) => {
|
|
896
|
+
let request = (idx, resolve) => {
|
|
919
897
|
// Get the list configuration
|
|
920
|
-
|
|
898
|
+
let cfgList = cfgLists[idx];
|
|
921
899
|
// See if the target name exists
|
|
922
900
|
if (_targetName) {
|
|
923
901
|
// Ensure it's for this list
|
|
@@ -930,7 +908,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
930
908
|
// Ensure the configuration exists
|
|
931
909
|
if (cfgList) {
|
|
932
910
|
// Get the web
|
|
933
|
-
|
|
911
|
+
Web(webUrl, { disableCache: true, requestDigest: _requestDigest })
|
|
934
912
|
// Get the list
|
|
935
913
|
.Lists(cfgList.ListInformation.Title)
|
|
936
914
|
// Expand the content types, fields and views
|
|
@@ -938,17 +916,17 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
938
916
|
Expand: ["ContentTypes", "Fields", "UserCustomActions", "Views"]
|
|
939
917
|
})
|
|
940
918
|
// Execute the request
|
|
941
|
-
.execute(
|
|
919
|
+
.execute(list => {
|
|
942
920
|
// Update the title field
|
|
943
|
-
updateListTitleField(list, cfgList).then(
|
|
921
|
+
updateListTitleField(list, cfgList).then(() => {
|
|
944
922
|
// Create the fields
|
|
945
|
-
createFields(list.Fields, cfgList.CustomFields, list).then(
|
|
923
|
+
createFields(list.Fields, cfgList.CustomFields, list).then(() => {
|
|
946
924
|
// Create the content types
|
|
947
|
-
createContentTypes(list.ContentTypes, cfgList.ContentTypes, list).then(
|
|
925
|
+
createContentTypes(list.ContentTypes, cfgList.ContentTypes, list).then(() => {
|
|
948
926
|
// Update the views
|
|
949
|
-
createViews(list, list.Views, cfgList.ViewInformation).then(
|
|
927
|
+
createViews(list, list.Views, cfgList.ViewInformation).then(() => {
|
|
950
928
|
// Update the views
|
|
951
|
-
createUserCustomActions(list.UserCustomActions, cfgList.UserCustomActions).then(
|
|
929
|
+
createUserCustomActions(list.UserCustomActions, cfgList.UserCustomActions).then(() => {
|
|
952
930
|
// Trigger the event
|
|
953
931
|
cfgList.onUpdated ? cfgList.onUpdated(list) : null;
|
|
954
932
|
// Update the next list
|
|
@@ -970,13 +948,13 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
970
948
|
});
|
|
971
949
|
};
|
|
972
950
|
// Method to update the list title field
|
|
973
|
-
|
|
951
|
+
let updateListTitleField = (list, cfgList) => {
|
|
974
952
|
// Return a promise
|
|
975
|
-
return new Promise(
|
|
953
|
+
return new Promise((resolve, reject) => {
|
|
976
954
|
// Ensure an update is required
|
|
977
955
|
if (cfgList.TitleFieldDefaultValue || cfgList.TitleFieldDescription || cfgList.TitleFieldDisplayName ||
|
|
978
956
|
cfgList.TitleFieldIndexed || cfgList.TitleFieldRequired || cfgList.TitleFieldUniqueValues) {
|
|
979
|
-
|
|
957
|
+
let values = {};
|
|
980
958
|
// See if we are setting a default value
|
|
981
959
|
if (cfgList.TitleFieldDefaultValue) {
|
|
982
960
|
// Update the values
|
|
@@ -1009,7 +987,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1009
987
|
values["EnforceUniqueValues"] = true;
|
|
1010
988
|
}
|
|
1011
989
|
// Update the field name
|
|
1012
|
-
list.Fields.getByInternalNameOrTitle("Title").update(values).execute(
|
|
990
|
+
list.Fields.getByInternalNameOrTitle("Title").update(values).execute(() => {
|
|
1013
991
|
// Log
|
|
1014
992
|
cfgList.TitleFieldDefaultValue ? logMessage("[gd-sprest][List] The 'Title' field's default value was updated to '" + cfgList.TitleFieldDefaultValue + "'.") : null;
|
|
1015
993
|
cfgList.TitleFieldDescription ? logMessage("[gd-sprest][List] The 'Title' field's description was updated to '" + cfgList.TitleFieldDescription + "'.") : null;
|
|
@@ -1028,15 +1006,15 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1028
1006
|
});
|
|
1029
1007
|
};
|
|
1030
1008
|
// Method to update the views
|
|
1031
|
-
|
|
1009
|
+
let updateViews = (list, views, cfgViews) => {
|
|
1032
1010
|
// Return a promise
|
|
1033
|
-
return new Promise(
|
|
1011
|
+
return new Promise((resolve) => {
|
|
1034
1012
|
// Parse the configuration
|
|
1035
|
-
|
|
1013
|
+
Executor(cfgViews, cfg => {
|
|
1036
1014
|
// Return a promise
|
|
1037
|
-
return new Promise(
|
|
1015
|
+
return new Promise((resolve) => {
|
|
1038
1016
|
// Get the view
|
|
1039
|
-
|
|
1017
|
+
let view = views.getByTitle(cfg.ViewName);
|
|
1040
1018
|
// See if the view fields are defined
|
|
1041
1019
|
if (cfg.ViewFields && cfg.ViewFields.length > 0) {
|
|
1042
1020
|
// Log
|
|
@@ -1044,7 +1022,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1044
1022
|
// Clear the view fields
|
|
1045
1023
|
view.ViewFields().removeAllViewFields().execute(true);
|
|
1046
1024
|
// Parse the view fields
|
|
1047
|
-
for (
|
|
1025
|
+
for (let i = 0; i < cfg.ViewFields.length; i++) {
|
|
1048
1026
|
// Log
|
|
1049
1027
|
logMessage("[gd-sprest][View] Add view field '" + cfg.ViewFields[i] + "' to the view.");
|
|
1050
1028
|
// Add the view field
|
|
@@ -1055,7 +1033,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1055
1033
|
if (typeof (cfg.Default) === "boolean" || typeof (cfg.Hidden) === "boolean" ||
|
|
1056
1034
|
typeof (cfg.MobileDefaultView) === "boolean" || typeof (cfg.MobileView) === "boolean" ||
|
|
1057
1035
|
typeof (cfg.Tabular) === "boolean" || cfg.JSLink || cfg.RowLimit > 0 || cfg.ViewQuery) {
|
|
1058
|
-
|
|
1036
|
+
let props = {};
|
|
1059
1037
|
// Log
|
|
1060
1038
|
logMessage("[gd-sprest][View] Updating the view properties for the '" + cfg.ViewName + "' view.");
|
|
1061
1039
|
// Set the properties
|
|
@@ -1072,11 +1050,7 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1072
1050
|
view.update(props).execute(true);
|
|
1073
1051
|
}
|
|
1074
1052
|
// Wait for the requests to complete
|
|
1075
|
-
view.done(
|
|
1076
|
-
var args = [];
|
|
1077
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1078
|
-
args[_i] = arguments[_i];
|
|
1079
|
-
}
|
|
1053
|
+
view.done((...args) => {
|
|
1080
1054
|
// Log
|
|
1081
1055
|
logMessage("[gd-sprest][View] The updates for the '" + cfg.ViewName + "' view has completed.");
|
|
1082
1056
|
// Trigger the event
|
|
@@ -1089,25 +1063,25 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1089
1063
|
});
|
|
1090
1064
|
};
|
|
1091
1065
|
// Method to uninstall the site components
|
|
1092
|
-
|
|
1066
|
+
let uninstallSite = () => {
|
|
1093
1067
|
// Return a promise
|
|
1094
|
-
return new Promise(
|
|
1068
|
+
return new Promise((resolve, reject) => {
|
|
1095
1069
|
// Ensure we need to complete this request
|
|
1096
1070
|
if ((cfg.CustomActionCfg != null && cfg.CustomActionCfg.Site != null) || cfg.WebPartCfg != null) {
|
|
1097
1071
|
// Log
|
|
1098
1072
|
logMessage("[gd-sprest][uninstall] Loading the site information...");
|
|
1099
1073
|
// Get the site
|
|
1100
|
-
|
|
1074
|
+
Site(webUrl, { disableCache: true, requestDigest: _requestDigest })
|
|
1101
1075
|
// Expand the user custom actions
|
|
1102
1076
|
.query({
|
|
1103
1077
|
Expand: ["UserCustomActions"]
|
|
1104
1078
|
})
|
|
1105
1079
|
// Execute the request
|
|
1106
|
-
.execute(
|
|
1080
|
+
.execute(site => {
|
|
1107
1081
|
// Remove the user custom actions
|
|
1108
|
-
removeUserCustomActions(site.UserCustomActions, cfg.CustomActionCfg ? cfg.CustomActionCfg.Site : []).then(
|
|
1082
|
+
removeUserCustomActions(site.UserCustomActions, cfg.CustomActionCfg ? cfg.CustomActionCfg.Site : []).then(() => {
|
|
1109
1083
|
// Remove the webpart
|
|
1110
|
-
removeWebParts(site).then(
|
|
1084
|
+
removeWebParts(site).then(() => {
|
|
1111
1085
|
// Resolve the promise
|
|
1112
1086
|
resolve(site);
|
|
1113
1087
|
}, reject);
|
|
@@ -1121,10 +1095,10 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1121
1095
|
});
|
|
1122
1096
|
};
|
|
1123
1097
|
// Method to uninstall the web components
|
|
1124
|
-
|
|
1098
|
+
let uninstallWeb = () => {
|
|
1125
1099
|
// Return a promise
|
|
1126
|
-
return new Promise(
|
|
1127
|
-
|
|
1100
|
+
return new Promise((resolve, reject) => {
|
|
1101
|
+
let Expand = [];
|
|
1128
1102
|
// Log
|
|
1129
1103
|
logMessage("[gd-sprest][uninstall] Loading the web information...");
|
|
1130
1104
|
// Set the query
|
|
@@ -1141,17 +1115,17 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1141
1115
|
Expand.push("Lists");
|
|
1142
1116
|
}
|
|
1143
1117
|
// Query the web
|
|
1144
|
-
|
|
1118
|
+
Web(webUrl, { disableCache: true, requestDigest: _requestDigest }).query({ Expand })
|
|
1145
1119
|
// Execute the request
|
|
1146
|
-
.execute(
|
|
1120
|
+
.execute(web => {
|
|
1147
1121
|
// Remove the web custom actions
|
|
1148
|
-
removeUserCustomActions(web.UserCustomActions, cfg.CustomActionCfg ? cfg.CustomActionCfg.Web : null).then(
|
|
1122
|
+
removeUserCustomActions(web.UserCustomActions, cfg.CustomActionCfg ? cfg.CustomActionCfg.Web : null).then(() => {
|
|
1149
1123
|
// Remove the lists
|
|
1150
|
-
removeLists(web.Lists, cfg.ListCfg).then(
|
|
1124
|
+
removeLists(web.Lists, cfg.ListCfg).then(() => {
|
|
1151
1125
|
// Remove the content types
|
|
1152
|
-
removeContentTypes(web.ContentTypes, cfg.ContentTypes).then(
|
|
1126
|
+
removeContentTypes(web.ContentTypes, cfg.ContentTypes).then(() => {
|
|
1153
1127
|
// Remove the fields
|
|
1154
|
-
removeFields(web.Fields, cfg.Fields).then(
|
|
1128
|
+
removeFields(web.Fields, cfg.Fields).then(() => {
|
|
1155
1129
|
// Resolve the promise
|
|
1156
1130
|
resolve();
|
|
1157
1131
|
}, reject);
|
|
@@ -1168,42 +1142,42 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1168
1142
|
// The configuration
|
|
1169
1143
|
_configuration: cfg,
|
|
1170
1144
|
// Method to get the web url to target
|
|
1171
|
-
getWebUrl:
|
|
1145
|
+
getWebUrl: () => { return webUrl; },
|
|
1172
1146
|
// Method to install the configuration
|
|
1173
|
-
install:
|
|
1174
|
-
|
|
1175
|
-
return new Promise(
|
|
1147
|
+
install: () => {
|
|
1148
|
+
let initSPLib = () => {
|
|
1149
|
+
return new Promise(resolve => {
|
|
1176
1150
|
// See if the SP lib exists
|
|
1177
1151
|
if (window["SP"]) {
|
|
1178
1152
|
resolve(null);
|
|
1179
1153
|
return;
|
|
1180
1154
|
}
|
|
1181
1155
|
// Load the core and taxonomy libraries
|
|
1182
|
-
|
|
1156
|
+
loadSPCore(["sp.taxonomy"]).then(() => { resolve(null); });
|
|
1183
1157
|
});
|
|
1184
1158
|
};
|
|
1185
1159
|
// Return a promise
|
|
1186
|
-
return new Promise(
|
|
1160
|
+
return new Promise((resolve, reject) => {
|
|
1187
1161
|
// Ensure the SP core lib exists
|
|
1188
|
-
initSPLib().then(
|
|
1162
|
+
initSPLib().then(() => {
|
|
1189
1163
|
// Set the request digest
|
|
1190
|
-
setRequestDigest().then(
|
|
1164
|
+
setRequestDigest().then(() => {
|
|
1191
1165
|
// Log
|
|
1192
1166
|
logMessage("[gd-sprest] Installing the web assets...");
|
|
1193
1167
|
// Get the web
|
|
1194
|
-
|
|
1168
|
+
let web = Web(webUrl, { disableCache: true, requestDigest: _requestDigest });
|
|
1195
1169
|
// Create the site fields
|
|
1196
|
-
|
|
1170
|
+
let createSiteFields = () => {
|
|
1197
1171
|
// Return a promise
|
|
1198
|
-
return new Promise(
|
|
1172
|
+
return new Promise((resolve, reject) => {
|
|
1199
1173
|
// See if we are creating fields
|
|
1200
1174
|
if (cfg.Fields && cfg.Fields.length > 0) {
|
|
1201
1175
|
// Log
|
|
1202
1176
|
logMessage("[gd-sprest][Fields] Starting the requests.");
|
|
1203
1177
|
// Get the fields
|
|
1204
|
-
web.Fields().execute(
|
|
1178
|
+
web.Fields().execute(fields => {
|
|
1205
1179
|
// Create the fields
|
|
1206
|
-
createFields(fields, cfg.Fields).then(
|
|
1180
|
+
createFields(fields, cfg.Fields).then(() => {
|
|
1207
1181
|
// Log
|
|
1208
1182
|
logMessage("[gd-sprest][Fields] Completed the requests.");
|
|
1209
1183
|
// Resolve the promise
|
|
@@ -1218,17 +1192,17 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1218
1192
|
});
|
|
1219
1193
|
};
|
|
1220
1194
|
// Create the site content types
|
|
1221
|
-
|
|
1195
|
+
let createSiteContentTypes = () => {
|
|
1222
1196
|
// Return a promise
|
|
1223
|
-
return new Promise(
|
|
1197
|
+
return new Promise((resolve, reject) => {
|
|
1224
1198
|
// See if we are creating the content types
|
|
1225
1199
|
if (cfg.ContentTypes && cfg.ContentTypes.length > 0) {
|
|
1226
1200
|
// Log
|
|
1227
1201
|
logMessage("[gd-sprest][Content Types] Starting the requests.");
|
|
1228
1202
|
// Get the content types
|
|
1229
|
-
web.ContentTypes().execute(
|
|
1203
|
+
web.ContentTypes().execute(contentTypes => {
|
|
1230
1204
|
// Create the content types
|
|
1231
|
-
createContentTypes(contentTypes, cfg.ContentTypes).then(
|
|
1205
|
+
createContentTypes(contentTypes, cfg.ContentTypes).then(() => {
|
|
1232
1206
|
// Log
|
|
1233
1207
|
logMessage("[gd-sprest][Content Types] Completed the requests.");
|
|
1234
1208
|
// Resolve the promise
|
|
@@ -1243,17 +1217,17 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1243
1217
|
});
|
|
1244
1218
|
};
|
|
1245
1219
|
// Create the site lists
|
|
1246
|
-
|
|
1220
|
+
let createSiteLists = () => {
|
|
1247
1221
|
// Return a promise
|
|
1248
|
-
return new Promise(
|
|
1222
|
+
return new Promise((resolve, reject) => {
|
|
1249
1223
|
// See if we are creating the lists
|
|
1250
1224
|
if (cfg.ListCfg && cfg.ListCfg.length) {
|
|
1251
1225
|
// Log
|
|
1252
1226
|
logMessage("[gd-sprest][Lists] Starting the requests.");
|
|
1253
1227
|
// Get the lists
|
|
1254
|
-
web.Lists().execute(
|
|
1228
|
+
web.Lists().execute(lists => {
|
|
1255
1229
|
// Create the lists
|
|
1256
|
-
createLists(lists, cfg.ListCfg).then(
|
|
1230
|
+
createLists(lists, cfg.ListCfg).then(() => {
|
|
1257
1231
|
// Log
|
|
1258
1232
|
logMessage("[gd-sprest][Lists] Completed the requests.");
|
|
1259
1233
|
// Resolve the promise
|
|
@@ -1268,15 +1242,15 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1268
1242
|
});
|
|
1269
1243
|
};
|
|
1270
1244
|
// Create the site webparts
|
|
1271
|
-
|
|
1245
|
+
let createSiteWebParts = () => {
|
|
1272
1246
|
// Return a promise
|
|
1273
|
-
return new Promise(
|
|
1247
|
+
return new Promise((resolve, reject) => {
|
|
1274
1248
|
// See if we are creating the webparts
|
|
1275
1249
|
if (cfg.WebPartCfg && cfg.WebPartCfg.length > 0) {
|
|
1276
1250
|
// Log
|
|
1277
1251
|
logMessage("[gd-sprest][WebParts] Starting the requests.");
|
|
1278
1252
|
// Create the webparts
|
|
1279
|
-
createWebParts().then(
|
|
1253
|
+
createWebParts().then(() => {
|
|
1280
1254
|
// Log
|
|
1281
1255
|
logMessage("[gd-sprest][WebParts] Completed the requests.");
|
|
1282
1256
|
// Resolve the promise
|
|
@@ -1290,19 +1264,19 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1290
1264
|
});
|
|
1291
1265
|
};
|
|
1292
1266
|
// Create the custom actions
|
|
1293
|
-
|
|
1267
|
+
let createSiteCollectionCustomActions = () => {
|
|
1294
1268
|
// Return a promise
|
|
1295
|
-
return new Promise(
|
|
1269
|
+
return new Promise((resolve, reject) => {
|
|
1296
1270
|
// See if we are targeting the site collection
|
|
1297
1271
|
if (cfg.CustomActionCfg && cfg.CustomActionCfg.Site) {
|
|
1298
1272
|
// Log
|
|
1299
1273
|
logMessage("[gd-sprest][Site Custom Actions] Starting the requests.");
|
|
1300
1274
|
// Get the site
|
|
1301
|
-
|
|
1275
|
+
Site(webUrl, { disableCache: true, requestDigest: _requestDigest })
|
|
1302
1276
|
// Get the user custom actions
|
|
1303
|
-
.UserCustomActions().execute(
|
|
1277
|
+
.UserCustomActions().execute(customActions => {
|
|
1304
1278
|
// Create the user custom actions
|
|
1305
|
-
createUserCustomActions(customActions, cfg.CustomActionCfg.Site).then(
|
|
1279
|
+
createUserCustomActions(customActions, cfg.CustomActionCfg.Site).then(() => {
|
|
1306
1280
|
// Log
|
|
1307
1281
|
logMessage("[gd-sprest][Site Custom Actions] Completed the requests.");
|
|
1308
1282
|
// Resolve the promise
|
|
@@ -1317,17 +1291,17 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1317
1291
|
});
|
|
1318
1292
|
};
|
|
1319
1293
|
// Create the custom actions
|
|
1320
|
-
|
|
1294
|
+
let createSiteCustomActions = () => {
|
|
1321
1295
|
// Return a promise
|
|
1322
|
-
return new Promise(
|
|
1296
|
+
return new Promise((resolve, reject) => {
|
|
1323
1297
|
// See if we are targeting the web
|
|
1324
1298
|
if (cfg.CustomActionCfg && cfg.CustomActionCfg.Web) {
|
|
1325
1299
|
// Log
|
|
1326
1300
|
logMessage("[gd-sprest][Web Custom Actions] Starting the requests.");
|
|
1327
1301
|
// Get the user custom actions
|
|
1328
|
-
web.UserCustomActions().execute(
|
|
1302
|
+
web.UserCustomActions().execute(customActions => {
|
|
1329
1303
|
// Create the user custom actions
|
|
1330
|
-
createUserCustomActions(customActions, cfg.CustomActionCfg.Web).then(
|
|
1304
|
+
createUserCustomActions(customActions, cfg.CustomActionCfg.Web).then(() => {
|
|
1331
1305
|
// Log
|
|
1332
1306
|
logMessage("[gd-sprest][Web Custom Actions] Completed the requests.");
|
|
1333
1307
|
// Resolve the promise
|
|
@@ -1342,17 +1316,17 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1342
1316
|
});
|
|
1343
1317
|
};
|
|
1344
1318
|
// Create the site fields
|
|
1345
|
-
createSiteFields().then(
|
|
1319
|
+
createSiteFields().then(() => {
|
|
1346
1320
|
// Create the site content types
|
|
1347
|
-
createSiteContentTypes().then(
|
|
1321
|
+
createSiteContentTypes().then(() => {
|
|
1348
1322
|
// Create the site lists
|
|
1349
|
-
createSiteLists().then(
|
|
1323
|
+
createSiteLists().then(() => {
|
|
1350
1324
|
// Create the webparts
|
|
1351
|
-
createSiteWebParts().then(
|
|
1325
|
+
createSiteWebParts().then(() => {
|
|
1352
1326
|
// Create the site collection custom actions
|
|
1353
|
-
createSiteCollectionCustomActions().then(
|
|
1327
|
+
createSiteCollectionCustomActions().then(() => {
|
|
1354
1328
|
// Create the site custom actions
|
|
1355
|
-
createSiteCustomActions().then(
|
|
1329
|
+
createSiteCustomActions().then(() => {
|
|
1356
1330
|
// Log
|
|
1357
1331
|
logMessage("[gd-sprest] The configuration script completed, but some requests may still be running.");
|
|
1358
1332
|
// Resolve the request
|
|
@@ -1368,17 +1342,17 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1368
1342
|
});
|
|
1369
1343
|
},
|
|
1370
1344
|
// Method to update the web url to target
|
|
1371
|
-
setWebUrl:
|
|
1345
|
+
setWebUrl: (url) => { webUrl = url; },
|
|
1372
1346
|
// Method to uninstall the configuration
|
|
1373
|
-
uninstall:
|
|
1347
|
+
uninstall: () => {
|
|
1374
1348
|
// Return a promise
|
|
1375
|
-
return new Promise(
|
|
1349
|
+
return new Promise((resolve, reject) => {
|
|
1376
1350
|
// Set the request digest
|
|
1377
|
-
setRequestDigest().then(
|
|
1351
|
+
setRequestDigest().then(() => {
|
|
1378
1352
|
// Uninstall the web components
|
|
1379
|
-
uninstallWeb().then(
|
|
1353
|
+
uninstallWeb().then(() => {
|
|
1380
1354
|
// Uninstall the site components
|
|
1381
|
-
uninstallSite().then(
|
|
1355
|
+
uninstallSite().then(() => {
|
|
1382
1356
|
// Log
|
|
1383
1357
|
logMessage("[gd-sprest] The configuration script completed, but some requests may still be running.");
|
|
1384
1358
|
// Resolve the promise
|
|
@@ -1390,4 +1364,3 @@ var SPConfig = function (cfg, webUrl) {
|
|
|
1390
1364
|
}
|
|
1391
1365
|
};
|
|
1392
1366
|
};
|
|
1393
|
-
exports.SPConfig = SPConfig;
|