Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gd-sprest-react

Package Overview
Dependencies
Maintainers
1
Versions
309
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gd-sprest-react - npm Package Compare versions

Comparing version 2.6.7 to 2.6.8

8

build/components/itemForm.js

@@ -93,3 +93,3 @@ "use strict";

React.createElement("div", { className: "ms-Grid-col-md12" },
React.createElement(__1.Fields.FieldAttachments, { controlMode: _this.ControlMode, files: item ? item.AttachmentFiles : null, key: "Attachments", itemId: item.Id, listName: _this.props.listName, onAttachmentsRender: _this.props.onFieldRender == null ? null : function (attachments) { return _this.props.onFieldRender({ listName: _this.props.listName, name: "Attachments" }, attachments); }, onFileAdded: _this.props.onAttachmentAdded, onFileClick: _this.props.onAttachmentClick == null ? null : function (file) { return _this.props.onAttachmentClick(file, _this.ControlMode); }, onFileRender: _this.props.onAttachmentRender == null ? null : function (file) { return _this.props.onAttachmentRender(file, _this.ControlMode); }, onRender: _this.props.onRenderAttachments == null ? null : function (files) { return _this.props.onRenderAttachments(files, _this.ControlMode); }, ref: function (field) { _this._attachmentField = field; }, webUrl: _this.props.webUrl }))));
React.createElement(__1.Fields.FieldAttachments, { className: _this.props.fieldClassName, controlMode: _this.ControlMode, files: item ? item.AttachmentFiles : null, key: "Attachments", itemId: item.Id, listName: _this.props.listName, onAttachmentsRender: _this.props.onFieldRender == null ? null : function (attachments) { return _this.props.onFieldRender({ listName: _this.props.listName, name: "Attachments" }, attachments); }, onFileAdded: _this.props.onAttachmentAdded, onFileClick: _this.props.onAttachmentClick == null ? null : function (file) { return _this.props.onAttachmentClick(file, _this.ControlMode); }, onFileRender: _this.props.onAttachmentRender == null ? null : function (file) { return _this.props.onAttachmentRender(file, _this.ControlMode); }, onRender: _this.props.onRenderAttachments == null ? null : function (files) { return _this.props.onRenderAttachments(files, _this.ControlMode); }, ref: function (field) { _this._attachmentField = field; }, webUrl: _this.props.webUrl }))));
}

@@ -147,3 +147,3 @@ // Render nothing

