├── .eslintrc.js ├── .github ├── no-response.yml └── workflows │ └── github-twittction.yml ├── .gitignore ├── .npmignore ├── LICENSE.md ├── README.md ├── babel.config.js ├── browser └── sharepointplus.js ├── changelog.md ├── dist ├── files │ ├── checkin.js │ ├── createFile.js │ └── createFolder.js ├── index.js ├── init.js ├── lists │ ├── _buildBodyForSOAP.js │ ├── add.js │ ├── addAttachment.js │ ├── cleanResult.js │ ├── get.js │ ├── getAttachment.js │ ├── getContentTypeInfo.js │ ├── getContentTypes.js │ ├── getVersions.js │ ├── getWorkflowID.js │ ├── hasPermission.js │ ├── history.js │ ├── info.js │ ├── list.js │ ├── lists.js │ ├── moderate.js │ ├── myElem.js │ ├── parse.js │ ├── parseRecurrence.js │ ├── remove.js │ ├── removeAttachment.js │ ├── restoreVersion.js │ ├── setReadOnly.js │ ├── startWorkflow.js │ ├── startWorkflow2013.js │ ├── stopWorkflow.js │ ├── update.js │ ├── view.js │ └── views.js ├── main.js ├── modals │ ├── closeModalDialog.js │ ├── getModalDialog.js │ ├── notify.js │ ├── removeNotify.js │ ├── resizeModalDialog.js │ ├── showModalDialog.js │ └── waitModalDialog.js ├── people │ ├── addressbook.js │ ├── distributionLists.js │ ├── getManager.js │ ├── getUserInfo.js │ ├── groupMembers.js │ ├── isMember.js │ ├── people.js │ ├── usergroups.js │ └── whoami.js └── utils │ ├── _cleanString.js │ ├── _nanoajax.js │ ├── ajax.js │ ├── arrayBufferToBase64.js │ ├── arrayChunk.js │ ├── cloneObject.js │ ├── getLookup.js │ ├── getPageSize.js │ ├── getPeopleLookup.js │ ├── getRequestDigest.js │ ├── getServerTime.js │ ├── getTimeZoneInfo.js │ ├── getURL.js │ ├── hasREST.js │ ├── isSPO.js │ ├── newGuid.js │ ├── regionalDateFormat.js │ ├── regionalSettings.js │ ├── toDate.js │ ├── toPeopleString.js │ ├── toSPDate.js │ ├── toXSLString.js │ ├── webService.js │ └── workflowStatusToText.js ├── docs ├── core.html ├── css │ ├── bootstrap-responsive.min.css │ ├── bootstrap.min.css │ ├── default.css │ ├── prettify.css │ └── sunburst.css ├── files.html ├── img │ ├── console_example.png │ ├── favicon.ico │ ├── favicon128x128.png │ ├── favicon16x16.png │ ├── sharepointplus.png │ ├── sharepointplus.svg │ └── sibbell.png ├── index.html ├── js │ ├── bootstrap-collapse.js │ ├── bootstrap-dropdown.js │ ├── bootstrap-scrollspy.js │ └── prettify.js ├── lists.html ├── modals.html ├── node.html ├── people.html └── utils.html ├── es5 ├── files │ ├── checkin.js │ ├── createFile.js │ └── createFolder.js ├── index.js ├── init.js ├── lists │ ├── _buildBodyForSOAP.js │ ├── add.js │ ├── addAttachment.js │ ├── cleanResult.js │ ├── get.js │ ├── getAttachment.js │ ├── getContentTypeInfo.js │ ├── getContentTypes.js │ ├── getVersions.js │ ├── getWorkflowID.js │ ├── hasPermission.js │ ├── history.js │ ├── info.js │ ├── list.js │ ├── lists.js │ ├── moderate.js │ ├── myElem.js │ ├── parse.js │ ├── parseRecurrence.js │ ├── remove.js │ ├── removeAttachment.js │ ├── restoreVersion.js │ ├── setReadOnly.js │ ├── startWorkflow.js │ ├── startWorkflow2013.js │ ├── stopWorkflow.js │ ├── update.js │ ├── view.js │ └── views.js ├── main.js ├── modals │ ├── closeModalDialog.js │ ├── getModalDialog.js │ ├── notify.js │ ├── removeNotify.js │ ├── resizeModalDialog.js │ ├── showModalDialog.js │ └── waitModalDialog.js ├── people │ ├── addressbook.js │ ├── distributionLists.js │ ├── getManager.js │ ├── getUserInfo.js │ ├── groupMembers.js │ ├── isMember.js │ ├── people.js │ ├── usergroups.js │ └── whoami.js └── utils │ ├── _cleanString.js │ ├── _nanoajax.js │ ├── ajax.js │ ├── arrayBufferToBase64.js │ ├── arrayChunk.js │ ├── cloneObject.js │ ├── getLookup.js │ ├── getPageSize.js │ ├── getPeopleLookup.js │ ├── getRequestDigest.js │ ├── getServerTime.js │ ├── getTimeZoneInfo.js │ ├── getURL.js │ ├── hasREST.js │ ├── isSPO.js │ ├── newGuid.js │ ├── regionalDateFormat.js │ ├── regionalSettings.js │ ├── toDate.js │ ├── toPeopleString.js │ ├── toSPDate.js │ ├── toXSLString.js │ ├── webService.js │ └── workflowStatusToText.js ├── jsdoc_template ├── publish.js ├── static │ ├── css │ │ ├── bootstrap-responsive.min.css │ │ ├── bootstrap.min.css │ │ ├── default.css │ │ ├── prettify.css │ │ └── sunburst.css │ ├── img │ │ ├── console_example.png │ │ ├── favicon.ico │ │ ├── favicon128x128.png │ │ ├── favicon16x16.png │ │ ├── sharepointplus.png │ │ ├── sharepointplus.svg │ │ └── sibbell.png │ └── js │ │ ├── bootstrap-collapse.js │ │ ├── bootstrap-dropdown.js │ │ ├── bootstrap-scrollspy.js │ │ └── prettify.js └── tmpl │ ├── container.tmpl │ ├── layout.tmpl │ └── mainpage.tmpl ├── package.json ├── src ├── files │ ├── checkin.js │ ├── createFile.js │ └── createFolder.js ├── index.js ├── init.js ├── lists │ ├── _buildBodyForSOAP.js │ ├── add.js │ ├── addAttachment.js │ ├── cleanResult.js │ ├── get.js │ ├── getAttachment.js │ ├── getContentTypeInfo.js │ ├── getContentTypes.js │ ├── getVersions.js │ ├── getWorkflowID.js │ ├── hasPermission.js │ ├── history.js │ ├── info.js │ ├── list.js │ ├── lists.js │ ├── moderate.js │ ├── myElem.js │ ├── parse.js │ ├── parseRecurrence.js │ ├── remove.js │ ├── removeAttachment.js │ ├── restoreVersion.js │ ├── setReadOnly.js │ ├── startWorkflow.js │ ├── startWorkflow2013.js │ ├── stopWorkflow.js │ ├── update.js │ ├── view.js │ └── views.js ├── main.js ├── modals │ ├── closeModalDialog.js │ ├── getModalDialog.js │ ├── notify.js │ ├── removeNotify.js │ ├── resizeModalDialog.js │ ├── showModalDialog.js │ └── waitModalDialog.js ├── people │ ├── addressbook.js │ ├── distributionLists.js │ ├── getManager.js │ ├── getUserInfo.js │ ├── groupMembers.js │ ├── isMember.js │ ├── people.js │ ├── usergroups.js │ └── whoami.js └── utils │ ├── _cleanString.js │ ├── _nanoajax.js │ ├── ajax.js │ ├── arrayBufferToBase64.js │ ├── arrayChunk.js │ ├── cloneObject.js │ ├── getLookup.js │ ├── getPageSize.js │ ├── getPeopleLookup.js │ ├── getRequestDigest.js │ ├── getServerTime.js │ ├── getTimeZoneInfo.js │ ├── getURL.js │ ├── hasREST.js │ ├── isSPO.js │ ├── newGuid.js │ ├── regionalDateFormat.js │ ├── regionalSettings.js │ ├── toDate.js │ ├── toPeopleString.js │ ├── toSPDate.js │ ├── toXSLString.js │ ├── webService.js │ └── workflowStatusToText.js ├── tests ├── index.js └── tests.js └── webpack.config.js /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root:true, 3 | parser: "babel-eslint", 4 | env: { 5 | node: true, 6 | browser: true, 7 | es6: true 8 | }, 9 | extends: "eslint:recommended", 10 | rules: { 11 | 'no-console': process.env.NODE_ENV === 'production' ? ['error', { "allow": ["warn", "error"] }] : 'off', 12 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 13 | 'require-atomic-updates': 'off', 14 | 'no-extra-semi': 'off', 15 | 'no-useless-escape': 'off' 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /.github/no-response.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-no-response - https://github.com/probot/no-response 2 | 3 | # Number of days of inactivity before an Issue is closed for lack of response 4 | daysUntilClose: 5 5 | # Label requiring a response 6 | responseRequiredLabel: waiting-for-requestor 7 | # Comment to post when closing an Issue for lack of response. Set to `false` to disable 8 | closeComment: > 9 | This issue has been automatically closed because the requestor didn't provide any additional comment. 10 | -------------------------------------------------------------------------------- /.github/workflows/github-twittction.yml: -------------------------------------------------------------------------------- 1 | name: 'Release to Twitter Workflow' 2 | # Trigger on release 3 | on: 4 | release: 5 | types: 6 | - published 7 | jobs: 8 | test: 9 | name: posting_on_twitter 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: GitHub Twittction 13 | uses: m1ner79/Github-Twittction@v1.0.1 14 | with: 15 | twitter_status: "[New Release] SharepointPlus ${{github.event.release.tag_name}} – review the changelog at ${{github.event.release.html_url}}" 16 | twitter_consumer_key: ${{ secrets.TWITTER_API_KEY }} 17 | twitter_consumer_secret: ${{ secrets.TWITTER_API_SECRET_KEY }} 18 | twitter_access_token_key: ${{ secrets.TWITTER_ACCESS_TOKEN }} 19 | twitter_access_token_secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | package-lock.json 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | generate_docs.bat 2 | inch.json 3 | node_modules 4 | package-lock.json 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SharepointPlus 2 | 3 | [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/aymkdn/sharepointplus.svg)](http://isitmaintained.com/project/aymkdn/sharepointplus "Average time to resolve an issue") 4 | [![Percentage of issues still open](http://isitmaintained.com/badge/open/aymkdn/sharepointplus.svg)](http://isitmaintained.com/project/aymkdn/sharepointplus "Percentage of issues still open") 5 | [![](https://data.jsdelivr.com/v1/package/npm/sharepointplus/badge)](https://www.jsdelivr.com/package/npm/sharepointplus) 6 | 7 | SharepointPlus ($SP) is a JavaScript library which offers some extended features for SharePoint entirely on client side (requires no server install). $SP will simplify your interactions with Sharepoint. 8 | 9 | ## Documentation 10 | 11 | Browse the [online documentation here](https://aymkdn.github.io/SharepointPlus/). 12 | 13 | ## Quick Start 14 | 15 | ### Node Environment 16 | 17 | ```sh 18 | npm install sharepointplus 19 | ``` 20 | 21 | Then: 22 | ```javascript 23 | import $SP from 'sharepointplus' 24 | ``` 25 | 26 | Please, make sure to read [the documentation](https://aymkdn.github.io/SharepointPlus/) to optimize your bundle size. 27 | 28 | ### Browser Only 29 | 30 | To directly use it in a browser: 31 | ```html 32 | 33 | ``` 34 | 35 | ## Usage / Examples 36 | 37 | Update all items with an "Amount" value bigger than 1000: 38 | 39 | ```javascript 40 | $SP().list('My List Name').update({ 41 | Title:"Too expensive" 42 | }, { 43 | where:"Amount > 1000" 44 | }) 45 | .then(function(res) { 46 | alert(res.passed.length+" items successfully updated!"); 47 | }); 48 | ``` 49 | 50 | Get all items with "Requestor" as the current user and with "Default Color" is "pink": 51 | 52 | ```javascript 53 | $SP().list('ListName').get({ 54 | fields:"Title,Size", 55 | where:"Requestor = '[Me]' AND Default_x0020_Color = 'pink'", 56 | orderby:"Size DESC", 57 | json:true 58 | }) 59 | .then(function(data) { 60 | data.forEach(function(d) { 61 | console.log("Model = "+d.Title+" (size: "+d.size+")"; 62 | }) 63 | }); 64 | ``` 65 | 66 | ## More information 67 | 68 | Please visit the [online documentation](https://aymkdn.github.io/SharepointPlus/) to know more. 69 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "es": { 4 | "presets": [ 5 | [ 6 | "@babel/preset-env", 7 | { 8 | "modules":false 9 | } 10 | ] 11 | ], 12 | "plugins": [ 13 | [ "@babel/plugin-transform-runtime", { 14 | corejs:3, 15 | useESModules:true 16 | } ] 17 | ] 18 | }, 19 | "dist": { 20 | "presets": [ 21 | [ 22 | "@babel/preset-env" 23 | ] 24 | ], 25 | "plugins": [ 26 | [ "@babel/plugin-transform-runtime", { 27 | corejs:3, 28 | useESModules:false 29 | } ], 30 | "add-module-exports" 31 | ] 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /dist/init.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); 4 | 5 | var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); 6 | 7 | _Object$defineProperty(exports, "__esModule", { 8 | value: true 9 | }); 10 | 11 | exports.default = spInit; 12 | 13 | var _main = _interopRequireDefault(require("./main.js")); 14 | 15 | function spInit(params) { 16 | return function () { 17 | var sp = new _main.default(); 18 | sp.init(params); 19 | return sp; 20 | }; 21 | } 22 | 23 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/lists/_buildBodyForSOAP.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); 4 | 5 | _Object$defineProperty(exports, "__esModule", { 6 | value: true 7 | }); 8 | 9 | exports.default = _buildBodyForSOAP; 10 | 11 | /** 12 | @ignore 13 | @function 14 | @param {String} methodName 15 | @param {String} bodyContent 16 | @param {String} [xmlns="http://schemas.microsoft.com/sharepoint/soap/"] 17 | @description (internal use only) Permits to create the body for a SOAP request 18 | */ 19 | function _buildBodyForSOAP(methodName, bodyContent, xmlns) { 20 | xmlns = xmlns || "http://schemas.microsoft.com/sharepoint/soap/"; 21 | return '<' + methodName + ' xmlns="' + xmlns.replace(/webpartpages\/$/, 'webpartpages') + '">' + bodyContent + ''; 22 | } 23 | 24 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/lists/cleanResult.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); 4 | 5 | _Object$defineProperty(exports, "__esModule", { 6 | value: true 7 | }); 8 | 9 | exports.default = cleanResult; 10 | 11 | /** 12 | @name $SP().cleanResult 13 | @function 14 | @category lists 15 | @description clean a string returned by a GET (remove ";#" and "string;#" and null becomes "") 16 | 17 | @param {String} str The string to clean 18 | @param {String} [separator=";"] When it's a list we may want to have a different output (see examples) 19 | @return {String} the cleaned string 20 | 21 | @example 22 | $SP().cleanResult("15;#Paul"); // -> "Paul" 23 | $SP().cleanResult("string;#Paul"); // -> "Paul" 24 | $SP().cleanResult("string;#"); // -> "" 25 | $SP().cleanResult(";#Paul;#Jacques;#Aymeric;#"); // -> "Paul;Jacques;Aymeric" 26 | $SP().cleanResult(";#Paul;#Jacques;#Aymeric;#", ", "); // -> "Paul, Jacques, Aymeric" 27 | $SP().cleanResult("2022-01-19 00:00:00"); // -> "2022-01-19" 28 | */ 29 | function cleanResult(str, separator) { 30 | if (str === null || typeof str === "undefined") return ""; 31 | separator = separator || ";"; 32 | return typeof str === "string" ? str.replace(/^(string;|float;|datetime;)#?/, "").replace(/^(\d{4}-\d{2}-\d{2}) 00:00:00$/, "$1").replace(/;#-?[0-9]+;#/g, separator).replace(/^-?[0-9]+;#/, "").replace(/^;#|;#$/g, "").replace(/;#/g, separator) : str; 33 | } 34 | 35 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/lists/getAttachment.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); 4 | 5 | var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); 6 | 7 | _Object$defineProperty(exports, "__esModule", { 8 | value: true 9 | }); 10 | 11 | exports.default = getAttachment; 12 | 13 | var _ajax = _interopRequireDefault(require("../utils/ajax.js")); 14 | 15 | var _buildBodyForSOAP2 = _interopRequireDefault(require("./_buildBodyForSOAP.js")); 16 | 17 | /** 18 | @name $SP().list.getAttachment 19 | @function 20 | @description Get the attachment(s) for an item 21 | 22 | @param {String|Number} itemID The item ID 23 | @return {Promise} resolve([results]) 24 | 25 | @example 26 | $SP().list("My List","http://my.site.com/mydir/").getAttachment(1).then(function(attachments) { 27 | for (var i=0; i<attachments.length; i++) console.log(attachments[i]); -> "https://my.site.com/site/Lists/Something/Attachments/46/helloworld.txt" 28 | }); 29 | 30 | // you can also use $SP().list().get() using the "Attachments" field 31 | */ 32 | function getAttachment(itemID) { 33 | if (!this.listID) throw "[SharepointPlus 'getAttachment']: the list ID/Name is required"; 34 | if (!this.url) throw "[SharepointPlus 'getAttachment']: not able to find the URL!"; // we cannot determine the url 35 | // do the request 36 | 37 | return _ajax.default.call(this, { 38 | url: this.url + "/_vti_bin/lists.asmx", 39 | body: (0, _buildBodyForSOAP2.default)("GetAttachmentCollection", "" + this.listID + "" + itemID + ""), 40 | headers: { 41 | 'SOAPAction': 'http://schemas.microsoft.com/sharepoint/soap/GetAttachmentCollection' 42 | } 43 | }).then(function (data) { 44 | var aReturn = [], 45 | i = 0, 46 | a = data.getElementsByTagName('Attachment'); 47 | 48 | for (; i < a.length; i++) { 49 | aReturn.push(a[i].firstChild.nodeValue); 50 | } 51 | 52 | return aReturn; 53 | }); 54 | } 55 | 56 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/lists/getContentTypes.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); 4 | 5 | var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); 6 | 7 | _Object$defineProperty(exports, "__esModule", { 8 | value: true 9 | }); 10 | 11 | exports.default = getContentTypes; 12 | 13 | var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise")); 14 | 15 | var _ajax = _interopRequireDefault(require("../utils/ajax.js")); 16 | 17 | var _buildBodyForSOAP2 = _interopRequireDefault(require("./_buildBodyForSOAP.js")); 18 | 19 | /** 20 | @name $SP().list.getContentTypes 21 | @function 22 | @description Get the Content Types for the list (returns Name, ID and Description) 23 | 24 | @param {Object} [options] 25 | @param {Boolean} [options.cache=true] Do we want to use the cache on recall for this function? 26 | @return {Promise} resolve(contentTypes), reject(error) 27 | 28 | @example 29 | $SP().list("List Name").getContentTypes().then(function(contentTypes) { 30 | for (var i=0; i<contentTypes.length; i++) console.log(contentTypes[i].Name, contentTypes[i].ID, contentTypes[i].Description); 31 | }); 32 | */ 33 | function getContentTypes(options) { 34 | var _this = this; 35 | 36 | if (!this.listID) throw "[SharepointPlus 'getContentTypes'] the list ID/name is required."; // default values 37 | 38 | if (!this.url) throw "[SharepointPlus 'getContentTypes'] not able to find the URL!"; // we cannot determine the url 39 | // check the Cache 40 | 41 | options = options || { 42 | cache: true 43 | }; 44 | 45 | if (options.cache) { 46 | for (var i = 0; i < global._SP_CACHE_CONTENTTYPES.length; i++) { 47 | if (global._SP_CACHE_CONTENTTYPES[i].list === this.listID && global._SP_CACHE_CONTENTTYPES[i].url === this.url) { 48 | return _promise.default.resolve(global._SP_CACHE_CONTENTTYPES[i].contentTypes); 49 | } 50 | } 51 | } // do the request 52 | 53 | 54 | return _ajax.default.call(this, { 55 | url: this.url + "/_vti_bin/lists.asmx", 56 | body: (0, _buildBodyForSOAP2.default)("GetListContentTypes", '' + this.listID + ''), 57 | headers: { 58 | 'SOAPAction': 'http://schemas.microsoft.com/sharepoint/soap/GetListContentTypes' 59 | } 60 | }).then(function (data) { 61 | var arr = data.getElementsByTagName('ContentType'), 62 | ID, 63 | i = 0, 64 | aReturn = []; 65 | 66 | for (; i < arr.length; i++) { 67 | ID = arr[i].getAttribute("ID"); 68 | 69 | if (ID) { 70 | aReturn.push({ 71 | "ID": ID, 72 | "Name": arr[i].getAttribute("Name"), 73 | "Description": arr[i].getAttribute("Description") 74 | }); 75 | } 76 | } // we cache the result 77 | 78 | 79 | global._SP_CACHE_CONTENTTYPES.push({ 80 | "list": _this.listID, 81 | "url": _this.url, 82 | "contentTypes": aReturn 83 | }); 84 | 85 | return aReturn; 86 | }); 87 | } 88 | 89 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/lists/getVersions.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); 4 | 5 | var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); 6 | 7 | _Object$defineProperty(exports, "__esModule", { 8 | value: true 9 | }); 10 | 11 | exports.default = getVersions; 12 | 13 | var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator")); 14 | 15 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator")); 16 | 17 | var _ajax = _interopRequireDefault(require("../utils/ajax.js")); 18 | 19 | /** 20 | @name $SP().list.getVersions 21 | @function 22 | @description When versionning is activated on a list, you can use this function to get the different versions of a list item 23 | 24 | @param {Number} ID The item ID 25 | @return {Promise} resolve(arrayOfVersions) 26 | 27 | @example 28 | $SP().list("My List").getVersions(1234).then(function(versions) { 29 | versions.forEach(function(version) { 30 | console.log(version); 31 | }) 32 | }); 33 | */ 34 | function getVersions(_x) { 35 | return _getVersions.apply(this, arguments); 36 | } 37 | 38 | function _getVersions() { 39 | _getVersions = (0, _asyncToGenerator2.default)( 40 | /*#__PURE__*/ 41 | _regenerator.default.mark(function _callee(itemID) { 42 | return _regenerator.default.wrap(function _callee$(_context) { 43 | while (1) { 44 | switch (_context.prev = _context.next) { 45 | case 0: 46 | if (this.listID) { 47 | _context.next = 2; 48 | break; 49 | } 50 | 51 | throw "[SharepointPlus 'getVersions'] the list ID/Name is required."; 52 | 53 | case 2: 54 | if (this.url) { 55 | _context.next = 4; 56 | break; 57 | } 58 | 59 | throw "[SharepointPlus 'getVersions'] not able to find the URL!"; 60 | 61 | case 4: 62 | if (itemID) { 63 | _context.next = 6; 64 | break; 65 | } 66 | 67 | throw "[SharepointPlus 'getVersions'] the item ID is required."; 68 | 69 | case 6: 70 | return _context.abrupt("return", _ajax.default.call(this, { 71 | url: this.url + "/_api/lists/getbytitle('" + this.listID + "')/Items(" + itemID + ")/Versions" 72 | }).then(function (res) { 73 | return (res.d ? res.d.results : res.value) || []; 74 | })); 75 | 76 | case 7: 77 | case "end": 78 | return _context.stop(); 79 | } 80 | } 81 | }, _callee, this); 82 | })); 83 | return _getVersions.apply(this, arguments); 84 | } 85 | 86 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/lists/history.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); 4 | 5 | var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); 6 | 7 | _Object$defineProperty(exports, "__esModule", { 8 | value: true 9 | }); 10 | 11 | exports.default = history; 12 | 13 | var _ajax = _interopRequireDefault(require("../utils/ajax.js")); 14 | 15 | var _buildBodyForSOAP2 = _interopRequireDefault(require("./_buildBodyForSOAP.js")); 16 | 17 | /** 18 | @name $SP().list.history 19 | @function 20 | @description When versioning is an active option for your list, then you can use this function to find the previous values for a field 21 | 22 | @param {Object} params See below 23 | @param {String|Number} params.ID The item ID 24 | @param {String} params.Name The field name 25 | @return {Promise} resolve(data), reject(error) 26 | 27 | @example 28 | $SP().list("My List").history({ID:1981, Name:"Critical_x0020_Comments"}).then(function(data) { 29 | for (var i=0,len=data.length; i<len; i++) { 30 | console.log("Date: "+data[i].getAttribute("Modified")); // you can use $SP().toDate() to convert it to a JavaScript Date object 31 | console.log("Editor: "+data[i].getAttribute("Editor")); // it's the long format type, so the result looks like that "328;#Doe,, John,#DOMAIN\john_doe,#John_Doe@example.com,#,#Doe,, John" 32 | console.log("Content: "+data[i].getAttribute("Critical_x0020_Comments")); // use the field name here 33 | } 34 | }); 35 | */ 36 | function history(params) { 37 | if (!this.listID) throw "[SharepointPlus 'history'] the list ID/Name is required."; 38 | params = params || {}; 39 | if (!params.ID || !params.Name) throw "[SharepointPlus 'history'] you must provide the item ID and field Name."; // send the request 40 | 41 | return _ajax.default.call(this, { 42 | url: this.url + "/_vti_bin/lists.asmx", 43 | body: (0, _buildBodyForSOAP2.default)("GetVersionCollection", "" + this.listID + "" + params.ID + "" + params.Name + ""), 44 | headers: { 45 | 'SOAPAction': 'http://schemas.microsoft.com/sharepoint/soap/GetVersionCollection' 46 | } 47 | }).then(function (data) { 48 | return data.getElementsByTagName('Version'); 49 | }); 50 | } 51 | 52 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/lists/list.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); 4 | 5 | var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); 6 | 7 | _Object$defineProperty(exports, "__esModule", { 8 | value: true 9 | }); 10 | 11 | exports.default = list; 12 | 13 | var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator")); 14 | 15 | var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise")); 16 | 17 | var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice")); 18 | 19 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator")); 20 | 21 | var _getURL = _interopRequireDefault(require("../utils/getURL.js")); 22 | 23 | /** 24 | @name $SP().list 25 | @namespace 26 | @description Permits to define the list ID/name 27 | 28 | @param {String} listID Ths list ID or the list name 29 | @param {String} [url] If the list name is provided, then you need to make sure URL is provided too (then no need to define the URL again for the chained functions like 'get' or 'update') 30 | @return {Object} the current SharepointPlus object 31 | 32 | @example 33 | $SP().list("My List"); 34 | $SP().list("My List","http://my.sharpoi.nt/other.directory/"); 35 | */ 36 | function list(_x, _x2) { 37 | return _list.apply(this, arguments); 38 | } 39 | 40 | function _list() { 41 | _list = (0, _asyncToGenerator2.default)( 42 | /*#__PURE__*/ 43 | _regenerator.default.mark(function _callee(list, url) { 44 | return _regenerator.default.wrap(function _callee$(_context) { 45 | while (1) { 46 | switch (_context.prev = _context.next) { 47 | case 0: 48 | this.listID = list.replace(/&/g, "&"); 49 | 50 | if (!url) { 51 | _context.next = 5; 52 | break; 53 | } 54 | 55 | // make sure we don't have a '/' at the end 56 | this.url = (0, _slice.default)(url).call(url, -1) === '/' ? (0, _slice.default)(url).call(url, 0, -1) : url; 57 | _context.next = 8; 58 | break; 59 | 60 | case 5: 61 | _context.next = 7; 62 | return _getURL.default.call(this); 63 | 64 | case 7: 65 | this.url = _context.sent; 66 | 67 | case 8: 68 | return _context.abrupt("return", _promise.default.resolve()); 69 | 70 | case 9: 71 | case "end": 72 | return _context.stop(); 73 | } 74 | } 75 | }, _callee, this); 76 | })); 77 | return _list.apply(this, arguments); 78 | } 79 | 80 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/lists/myElem.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); 4 | 5 | var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); 6 | 7 | _Object$defineProperty(exports, "__esModule", { 8 | value: true 9 | }); 10 | 11 | exports.default = void 0; 12 | 13 | var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck")); 14 | 15 | var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass")); 16 | 17 | /** 18 | * @ignore 19 | * @description we need to extend an element for some cases with $SP().get 20 | **/ 21 | var _default = 22 | /*#__PURE__*/ 23 | function () { 24 | function _default(elem) { 25 | (0, _classCallCheck2.default)(this, _default); 26 | this.mynode = elem; 27 | this.singleList = true; 28 | } 29 | 30 | (0, _createClass2.default)(_default, [{ 31 | key: "getAttribute", 32 | value: function getAttribute(id) { 33 | return this.mynode.getAttribute("ows_" + id.replace(/ /g, "")); 34 | } 35 | }, { 36 | key: "getAttributes", 37 | value: function getAttributes() { 38 | return this.mynode.attributes; 39 | } 40 | }]); 41 | return _default; 42 | }(); 43 | 44 | exports.default = _default; 45 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/modals/closeModalDialog.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); 4 | 5 | var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); 6 | 7 | _Object$defineProperty(exports, "__esModule", { 8 | value: true 9 | }); 10 | 11 | exports.default = closeModalDialog; 12 | 13 | var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof")); 14 | 15 | /** 16 | @name $SP().closeModalDialog 17 | @function 18 | @category modals 19 | @description Close the last modal dialog 20 | 21 | @param {Object} [dialogResult] One of the enumeration values specifying the result of the modal dialog (SP.UI.DialogResult|), or the modal object returned by $SP().getModalDialog() 22 | @param {Object} [returnValue] The return value of the modal dialog 23 | 24 | @example 25 | // if the user use the cross to close the modal, then `dialogResult` equals to 0 in the callback 26 | // but you can trigger the close of the modal and pass anything you want 27 | $SP().showModalDialog({ 28 | id:"demo", 29 | title:"Hello World", 30 | html:'<p>This is an example. Click one of the buttons.</p><p class="ms-alignCenter"><button onclick="$SP().closeModalDialog(\'Continue has been clicked\')">Continue</button></p>', 31 | callback:function(res) { 32 | alert(res) 33 | } 34 | }) 35 | 36 | // or 37 | var modal = $SP().getModalDialog('demo'); 38 | if (modal) $SP().closeModalDialog(modal); 39 | */ 40 | function closeModalDialog(dialogResult, returnValue) { 41 | var fct = function fct() { 42 | var md; 43 | 44 | if ((0, _typeof2.default)(dialogResult) === "object" && dialogResult.type === "modalDialog") { 45 | md = { 46 | id: dialogResult.id, 47 | dialogResult: returnValue, 48 | returnValue: undefined, 49 | type: "closeModalDialog" 50 | }; 51 | dialogResult.modal.close(md); // if it's a wait screen, then we need to remove the