Skip to content

Commit

Permalink
v6.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aymkdn committed Apr 10, 2020
1 parent e0bf990 commit f468f36
Show file tree
Hide file tree
Showing 108 changed files with 12,877 additions and 462 deletions.
14 changes: 14 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ module.exports = {
useESModules:true
} ]
]
},
"dist": {
"presets": [
[
"@babel/preset-env"
]
],
"plugins": [
[ "@babel/plugin-transform-runtime", {
corejs:3,
useESModules:false
} ],
"add-module-exports"
]
}
}
}
9 changes: 1 addition & 8 deletions browser/sharepointplus.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

**Change Log v6.1.0 (April 10, 2020)**

- Added support for short date format ("YYYY-MM-DD") for `$SP().toDate()`
- Added `$SP().list().hasPermission()` to check the permissions of the current user with a list/library
- Added support for configuration without transpiling (`const $SP = require('sharepointplus/dist/');`)
- Added option `viewCache` to `$SP().list().get()`
- Changed behavior for `$SP().getRequestDigest()` and lifetime from 24h to 1800secs
- Fixed a bug in `$SP().parse()` when too many embedded brackets
- Fixed a bug in `$SP().ajax()` when the request digest was incorrect

**Change Log v6.0.4 (January 13, 2020)**

- Fixed `$SP().list().get()` when using `json:true`
Expand Down
145 changes: 145 additions & 0 deletions dist/files/checkin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
"use strict";

var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");

var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");

_Object$defineProperty(exports, "__esModule", {
value: true
});

exports["default"] = checkin;

var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));

var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));

var _getURL = _interopRequireDefault(require("../utils/getURL.js"));

var _ajax = _interopRequireDefault(require("../utils/ajax.js"));

var _buildBodyForSOAP2 = _interopRequireDefault(require("../lists/_buildBodyForSOAP.js"));

/**
@name $SP().checkin
@function
@category files
@description Checkin a file
@param {Object} [setup] Options (see below)
@param {String} setup.destination The full path to the file to check in
@param {String} [setup.type='MajorCheckIn'] It can be 'MinorCheckIn' (incremented as a minor version), 'MajorCheckIn' (incremented as a major version), or 'OverwriteCheckIn' (overwrite the file)
@param {String} [setup.comments=""] The comments related to the check in
@param {String} [setup.url='current website'] The website url
@return {Promise} resolve() then checked in is done, reject(error) otherwise
@example
// with Promise
$SP().checkin({
destination:"http://mysite/Shared Documents/myfile.txt",
comments:"Automatic check in with SharepointPlus"
}).then(function() {
alert("Done");
}).catch(function(error) {
alert("Check in failed")
})
*/
function checkin(_x) {
return _checkin.apply(this, arguments);
}

function _checkin() {
_checkin = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(setup) {
var type, data, res;
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
setup = setup || {};

if (setup.destination) {
_context.next = 4;
break;
}

throw "[SharepointPlus 'checkin'] the file destination path is required.";

case 4:
if (this.url && !setup.url) setup.url = this.url;

if (setup.url) {
_context.next = 9;
break;
}

_context.next = 8;
return _getURL["default"].call(this);

case 8:
setup.url = _context.sent;

case 9:
setup.comments = (setup.comments || "").replace(/&/g, "&");
type = 1;
_context.t0 = setup.type;
_context.next = _context.t0 === "MinorCheckIn" ? 14 : _context.t0 === "OverwriteCheckIn" ? 16 : 18;
break;

case 14:
type = 0;
return _context.abrupt("break", 18);

case 16:
type = 2;
return _context.abrupt("break", 18);

case 18:
_context.next = 20;
return _ajax["default"].call(this, {
url: setup.url + "/_vti_bin/Lists.asmx",
body: (0, _buildBodyForSOAP2["default"])("CheckInFile", '<pageUrl>' + setup.destination + '</pageUrl><comment>' + setup.comments + '</comment><CheckinType>' + type + '</CheckinType>'),
headers: {
'SOAPAction': 'http://schemas.microsoft.com/sharepoint/soap/CheckInFile'
}
});

case 20:
data = _context.sent;
res = data.getElementsByTagName('CheckInFileResult');
res = res.length > 0 ? res[0] : null;

if (!(res && res.firstChild.nodeValue != "true")) {
_context.next = 27;
break;
}

return _context.abrupt("return", _promise["default"].reject(res));

case 27:
return _context.abrupt("return", _promise["default"].resolve());

case 28:
_context.next = 33;
break;

case 30:
_context.prev = 30;
_context.t1 = _context["catch"](0);
return _context.abrupt("return", _promise["default"].reject(_context.t1));

case 33:
case "end":
return _context.stop();
}
}
}, _callee, this, [[0, 30]]);
}));
return _checkin.apply(this, arguments);
}

module.exports = exports.default;
Loading

0 comments on commit f468f36

Please sign in to comment.