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/taxonomy.js
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Taxonomy = void 0;
|
|
4
|
-
var contextInfo_1 = require("../lib/contextInfo");
|
|
1
|
+
import { ContextInfo } from "../lib/contextInfo";
|
|
5
2
|
/**
|
|
6
3
|
* Taxonomy Helper Class
|
|
7
4
|
*/
|
|
8
|
-
|
|
5
|
+
export const Taxonomy = {
|
|
9
6
|
/**
|
|
10
7
|
* Method to find a term by id
|
|
11
8
|
*/
|
|
12
|
-
findById:
|
|
9
|
+
findById: (term, termId) => {
|
|
13
10
|
// See if this is the root node
|
|
14
11
|
if (term.info && term.info.id == termId) {
|
|
15
12
|
// Return the root node
|
|
16
13
|
return term;
|
|
17
14
|
}
|
|
18
15
|
// Parse the child nodes
|
|
19
|
-
for (
|
|
16
|
+
for (let prop in term) {
|
|
20
17
|
// Skip the info and parent
|
|
21
18
|
if (prop == "info" || prop == "parent") {
|
|
22
19
|
continue;
|
|
23
20
|
}
|
|
24
21
|
// Find the term by id
|
|
25
|
-
|
|
22
|
+
let childTerm = Taxonomy.findById(term[prop], termId);
|
|
26
23
|
if (childTerm) {
|
|
27
24
|
return childTerm;
|
|
28
25
|
}
|
|
@@ -31,20 +28,20 @@ exports.Taxonomy = {
|
|
|
31
28
|
/**
|
|
32
29
|
* Method to find a term by name
|
|
33
30
|
*/
|
|
34
|
-
findByName:
|
|
31
|
+
findByName: (term, termName) => {
|
|
35
32
|
// See if this is the root node
|
|
36
33
|
if (term.info && term.info.name == termName) {
|
|
37
34
|
// Return the root node
|
|
38
35
|
return term;
|
|
39
36
|
}
|
|
40
37
|
// Parse the child nodes
|
|
41
|
-
for (
|
|
38
|
+
for (let prop in term) {
|
|
42
39
|
// Skip the info and parent
|
|
43
40
|
if (prop == "info" || prop == "parent") {
|
|
44
41
|
continue;
|
|
45
42
|
}
|
|
46
43
|
// Find the term by id
|
|
47
|
-
|
|
44
|
+
let childTerm = Taxonomy.findByName(term[prop], termName);
|
|
48
45
|
if (childTerm) {
|
|
49
46
|
return childTerm;
|
|
50
47
|
}
|
|
@@ -53,8 +50,8 @@ exports.Taxonomy = {
|
|
|
53
50
|
/**
|
|
54
51
|
* Method to get the terms
|
|
55
52
|
*/
|
|
56
|
-
getTerms:
|
|
57
|
-
|
|
53
|
+
getTerms: (termSet, termSetTerms) => {
|
|
54
|
+
let terms = [];
|
|
58
55
|
// Add the root term
|
|
59
56
|
terms.push({
|
|
60
57
|
description: termSet.get_description(),
|
|
@@ -65,9 +62,9 @@ exports.Taxonomy = {
|
|
|
65
62
|
props: termSet.get_customProperties()
|
|
66
63
|
});
|
|
67
64
|
// Parse the term sets terms
|
|
68
|
-
|
|
65
|
+
let enumerator = termSetTerms.getEnumerator();
|
|
69
66
|
while (enumerator.moveNext()) {
|
|
70
|
-
|
|
67
|
+
let term = enumerator.get_current();
|
|
71
68
|
// Create the terms
|
|
72
69
|
terms.push({
|
|
73
70
|
description: term.get_description(),
|
|
@@ -79,7 +76,7 @@ exports.Taxonomy = {
|
|
|
79
76
|
});
|
|
80
77
|
}
|
|
81
78
|
// Sort the terms
|
|
82
|
-
terms = terms.sort(
|
|
79
|
+
terms = terms.sort((a, b) => {
|
|
83
80
|
if (a.pathAsString < b.pathAsString) {
|
|
84
81
|
return -1;
|
|
85
82
|
}
|
|
@@ -94,50 +91,46 @@ exports.Taxonomy = {
|
|
|
94
91
|
/**
|
|
95
92
|
* Method to get the term group
|
|
96
93
|
*/
|
|
97
|
-
getTermGroup:
|
|
94
|
+
getTermGroup: (groupName) => {
|
|
98
95
|
// Return a promise
|
|
99
|
-
return new Promise(
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
100
97
|
// Load the scripts
|
|
101
|
-
|
|
98
|
+
Taxonomy.loadScripts().then(() => {
|
|
102
99
|
// Get the taxonomy session
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
let context = SP.ClientContext.get_current();
|
|
101
|
+
let session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
|
|
105
102
|
// See if we are getting a specific group name
|
|
106
103
|
if (groupName) {
|
|
107
104
|
// Resolve the promise
|
|
108
|
-
|
|
109
|
-
context.load(
|
|
110
|
-
context.executeQueryAsync(
|
|
105
|
+
let termStores = session.get_termStores();
|
|
106
|
+
context.load(termStores, "Include(Groups)");
|
|
107
|
+
context.executeQueryAsync(() => {
|
|
111
108
|
// Get the default store
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
let enumerator = termStores.getEnumerator();
|
|
110
|
+
let termStore = enumerator.moveNext() ? enumerator.get_current() : null;
|
|
114
111
|
if (termStore) {
|
|
115
112
|
// Get the term group
|
|
116
|
-
|
|
113
|
+
let termGroup = termStore.get_groups().getByName(groupName);
|
|
117
114
|
context.load(termGroup);
|
|
118
115
|
// Resolve the promise
|
|
119
|
-
resolve({ context
|
|
116
|
+
resolve({ context, termGroup });
|
|
120
117
|
}
|
|
121
118
|
else {
|
|
122
119
|
// Reject the promise
|
|
123
120
|
reject("Unable to find the taxonomy store.");
|
|
124
121
|
}
|
|
125
|
-
},
|
|
126
|
-
var args = [];
|
|
127
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
128
|
-
args[_i] = arguments[_i];
|
|
129
|
-
}
|
|
122
|
+
}, (...args) => {
|
|
130
123
|
// Reject the promise
|
|
131
124
|
reject(args[1].get_message());
|
|
132
125
|
});
|
|
133
126
|
}
|
|
134
127
|
else {
|
|
135
128
|
// Get the default site collection group
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
let termStore = session.getDefaultSiteCollectionTermStore();
|
|
130
|
+
let termGroup = termStore.getSiteCollectionGroup(context.get_site());
|
|
138
131
|
context.load(termGroup);
|
|
139
132
|
// Resolve the promise
|
|
140
|
-
resolve({ context
|
|
133
|
+
resolve({ context, termGroup });
|
|
141
134
|
}
|
|
142
135
|
});
|
|
143
136
|
});
|
|
@@ -145,34 +138,34 @@ exports.Taxonomy = {
|
|
|
145
138
|
/**
|
|
146
139
|
* Method to get the term groups
|
|
147
140
|
*/
|
|
148
|
-
getTermGroups:
|
|
141
|
+
getTermGroups: () => {
|
|
149
142
|
// Return a promise
|
|
150
|
-
return new Promise(
|
|
143
|
+
return new Promise((resolve, reject) => {
|
|
151
144
|
// Load the scripts
|
|
152
|
-
|
|
145
|
+
Taxonomy.loadScripts().then(() => {
|
|
153
146
|
// Get the taxonomy session
|
|
154
|
-
|
|
155
|
-
|
|
147
|
+
let context = SP.ClientContext.get_current();
|
|
148
|
+
let session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
|
|
156
149
|
// Resolve the promise
|
|
157
|
-
|
|
150
|
+
let termStores = session.get_termStores();
|
|
158
151
|
context.load(termStores, "Include(Groups)");
|
|
159
|
-
context.executeQueryAsync(
|
|
152
|
+
context.executeQueryAsync(() => {
|
|
160
153
|
// Get the default store
|
|
161
|
-
|
|
162
|
-
|
|
154
|
+
let enumerator = termStores.getEnumerator();
|
|
155
|
+
let termStore = enumerator.moveNext() ? enumerator.get_current() : null;
|
|
163
156
|
if (termStore) {
|
|
164
157
|
// Get the term groups
|
|
165
|
-
|
|
166
|
-
context.load(
|
|
158
|
+
let termGroups = termStore.get_groups();
|
|
159
|
+
context.load(termGroups, "Include(Description, Id, Name)");
|
|
167
160
|
// Execute the request
|
|
168
161
|
context.executeQueryAsync(
|
|
169
162
|
// Success
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
() => {
|
|
164
|
+
let groups = [];
|
|
172
165
|
// Parse the groups
|
|
173
|
-
|
|
166
|
+
let enumerator = termGroups.getEnumerator();
|
|
174
167
|
while (enumerator.moveNext()) {
|
|
175
|
-
|
|
168
|
+
let group = enumerator.get_current();
|
|
176
169
|
// Add the group information
|
|
177
170
|
groups.push({
|
|
178
171
|
description: group.get_description(),
|
|
@@ -182,11 +175,7 @@ exports.Taxonomy = {
|
|
|
182
175
|
}
|
|
183
176
|
// Resolve the promise
|
|
184
177
|
resolve(groups);
|
|
185
|
-
},
|
|
186
|
-
var args = [];
|
|
187
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
188
|
-
args[_i] = arguments[_i];
|
|
189
|
-
}
|
|
178
|
+
}, (...args) => {
|
|
190
179
|
// Reject the promise
|
|
191
180
|
reject(args[1].get_message());
|
|
192
181
|
});
|
|
@@ -195,11 +184,7 @@ exports.Taxonomy = {
|
|
|
195
184
|
// Reject the promise
|
|
196
185
|
reject("Unable to find the taxonomy store.");
|
|
197
186
|
}
|
|
198
|
-
},
|
|
199
|
-
var args = [];
|
|
200
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
201
|
-
args[_i] = arguments[_i];
|
|
202
|
-
}
|
|
187
|
+
}, (...args) => {
|
|
203
188
|
// Reject the promise
|
|
204
189
|
reject(args[1].get_message());
|
|
205
190
|
});
|
|
@@ -209,24 +194,23 @@ exports.Taxonomy = {
|
|
|
209
194
|
/**
|
|
210
195
|
* Method to get the term sets for a group
|
|
211
196
|
*/
|
|
212
|
-
getTermSets:
|
|
197
|
+
getTermSets: (groupName) => {
|
|
213
198
|
// Return a promise
|
|
214
|
-
return new Promise(
|
|
199
|
+
return new Promise((resolve, reject) => {
|
|
215
200
|
// Get the term gruop
|
|
216
|
-
|
|
201
|
+
Taxonomy.getTermGroup(groupName).then(
|
|
217
202
|
// Success
|
|
218
|
-
|
|
219
|
-
var context = _a.context, termGroup = _a.termGroup;
|
|
203
|
+
({ context, termGroup }) => {
|
|
220
204
|
// Get the term group information
|
|
221
|
-
|
|
205
|
+
let termGroupInfo = termGroup.get_termSets();
|
|
222
206
|
context.load(termGroupInfo, "Include(CustomProperties, Description, Id, Name)");
|
|
223
207
|
// Execute the request
|
|
224
|
-
context.executeQueryAsync(
|
|
225
|
-
|
|
208
|
+
context.executeQueryAsync(() => {
|
|
209
|
+
let termSets = [];
|
|
226
210
|
// Parse the term group information
|
|
227
|
-
|
|
211
|
+
let enumerator = termGroupInfo.getEnumerator();
|
|
228
212
|
while (enumerator.moveNext()) {
|
|
229
|
-
|
|
213
|
+
let termSet = enumerator.get_current();
|
|
230
214
|
// Add the group information
|
|
231
215
|
termSets.push({
|
|
232
216
|
description: termSet.get_description(),
|
|
@@ -237,17 +221,13 @@ exports.Taxonomy = {
|
|
|
237
221
|
}
|
|
238
222
|
// Resolve the promise
|
|
239
223
|
resolve(termSets);
|
|
240
|
-
},
|
|
241
|
-
var args = [];
|
|
242
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
243
|
-
args[_i] = arguments[_i];
|
|
244
|
-
}
|
|
224
|
+
}, (...args) => {
|
|
245
225
|
// Reject the promise
|
|
246
226
|
reject(args[1].get_message());
|
|
247
227
|
});
|
|
248
228
|
},
|
|
249
229
|
// Error
|
|
250
|
-
|
|
230
|
+
reason => {
|
|
251
231
|
// Reject the promise
|
|
252
232
|
reject(reason);
|
|
253
233
|
});
|
|
@@ -256,28 +236,28 @@ exports.Taxonomy = {
|
|
|
256
236
|
/**
|
|
257
237
|
* Method to get the term sets from the default site collection.
|
|
258
238
|
*/
|
|
259
|
-
getTermSetsFromDefaultSC:
|
|
239
|
+
getTermSetsFromDefaultSC: () => {
|
|
260
240
|
// Return a promise
|
|
261
|
-
return new Promise(
|
|
241
|
+
return new Promise((resolve, reject) => {
|
|
262
242
|
// Load the scripts
|
|
263
|
-
|
|
243
|
+
Taxonomy.loadScripts().then(() => {
|
|
264
244
|
// Get the taxonomy session
|
|
265
|
-
|
|
266
|
-
|
|
245
|
+
let context = SP.ClientContext.get_current();
|
|
246
|
+
let session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
|
|
267
247
|
// Get the terms sets from the default site collection
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
248
|
+
let termStore = session.getDefaultSiteCollectionTermStore();
|
|
249
|
+
let termGroup = termStore.getSiteCollectionGroup(context.get_site());
|
|
250
|
+
let termGroupInfo = termGroup.get_termSets();
|
|
271
251
|
context.load(termGroupInfo, "Include(CustomProperties, Description, Id, Name)");
|
|
272
252
|
// Execute the request
|
|
273
253
|
context.executeQueryAsync(
|
|
274
254
|
// Success
|
|
275
|
-
|
|
276
|
-
|
|
255
|
+
() => {
|
|
256
|
+
let termSets = [];
|
|
277
257
|
// Parse the term group information
|
|
278
|
-
|
|
258
|
+
let enumerator = termGroupInfo.getEnumerator();
|
|
279
259
|
while (enumerator.moveNext()) {
|
|
280
|
-
|
|
260
|
+
let termSet = enumerator.get_current();
|
|
281
261
|
// Add the group information
|
|
282
262
|
termSets.push({
|
|
283
263
|
description: termSet.get_description(),
|
|
@@ -288,11 +268,7 @@ exports.Taxonomy = {
|
|
|
288
268
|
}
|
|
289
269
|
// Resolve the promise
|
|
290
270
|
resolve(termSets);
|
|
291
|
-
},
|
|
292
|
-
var args = [];
|
|
293
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
294
|
-
args[_i] = arguments[_i];
|
|
295
|
-
}
|
|
271
|
+
}, (...args) => {
|
|
296
272
|
// Reject the promise
|
|
297
273
|
reject(args[1].get_message());
|
|
298
274
|
});
|
|
@@ -302,29 +278,25 @@ exports.Taxonomy = {
|
|
|
302
278
|
/**
|
|
303
279
|
* Method to get the terms by id
|
|
304
280
|
*/
|
|
305
|
-
getTermsById:
|
|
281
|
+
getTermsById: (termStoreId, termSetId) => {
|
|
306
282
|
// Return a promise
|
|
307
|
-
return new Promise(
|
|
283
|
+
return new Promise((resolve, reject) => {
|
|
308
284
|
// Load the scripts
|
|
309
|
-
|
|
285
|
+
Taxonomy.loadScripts().then(() => {
|
|
310
286
|
// Get the taxonomy session
|
|
311
|
-
|
|
312
|
-
|
|
287
|
+
let context = SP.ClientContext.get_current();
|
|
288
|
+
let session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
|
|
313
289
|
// Get the term set terms
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
290
|
+
let termStore = session.get_termStores().getById(termStoreId);
|
|
291
|
+
let termSet = termStore.getTermSet(termSetId);
|
|
292
|
+
let terms = termSet.getAllTerms();
|
|
317
293
|
context.load(termSet);
|
|
318
294
|
context.load(terms, "Include(CustomProperties, Description, Id, Name, PathOfTerm)");
|
|
319
295
|
// Execute the request
|
|
320
|
-
context.executeQueryAsync(
|
|
296
|
+
context.executeQueryAsync(() => {
|
|
321
297
|
// Resolve the promise
|
|
322
|
-
resolve(
|
|
323
|
-
},
|
|
324
|
-
var args = [];
|
|
325
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
326
|
-
args[_i] = arguments[_i];
|
|
327
|
-
}
|
|
298
|
+
resolve(Taxonomy.getTerms(termSet, terms));
|
|
299
|
+
}, (...args) => {
|
|
328
300
|
// Reject the promise
|
|
329
301
|
reject(args[1].get_message());
|
|
330
302
|
});
|
|
@@ -334,18 +306,18 @@ exports.Taxonomy = {
|
|
|
334
306
|
/**
|
|
335
307
|
* Method to get the term set by id
|
|
336
308
|
*/
|
|
337
|
-
getTermSetById:
|
|
309
|
+
getTermSetById: (termStoreId, termSetId) => {
|
|
338
310
|
// Return a promise
|
|
339
|
-
return new Promise(
|
|
311
|
+
return new Promise((resolve, reject) => {
|
|
340
312
|
// Get the terms
|
|
341
|
-
|
|
313
|
+
Taxonomy.getTermsById(termStoreId, termSetId).then(
|
|
342
314
|
// Success
|
|
343
|
-
|
|
315
|
+
terms => {
|
|
344
316
|
// Resolve the promise
|
|
345
|
-
resolve(
|
|
317
|
+
resolve(Taxonomy.toObject(terms));
|
|
346
318
|
},
|
|
347
319
|
// Error
|
|
348
|
-
|
|
320
|
+
reason => {
|
|
349
321
|
// Reject the promise
|
|
350
322
|
reject(reason);
|
|
351
323
|
});
|
|
@@ -354,34 +326,29 @@ exports.Taxonomy = {
|
|
|
354
326
|
/**
|
|
355
327
|
* Method to get the terms from the default site collection
|
|
356
328
|
*/
|
|
357
|
-
getTermsFromDefaultSC:
|
|
329
|
+
getTermsFromDefaultSC: (termSetName) => {
|
|
358
330
|
// Return a promise
|
|
359
|
-
return new Promise(
|
|
331
|
+
return new Promise((resolve, reject) => {
|
|
360
332
|
// Get the term group
|
|
361
|
-
|
|
333
|
+
Taxonomy.getTermGroup().then(
|
|
362
334
|
// Success
|
|
363
|
-
|
|
364
|
-
var context = _a.context, termGroup = _a.termGroup;
|
|
335
|
+
({ context, termGroup }) => {
|
|
365
336
|
// Get the term set terms
|
|
366
|
-
|
|
367
|
-
|
|
337
|
+
let termSet = termGroup.get_termSets().getByName(termSetName);
|
|
338
|
+
let terms = termSet.getAllTerms();
|
|
368
339
|
context.load(termSet);
|
|
369
340
|
context.load(terms, "Include(CustomProperties, Description, Id, Name, PathOfTerm)");
|
|
370
341
|
// Execute the request
|
|
371
|
-
context.executeQueryAsync(
|
|
342
|
+
context.executeQueryAsync(() => {
|
|
372
343
|
// Resolve the promise
|
|
373
|
-
resolve(
|
|
374
|
-
},
|
|
375
|
-
var args = [];
|
|
376
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
377
|
-
args[_i] = arguments[_i];
|
|
378
|
-
}
|
|
344
|
+
resolve(Taxonomy.getTerms(termSet, terms));
|
|
345
|
+
}, (...args) => {
|
|
379
346
|
// Reject the promise
|
|
380
347
|
reject(args[1].get_message());
|
|
381
348
|
});
|
|
382
349
|
},
|
|
383
350
|
// Error
|
|
384
|
-
|
|
351
|
+
reason => {
|
|
385
352
|
// Reject the promise
|
|
386
353
|
reject(reason);
|
|
387
354
|
});
|
|
@@ -390,18 +357,18 @@ exports.Taxonomy = {
|
|
|
390
357
|
/**
|
|
391
358
|
* Method to get the term set from the default site collection
|
|
392
359
|
*/
|
|
393
|
-
getTermSetFromDefaultSC:
|
|
360
|
+
getTermSetFromDefaultSC: (termSetName) => {
|
|
394
361
|
// Return a promise
|
|
395
|
-
return new Promise(
|
|
362
|
+
return new Promise((resolve, reject) => {
|
|
396
363
|
// Get the terms
|
|
397
|
-
|
|
364
|
+
Taxonomy.getTermsFromDefaultSC(termSetName).then(
|
|
398
365
|
// Success
|
|
399
|
-
|
|
366
|
+
terms => {
|
|
400
367
|
// Resolve the object
|
|
401
|
-
resolve(
|
|
368
|
+
resolve(Taxonomy.toObject(terms));
|
|
402
369
|
},
|
|
403
370
|
// Error
|
|
404
|
-
|
|
371
|
+
reason => {
|
|
405
372
|
// Reject the promise
|
|
406
373
|
reject(reason);
|
|
407
374
|
});
|
|
@@ -410,26 +377,21 @@ exports.Taxonomy = {
|
|
|
410
377
|
/**
|
|
411
378
|
* Method to get a terms from a specified group
|
|
412
379
|
*/
|
|
413
|
-
getTermsByGroupName:
|
|
380
|
+
getTermsByGroupName: (termSetName, groupName) => {
|
|
414
381
|
// Return a promise
|
|
415
|
-
return new Promise(
|
|
382
|
+
return new Promise((resolve, reject) => {
|
|
416
383
|
// Get the term group
|
|
417
|
-
|
|
418
|
-
var context = _a.context, termGroup = _a.termGroup;
|
|
384
|
+
Taxonomy.getTermGroup(groupName).then(({ context, termGroup }) => {
|
|
419
385
|
// Get the term set terms
|
|
420
|
-
|
|
421
|
-
|
|
386
|
+
let termSet = termGroup.get_termSets().getByName(termSetName);
|
|
387
|
+
let terms = termSet.getAllTerms();
|
|
422
388
|
context.load(termSet);
|
|
423
389
|
context.load(terms, "Include(CustomProperties, Description, Id, Name, PathOfTerm)");
|
|
424
390
|
// Execute the request
|
|
425
|
-
context.executeQueryAsync(
|
|
391
|
+
context.executeQueryAsync(() => {
|
|
426
392
|
// Resolve the promise
|
|
427
|
-
resolve(
|
|
428
|
-
},
|
|
429
|
-
var args = [];
|
|
430
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
431
|
-
args[_i] = arguments[_i];
|
|
432
|
-
}
|
|
393
|
+
resolve(Taxonomy.getTerms(termSet, terms));
|
|
394
|
+
}, (...args) => {
|
|
433
395
|
// Reject the promise
|
|
434
396
|
reject(args[1].get_message());
|
|
435
397
|
});
|
|
@@ -439,18 +401,18 @@ exports.Taxonomy = {
|
|
|
439
401
|
/**
|
|
440
402
|
* Method to get the term set from the default site collection
|
|
441
403
|
*/
|
|
442
|
-
getTermSetByGroupName:
|
|
404
|
+
getTermSetByGroupName: (termSetName, groupName) => {
|
|
443
405
|
// Return a promise
|
|
444
|
-
return new Promise(
|
|
406
|
+
return new Promise((resolve, reject) => {
|
|
445
407
|
// Get the terms
|
|
446
|
-
|
|
408
|
+
Taxonomy.getTermsByGroupName(termSetName, groupName).then(
|
|
447
409
|
// Success
|
|
448
|
-
|
|
410
|
+
terms => {
|
|
449
411
|
// Resolve the object
|
|
450
|
-
resolve(
|
|
412
|
+
resolve(Taxonomy.toObject(terms));
|
|
451
413
|
},
|
|
452
414
|
// Error
|
|
453
|
-
|
|
415
|
+
reason => {
|
|
454
416
|
// Reject the promise
|
|
455
417
|
reject(reason);
|
|
456
418
|
});
|
|
@@ -459,14 +421,14 @@ exports.Taxonomy = {
|
|
|
459
421
|
/**
|
|
460
422
|
* Method to ensure the taxonomy script references are loaded.
|
|
461
423
|
*/
|
|
462
|
-
loadScripts:
|
|
424
|
+
loadScripts: () => {
|
|
463
425
|
// Return a promise
|
|
464
|
-
return new Promise(
|
|
426
|
+
return new Promise((resolve, reject) => {
|
|
465
427
|
// Ensure the core script is loaded
|
|
466
|
-
SP.SOD.executeFunc("sp.js", "SP.Utilities.Utility",
|
|
428
|
+
SP.SOD.executeFunc("sp.js", "SP.Utilities.Utility", () => {
|
|
467
429
|
// Ensure the taxonomy script is loaded
|
|
468
|
-
SP.SOD.registerSod("sp.taxonomy.js",
|
|
469
|
-
SP.SOD.executeFunc("sp.taxonomy.js", "SP.Taxonomy.TaxonomySession",
|
|
430
|
+
SP.SOD.registerSod("sp.taxonomy.js", ContextInfo.webServerRelativeUrl + "/_layouts/15/sp.taxonomy.js");
|
|
431
|
+
SP.SOD.executeFunc("sp.taxonomy.js", "SP.Taxonomy.TaxonomySession", () => {
|
|
470
432
|
// Resolve the promise
|
|
471
433
|
resolve();
|
|
472
434
|
});
|
|
@@ -476,18 +438,18 @@ exports.Taxonomy = {
|
|
|
476
438
|
/**
|
|
477
439
|
* Method to convert a term to an array of term information
|
|
478
440
|
*/
|
|
479
|
-
toArray:
|
|
480
|
-
|
|
441
|
+
toArray: (term) => {
|
|
442
|
+
let terms = [];
|
|
481
443
|
// Recursive method to extract the child terms
|
|
482
|
-
|
|
444
|
+
let getChildTerms = (term, terms) => {
|
|
483
445
|
// Parse the properties
|
|
484
|
-
for (
|
|
446
|
+
for (let prop in term) {
|
|
485
447
|
// Skip the info and parent properties
|
|
486
448
|
if (prop == "info" || prop == "parent") {
|
|
487
449
|
continue;
|
|
488
450
|
}
|
|
489
451
|
// Add the child term
|
|
490
|
-
|
|
452
|
+
let childTerm = term[prop];
|
|
491
453
|
terms.push(childTerm.info);
|
|
492
454
|
// Add the child terms
|
|
493
455
|
getChildTerms(childTerm, terms);
|
|
@@ -509,8 +471,8 @@ exports.Taxonomy = {
|
|
|
509
471
|
/**
|
|
510
472
|
* Method to convert a term to a field value
|
|
511
473
|
*/
|
|
512
|
-
toFieldValue:
|
|
513
|
-
|
|
474
|
+
toFieldValue: (term) => {
|
|
475
|
+
let termInfo = term ? term["info"] || term : null;
|
|
514
476
|
// Ensure the term exists
|
|
515
477
|
if (termInfo) {
|
|
516
478
|
return {
|
|
@@ -526,13 +488,13 @@ exports.Taxonomy = {
|
|
|
526
488
|
/**
|
|
527
489
|
* Method to convert a collection of terms to a field value
|
|
528
490
|
*/
|
|
529
|
-
toFieldMultiValue:
|
|
530
|
-
|
|
491
|
+
toFieldMultiValue: (terms) => {
|
|
492
|
+
let results = [];
|
|
531
493
|
// Ensure terms exist
|
|
532
494
|
if (terms && terms.length > 0) {
|
|
533
495
|
// Parse the terms
|
|
534
|
-
for (
|
|
535
|
-
|
|
496
|
+
for (let i = 0; i < terms.length; i++) {
|
|
497
|
+
let termInfo = terms[i]["info"] || terms[i];
|
|
536
498
|
// Add the term
|
|
537
499
|
results.push(";#" + termInfo.name + "|" + termInfo.id);
|
|
538
500
|
}
|
|
@@ -540,18 +502,18 @@ exports.Taxonomy = {
|
|
|
540
502
|
// Return a blank array
|
|
541
503
|
return {
|
|
542
504
|
__metadata: { type: "Collection(SP.Taxonomy.TaxonomyFieldValue)" },
|
|
543
|
-
results
|
|
505
|
+
results
|
|
544
506
|
};
|
|
545
507
|
},
|
|
546
508
|
/**
|
|
547
509
|
* Method to convert the terms to an object
|
|
548
510
|
*/
|
|
549
|
-
toObject:
|
|
550
|
-
|
|
511
|
+
toObject: (terms) => {
|
|
512
|
+
let root = {};
|
|
551
513
|
// Recursive method to add terms
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
514
|
+
let addTerm = (node, info, path) => {
|
|
515
|
+
let term = node;
|
|
516
|
+
let termName = "";
|
|
555
517
|
// Loop for each term
|
|
556
518
|
while (path.length > 0) {
|
|
557
519
|
// Ensure the term exists
|
|
@@ -561,10 +523,10 @@ exports.Taxonomy = {
|
|
|
561
523
|
term[termName] = {};
|
|
562
524
|
}
|
|
563
525
|
// Set the term
|
|
564
|
-
|
|
526
|
+
let parent = term;
|
|
565
527
|
term = term[termName];
|
|
566
528
|
// Set the parent
|
|
567
|
-
term.parent =
|
|
529
|
+
term.parent = parent;
|
|
568
530
|
// Remove the term from the path
|
|
569
531
|
path.splice(0, 1);
|
|
570
532
|
}
|
|
@@ -574,8 +536,8 @@ exports.Taxonomy = {
|
|
|
574
536
|
// Ensure the terms exist
|
|
575
537
|
if (terms && terms.length > 0) {
|
|
576
538
|
// Parse the terms
|
|
577
|
-
for (
|
|
578
|
-
|
|
539
|
+
for (let i = 0; i < terms.length; i++) {
|
|
540
|
+
let term = terms[i];
|
|
579
541
|
// See if this is the root term
|
|
580
542
|
if (term.pathAsString == "") {
|
|
581
543
|
// Set the root information
|
|
@@ -587,7 +549,7 @@ exports.Taxonomy = {
|
|
|
587
549
|
}
|
|
588
550
|
}
|
|
589
551
|
// Return the root term
|
|
590
|
-
return
|
|
552
|
+
return Taxonomy.findById(root, terms[0].id);
|
|
591
553
|
}
|
|
592
554
|
// Return nothing
|
|
593
555
|
return null;
|