Function
Static Public Summary | ||
public |
Adds an executeQuery function to the SP ClientContext that calls the executeQueryAsync function and returns a promise. |
|
public |
deleteItem(list: string, id: string): Promise<number> Deletes an item from a list. |
|
public |
fetchViewer(): Promise<Object> Get the currently logged in user. |
|
public |
getAvatarUrlByEmail(email: string): string |
|
public |
Fetches an item by id from list. |
|
public |
Fetches a list. |
|
public |
readFileToString(file: File): string Get the content of a File object. |
|
public |
respToJson(response: Object): Objcet Convert fetch result to json |
|
public |
Save or update an item. |
|
public |
searchPerson(searchText: string, options: Object): Promise<Object[]> Search for persons in SP using clientPeoplePickerSearchUser. |
|
public |
shallowEqual(objA: *, objB: *): boolean |
|
public |
uploadFile(file: File, filename: string): Promise Upload file to project Documents |
|
public |
uploadFiles(files: Object[]): Promise Upload list for files to project Documents |
|
public |
uploadListItemFile(list: string, id: string, file: File): Promise Upload file as attachment to a list item. |
|
public |
uploadListItemFiles(list: string, id: string, files: Object[]): Promise Upload file as attachment to a list item. |
Static Public
public addExecuteQuery() source
import addExecuteQuery from 'ntnu-react/util/sp/addExecuteQuery.js'
Adds an executeQuery function to the SP ClientContext that calls the executeQueryAsync function and returns a promise.
Example:
const ctx = window.SP.ClientContext.get_current();
const item = ctx.get_web().getList(list).getItemById(id);
addExecuteQuery();
ctx.executeQuery()
.then(() => {})
.catch(() => {});
public deleteItem(list: string, id: string): Promise<number> source
import deleteItem from 'ntnu-react/util/sp/deleteItem.js'
Deletes an item from a list.
public fetchViewer(): Promise<Object> source
import fetchViewer from 'ntnu-react/util/sp/fetchViewer.js'
Get the currently logged in user.
public getAvatarUrlByEmail(email: string): string source
import {getAvatarUrlByEmail} from 'ntnu-react/util/sp/index.js'
Params:
Name | Type | Attribute | Description |
string |
public getItem(list: string, id: string, options: Object): Promise<Object> source
import getItem from 'ntnu-react/util/sp/getItem.js'
Fetches an item by id from list.
Example:
getItem('List', '2', {
fields: [ 'Id', 'Title' ],
mapper: function(item) {
return {
id: item.get_id(),
title: item.get_item('Title')
};
}
})
.then((item) => {})
.catch((sender, args) => {});
public getList(list: string, options: Object): Promise<Object[]> source
import getList from 'ntnu-react/util/sp/getList.js'
Fetches a list.
Example:
getList('List', {
fields: [ 'Id', 'Title' ],
mapper: function(item) {
return {
id: item.get_id(),
title: item.get_item('Title')
};
}
})
.then((items) => {})
.catch((sender, args) => {});
public readFileToString(file: File): string source
import readFileToString from 'ntnu-react/util/readFileToString.js'
Get the content of a File object.
Params:
Name | Type | Attribute | Description |
file | File |
public respToJson(response: Object): Objcet source
import respToJson from 'ntnu-react/util/respToJson.js'
Convert fetch result to json
Params:
Name | Type | Attribute | Description |
response | Object | fetch response object |
Return:
Objcet | json data. |
public saveItem(list: string, item: Object, assigner: function(sp_item: Object)): Promise<Object> source
import saveItem from 'ntnu-react/util/sp/saveItem.js'
Save or update an item.
Example:
const obj = { id: 21, title: 'Mr.Beet' };
saveItem('List', obj, (item) => {
item.set_item('Id', obj.id);
item.set_item('Title', obj.title);
});
public searchPerson(searchText: string, options: Object): Promise<Object[]> source
import searchPerson from 'ntnu-react/util/sp/searchPerson.js'
Search for persons in SP using clientPeoplePickerSearchUser.
public shallowEqual(objA: *, objB: *): boolean source
import shallowEqual from 'ntnu-react/util/shallowEqual.js'
Params:
Name | Type | Attribute | Description |
objA | * | ||
objB | * |
public uploadFile(file: File, filename: string): Promise source
import uploadFile from 'ntnu-react/util/sp/uploadFile.js'
Upload file to project Documents
Params:
Name | Type | Attribute | Description |
file | File | File object from upload. |
|
filename | string | Wanted file name. Default file.name. |
public uploadFiles(files: Object[]): Promise source
import uploadFiles from 'ntnu-react/util/sp/uploadFiles.js'
Upload list for files to project Documents
Params:
Name | Type | Attribute | Description |
files | Object[] | {file: string, name: string}[] |
public uploadListItemFile(list: string, id: string, file: File): Promise source
import uploadListItemFile from 'ntnu-react/util/sp/uploadListItemFile.js'
Upload file as attachment to a list item.