gd-sprest 8.2.9 → 8.3.1
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/helper/methods/index.d.ts +1 -0
- package/@types/helper/methods/setWebProperty.d.ts +11 -0
- package/build/helper/listForm.js +7 -5
- package/build/helper/methods/index.js +1 -0
- package/build/helper/methods/setWebProperty.js +23 -0
- package/build/rest.js +1 -1
- package/build/utils/request.js +8 -2
- package/dist/gd-sprest.d.ts +15 -0
- package/dist/gd-sprest.js +1 -1
- package/dist/gd-sprest.js.LICENSE.txt +4 -0
- package/dist/gd-sprest.min.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds or updates a key/value pair for a web's property bag
|
|
3
|
+
* This uses JSOM to set a web's property. The REST API doesn't support this at the moment.
|
|
4
|
+
* @param key The property key.
|
|
5
|
+
* @param value The property value.
|
|
6
|
+
* @param siteUrl The site url to apply the property to. If blank, it will default to the current web.
|
|
7
|
+
*/
|
|
8
|
+
export const setWebProperty: IsetWebProperty;
|
|
9
|
+
export interface IsetWebProperty {
|
|
10
|
+
(key: string, value: string, siteUrl?: string): PromiseLike<void>;
|
|
11
|
+
}
|
package/build/helper/listForm.js
CHANGED
|
@@ -524,14 +524,18 @@ exports.ListForm = {
|
|
|
524
524
|
});
|
|
525
525
|
},
|
|
526
526
|
// Method to save a new or existing item
|
|
527
|
-
saveItem: function (info, formValues) {
|
|
527
|
+
saveItem: function (info, formValues, checkItemVersion) {
|
|
528
528
|
if (formValues === void 0) { formValues = {}; }
|
|
529
529
|
// Return a promise
|
|
530
530
|
return new Promise(function (resolve, reject) {
|
|
531
531
|
// See if this is an existing item
|
|
532
532
|
if (info.item && info.item.update) {
|
|
533
|
+
// Set the request properties if we are checking the item version
|
|
534
|
+
var requestProps = checkItemVersion && info.item.etag ? {
|
|
535
|
+
requestHeader: { "IF-MATCH": info.item.etag }
|
|
536
|
+
} : null;
|
|
533
537
|
// Update the item
|
|
534
|
-
info.item.update(formValues).execute(function (response) {
|
|
538
|
+
__1.Web(info.webUrl, requestProps).Lists(info.list.Title).Items(info.item.Id).update(formValues).execute(function (response) {
|
|
535
539
|
// Refresh the item
|
|
536
540
|
exports.ListForm.refreshItem(info).then(function (info) {
|
|
537
541
|
// Resolve the promise
|
|
@@ -543,9 +547,7 @@ exports.ListForm = {
|
|
|
543
547
|
// Set the metadata type
|
|
544
548
|
formValues["__metadata"] = { type: info.list.ListItemEntityTypeFullName };
|
|
545
549
|
// Add the item
|
|
546
|
-
info.list.Items().add(formValues)
|
|
547
|
-
// Execute the request
|
|
548
|
-
.execute(function (item) {
|
|
550
|
+
info.list.Items().add(formValues).execute(function (item) {
|
|
549
551
|
// Update the info
|
|
550
552
|
info.item = item;
|
|
551
553
|
// Refresh the item
|
|
@@ -23,4 +23,5 @@ __exportStar(require("./parse"), exports);
|
|
|
23
23
|
__exportStar(require("./request"), exports);
|
|
24
24
|
__exportStar(require("./setContentTypeFields"), exports);
|
|
25
25
|
__exportStar(require("./setGroupOwner"), exports);
|
|
26
|
+
__exportStar(require("./setWebProperty"), exports);
|
|
26
27
|
__exportStar(require("./stringify"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setWebProperty = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Adds or updates a key/value pair for a web's property bag
|
|
6
|
+
* This uses JSOM to set a web's property. The REST API doesn't support this at the moment.
|
|
7
|
+
*/
|
|
8
|
+
exports.setWebProperty = function (key, value, siteUrl) {
|
|
9
|
+
// Return a promise
|
|
10
|
+
return new Promise(function (resolve, reject) {
|
|
11
|
+
// Get the site groups
|
|
12
|
+
var context = siteUrl ? new SP.ClientContext(siteUrl) : SP.ClientContext.get_current();
|
|
13
|
+
var web = context.get_web();
|
|
14
|
+
var allProps = web.get_allProperties();
|
|
15
|
+
// Set the property
|
|
16
|
+
allProps.set_item(key, value);
|
|
17
|
+
// Save the changes
|
|
18
|
+
context.load(web);
|
|
19
|
+
web.update();
|
|
20
|
+
// Execute the request
|
|
21
|
+
context.executeQueryAsync(resolve, reject);
|
|
22
|
+
});
|
|
23
|
+
};
|
package/build/rest.js
CHANGED
package/build/utils/request.js
CHANGED
|
@@ -152,8 +152,14 @@ exports.Request = {
|
|
|
152
152
|
// Parse the data properties
|
|
153
153
|
for (var key in data) {
|
|
154
154
|
var value = data[key];
|
|
155
|
-
// Skip
|
|
156
|
-
if (key == "
|
|
155
|
+
// Skip the results
|
|
156
|
+
if (key == "results") {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
// See if this is the metadata
|
|
160
|
+
if (key == "__metadata") {
|
|
161
|
+
// Set the etag value and continue
|
|
162
|
+
base["etag"] = value["etag"];
|
|
157
163
|
continue;
|
|
158
164
|
}
|
|
159
165
|
// See if the base is a collection property
|
package/dist/gd-sprest.d.ts
CHANGED
|
@@ -4425,6 +4425,7 @@ declare module 'gd-sprest/helper/methods' {
|
|
|
4425
4425
|
export * from "gd-sprest/helper/methods/request";
|
|
4426
4426
|
export * from "gd-sprest/helper/methods/setContentTypeFields";
|
|
4427
4427
|
export * from "gd-sprest/helper/methods/setGroupOwner";
|
|
4428
|
+
export * from "gd-sprest/helper/methods/setWebProperty";
|
|
4428
4429
|
export * from "gd-sprest/helper/methods/stringify";
|
|
4429
4430
|
}
|
|
4430
4431
|
|
|
@@ -6989,6 +6990,20 @@ declare module 'gd-sprest/helper/methods/setGroupOwner' {
|
|
|
6989
6990
|
}
|
|
6990
6991
|
}
|
|
6991
6992
|
|
|
6993
|
+
declare module 'gd-sprest/helper/methods/setWebProperty' {
|
|
6994
|
+
/**
|
|
6995
|
+
* Adds or updates a key/value pair for a web's property bag
|
|
6996
|
+
* This uses JSOM to set a web's property. The REST API doesn't support this at the moment.
|
|
6997
|
+
* @param key The property key.
|
|
6998
|
+
* @param value The property value.
|
|
6999
|
+
* @param siteUrl The site url to apply the property to. If blank, it will default to the current web.
|
|
7000
|
+
*/
|
|
7001
|
+
export const setWebProperty: IsetWebProperty;
|
|
7002
|
+
export interface IsetWebProperty {
|
|
7003
|
+
(key: string, value: string, siteUrl?: string): PromiseLike<void>;
|
|
7004
|
+
}
|
|
7005
|
+
}
|
|
7006
|
+
|
|
6992
7007
|
declare module 'gd-sprest/helper/methods/stringify' {
|
|
6993
7008
|
/**
|
|
6994
7009
|
* Convert an object to a string
|