Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Jun 28, 2021
2 parents 442607e + 8133890 commit 66f0362
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 40 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.JSON
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
{
"versions": [
{
"version": "3.2.1",
"changes": {
"new": [],
"enhancements": [],
"fixes": [
"`ListPicker`: `ListPicker` stopped working in upgrade from 3.1.0 to 3.2.0 [#945](https://github.com/pnp/sp-dev-fx-controls-react/issues/945)"
]
}
},
{
"version": "3.3.0",
"changes": {
"new": [
],
"enhancements": [
"`ListItemAttachments`: Add new label and description properties [#943](https://github.com/pnp/sp-dev-fx-controls-react/pull/943)"
],
"fixes": [
"`ListItemAttachments`: Fixed multiple bugs [#943](https://github.com/pnp/sp-dev-fx-controls-react/pull/943)"
]
},
"contributions": [
]
},
{
"version": "3.2.0",
"changes": {
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Releases

## 3.2.1

### Fixes

- `ListPicker`: `ListPicker` stopped working in upgrade from 3.1.0 to 3.2.0 [#945](https://github.com/pnp/sp-dev-fx-controls-react/issues/945)

## 3.3.0

### Enhancements

- `ListItemAttachments`: Add new label and description properties [#943](https://github.com/pnp/sp-dev-fx-controls-react/pull/943)

### Fixes

- `ListItemAttachments`: Fixed multiple bugs [#943](https://github.com/pnp/sp-dev-fx-controls-react/pull/943)

## 3.2.0

### New control(s)
Expand Down
16 changes: 16 additions & 0 deletions docs/documentation/docs/about/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Releases

## 3.2.1

### Fixes

- `ListPicker`: `ListPicker` stopped working in upgrade from 3.1.0 to 3.2.0 [#945](https://github.com/pnp/sp-dev-fx-controls-react/issues/945)

## 3.3.0

### Enhancements

- `ListItemAttachments`: Add new label and description properties [#943](https://github.com/pnp/sp-dev-fx-controls-react/pull/943)

### Fixes

- `ListItemAttachments`: Fixed multiple bugs [#943](https://github.com/pnp/sp-dev-fx-controls-react/pull/943)

## 3.2.0

### New control(s)
Expand Down
2 changes: 2 additions & 0 deletions docs/documentation/docs/controls/ListItemAttachments.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ The `ListItemAttachments` control can be configured with the following propertie
| itemId | number | no | List Item Id |
| listId | string | yes | Guid of the list. |
| webUrl | string | no | URL of the site. By default it uses the current site URL. |
| label | string | no | Main text to display on the placeholder, next to the icon. |
| description | string | no | Description text to display on the placeholder, below the main text and icon. |
| disabled | boolean | no | Specifies if the control is disabled or not. |
| openAttachmentsInNewWindow | boolean | no | Specifies if the attachment should be openend in a separate browser tab. Use this property set to `true` if you plan to use the component in Microsoft Teams. |

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@pnp/spfx-controls-react",
"description": "Reusable React controls for SharePoint Framework solutions",
"version": "3.2.0",
"version": "3.2.1",
"scripts": {
"build": "gulp build",
"clean": "gulp clean",
Expand Down
2 changes: 1 addition & 1 deletion src/common/telemetry/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version: string = "3.2.0";
export const version: string = "3.2.1";
8 changes: 8 additions & 0 deletions src/controls/listItemAttachments/IListItemAttachmentsProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@ export interface IListItemAttachmentsProps {
disabled?: boolean;
context: BaseComponentContext;
openAttachmentsInNewWindow?: boolean; // JJ - 20200613 - needed to support Microsoft Teams
/**
* Main text to display on the placeholder, next to the icon
*/
label?:string;
/**
* Description text to display on the placeholder, below the main text and icon
*/
description?:string;
}
3 changes: 1 addition & 2 deletions src/controls/listItemAttachments/IUploadAttachmentState.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

export interface IUploadAttachmentState {
file: any;
hideDialog: boolean;
dialogMessage: string;
isLoading: boolean;

}
38 changes: 19 additions & 19 deletions src/controls/listItemAttachments/ListItemAttachments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,22 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
dialogMessage: strings.ListItemAttachmentserrorLoadAttachments.replace('{0}', error.message)
});
});
}
else if(this.state.filesToUpload && this.state.filesToUpload.length > 0){
let files = this.state.filesToUpload.map(file=>({
FileName: file.name,
ServerRelativeUrl: undefined
}));
await this.loadAttachmentsPreview(files);
}
else{
this.setState({
fireUpload: false,
hideDialog: true,
dialogMessage: '',
showPlaceHolder: true
});
}
}
else if(this.state.filesToUpload && this.state.filesToUpload.length > 0){
let files = this.state.filesToUpload.map(file=>({
FileName: file.name,
ServerRelativeUrl: undefined
}));
await this.loadAttachmentsPreview(files);
}
else{
this.setState({
fireUpload: false,
hideDialog: true,
dialogMessage: '',
showPlaceHolder: true
});
}
}

/**
Expand Down Expand Up @@ -255,8 +255,8 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
this.state.showPlaceHolder ?
<Placeholder
iconName='Upload'
iconText={strings.ListItemAttachmentslPlaceHolderIconText}
description={strings.ListItemAttachmentslPlaceHolderDescription}
iconText={this.props.label || strings.ListItemAttachmentslPlaceHolderIconText}
description={this.props.description || strings.ListItemAttachmentslPlaceHolderDescription}
buttonLabel={strings.ListItemAttachmentslPlaceHolderButtonLabel}
hideButton={this.props.disabled}
onConfigure={() => this.setState({ fireUpload: true })} />
Expand Down Expand Up @@ -304,7 +304,7 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
</div>
);
})}
{
{ !this.state.hideDialog &&

<Dialog
hidden={this.state.hideDialog}
Expand Down
17 changes: 8 additions & 9 deletions src/controls/listItemAttachments/UploadAttachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import styles from './ListItemAttachments.module.scss';
export class UploadAttachment extends React.Component<IUploadAttachmentProps, IUploadAttachmentState> {
private _spservice: SPservice;
private fileInput;
private _isFileExplorerOpen = false;

constructor(props: IUploadAttachmentProps) {
super(props);

this.state = {
file: null,
hideDialog: true,
dialogMessage: '',
isLoading: false,
Expand All @@ -35,9 +35,10 @@ export class UploadAttachment extends React.Component<IUploadAttachmentProps, IU
* @param prevState
*/
public componentDidUpdate(prevProps: IUploadAttachmentProps, prevState: IUploadAttachmentState): void {
if (this.props.fireUpload) {
if (this.props.fireUpload && !this._isFileExplorerOpen) {
this.fileInput.current.value = '';
this.fileInput.current.click();
this._isFileExplorerOpen = true;
}
}

Expand All @@ -62,19 +63,16 @@ export class UploadAttachment extends React.Component<IUploadAttachmentProps, IU
const file = e.target.files[0];
return new Promise<void>((resolve,errorCallback)=>{
reader.onloadend = async () => {
this.setState({
file: file
});


try {
if(this.props.itemId && this.props.itemId > 0){
await this._spservice.addAttachment(this.props.listId, this.props.itemId, file.name, file, this.props.webUrl);
}


this.props.onAttachmentUpload(file);
this.setState({
isLoading: false
});
this.props.onAttachmentUpload(file);
resolve();
} catch (error) {
this.setState({
Expand All @@ -84,10 +82,11 @@ export class UploadAttachment extends React.Component<IUploadAttachmentProps, IU
});
errorCallback(error);
}
this._isFileExplorerOpen = false;
};
reader.readAsDataURL(file);
});

}

/**
Expand Down
16 changes: 9 additions & 7 deletions src/services/SPService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,16 @@ export default class SPService implements ISPService {

const data = await this._context.spHttpClient.get(queryUrl, SPHttpClient.configurations.v1);
if (data.ok) {
var result: ISPLists = await data.json();
var filteredLists = filter(result.value, (aList: ISPList) => {
return find(aList.ContentTypes, (ct) => {
return ct.Id.StringValue.toUpperCase().startsWith(options.contentTypeId.toUpperCase());
});
const result: ISPLists = await data.json();
if (options.contentTypeId) {
const filteredLists = filter(result.value, (aList: ISPList) => {
return find(aList.ContentTypes, (ct) => {
return ct.Id.StringValue.toUpperCase().startsWith(options.contentTypeId.toUpperCase());
});

});
result.value = filteredLists as ISPList[];
});
result.value = filteredLists as ISPList[];
}
return result as ISPLists;
} else {
return null;
Expand Down

0 comments on commit 66f0362

Please sign in to comment.