jitz-sharepoint-utilities 2.0.14 → 2.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/context/List.ts +5 -8
- package/data/interfaces/IList.ts +2 -2
- package/lib/common/IModels.d.ts +40 -0
- package/lib/common/IModels.js +2 -0
- package/lib/common/IObjects.d.ts +72 -0
- package/lib/common/IObjects.js +30 -0
- package/lib/controls/JitzGrid.d.ts +75 -0
- package/lib/controls/JitzGrid.js +606 -0
- package/lib/controls/JitzImage.d.ts +14 -0
- package/lib/controls/JitzImage.js +37 -0
- package/lib/controls/JitzPeoplePicker.d.ts +49 -0
- package/lib/controls/JitzPeoplePicker.js +311 -0
- package/lib/controls/JitzPersonInfo.d.ts +32 -0
- package/lib/controls/JitzPersonInfo.js +98 -0
- package/lib/controls/JitzPersona.d.ts +23 -0
- package/lib/controls/JitzPersona.js +48 -0
- package/lib/data/context/CommonRepository.d.ts +17 -0
- package/lib/data/context/CommonRepository.js +287 -0
- package/lib/data/context/JitzContext.d.ts +13 -0
- package/lib/data/context/JitzContext.js +80 -0
- package/lib/data/context/JitzSPContext.d.ts +8 -0
- package/lib/data/context/JitzSPContext.js +58 -0
- package/lib/data/context/JitzSPHttpClient.d.ts +14 -0
- package/lib/data/context/JitzSPHttpClient.js +173 -0
- package/lib/data/context/List.d.ts +39 -0
- package/lib/data/context/List.js +492 -0
- package/lib/data/context/Repository.d.ts +22 -0
- package/lib/data/context/Repository.js +486 -0
- package/lib/data/interfaces/ICommonRepository.d.ts +6 -0
- package/lib/data/interfaces/ICommonRepository.js +2 -0
- package/lib/data/interfaces/IJitzContext.d.ts +10 -0
- package/lib/data/interfaces/IJitzContext.js +2 -0
- package/lib/data/interfaces/IJitzSPContext.d.ts +6 -0
- package/lib/data/interfaces/IJitzSPContext.js +2 -0
- package/lib/data/interfaces/IJitzSPHttpClient.d.ts +6 -0
- package/lib/data/interfaces/IJitzSPHttpClient.js +2 -0
- package/lib/data/interfaces/IList.d.ts +26 -0
- package/lib/data/interfaces/IList.js +2 -0
- package/lib/data/interfaces/IModels.d.ts +32 -0
- package/lib/data/interfaces/IModels.js +2 -0
- package/lib/data/interfaces/IRepository.d.ts +17 -0
- package/lib/data/interfaces/IRepository.js +2 -0
- package/lib/jitzHttpClient.d.ts +11 -0
- package/lib/jitzHttpClient.js +37 -0
- package/lib/jitzSPHttpClient.d.ts +30 -0
- package/lib/jitzSPHttpClient.js +193 -0
- package/lib/repositories/CommonRepository.d.ts +17 -0
- package/lib/repositories/CommonRepository.js +287 -0
- package/lib/repositories/ICommonRepository.d.ts +6 -0
- package/lib/repositories/ICommonRepository.js +2 -0
- package/lib/repositories/IRepository.d.ts +13 -0
- package/lib/repositories/IRepository.js +2 -0
- package/lib/repositories/Repository.d.ts +18 -0
- package/lib/repositories/Repository.js +392 -0
- package/lib/services/GraphService.d.ts +10 -0
- package/lib/services/GraphService.js +103 -0
- package/lib/services/UserService.d.ts +15 -0
- package/lib/services/UserService.js +202 -0
- package/lib/services/UtilityService.d.ts +29 -0
- package/lib/services/UtilityService.js +254 -0
- package/package.json +1 -1
@@ -0,0 +1,49 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import IJitzSPContext from "../data/interfaces/IJitzSPContext";
|
3
|
+
import { IJitzPeoplePickerState, SharePointUserPersona } from "../common/IObjects";
|
4
|
+
export interface IJitzPeoplePickerProps {
|
5
|
+
description: string;
|
6
|
+
context: IJitzSPContext;
|
7
|
+
hostSiteUrl?: string;
|
8
|
+
typePicker: string;
|
9
|
+
disabled: boolean;
|
10
|
+
principalTypeUser: boolean;
|
11
|
+
principalTypeSharePointGroup: boolean;
|
12
|
+
principalTypeSecurityGroup: boolean;
|
13
|
+
principalTypeDistributionList: boolean;
|
14
|
+
numberOfItems: number;
|
15
|
+
onChange?: (items: SharePointUserPersona[]) => void;
|
16
|
+
prePopulatedItems: string[];
|
17
|
+
errorMessage?: string;
|
18
|
+
errorCss?: string;
|
19
|
+
multiSelect: boolean;
|
20
|
+
}
|
21
|
+
export declare class JitzPeoplePicker extends React.Component<IJitzPeoplePickerProps, IJitzPeoplePickerState> {
|
22
|
+
private _peopleList;
|
23
|
+
private contextualMenuItems;
|
24
|
+
constructor(props: IJitzPeoplePickerProps);
|
25
|
+
getSelectedItems(): void;
|
26
|
+
componentDidMount(): void;
|
27
|
+
componentDidUpdate(prevProps: IJitzPeoplePickerProps, prevState: IJitzPeoplePickerState, prevContext: any): void;
|
28
|
+
componentWillReceiveProps(nextProps: IJitzPeoplePickerProps): void;
|
29
|
+
render(): React.ReactElement<IJitzPeoplePickerProps>;
|
30
|
+
private _onChange;
|
31
|
+
private prePopulate;
|
32
|
+
private _onFilterChanged;
|
33
|
+
/**
|
34
|
+
* @function
|
35
|
+
* Returns fake people results for the Mock mode
|
36
|
+
*/
|
37
|
+
private searchPeopleFromMock;
|
38
|
+
/**
|
39
|
+
* @function
|
40
|
+
* Returns people results after a REST API call
|
41
|
+
*/
|
42
|
+
private _searchPeople;
|
43
|
+
private _filterPersonasByText;
|
44
|
+
private _removeDuplicates;
|
45
|
+
private _listContainsPersona;
|
46
|
+
private _filterPromise;
|
47
|
+
private _convertResultsToPromise;
|
48
|
+
private _doesTextStartWith;
|
49
|
+
}
|
@@ -0,0 +1,311 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
if (typeof b !== "function" && b !== null)
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
+
extendStatics(d, b);
|
13
|
+
function __() { this.constructor = d; }
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
})();
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
+
exports.JitzPeoplePicker = void 0;
|
19
|
+
var React = require("react");
|
20
|
+
var lodash = require("lodash");
|
21
|
+
var UtilityService_1 = require("../services/UtilityService");
|
22
|
+
var react_1 = require("@fluentui/react");
|
23
|
+
var IObjects_1 = require("../common/IObjects");
|
24
|
+
var suggestionProps = {
|
25
|
+
suggestionsHeaderText: "Suggested People",
|
26
|
+
noResultsFoundText: "No results found",
|
27
|
+
loadingText: "Loading",
|
28
|
+
};
|
29
|
+
var JitzPeoplePicker = /** @class */ (function (_super) {
|
30
|
+
__extends(JitzPeoplePicker, _super);
|
31
|
+
function JitzPeoplePicker(props) {
|
32
|
+
var _this = _super.call(this, props) || this;
|
33
|
+
_this.contextualMenuItems = [
|
34
|
+
{
|
35
|
+
key: "newItem",
|
36
|
+
icon: "circlePlus",
|
37
|
+
name: "New",
|
38
|
+
},
|
39
|
+
{
|
40
|
+
key: "upload",
|
41
|
+
icon: "upload",
|
42
|
+
name: "Upload",
|
43
|
+
},
|
44
|
+
{
|
45
|
+
key: "divider_1",
|
46
|
+
name: "-",
|
47
|
+
},
|
48
|
+
{
|
49
|
+
key: "rename",
|
50
|
+
name: "Rename",
|
51
|
+
},
|
52
|
+
{
|
53
|
+
key: "properties",
|
54
|
+
name: "Properties",
|
55
|
+
},
|
56
|
+
{
|
57
|
+
key: "disabled",
|
58
|
+
name: "Disabled item",
|
59
|
+
disabled: true,
|
60
|
+
},
|
61
|
+
];
|
62
|
+
_this.prePopulate = function (nextPrePopulatedItems) {
|
63
|
+
var ensureUserUrl = "".concat(_this.props.context.siteUrl, "/_api/web/ensureUser");
|
64
|
+
if (nextPrePopulatedItems != undefined &&
|
65
|
+
nextPrePopulatedItems != null &&
|
66
|
+
nextPrePopulatedItems[0] != null) {
|
67
|
+
nextPrePopulatedItems.map(function (item) {
|
68
|
+
// console.log(item);
|
69
|
+
_this.props.context.client
|
70
|
+
.post(ensureUserUrl, { logonName: item })
|
71
|
+
.then(function (response) {
|
72
|
+
var res = response.data.d;
|
73
|
+
return res;
|
74
|
+
})
|
75
|
+
.then(function (res) {
|
76
|
+
var pers = new IObjects_1.SharePointUserPersona(res);
|
77
|
+
pers.imageUrl = UtilityService_1.default.getProfilePictureUrl(_this.props.hostSiteUrl || _this.props.context.siteUrl, pers.User.Email || "");
|
78
|
+
// (this.props.hostSiteUrl || this.props.context.siteUrl) +
|
79
|
+
// `/_layouts/15/userphoto.aspx?size=S&accountname=${pers.User.Email}`;
|
80
|
+
var prepopulatedItems = _this.state.selectedItems;
|
81
|
+
if (prepopulatedItems.filter(function (x) { return x.User.LoginName == pers.User.LoginName; }).length == 0) {
|
82
|
+
prepopulatedItems.push(pers);
|
83
|
+
_this.setState({
|
84
|
+
selectedItems: _this.props.multiSelect
|
85
|
+
? prepopulatedItems
|
86
|
+
: prepopulatedItems.length > 0
|
87
|
+
? [prepopulatedItems[0]]
|
88
|
+
: prepopulatedItems,
|
89
|
+
});
|
90
|
+
}
|
91
|
+
if (_this.props.onChange) {
|
92
|
+
_this.props.onChange(prepopulatedItems);
|
93
|
+
}
|
94
|
+
});
|
95
|
+
});
|
96
|
+
}
|
97
|
+
};
|
98
|
+
_this._onFilterChanged = function (filterText, currentPersonas) {
|
99
|
+
if (filterText) {
|
100
|
+
if (filterText.length > 2) {
|
101
|
+
return _this._searchPeople(filterText, _this._peopleList);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
else {
|
105
|
+
return [];
|
106
|
+
}
|
107
|
+
};
|
108
|
+
_this._peopleList = [];
|
109
|
+
_this.state = {
|
110
|
+
currentPicker: 1,
|
111
|
+
disabled: false,
|
112
|
+
delayResults: false,
|
113
|
+
selectedItems: [],
|
114
|
+
};
|
115
|
+
return _this;
|
116
|
+
}
|
117
|
+
JitzPeoplePicker.prototype.getSelectedItems = function () { };
|
118
|
+
JitzPeoplePicker.prototype.componentDidMount = function () {
|
119
|
+
this.setState({ disabled: this.props.disabled });
|
120
|
+
this.prePopulate(this.props.prePopulatedItems);
|
121
|
+
};
|
122
|
+
JitzPeoplePicker.prototype.componentDidUpdate = function (prevProps, prevState, prevContext) {
|
123
|
+
//this.prePopulate();
|
124
|
+
};
|
125
|
+
JitzPeoplePicker.prototype.componentWillReceiveProps = function (nextProps) {
|
126
|
+
this.setState({ disabled: nextProps.disabled });
|
127
|
+
this.prePopulate(nextProps.prePopulatedItems);
|
128
|
+
};
|
129
|
+
JitzPeoplePicker.prototype.render = function () {
|
130
|
+
if (this.props.typePicker == "Normal") {
|
131
|
+
return (React.createElement(react_1.NormalPeoplePicker, { onChange: this._onChange.bind(this), disabled: this.state.disabled, onResolveSuggestions: this._onFilterChanged, getTextFromItem: function (persona) {
|
132
|
+
return persona.primaryText || "";
|
133
|
+
}, pickerSuggestionsProps: suggestionProps, selectedItems: this.state.selectedItems, className: "ms-PeoplePicker " +
|
134
|
+
(this.props.errorMessage != null &&
|
135
|
+
this.props.errorMessage != undefined &&
|
136
|
+
this.props.errorMessage.length > 0
|
137
|
+
? this.props.errorCss
|
138
|
+
: ""), key: "normal" }));
|
139
|
+
}
|
140
|
+
else {
|
141
|
+
return (React.createElement(react_1.CompactPeoplePicker, { onChange: this._onChange.bind(this), onResolveSuggestions: this._onFilterChanged, disabled: this.state.disabled, getTextFromItem: function (persona) {
|
142
|
+
return persona.primaryText || "";
|
143
|
+
}, pickerSuggestionsProps: suggestionProps, selectedItems: this.state.selectedItems, className: "ms-PeoplePicker" +
|
144
|
+
(this.props.errorMessage != null &&
|
145
|
+
this.props.errorMessage != undefined &&
|
146
|
+
this.props.errorMessage.length > 0
|
147
|
+
? this.props.errorCss
|
148
|
+
: ""), key: "normal" }));
|
149
|
+
}
|
150
|
+
};
|
151
|
+
JitzPeoplePicker.prototype._onChange = function (items) {
|
152
|
+
var _this = this;
|
153
|
+
this.setState({
|
154
|
+
selectedItems: (this.props.multiSelect
|
155
|
+
? items
|
156
|
+
: items != undefined
|
157
|
+
? items.length > 0
|
158
|
+
? [items[0]]
|
159
|
+
: items
|
160
|
+
: []) || [],
|
161
|
+
});
|
162
|
+
if (items != undefined) {
|
163
|
+
items.map(function (p, v) {
|
164
|
+
// console.log(p);
|
165
|
+
var ensureUserUrl = "".concat(_this.props.context.siteUrl, "/_api/web/ensureUser");
|
166
|
+
_this.props.context.client
|
167
|
+
.post(ensureUserUrl, { logonName: p.User.Key })
|
168
|
+
.then(function (response) {
|
169
|
+
var res = response.data.d;
|
170
|
+
return res;
|
171
|
+
})
|
172
|
+
.then(function (res) { });
|
173
|
+
});
|
174
|
+
}
|
175
|
+
if (this.props.onChange) {
|
176
|
+
this.props.onChange(items || []);
|
177
|
+
}
|
178
|
+
};
|
179
|
+
/**
|
180
|
+
* @function
|
181
|
+
* Returns fake people results for the Mock mode
|
182
|
+
*/
|
183
|
+
JitzPeoplePicker.prototype.searchPeopleFromMock = function () {
|
184
|
+
return (this._peopleList = []);
|
185
|
+
};
|
186
|
+
/**
|
187
|
+
* @function
|
188
|
+
* Returns people results after a REST API call
|
189
|
+
*/
|
190
|
+
JitzPeoplePicker.prototype._searchPeople = function (terms, results) {
|
191
|
+
var _this = this;
|
192
|
+
var userRequestUrl = "".concat(this.props.context.siteUrl, "/_api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUser");
|
193
|
+
var principalType = 0;
|
194
|
+
if (this.props.principalTypeUser === true) {
|
195
|
+
principalType += 1;
|
196
|
+
}
|
197
|
+
if (this.props.principalTypeSharePointGroup === true) {
|
198
|
+
principalType += 8;
|
199
|
+
}
|
200
|
+
if (this.props.principalTypeSecurityGroup === true) {
|
201
|
+
principalType += 4;
|
202
|
+
}
|
203
|
+
if (this.props.principalTypeDistributionList === true) {
|
204
|
+
principalType += 2;
|
205
|
+
}
|
206
|
+
var userQueryParams = {
|
207
|
+
queryParams: {
|
208
|
+
AllowEmailAddresses: true,
|
209
|
+
AllowMultipleEntities: false,
|
210
|
+
AllUrlZones: false,
|
211
|
+
MaximumEntitySuggestions: this.props.numberOfItems,
|
212
|
+
PrincipalSource: 15,
|
213
|
+
// PrincipalType controls the type of entities that are returned in the results.
|
214
|
+
// Choices are All - 15, Distribution List - 2 , Security Groups - 4, SharePoint Groups - 8, User - 1.
|
215
|
+
// These values can be combined (example: 13 is security + SP groups + users)
|
216
|
+
PrincipalType: principalType,
|
217
|
+
QueryString: terms,
|
218
|
+
},
|
219
|
+
};
|
220
|
+
return new Promise(function (resolve, reject) {
|
221
|
+
return _this.props.context.client
|
222
|
+
.post(userRequestUrl, userQueryParams)
|
223
|
+
.then(function (response) {
|
224
|
+
return response.data.d;
|
225
|
+
})
|
226
|
+
.then(function (response) {
|
227
|
+
var userQueryResults = JSON.parse(response.ClientPeoplePickerSearchUser);
|
228
|
+
var persons = userQueryResults.map(function (p) { return new IObjects_1.SharePointUserPersona(p); });
|
229
|
+
persons.map(function (p, index) {
|
230
|
+
persons[index].imageUrl = UtilityService_1.default.getProfilePictureUrl(_this.props.hostSiteUrl || _this.props.context.siteUrl, persons[index].User.Email ||
|
231
|
+
persons[index].User.Key.substr(persons[index].User.Key.lastIndexOf("|") + 1));
|
232
|
+
// (this.props.hostSiteUrl || this.props.context.siteUrl) +
|
233
|
+
// `/_layouts/15/userphoto.aspx?size=S&accountname=${
|
234
|
+
// persons[index].User.Email ||
|
235
|
+
// persons[index].User.Key.substr(
|
236
|
+
// persons[index].User.Key.lastIndexOf("|") + 1
|
237
|
+
// )
|
238
|
+
// }`;
|
239
|
+
});
|
240
|
+
return persons;
|
241
|
+
})
|
242
|
+
.then(function (persons) {
|
243
|
+
//const batch = this.props.spHttpClient.beginBatch();
|
244
|
+
var ensureUserUrl = "".concat(_this.props.context.siteUrl, "/_api/web/ensureUser");
|
245
|
+
var batchPromises = persons.map(function (p) {
|
246
|
+
p.primaryText = p.User.DisplayText;
|
247
|
+
p.secondaryText = p.User.EntityData.Title;
|
248
|
+
var userQuery = { logonName: p.User.Key };
|
249
|
+
return (_this.props.context.client
|
250
|
+
.post(ensureUserUrl, userQuery)
|
251
|
+
// return this.props.spHttpClient.post(ensureUserUrl,
|
252
|
+
// SPHttpClient.configurations.v1,
|
253
|
+
// {body:JSON.stringify({logonName: p.User.Key})})
|
254
|
+
.then(function (response) {
|
255
|
+
return response.data.d;
|
256
|
+
})
|
257
|
+
.then(function (json) { return json; }));
|
258
|
+
});
|
259
|
+
// var users = this.props.spHttpClient.execute().then(() => );
|
260
|
+
var users = Promise.all(batchPromises).then(function (values) {
|
261
|
+
values.forEach(function (v) {
|
262
|
+
var userPersona = lodash.find(persons, function (o) { return o.User.Key == v.LoginName; });
|
263
|
+
if (userPersona && userPersona.User) {
|
264
|
+
var user = userPersona.User;
|
265
|
+
lodash.assign(user, v);
|
266
|
+
userPersona.User = user;
|
267
|
+
}
|
268
|
+
});
|
269
|
+
resolve(persons);
|
270
|
+
});
|
271
|
+
}, function (error) {
|
272
|
+
reject((_this._peopleList = []));
|
273
|
+
});
|
274
|
+
});
|
275
|
+
};
|
276
|
+
JitzPeoplePicker.prototype._filterPersonasByText = function (filterText) {
|
277
|
+
var _this = this;
|
278
|
+
return this._peopleList.filter(function (item) {
|
279
|
+
return _this._doesTextStartWith(item.primaryText, filterText);
|
280
|
+
});
|
281
|
+
};
|
282
|
+
JitzPeoplePicker.prototype._removeDuplicates = function (personas, possibleDupes) {
|
283
|
+
var _this = this;
|
284
|
+
return personas.filter(function (persona) { return !_this._listContainsPersona(persona, possibleDupes); });
|
285
|
+
};
|
286
|
+
JitzPeoplePicker.prototype._listContainsPersona = function (persona, personas) {
|
287
|
+
if (!personas || !personas.length || personas.length === 0) {
|
288
|
+
return false;
|
289
|
+
}
|
290
|
+
return (personas.filter(function (item) { return item.primaryText === persona.primaryText; })
|
291
|
+
.length > 0);
|
292
|
+
};
|
293
|
+
JitzPeoplePicker.prototype._filterPromise = function (personasToReturn) {
|
294
|
+
if (this.state.delayResults) {
|
295
|
+
return this._convertResultsToPromise(personasToReturn);
|
296
|
+
}
|
297
|
+
else {
|
298
|
+
return personasToReturn;
|
299
|
+
}
|
300
|
+
};
|
301
|
+
JitzPeoplePicker.prototype._convertResultsToPromise = function (results) {
|
302
|
+
return new Promise(function (resolve, reject) {
|
303
|
+
return setTimeout(function () { return resolve(results); }, 2000);
|
304
|
+
});
|
305
|
+
};
|
306
|
+
JitzPeoplePicker.prototype._doesTextStartWith = function (text, filterText) {
|
307
|
+
return text.toLowerCase().indexOf(filterText.toLowerCase()) === 0;
|
308
|
+
};
|
309
|
+
return JitzPeoplePicker;
|
310
|
+
}(React.Component));
|
311
|
+
exports.JitzPeoplePicker = JitzPeoplePicker;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import IJitzSPContext from "../data/interfaces/IJitzSPContext";
|
3
|
+
import { PersonaSize } from "@fluentui/react";
|
4
|
+
export interface IPersonInfoProps {
|
5
|
+
userId: number;
|
6
|
+
email?: string;
|
7
|
+
title?: string;
|
8
|
+
department?: string;
|
9
|
+
location?: string;
|
10
|
+
context?: IJitzSPContext;
|
11
|
+
siteUrl?: string;
|
12
|
+
imageUrl?: string;
|
13
|
+
size?: PersonaSize;
|
14
|
+
className?: string;
|
15
|
+
hidePersonaDetails?: boolean;
|
16
|
+
}
|
17
|
+
export interface IPersonInfoState {
|
18
|
+
user: {
|
19
|
+
email?: string;
|
20
|
+
title?: string;
|
21
|
+
department?: string;
|
22
|
+
location?: string;
|
23
|
+
};
|
24
|
+
}
|
25
|
+
export declare class JitzPersonInfo extends React.Component<IPersonInfoProps, IPersonInfoState> {
|
26
|
+
private _userInfo;
|
27
|
+
constructor(props: IPersonInfoProps, state: IPersonInfoState);
|
28
|
+
componentDidMount(): void;
|
29
|
+
componentWillReceiveProps(nextProps: IPersonInfoProps): void;
|
30
|
+
private loadUser;
|
31
|
+
render(): React.ReactElement<IPersonInfoProps>;
|
32
|
+
}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
if (typeof b !== "function" && b !== null)
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
+
extendStatics(d, b);
|
13
|
+
function __() { this.constructor = d; }
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
})();
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
18
|
+
__assign = Object.assign || function(t) {
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
20
|
+
s = arguments[i];
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
22
|
+
t[p] = s[p];
|
23
|
+
}
|
24
|
+
return t;
|
25
|
+
};
|
26
|
+
return __assign.apply(this, arguments);
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.JitzPersonInfo = void 0;
|
30
|
+
var React = require("react");
|
31
|
+
var react_1 = require("@fluentui/react");
|
32
|
+
var UserService_1 = require("../services/UserService");
|
33
|
+
var UtilityService_1 = require("../services/UtilityService");
|
34
|
+
var JitzPersonInfo = /** @class */ (function (_super) {
|
35
|
+
__extends(JitzPersonInfo, _super);
|
36
|
+
function JitzPersonInfo(props, state) {
|
37
|
+
var _this = _super.call(this, props) || this;
|
38
|
+
_this.loadUser = function (id) {
|
39
|
+
if (_this.props.context != undefined) {
|
40
|
+
_this._userInfo = new UserService_1.default(_this.props.context);
|
41
|
+
_this._userInfo.getUserById(id).then(function (userInfo) {
|
42
|
+
_this.setState({
|
43
|
+
user: {
|
44
|
+
email: userInfo.Email,
|
45
|
+
title: userInfo.Title,
|
46
|
+
// department: userInfo.Department,
|
47
|
+
},
|
48
|
+
});
|
49
|
+
});
|
50
|
+
}
|
51
|
+
};
|
52
|
+
_this.state = {
|
53
|
+
user: {},
|
54
|
+
};
|
55
|
+
return _this;
|
56
|
+
}
|
57
|
+
JitzPersonInfo.prototype.componentDidMount = function () {
|
58
|
+
if (this.props.userId > 0 &&
|
59
|
+
this.props.email == undefined &&
|
60
|
+
this.props.title == undefined) {
|
61
|
+
this.loadUser(this.props.userId);
|
62
|
+
}
|
63
|
+
};
|
64
|
+
JitzPersonInfo.prototype.componentWillReceiveProps = function (nextProps) {
|
65
|
+
if (nextProps.userId > 0 &&
|
66
|
+
nextProps.email == undefined &&
|
67
|
+
nextProps.title == undefined) {
|
68
|
+
this.loadUser(nextProps.userId);
|
69
|
+
}
|
70
|
+
};
|
71
|
+
JitzPersonInfo.prototype.render = function () {
|
72
|
+
// const userDetails = this.state.user;
|
73
|
+
var userDetails = {
|
74
|
+
imageUrl: UtilityService_1.default.getProfilePictureUrl(this.props.siteUrl || this.props.context.siteUrl, this.props.email || this.state.user.email || ""),
|
75
|
+
// this.props.imageUrl ||
|
76
|
+
// (this.props.siteUrl || this.props.context!.siteUrl) +
|
77
|
+
// `/_layouts/15/userphoto.aspx?size=${
|
78
|
+
// this.props.size == PersonaSize.size48 ||
|
79
|
+
// this.props.size == PersonaSize.size56 ||
|
80
|
+
// this.props.size == PersonaSize.size72 ||
|
81
|
+
// this.props.size == PersonaSize.size100 ||
|
82
|
+
// this.props.size == PersonaSize.size120
|
83
|
+
// ? "L"
|
84
|
+
// : "M"
|
85
|
+
// }&accountname=${this.props.email || this.state.user.email}`,
|
86
|
+
imageInitials: "",
|
87
|
+
primaryText: this.props.title || this.state.user.title,
|
88
|
+
secondaryText: this.props.department || this.state.user.department,
|
89
|
+
tertiaryText: "",
|
90
|
+
optionalText: "",
|
91
|
+
};
|
92
|
+
return (React.createElement(react_1.Persona, __assign({ title: this.props.hidePersonaDetails ? userDetails.primaryText : "" }, userDetails, { className: this.props.className, size: this.props.size || react_1.PersonaSize.size24,
|
93
|
+
// presence={PersonaPresence.online} //TODO: Actual presence
|
94
|
+
hidePersonaDetails: this.props.hidePersonaDetails || false })));
|
95
|
+
};
|
96
|
+
return JitzPersonInfo;
|
97
|
+
}(React.Component));
|
98
|
+
exports.JitzPersonInfo = JitzPersonInfo;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { PersonaPresence, PersonaSize } from "@fluentui/react";
|
3
|
+
export interface IJitzPersonaProps {
|
4
|
+
className?: string;
|
5
|
+
imageUrl?: string;
|
6
|
+
personaSize?: PersonaSize;
|
7
|
+
presence?: PersonaPresence;
|
8
|
+
showPersonalDetails?: boolean;
|
9
|
+
imageInitials?: string;
|
10
|
+
text?: string;
|
11
|
+
secondaryText?: string;
|
12
|
+
tertiaryText?: string;
|
13
|
+
optionalText?: string;
|
14
|
+
}
|
15
|
+
export interface IJitzPersonaState {
|
16
|
+
}
|
17
|
+
export declare class JitzPersona extends React.Component<IJitzPersonaProps, IJitzPersonaState> {
|
18
|
+
private _userInfo;
|
19
|
+
constructor(props: IJitzPersonaProps, state: IJitzPersonaState);
|
20
|
+
componentDidMount(): void;
|
21
|
+
componentWillReceiveProps(nextProps: IJitzPersonaProps): void;
|
22
|
+
render(): React.ReactElement<IJitzPersonaProps>;
|
23
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
if (typeof b !== "function" && b !== null)
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
+
extendStatics(d, b);
|
13
|
+
function __() { this.constructor = d; }
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
})();
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
18
|
+
__assign = Object.assign || function(t) {
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
20
|
+
s = arguments[i];
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
22
|
+
t[p] = s[p];
|
23
|
+
}
|
24
|
+
return t;
|
25
|
+
};
|
26
|
+
return __assign.apply(this, arguments);
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.JitzPersona = void 0;
|
30
|
+
var React = require("react");
|
31
|
+
var react_1 = require("@fluentui/react");
|
32
|
+
var JitzPersona = /** @class */ (function (_super) {
|
33
|
+
__extends(JitzPersona, _super);
|
34
|
+
function JitzPersona(props, state) {
|
35
|
+
var _this = _super.call(this, props) || this;
|
36
|
+
_this.state = {
|
37
|
+
user: {},
|
38
|
+
};
|
39
|
+
return _this;
|
40
|
+
}
|
41
|
+
JitzPersona.prototype.componentDidMount = function () { };
|
42
|
+
JitzPersona.prototype.componentWillReceiveProps = function (nextProps) { };
|
43
|
+
JitzPersona.prototype.render = function () {
|
44
|
+
return (React.createElement(react_1.Persona, __assign({ className: this.props.className || "" }, this.props, { text: this.props.text, hidePersonaDetails: !this.props.showPersonalDetails, size: this.props.personaSize || react_1.PersonaSize.size56, presence: this.props.presence || react_1.PersonaPresence.none, imageAlt: "" })));
|
45
|
+
};
|
46
|
+
return JitzPersona;
|
47
|
+
}(React.Component));
|
48
|
+
exports.JitzPersona = JitzPersona;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { ICommonRepository } from "../interfaces/ICommonRepository";
|
2
|
+
import IJitzSPContext from "../interfaces/IJitzSPContext";
|
3
|
+
import { IEmail } from "../interfaces/IModels";
|
4
|
+
export default class CommonRepository implements ICommonRepository {
|
5
|
+
context: IJitzSPContext;
|
6
|
+
constructor(context: IJitzSPContext);
|
7
|
+
sendEmail(email: IEmail): Promise<boolean>;
|
8
|
+
getData(listName: string, selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, skipTokenUniqueField?: string, skipTokenUniqueFieldValue?: string): Promise<any>;
|
9
|
+
get(url: string): Promise<any>;
|
10
|
+
post(url: string, data: any, header?: any): Promise<any>;
|
11
|
+
getFiles(libraryName: string, selectFields: string, filter: string, expandFields: string): Promise<any>;
|
12
|
+
uploadFile(libraryName: string, fileName: string, arrayBuffer: ArrayBuffer): Promise<any>;
|
13
|
+
getFileItem(libraryName: string, fileUrl: string): Promise<any>;
|
14
|
+
updateMetadata(listName: string, item: any): Promise<any>;
|
15
|
+
deleteFile(listName: string, id: number): Promise<boolean>;
|
16
|
+
private getEntityType;
|
17
|
+
}
|