*/
_this.saveAttachments = function (itemId) {
_this.saveAttachments = function () {
// Return a promise

@@ -154,3 +154,3 @@ return new Promise(function (resolve, reject) {

// Save the attachments
_this._attachmentField.save(itemId).then(function () {
_this._attachmentField.save().then(function () {
// Resolve the promise

@@ -312,3 +312,3 @@ resolve();

// Save the attachments
_this.saveAttachments(formInfo.item.Id).then(function () {
_this.saveAttachments().then(function () {
// Refresh the item

@@ -315,0 +315,0 @@ gd_sprest_1.Helper.ListForm.refreshItem(formInfo).then(function (formInfo) {

@@ -47,4 +47,6 @@ /// <reference types="react" />

errorMessage?: string;
/** The file attachments. */
/** The file attachments */
files: Array<IAttachmentFile>;
/** The list information */
listInfo: Types.Helper.ListForm.IListFormProps;
/** Loading Flag */

@@ -51,0 +53,0 @@ loadingFl?: boolean;

@@ -25,5 +25,4 @@ /// <reference types="react" />

* Method to save the attachments to the item
* @param itemId - The item id.
*/
save: (itemId: number) => PromiseLike<any>;
save: () => PromiseLike<any>;
/**

@@ -64,3 +63,2 @@ * Method to show the file dialog

* Method to save the attachments
* @param itemId - The item id.
*/

@@ -67,0 +65,0 @@ private saveAttachments;

@@ -38,5 +38,4 @@ "use strict";

* Method to save the attachments to the item
* @param itemId - The item id.
*/
_this.save = function (itemId) {
_this.save = function () {
// Return a promise

@@ -47,5 +46,5 @@ return new Promise(function (resolve, reject) {

// Save the attachments
_this.saveAttachments(itemId).then(function () {
_this.saveAttachments().then(function (attachments) {
// Resolve the promise
resolve();
resolve(attachments);
});

@@ -144,25 +143,24 @@ });

return new Promise(function (resolve, reject) {
// Get the web
var web = new gd_sprest_1.Web(_this.props.webUrl);
// Parse the files
var files = _this.state.files || [];
for (var i = 0; i < files.length; i++) {
var file = files[i];
// See if we are deleting the file
if (file.deleteFl) {
// Get the file
web.getFileByServerRelativeUrl(file.url)
.delete()
.execute(true);
}
var files = [];
// Parse the files to delete
for (var i = 0; i < _this.state.files.length; i++) {
var file = _this.state.files[i];
// add the file
files.push({
FileName: file.name,
ServerRelativeUrl: file.url
});
}
// Wait for the requests to complete
web.done(function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// Resolve the proimse
resolve(args);
});
// Ensure files exist
if (files.length > 0) {
// Remove the attachments
gd_sprest_1.Helper.ListForm.removeAttachments(_this.state.listInfo, files).then(function () {
// Resolve the promise
resolve();
});
}
else {
// Resolve the promise
resolve();
}
});

@@ -176,24 +174,11 @@ };

return new Promise(function (resolve, reject) {
// Ensure the list and item id exists
if (_this.props.listName && _this.props.itemId && _this.props.itemId > 0) {
// Get the web
(new gd_sprest_1.Web(_this.props.webUrl))
.Lists(_this.props.listName)
.Items(_this.props.itemId)
.AttachmentFiles()
.execute(function (attachments) {
// Update the state
_this.setState({
files: _this.toArray(attachments)
});
// Resolve the promise
resolve();
// Load the attachments
gd_sprest_1.Helper.ListForm.loadAttachments(_this.state.listInfo).then(function (attachments) {
// Update the state
_this.setState({
files: _this.toArray(attachments)
});
}
else {
// Set the state
_this.setState({ files: [] });
// Resolve the promise
resolve();
}
});
});

@@ -292,36 +277,35 @@ };

* Method to save the attachments
* @param itemId - The item id.
*/
_this.saveAttachments = function (itemId) {
_this.saveAttachments = function () {
// Return a promise
return new Promise(function (resolve, reject) {
// Get the list item
var item = (new gd_sprest_1.Web(_this.props.webUrl))
.Lists(_this.props.listName)
.Items(itemId);
// Parse the files
var files = _this.state.files || [];
for (var i = 0; i < files.length; i++) {
var file = files[i];
// See if we are deleting the file
var files = [];
// Parse the files to delete
for (var i = 0; i < _this.state.files.length; i++) {
var file = _this.state.files[i];
// See if we are deleting this file
if (file.deleteFl) {
continue;
}
// See if the binary data exists
// See if data exists
if (file.data) {
// Get the item attachments
item.AttachmentFiles()
.add(file.name, file.data)
.execute(true);
// add the file
files.push({
data: file.data,
name: file.name
});
}
}
// Wait for the requests to complete
item.done(function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// Ensure files exist
if (files.length > 0) {
// Save the attachments
gd_sprest_1.Helper.ListForm.saveAttachments(_this.state.listInfo, files).then(function (attachments) {
// Resolve the promise
resolve(attachments);
});
}
else {
// Resolve the promise
resolve(args);
});
resolve([]);
}
});

@@ -361,2 +345,7 @@ };

files: props.files && typeof (props.files) !== "function" ? _this.toArray(props.files) : null,
listInfo: {
itemId: _this.props.itemId,
listName: _this.props.listName,
webUrl: _this.props.webUrl
},
loadingFl: false

@@ -363,0 +352,0 @@ };

{
"name": "gd-sprest-react",
"version": "2.6.7",
"version": "2.6.8",
"description": "SharePoint react components.",

@@ -41,3 +41,3 @@ "main": "build/index.js",

"css-loader": "^0.28.9",
"gd-sprest": "^3.0.4",
"gd-sprest": "^3.0.8",
"node-sass": "^4.7.2",

@@ -44,0 +44,0 @@ "office-ui-fabric-react": "^5.40.2",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc