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
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ListFormField = void 0;
|
|
4
|
-
var __1 = require("..");
|
|
1
|
+
import { Helper, Site, SPTypes, Web } from "..";
|
|
5
2
|
/**
|
|
6
3
|
* List Form Field
|
|
7
4
|
*/
|
|
8
|
-
|
|
5
|
+
export const ListFormField = {
|
|
9
6
|
// Method to create an instance of the list form field
|
|
10
|
-
create:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
create: (props) => {
|
|
8
|
+
let _fieldInfo = props || {};
|
|
9
|
+
let _reject = null;
|
|
10
|
+
let _resolve = null;
|
|
14
11
|
// Load the field
|
|
15
|
-
|
|
12
|
+
let load = () => {
|
|
16
13
|
// See if the field exists
|
|
17
14
|
if (_fieldInfo.field) {
|
|
18
15
|
// Process the field
|
|
@@ -21,7 +18,7 @@ exports.ListFormField = {
|
|
|
21
18
|
// Else, load the field from the information provided
|
|
22
19
|
else {
|
|
23
20
|
// Get the web
|
|
24
|
-
|
|
21
|
+
Web(_fieldInfo.webUrl)
|
|
25
22
|
// Get the list
|
|
26
23
|
.Lists(_fieldInfo.listName)
|
|
27
24
|
// Get the fields
|
|
@@ -29,7 +26,7 @@ exports.ListFormField = {
|
|
|
29
26
|
// Get the field by its internal name
|
|
30
27
|
.getByInternalNameOrTitle(_fieldInfo.name)
|
|
31
28
|
// Execute the request
|
|
32
|
-
.execute(
|
|
29
|
+
.execute((field) => {
|
|
33
30
|
// Save the field
|
|
34
31
|
_fieldInfo.field = field;
|
|
35
32
|
// Process the field
|
|
@@ -38,7 +35,7 @@ exports.ListFormField = {
|
|
|
38
35
|
}
|
|
39
36
|
};
|
|
40
37
|
// Method to proces the field and save its information
|
|
41
|
-
|
|
38
|
+
let processField = () => {
|
|
42
39
|
// Update the field information
|
|
43
40
|
_fieldInfo.defaultValue = _fieldInfo.field.DefaultValue;
|
|
44
41
|
_fieldInfo.readOnly = _fieldInfo.field.ReadOnlyField;
|
|
@@ -49,58 +46,58 @@ exports.ListFormField = {
|
|
|
49
46
|
// Update the field info, based on the type
|
|
50
47
|
switch (_fieldInfo.type) {
|
|
51
48
|
// Choice
|
|
52
|
-
case
|
|
53
|
-
case
|
|
54
|
-
|
|
49
|
+
case SPTypes.FieldType.Choice:
|
|
50
|
+
case SPTypes.FieldType.MultiChoice:
|
|
51
|
+
let choices = _fieldInfo.field.Choices;
|
|
55
52
|
_fieldInfo.choices = (choices ? choices["results"] : null) || [];
|
|
56
|
-
_fieldInfo.multi = _fieldInfo.type ==
|
|
53
|
+
_fieldInfo.multi = _fieldInfo.type == SPTypes.FieldType.MultiChoice;
|
|
57
54
|
break;
|
|
58
55
|
// Date/Time
|
|
59
|
-
case
|
|
60
|
-
|
|
61
|
-
_fieldInfo.showTime = fldDate.DisplayFormat ==
|
|
56
|
+
case SPTypes.FieldType.DateTime:
|
|
57
|
+
let fldDate = _fieldInfo.field;
|
|
58
|
+
_fieldInfo.showTime = fldDate.DisplayFormat == SPTypes.DateFormat.DateTime;
|
|
62
59
|
break;
|
|
63
60
|
// Lookup
|
|
64
|
-
case
|
|
65
|
-
|
|
61
|
+
case SPTypes.FieldType.Lookup:
|
|
62
|
+
let fldLookup = _fieldInfo.field;
|
|
66
63
|
_fieldInfo.lookupField = fldLookup.LookupField;
|
|
67
64
|
_fieldInfo.lookupListId = fldLookup.LookupList;
|
|
68
65
|
_fieldInfo.lookupWebId = fldLookup.LookupWebId;
|
|
69
66
|
_fieldInfo.multi = fldLookup.AllowMultipleValues;
|
|
70
67
|
break;
|
|
71
68
|
// Number
|
|
72
|
-
case
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
case SPTypes.FieldType.Number:
|
|
70
|
+
let fldNumber = _fieldInfo.field;
|
|
71
|
+
let startIdx = fldNumber.SchemaXml.indexOf('Decimals="') + 10;
|
|
75
72
|
_fieldInfo.decimals = startIdx > 10 ? parseInt(fldNumber.SchemaXml.substr(startIdx, fldNumber.SchemaXml.substr(startIdx).indexOf('"'))) : 0;
|
|
76
73
|
_fieldInfo.maxValue = fldNumber.MaximumValue;
|
|
77
74
|
_fieldInfo.minValue = fldNumber.MinimumValue;
|
|
78
75
|
_fieldInfo.showAsPercentage = fldNumber.SchemaXml.indexOf('Percentage="TRUE"') > 0;
|
|
79
76
|
break;
|
|
80
77
|
// Note
|
|
81
|
-
case
|
|
82
|
-
|
|
78
|
+
case SPTypes.FieldType.Note:
|
|
79
|
+
let fldNote = _fieldInfo.field;
|
|
83
80
|
_fieldInfo.multiline = true;
|
|
84
81
|
_fieldInfo.richText = fldNote.RichText;
|
|
85
82
|
_fieldInfo.rows = fldNote.NumberOfLines;
|
|
86
83
|
break;
|
|
87
84
|
// Text
|
|
88
|
-
case
|
|
85
|
+
case SPTypes.FieldType.Text:
|
|
89
86
|
_fieldInfo.multiline = false;
|
|
90
87
|
_fieldInfo.richText = false;
|
|
91
88
|
_fieldInfo.rows = 1;
|
|
92
89
|
break;
|
|
93
90
|
// User
|
|
94
|
-
case
|
|
95
|
-
|
|
96
|
-
_fieldInfo.allowGroups = fldUser.SelectionMode ==
|
|
91
|
+
case SPTypes.FieldType.User:
|
|
92
|
+
let fldUser = _fieldInfo.field;
|
|
93
|
+
_fieldInfo.allowGroups = fldUser.SelectionMode == SPTypes.FieldUserSelectionType.PeopleAndGroups;
|
|
97
94
|
_fieldInfo.multi = fldUser.AllowMultipleValues;
|
|
98
95
|
break;
|
|
99
96
|
// Default
|
|
100
97
|
default:
|
|
101
98
|
// See if this is an MMS field
|
|
102
99
|
if (_fieldInfo.typeAsString.indexOf("TaxonomyFieldType") == 0) {
|
|
103
|
-
|
|
100
|
+
let fldMMS = _fieldInfo.field;
|
|
104
101
|
_fieldInfo.multi = fldMMS.AllowMultipleValues;
|
|
105
102
|
_fieldInfo.termId = fldMMS.IsAnchorValid ? fldMMS.AnchorId : fldMMS.TermSetId;
|
|
106
103
|
_fieldInfo.termSetId = fldMMS.TermSetId;
|
|
@@ -112,7 +109,7 @@ exports.ListFormField = {
|
|
|
112
109
|
_resolve(_fieldInfo);
|
|
113
110
|
};
|
|
114
111
|
// Return a promise
|
|
115
|
-
return new Promise(
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
116
113
|
// Save the methods
|
|
117
114
|
_resolve = resolve;
|
|
118
115
|
_reject = reject;
|
|
@@ -128,45 +125,45 @@ exports.ListFormField = {
|
|
|
128
125
|
});
|
|
129
126
|
},
|
|
130
127
|
// Method to get the folder to store the image field file in
|
|
131
|
-
getOrCreateImageFolder:
|
|
128
|
+
getOrCreateImageFolder: (info) => {
|
|
132
129
|
// Return a promise
|
|
133
|
-
return new Promise(
|
|
130
|
+
return new Promise((resolve, reject) => {
|
|
134
131
|
// Get the site assets library
|
|
135
|
-
(
|
|
136
|
-
return new Promise(
|
|
137
|
-
|
|
132
|
+
(() => {
|
|
133
|
+
return new Promise(resolve => {
|
|
134
|
+
Web(info.webUrl).Lists("Site Assets").execute(
|
|
138
135
|
// Exists
|
|
139
|
-
|
|
136
|
+
lib => {
|
|
140
137
|
// Resolve the request
|
|
141
138
|
resolve(lib);
|
|
142
139
|
},
|
|
143
140
|
// Doesn't Exist
|
|
144
|
-
|
|
141
|
+
() => {
|
|
145
142
|
// Create the list
|
|
146
|
-
|
|
143
|
+
Web(info.webUrl).Lists().add({
|
|
147
144
|
Title: "SiteAssets",
|
|
148
|
-
BaseTemplate:
|
|
149
|
-
}).execute(
|
|
145
|
+
BaseTemplate: SPTypes.ListTemplateType.DocumentLibrary
|
|
146
|
+
}).execute(lib => {
|
|
150
147
|
// Update the title
|
|
151
|
-
lib.update({ Title: "Site Assets" }).execute(
|
|
148
|
+
lib.update({ Title: "Site Assets" }).execute(() => {
|
|
152
149
|
// Resolve the request
|
|
153
150
|
resolve(lib);
|
|
154
151
|
}, reject);
|
|
155
152
|
});
|
|
156
153
|
});
|
|
157
154
|
});
|
|
158
|
-
})().then(
|
|
155
|
+
})().then((siteAssets) => {
|
|
159
156
|
// Get the list id folder
|
|
160
157
|
siteAssets.RootFolder().Folders(info.list.Id).execute(
|
|
161
158
|
// Exists
|
|
162
|
-
|
|
159
|
+
folder => {
|
|
163
160
|
// Resolve the request
|
|
164
161
|
resolve(folder);
|
|
165
162
|
},
|
|
166
163
|
// Doesn't Exist
|
|
167
|
-
|
|
164
|
+
() => {
|
|
168
165
|
// Create the folder
|
|
169
|
-
siteAssets.RootFolder().Folders().add(info.list.Id).execute(
|
|
166
|
+
siteAssets.RootFolder().Folders().add(info.list.Id).execute(folder => {
|
|
170
167
|
// Resolve the request
|
|
171
168
|
resolve(folder);
|
|
172
169
|
}, reject);
|
|
@@ -175,17 +172,17 @@ exports.ListFormField = {
|
|
|
175
172
|
});
|
|
176
173
|
},
|
|
177
174
|
// Method to load the lookup data
|
|
178
|
-
loadLookupData:
|
|
175
|
+
loadLookupData: (info, queryTop) => {
|
|
179
176
|
// Return a promise
|
|
180
|
-
return new Promise(
|
|
177
|
+
return new Promise((resolve, reject) => {
|
|
181
178
|
// Get the current site collection
|
|
182
|
-
|
|
179
|
+
Site()
|
|
183
180
|
// Get the web containing the lookup list
|
|
184
181
|
.openWebById(info.lookupWebId)
|
|
185
182
|
// Execute the request
|
|
186
|
-
.execute(
|
|
183
|
+
.execute((web) => {
|
|
187
184
|
// See if there is a filter
|
|
188
|
-
|
|
185
|
+
let query = info.lookupFilter || {};
|
|
189
186
|
if (typeof (query) == "string") {
|
|
190
187
|
// Set the filter
|
|
191
188
|
query = {
|
|
@@ -221,7 +218,7 @@ exports.ListFormField = {
|
|
|
221
218
|
// Set the query
|
|
222
219
|
.query(query)
|
|
223
220
|
// Execute the request
|
|
224
|
-
.execute(
|
|
221
|
+
.execute((items) => {
|
|
225
222
|
// Resolve the promise
|
|
226
223
|
resolve(items.results);
|
|
227
224
|
}, reject);
|
|
@@ -229,29 +226,29 @@ exports.ListFormField = {
|
|
|
229
226
|
});
|
|
230
227
|
},
|
|
231
228
|
// Method to load the mms data
|
|
232
|
-
loadMMSData:
|
|
229
|
+
loadMMSData: (info) => {
|
|
233
230
|
// Return a promise
|
|
234
|
-
return new Promise(
|
|
231
|
+
return new Promise((resolve, reject) => {
|
|
235
232
|
// Load the term set
|
|
236
|
-
|
|
233
|
+
Helper.Taxonomy.getTermSetById(info.termStoreId, info.termSetId).then(termSet => {
|
|
237
234
|
// Get the target root term
|
|
238
|
-
|
|
235
|
+
let root = Helper.Taxonomy.findById(termSet, info.termId);
|
|
239
236
|
// See if the root node doesn't exist
|
|
240
237
|
if (root == null) {
|
|
241
238
|
// Set the root to the term set
|
|
242
|
-
root =
|
|
239
|
+
root = Helper.Taxonomy.findById(termSet, info.termSetId);
|
|
243
240
|
}
|
|
244
241
|
// Resolve the request
|
|
245
|
-
resolve(
|
|
242
|
+
resolve(Helper.Taxonomy.toArray(root));
|
|
246
243
|
}, reject);
|
|
247
244
|
});
|
|
248
245
|
},
|
|
249
246
|
// Method to load the mms value field
|
|
250
|
-
loadMMSValueField:
|
|
247
|
+
loadMMSValueField: (info) => {
|
|
251
248
|
// Return a promise
|
|
252
|
-
return new Promise(
|
|
249
|
+
return new Promise((resolve, reject) => {
|
|
253
250
|
// Get the web
|
|
254
|
-
|
|
251
|
+
Web(info.webUrl)
|
|
255
252
|
// Get the list
|
|
256
253
|
.Lists(info.listName)
|
|
257
254
|
// Get the fields
|
|
@@ -261,12 +258,12 @@ exports.ListFormField = {
|
|
|
261
258
|
// Execute the request
|
|
262
259
|
.execute(
|
|
263
260
|
// Success
|
|
264
|
-
|
|
261
|
+
field => {
|
|
265
262
|
// Resolve the promise
|
|
266
263
|
resolve(field);
|
|
267
264
|
},
|
|
268
265
|
// Error
|
|
269
|
-
|
|
266
|
+
() => {
|
|
270
267
|
// Reject w/ a message
|
|
271
268
|
reject("Unable to find the hidden value field for '" + info.name + "'.");
|
|
272
269
|
});
|
|
@@ -1,37 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addContentEditorWebPart = void 0;
|
|
4
|
-
var webpart_1 = require("../webpart");
|
|
1
|
+
import { WebPart } from "../webpart";
|
|
5
2
|
// Method to add a script editor webpart to the page
|
|
6
|
-
|
|
3
|
+
export const addContentEditorWebPart = (url, wpProps) => {
|
|
7
4
|
// Return a promise
|
|
8
|
-
return new Promise(
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
9
6
|
// Get the current context
|
|
10
|
-
|
|
7
|
+
let context = SP.ClientContext.get_current();
|
|
11
8
|
// Get the webpart manager for the page
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
let page = context.get_web().getFileByServerRelativeUrl(url);
|
|
10
|
+
let wpMgr = page.getLimitedWebPartManager(SP.WebParts.PersonalizationScope.shared);
|
|
14
11
|
// Create the webpart
|
|
15
|
-
|
|
12
|
+
let wp = wpMgr.importWebPart(WebPart.generateContentEditorXML(wpProps)).get_webPart();
|
|
16
13
|
// Add the webpart to the page
|
|
17
14
|
wpMgr.addWebPart(wp, wpProps.zone || "", wpProps.index || 0);
|
|
18
15
|
// Save the page
|
|
19
16
|
context.load(wp);
|
|
20
17
|
context.executeQueryAsync(
|
|
21
18
|
// Success
|
|
22
|
-
|
|
19
|
+
() => {
|
|
23
20
|
// Resolve the promise
|
|
24
21
|
resolve();
|
|
25
22
|
},
|
|
26
23
|
// Error
|
|
27
|
-
|
|
28
|
-
var args = [];
|
|
29
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
30
|
-
args[_i] = arguments[_i];
|
|
31
|
-
}
|
|
24
|
+
(...args) => {
|
|
32
25
|
// Reject the promise
|
|
33
26
|
reject(args[1] ? args[1].get_message() : "");
|
|
34
27
|
});
|
|
35
28
|
});
|
|
36
29
|
};
|
|
37
|
-
exports.addContentEditorWebPart = addContentEditorWebPart;
|
|
@@ -1,37 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addPermissionLevel = void 0;
|
|
4
|
-
var lib_1 = require("../../lib");
|
|
1
|
+
import { Site } from "../../lib";
|
|
5
2
|
/**
|
|
6
3
|
* Adds a permission level to the current or specified web.
|
|
7
4
|
*/
|
|
8
|
-
|
|
5
|
+
export const addPermissionLevel = (props) => {
|
|
9
6
|
// Return a promise
|
|
10
|
-
return new Promise(
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
11
8
|
// Ensure the base permissions exist
|
|
12
9
|
if (SP && SP.BasePermissions) {
|
|
13
10
|
// Set the context and get the role definitions
|
|
14
|
-
|
|
11
|
+
let ctx = props.WebUrl ? new SP.ClientContext(props.WebUrl) : SP.ClientContext.get_current();
|
|
15
12
|
// Set the base permissions
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
for (
|
|
13
|
+
let basePermissions = new SP.BasePermissions();
|
|
14
|
+
let permissions = props.Permissions || [];
|
|
15
|
+
for (let i = 0; i < permissions.length; i++) {
|
|
19
16
|
// Set the flag
|
|
20
17
|
basePermissions.set(permissions[i]);
|
|
21
18
|
}
|
|
22
19
|
// Create the role definition
|
|
23
|
-
|
|
20
|
+
let roleDefInfo = new SP.RoleDefinitionCreationInformation();
|
|
24
21
|
roleDefInfo.set_basePermissions(basePermissions);
|
|
25
22
|
roleDefInfo.set_description(props.Description);
|
|
26
23
|
roleDefInfo.set_name(props.Name);
|
|
27
24
|
roleDefInfo.set_order(props.Order);
|
|
28
25
|
// Add the role definition
|
|
29
|
-
|
|
30
|
-
ctx.load(
|
|
26
|
+
let roleDef = ctx.get_site().get_rootWeb().get_roleDefinitions().add(roleDefInfo);
|
|
27
|
+
ctx.load(roleDef);
|
|
31
28
|
// Execute the request
|
|
32
|
-
ctx.executeQueryAsync(
|
|
29
|
+
ctx.executeQueryAsync(() => {
|
|
33
30
|
// Get the role definition
|
|
34
|
-
|
|
31
|
+
Site(props.WebUrl).RootWeb().RoleDefinitions().getById(roleDef.get_id()).execute(roleDef => {
|
|
35
32
|
// Resolve the request
|
|
36
33
|
resolve(roleDef);
|
|
37
34
|
}, reject);
|
|
@@ -43,4 +40,3 @@ var addPermissionLevel = function (props) {
|
|
|
43
40
|
}
|
|
44
41
|
});
|
|
45
42
|
};
|
|
46
|
-
exports.addPermissionLevel = addPermissionLevel;
|
|
@@ -1,37 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addScriptEditorWebPart = void 0;
|
|
4
|
-
var webpart_1 = require("../webpart");
|
|
1
|
+
import { WebPart } from "../webpart";
|
|
5
2
|
// Method to add a script editor webpart to the page
|
|
6
|
-
|
|
3
|
+
export const addScriptEditorWebPart = (url, wpProps) => {
|
|
7
4
|
// Return a promise
|
|
8
|
-
return new Promise(
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
9
6
|
// Get the current context
|
|
10
|
-
|
|
7
|
+
let context = SP.ClientContext.get_current();
|
|
11
8
|
// Get the webpart manager for the page
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
let page = context.get_web().getFileByServerRelativeUrl(url);
|
|
10
|
+
let wpMgr = page.getLimitedWebPartManager(SP.WebParts.PersonalizationScope.shared);
|
|
14
11
|
// Create the webpart
|
|
15
|
-
|
|
12
|
+
let wp = wpMgr.importWebPart(WebPart.generateScriptEditorXML(wpProps)).get_webPart();
|
|
16
13
|
// Add the webpart to the page
|
|
17
14
|
wpMgr.addWebPart(wp, wpProps.zone || "", wpProps.index || 0);
|
|
18
15
|
// Save the page
|
|
19
16
|
context.load(wp);
|
|
20
17
|
context.executeQueryAsync(
|
|
21
18
|
// Success
|
|
22
|
-
|
|
19
|
+
() => {
|
|
23
20
|
// Resolve the promise
|
|
24
21
|
resolve();
|
|
25
22
|
},
|
|
26
23
|
// Error
|
|
27
|
-
|
|
28
|
-
var args = [];
|
|
29
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
30
|
-
args[_i] = arguments[_i];
|
|
31
|
-
}
|
|
24
|
+
(...args) => {
|
|
32
25
|
// Reject the promise
|
|
33
26
|
reject(args[1] ? args[1].get_message() : "");
|
|
34
27
|
});
|
|
35
28
|
});
|
|
36
29
|
};
|
|
37
|
-
exports.addScriptEditorWebPart = addScriptEditorWebPart;
|
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.copyPermissionLevel = void 0;
|
|
4
|
-
var lib_1 = require("../../lib");
|
|
5
|
-
var sptypes_1 = require("../../sptypes");
|
|
1
|
+
import { Site } from "../../lib";
|
|
2
|
+
import { SPTypes } from "../../sptypes";
|
|
6
3
|
/**
|
|
7
4
|
* Copies a permission level to the current or specified web.
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
export const copyPermissionLevel = (props) => {
|
|
10
7
|
// Return a promise
|
|
11
|
-
return new Promise(
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
12
9
|
// Ensure the base permissions exist
|
|
13
10
|
if (SP && SP.BasePermissions) {
|
|
14
11
|
// Set the context and get the role definitions
|
|
15
|
-
|
|
12
|
+
let ctx = props.WebUrl ? new SP.ClientContext(props.WebUrl) : SP.ClientContext.get_current();
|
|
16
13
|
// Get the base permission
|
|
17
|
-
var basePerm =
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
var basePerm = ctx.get_site().get_rootWeb().get_roleDefinitions().getByName(props.BasePermission);
|
|
15
|
+
ctx.load(basePerm);
|
|
16
|
+
ctx.executeQueryAsync(
|
|
20
17
|
// Success
|
|
21
|
-
|
|
18
|
+
() => {
|
|
22
19
|
// Copy the base permissions
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
for (
|
|
27
|
-
|
|
20
|
+
let basePermissions = basePerm.get_basePermissions();
|
|
21
|
+
let permissions = new SP.BasePermissions();
|
|
22
|
+
let removePermissions = props.RemovePermissions || [];
|
|
23
|
+
for (let key in SPTypes.BasePermissionTypes) {
|
|
24
|
+
let permission = SPTypes.BasePermissionTypes[key];
|
|
28
25
|
// See if the base permission has this
|
|
29
26
|
if (basePermissions.has(permission) && removePermissions.indexOf(permission) < 0) {
|
|
30
27
|
// Set the permission
|
|
@@ -32,31 +29,31 @@ var copyPermissionLevel = function (props) {
|
|
|
32
29
|
}
|
|
33
30
|
}
|
|
34
31
|
// Parse the custom permissions to add
|
|
35
|
-
|
|
36
|
-
for (
|
|
32
|
+
let newPermissions = props.AddPermissions || [];
|
|
33
|
+
for (let i = 0; i < newPermissions.length; i++) {
|
|
37
34
|
// Set the flag
|
|
38
35
|
permissions.set(newPermissions[i]);
|
|
39
36
|
}
|
|
40
37
|
// Create the role definition
|
|
41
|
-
|
|
38
|
+
let roleDefInfo = new SP.RoleDefinitionCreationInformation();
|
|
42
39
|
roleDefInfo.set_basePermissions(permissions);
|
|
43
40
|
roleDefInfo.set_description(props.Description);
|
|
44
41
|
roleDefInfo.set_name(props.Name);
|
|
45
42
|
roleDefInfo.set_order(props.Order);
|
|
46
43
|
// Add the role definition
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
let roleDef = ctx.get_site().get_rootWeb().get_roleDefinitions().add(roleDefInfo);
|
|
45
|
+
ctx.load(roleDef);
|
|
49
46
|
// Execute the request
|
|
50
|
-
|
|
47
|
+
ctx.executeQueryAsync(() => {
|
|
51
48
|
// Get the role definition
|
|
52
|
-
|
|
49
|
+
Site(props.WebUrl).RootWeb().RoleDefinitions().getById(roleDef.get_id()).execute(roleDef => {
|
|
53
50
|
// Resolve the request
|
|
54
51
|
resolve(roleDef);
|
|
55
52
|
}, reject);
|
|
56
53
|
}, reject);
|
|
57
54
|
},
|
|
58
55
|
// Error
|
|
59
|
-
|
|
56
|
+
() => {
|
|
60
57
|
// Reject the request
|
|
61
58
|
reject("Permission not found in site: " + props.WebUrl);
|
|
62
59
|
});
|
|
@@ -67,4 +64,3 @@ var copyPermissionLevel = function (props) {
|
|
|
67
64
|
}
|
|
68
65
|
});
|
|
69
66
|
};
|
|
70
|
-
exports.copyPermissionLevel = copyPermissionLevel;
|