Skip to content

Commit

Permalink
Merge pull request #182 from gunjandatta/gdatta
Browse files Browse the repository at this point in the history
Update Helper Methods
  • Loading branch information
gunjandatta authored Sep 21, 2018
2 parents 6654d64 + ee05642 commit f8a3b85
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 137 deletions.
49 changes: 18 additions & 31 deletions build/helper/listForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,16 @@ exports.ListForm = {
loadListData().then(
// Success
function () {
// Ensure the list exists
if (_info.list) {
// See if the fields have been defined
if (_props.fields) {
// Process the fields
processFields();
// Load the item data
loadItem();
}
else {
// Load the content type
loadDefaultContentType();
}
// See if the fields have been defined
if (_props.fields) {
// Process the fields
processFields();
// Load the item data
loadItem();
}
else {
// Reject the promise
_reject();
// Load the content type
loadDefaultContentType();
}
},
// Reject
Expand Down Expand Up @@ -86,7 +79,7 @@ exports.ListForm = {
}
// Resolve the promise
loadDefaultFields(ct.results[0]);
});
}, _reject);
};
// Method to load the default fields
var loadDefaultFields = function (ct) {
Expand Down Expand Up @@ -259,7 +252,7 @@ exports.ListForm = {
_info.item = item;
// Resolve the promise
_resolve(_info);
});
}, _reject);
}
else {
// Resolve the promise
Expand All @@ -285,17 +278,11 @@ exports.ListForm = {
// Save the list and web url
_info.list = list;
_info.webUrl = _props.webUrl;
})
}, reject)
// Load the fields
.Fields()
// Execute the request
.execute(function (fields) {
// Ensure the fields exist
if (!fields.existsFl) {
// Reject the promise
reject(fields.response);
return;
}
// See if we are caching the data
if (_props.cacheKey) {
// Update the cache
Expand All @@ -309,7 +296,7 @@ exports.ListForm = {
loadFieldData(fields);
// Resolve the promise
resolve();
});
}, reject);
});
};
// Method to process the fields
Expand Down Expand Up @@ -431,7 +418,7 @@ exports.ListForm = {
}
// Resolve the promise
resolve(attachments.results || []);
});
}, reject);
}
else {
// Resolve the promise
Expand All @@ -451,7 +438,7 @@ exports.ListForm = {
info.item = item;
// Resolve the promise
resolve(info);
});
}, reject);
});
},
// Method to remove attachments from an item
Expand All @@ -475,7 +462,7 @@ exports.ListForm = {
.execute(function () {
// Resolve the promise
resolve(info);
});
}, reject);
// Attachment found
return;
}
Expand Down Expand Up @@ -537,7 +524,7 @@ exports.ListForm = {
exports.ListForm.refreshItem(info).then(function (info) {
// Resolve the promise
resolve(info);
});
}, reject);
});
}
else {
Expand All @@ -554,7 +541,7 @@ exports.ListForm = {
// Resolve the promise
resolve(info);
});
});
}, reject);
}
});
},
Expand Down Expand Up @@ -592,7 +579,7 @@ exports.ListForm = {
// Resolve the promise
resolve(info);
});
});
}, reject);
};
// Set the error
reader.onerror = function (ev) {
Expand Down
2 changes: 1 addition & 1 deletion build/helper/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ exports.createDocSet = function (name, listName, webUrl) {
reject(response["response"]);
}
});
});
}, reject);
});
};
/**
Expand Down
60 changes: 30 additions & 30 deletions build/helper/spCfg.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ exports.SPConfig = function (cfg, webUrl) {
// Log
console.log("[gd-sprest][Content Type] The parent content type '" + cfgContentType.Name + "' was not found.");
}
});
}, reject);
}
else {
// Create the content type
Expand All @@ -120,7 +120,7 @@ exports.SPConfig = function (cfg, webUrl) {
console.log("[gd-sprest][Content Type] The content type '" + cfgContentType.Name + "' failed to be created.");
console.error("[gd-sprest][Field] Error: " + ct.response);
}
}, true);
}, reject, true);
}
}
};
Expand Down Expand Up @@ -320,7 +320,7 @@ exports.SPConfig = function (cfg, webUrl) {
console.log("[gd-sprest][List] The list '" + listInfo_1.Title + "' failed to be created.");
console.log("[gd-sprest][List] Error: '" + list.response);
}
});
}, reject);
}
};
// Parse the content types
Expand Down Expand Up @@ -391,7 +391,7 @@ exports.SPConfig = function (cfg, webUrl) {
console.log("[gd-sprest][Custom Action] The custom action '" + ca.Name + "' failed to be created.");
console.log("[gd-sprest][Custom Action] Error: " + ca.response);
}
}, true);
}, reject, true);
}
}
// Wait for the requests to complete
Expand Down Expand Up @@ -437,7 +437,7 @@ exports.SPConfig = function (cfg, webUrl) {
console.log("[gd-sprest][View] The view '" + cfgView.ViewName + "' failed to be created.");
console.log("[gd-sprest][View] Error: " + view.response);
}
}, true);
}, reject, true);
}
};
// Parse the views
Expand Down Expand Up @@ -543,7 +543,7 @@ exports.SPConfig = function (cfg, webUrl) {
for (var i = 0; i < cfgWebParts.length; i++) {
_loop_6(i);
}
});
}, reject);
});
};
// Method to see if an object exists in a collection
Expand Down Expand Up @@ -581,7 +581,7 @@ exports.SPConfig = function (cfg, webUrl) {
ct.delete().execute(function () {
// Log
console.log("[gd-sprest][Field] The content type '" + ct.Name + "' was removed.");
}, true);
}, reject, true);
}
};
// Parse the configuration
Expand Down Expand Up @@ -614,7 +614,7 @@ exports.SPConfig = function (cfg, webUrl) {
field.delete().execute(function () {
// Log
console.log("[gd-sprest][Field] The field '" + field.InternalName + "' was removed.");
}, true);
}, reject, true);
}
};
// Parse the configuration
Expand Down Expand Up @@ -663,7 +663,7 @@ exports.SPConfig = function (cfg, webUrl) {
list.delete().execute(function () {
// Log
console.log("[gd-sprest][List] The list '" + list.Title + "' was removed.");
}, true);
}, reject, true);
}
};
// Parse the configuration
Expand Down Expand Up @@ -713,7 +713,7 @@ exports.SPConfig = function (cfg, webUrl) {
ca.delete().execute(function () {
// Log
console.log("[gd-sprest][Custom Action] The custom action '" + ca.Name + "' was removed.");
}, true);
}, reject, true);
}
};
// Parse the configuration
Expand Down Expand Up @@ -784,7 +784,7 @@ exports.SPConfig = function (cfg, webUrl) {
}
// Resolve the promise
resolve();
});
}, reject);
});
};
// Method to update the base permissions
Expand Down Expand Up @@ -896,11 +896,11 @@ exports.SPConfig = function (cfg, webUrl) {
cfgList.onUpdated ? cfgList.onUpdated(list) : null;
// Update the next list
request(idx + 1, resolve);
});
});
});
});
});
}, reject);
}, reject);
}, reject);
}, reject);
}, reject);
}
else {
// Resolve the promise
Expand Down Expand Up @@ -991,7 +991,7 @@ exports.SPConfig = function (cfg, webUrl) {
// Resolve the promise
resolve(site);
});
});
}, reject);
});
};
// Method to uninstall the web components
Expand All @@ -1018,11 +1018,11 @@ exports.SPConfig = function (cfg, webUrl) {
removeUserCustomActions(web.UserCustomActions, cfg.CustomActionCfg ? cfg.CustomActionCfg.Web : null).then(function () {
// Resolve the promise
resolve();
});
});
});
});
});
}, reject);
}, reject);
}, reject);
}, reject);
}, reject);
});
};
/**
Expand Down Expand Up @@ -1067,9 +1067,9 @@ exports.SPConfig = function (cfg, webUrl) {
postExecute();
// Resolve the promise
resolve();
});
}, reject);
});
});
}, reject);
}
// See if we are creating the content types
if (cfg.ContentTypes && cfg.ContentTypes.length > 0) {
Expand All @@ -1086,7 +1086,7 @@ exports.SPConfig = function (cfg, webUrl) {
// Execute the post execute method
postExecute();
});
}, true);
}, reject, true);
}
// See if we are creating the lists
if (cfg.ListCfg && cfg.ListCfg.length) {
Expand All @@ -1103,7 +1103,7 @@ exports.SPConfig = function (cfg, webUrl) {
// Execute the post execute method
postExecute();
});
}, true);
}, reject, true);
}
// See if we are creating the webparts
if (cfg.WebPartCfg && cfg.WebPartCfg.length > 0) {
Expand Down Expand Up @@ -1155,7 +1155,7 @@ exports.SPConfig = function (cfg, webUrl) {
// Execute the post execute method
postExecute();
});
});
}, reject);
}
}
});
Expand All @@ -1174,9 +1174,9 @@ exports.SPConfig = function (cfg, webUrl) {
console.log("[gd-sprest] The configuration script completed, but some requests may still be running.");
// Resolve the promise
resolve();
});
});
});
}, reject);
}, reject);
}, reject);
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion build/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var Mapper = require("./mapper");
* SharePoint REST Library
*/
exports.$REST = {
__ver: 4.24,
__ver: 4.26,
AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
ContextInfo: Lib.ContextInfo,
DefaultRequestToHostFl: false,
Expand Down
8 changes: 4 additions & 4 deletions dist/gd-sprest.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/gd-sprest.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gd-sprest",
"version": "4.2.4",
"version": "4.2.6",
"description": "An easy way to develop against the SharePoint REST API.",
"author": "Gunjan Datta <[email protected]> (https://gunjandatta.github.io/sprest)",
"license": "<LICENSE>",
Expand Down
Loading

0 comments on commit f8a3b85

Please sign in to comment.