gd-sprest 7.8.7 → 7.8.9
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/build/lib/sitePages.js +52 -23
- package/build/rest.js +1 -1
- package/build/utils/request.js +1 -1
- package/dist/gd-sprest.js +1 -1
- package/dist/gd-sprest.min.js +1 -1
- package/package.json +1 -1
package/build/lib/sitePages.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.SitePages = void 0;
|
|
4
15
|
var web_1 = require("./web");
|
|
@@ -70,6 +81,19 @@ exports.SitePages.convertPage = function (pageUrl, layout, webUrl) {
|
|
|
70
81
|
};
|
|
71
82
|
// Static method to create a modern page
|
|
72
83
|
exports.SitePages.createPage = (function (pageName, pageTitle, pageTemplate, url, targetInfo) {
|
|
84
|
+
var getContext = function () {
|
|
85
|
+
return new Promise(function (resolve) {
|
|
86
|
+
// See if the web url doesn't exists
|
|
87
|
+
if (url == null) {
|
|
88
|
+
resolve(null);
|
|
89
|
+
}
|
|
90
|
+
// Get the context of target web
|
|
91
|
+
contextInfo_1.ContextInfo.getWeb(url).execute(function (context) {
|
|
92
|
+
// Resolve the request
|
|
93
|
+
resolve(context.GetContextWebInformation.FormDigestValue);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
73
97
|
// Return a promise
|
|
74
98
|
return new Promise(function (resolve, reject) {
|
|
75
99
|
// Method called after the updates have completed
|
|
@@ -94,28 +118,33 @@ exports.SitePages.createPage = (function (pageName, pageTitle, pageTemplate, url
|
|
|
94
118
|
}, reject);
|
|
95
119
|
}, reject);
|
|
96
120
|
};
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}).execute(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
// Get the context information
|
|
122
|
+
getContext().then(function (requestDigest) {
|
|
123
|
+
// Set the target information
|
|
124
|
+
targetInfo = __assign({ requestDigest: requestDigest }, targetInfo);
|
|
125
|
+
// Create the page
|
|
126
|
+
exports.SitePages(url, targetInfo).Pages().createAppPage({
|
|
127
|
+
Title: pageTitle,
|
|
128
|
+
PageLayoutType: pageTemplate
|
|
129
|
+
}).execute(function (page) {
|
|
130
|
+
// Update the file name
|
|
131
|
+
web_1.Web(url, targetInfo).Lists("Site Pages").Items(page.Id).update({
|
|
132
|
+
FileLeafRef: pageName
|
|
133
|
+
}).execute(
|
|
134
|
+
// Updated the file name successfully
|
|
135
|
+
function () {
|
|
136
|
+
// Update the file url
|
|
137
|
+
var idx = page.Url.lastIndexOf('/');
|
|
138
|
+
var fileUrl = page.Url.substring(0, idx + 1) + pageName;
|
|
139
|
+
// Complete the request
|
|
140
|
+
onComplete(page.Id, fileUrl);
|
|
141
|
+
},
|
|
142
|
+
// Unable to update the file name, but still return the object
|
|
143
|
+
function () {
|
|
144
|
+
// Complete the request
|
|
145
|
+
onComplete(page.Id, page.Url);
|
|
146
|
+
});
|
|
147
|
+
}, reject);
|
|
148
|
+
});
|
|
120
149
|
});
|
|
121
150
|
});
|
package/build/rest.js
CHANGED
package/build/utils/request.js
CHANGED
|
@@ -143,7 +143,7 @@ exports.Request = {
|
|
|
143
143
|
methodInfo.metadataType = methods[methodName].metadataType(obj);
|
|
144
144
|
}
|
|
145
145
|
// Add the method to the object
|
|
146
|
-
obj[methodName] = new Function("return this.executeMethod('" + methodName + "', " + JSON.stringify(methodInfo) + ", arguments);");
|
|
146
|
+
obj[methodName] = obj[methodName] || new Function("return this.executeMethod('" + methodName + "', " + JSON.stringify(methodInfo) + ", arguments);");
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
},
|