gd-sprest
Advanced tools
Comparing version 8.1.2 to 8.1.3
@@ -17,10 +17,16 @@ "use strict"; | ||
var skipFields = []; | ||
var ct = lib_1.Web(webContext.WebFullUrl).Lists(ctInfo.listName).ContentTypes(ctInfo.id); | ||
// See if we need to remove any fields | ||
if (fieldLinks.length > 0) { | ||
var updateFl = false; | ||
var _loop_1 = function (i) { | ||
// Set the context | ||
var ctx = ctInfo.webUrl ? new SP.ClientContext(ctInfo.webUrl) : new SP.ClientContext(lib_1.ContextInfo.webServerRelativeUrl); | ||
// Get the source | ||
var src = ctInfo.listName ? ctx.get_web().get_lists().getByTitle(ctInfo.listName) : ctx.get_web(); | ||
// Get the content type | ||
var contentType = src.get_contentTypes().getById(ctInfo.id); | ||
// Parse the content type field links | ||
for (var i = 0; i < fieldLinks.length; i++) { | ||
var fieldLink = fieldLinks[i]; | ||
var removeFl = true; | ||
var _loop_2 = function (j) { | ||
var _loop_1 = function (j) { | ||
var field = ctInfo.fields[j]; | ||
@@ -62,3 +68,3 @@ var fieldName = typeof (field) === "string" ? field : field.Name || field.FieldInternalName; | ||
for (var j = 0; j < ctInfo.fields.length; j++) { | ||
var state_1 = _loop_2(j); | ||
var state_1 = _loop_1(j); | ||
if (state_1 === "break") | ||
@@ -69,28 +75,16 @@ break; | ||
if (removeFl) { | ||
// Log | ||
console.log("[gd-sprest][Set Content Type Fields] Removing the field link: " + fieldLink.Name); | ||
// Remove the field link | ||
ct.Fields().getById(fieldLink.Id).delete().execute( | ||
// Success | ||
function () { | ||
// Log | ||
console.log("[gd-sprest][Set Content Type Fields] Field link '" + fieldLink.Name + "' was removed successfully."); | ||
}, | ||
// Error | ||
function () { | ||
// Log | ||
console.log("[gd-sprest][Set Content Type Fields] Error removing the field link: " + fieldLink.Name); | ||
}, true); | ||
contentType.get_fieldLinks().getById(fieldLink.Id).deleteObject(); | ||
// Set the flag | ||
updateFl = true; | ||
// Log | ||
console.log("[gd-sprest][Set Content Type Fields] Removing the field link: " + fieldLink.Name); | ||
} | ||
}; | ||
// Parse the content type field links | ||
for (var i = 0; i < fieldLinks.length; i++) { | ||
_loop_1(i); | ||
} | ||
// See if we are updating the content type | ||
// See if an update is required | ||
if (updateFl) { | ||
// Wait for the requests to complete | ||
ct.done( | ||
// Update the content type | ||
contentType.update(false); | ||
// Execute the request | ||
ctx.executeQueryAsync( | ||
// Success | ||
@@ -102,2 +96,9 @@ function () { | ||
resolve(skipFields); | ||
}, | ||
// Error | ||
function (sender, args) { | ||
// Log | ||
console.log("[gd-sprest][Set Content Type Fields] Error removing the field links."); | ||
// Reject the request | ||
reject(); | ||
}); | ||
@@ -237,16 +238,2 @@ } | ||
}; | ||
// Sets the context for the target site | ||
var webContext = null; | ||
var setContext = function () { | ||
// Return a promise | ||
return new Promise(function (resolve, reject) { | ||
// Get the context information of the target web | ||
lib_1.ContextInfo.getWeb(ctInfo.webUrl || lib_1.ContextInfo.webServerRelativeUrl).execute(function (context) { | ||
// Set the web context info | ||
webContext = context.GetContextWebInformation; | ||
// Resolve the request | ||
resolve(); | ||
}, reject); | ||
}); | ||
}; | ||
// Set the order of the field references | ||
@@ -298,11 +285,8 @@ var setOrder = function () { | ||
if (ctInfo.fields) { | ||
// Set the context | ||
setContext().then(function () { | ||
// Clear the links | ||
clearLinks().then(function (skipFields) { | ||
// Create the links | ||
createLinks(skipFields).then(function () { | ||
// Set the field order | ||
setOrder().then(resolve, reject); | ||
}, reject); | ||
// Clear the links | ||
clearLinks().then(function (skipFields) { | ||
// Create the links | ||
createLinks(skipFields).then(function () { | ||
// Set the field order | ||
setOrder().then(resolve, reject); | ||
}, reject); | ||
@@ -309,0 +293,0 @@ }, reject); |
@@ -12,3 +12,3 @@ "use strict"; | ||
exports.$REST = { | ||
__ver: 8.12, | ||
__ver: 8.13, | ||
AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); }, | ||
@@ -15,0 +15,0 @@ Apps: Lib.Apps, |
{ | ||
"name": "gd-sprest", | ||
"version": "8.1.2", | ||
"version": "8.1.3", | ||
"description": "An easy way to develop against the SharePoint REST API.", | ||
@@ -5,0 +5,0 @@ "author": "Gunjan Datta <me@dattabase.com> (https://gunjandatta.github.io)", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2573771
31360