Merge pull request #1521 from sharepointknight/master

This commit is contained in:
Hugo Bernier 2020-10-02 02:56:18 -04:00 committed by GitHub
commit 48854f5480
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 13 deletions

View File

@ -61,7 +61,7 @@ The web part use PnPjs library, Office-ui-fabric-react components
Solution|Author(s)
--------|---------
Directory Web Part|João Mendes
Directory Web Part| João Mendes
Directory Web Part| Peter Paul Kirschner ([@petkir_at](https://twitter.com/petkir_at))
Directory Web Part| Sudharsan K ([@sudharsank](https://twitter.com/sudharsank))
@ -71,7 +71,7 @@ Version|Date|Comments
-------|----|--------
1.0.0|July 29, 2019|Initial release
1.0.1|July 19, 2020|Bugfix and mock-service for workbench (```LivePersonaCard``` not supported in workbench)
2.0.0.0|Sep 18 2020|React hooks, paging, dynamic search props, result alignment using office ui fabric stack.
2.0.0|Sep 18 2020|React hooks, paging, dynamic search props, result alignment using office ui fabric stack.
## Disclaimer

View File

@ -1,6 +1,6 @@
{
"name": "react-directory",
"version": "1.0.1",
"version": "2.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "react-directory",
"version": "1.0.1",
"version": "2.0.0",
"private": true,
"main": "lib/index.js",
"engines": {

View File

@ -1,6 +1,6 @@
{
"name": "react-form-webpart",
"version": "1.0.4",
"version": "1.0.5",
"private": true,
"engines": {
"node": ">=0.10.0"

View File

@ -154,13 +154,14 @@ export class ListFormService implements IListFormService {
},
};
const formValues = this.GetFormValues(fieldsSchema, data, originalData);
let createAttachmetns = this.GetAttachmentsCreate(data);
let deleteAttachmetns = this.GetAttachmentsDelete(data, originalData);
let createAttachments = this.GetAttachmentsCreate(data);
let deleteAttachments = this.GetAttachmentsDelete(data, originalData);
httpClientOptions.body = JSON.stringify({
bNewDocumentUpdate: false,
checkInComment: null,
formValues,
});
const endpoint = `${webUrl}/_api/web/GetList(@listUrl)/items(@itemId)/ValidateUpdateListItem()`
+ `?@listUrl=${encodeURIComponent('\'' + listUrl + '\'')}&@itemId=%27${itemId}%27`;
try {
@ -170,12 +171,12 @@ export class ListFormService implements IListFormService {
}
let responseData = await response.json();
responseData.AttachmentResponse = [];
if (deleteAttachmetns.length > 0) {
let deleteResponse = await this.deleteAttachments(webUrl, listUrl, itemId, deleteAttachmetns);
if (deleteAttachments.length > 0) {
let deleteResponse = await this.deleteAttachments(webUrl, listUrl, itemId, deleteAttachments);
responseData.AttachmentResponse.push(deleteResponse);
}
if (createAttachmetns.length > 0) {
let createResponse = await this.uploadAttachments(webUrl, listUrl, itemId, createAttachmetns);
if (createAttachments.length > 0) {
let createResponse = await this.uploadAttachments(webUrl, listUrl, itemId, createAttachments);
responseData.AttachmentResponse.push(createResponse);
}
return responseData.d.ValidateUpdateListItem.results;
@ -323,6 +324,15 @@ export class ListFormService implements IListFormService {
HasException: false,
};
}
else if (field.FieldType === "DateTime") {
let dateValue = data[field.InternalName].split('').map((c) => { return (c.charCodeAt(0) < 127) ? c : ''; }).join('');
return {
ErrorMessage: null,
FieldName: field.InternalName,
FieldValue: dateValue,
HasException: false,
};
}
else {
return {
ErrorMessage: null,

View File

@ -34,6 +34,29 @@ export default class ListFormWebPart extends BaseClientSideWebPart<IListFormWebP
protected onInit(): Promise<void> {
return super.onInit().then((_) => {
this.listService = new ListService(this.context.spHttpClient);
//Polyfill array find
if (!Array.prototype["find"]) {
Array.prototype["find"] = function (predicate) {
if (this == null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
}
}
return undefined;
};
}
});
}

View File

@ -35,7 +35,7 @@ export default class DateFormField extends React.Component<IDateFormFieldProps,
public componentDidUpdate(prevProps: IDateFormFieldProps, prevState: IDateFormFieldState) {
//Component Value property got updated from List State
if (this.props.value && prevProps.value != this.props.value) {
let momentDate = moment(this.props.value);
let momentDate = moment(this.props.value, moment.localeData(this.props.locale).longDateFormat('L'));
this.setState({
hours: momentDate.hour(),
minutes: momentDate.minute(),