@@ -7,7 +7,7 @@ import { Label } from "office-ui-fabric-react/lib/Label";
7
7
import { Link } from 'office-ui-fabric-react/lib/Link' ;
8
8
import * as strings from 'ControlStrings' ;
9
9
import styles from './ListItemAttachments.module.scss' ;
10
- import { UploadAttachment } from './UploadAttachment'
10
+ import { UploadAttachment } from './UploadAttachment' ;
11
11
import { IListItemAttachmentFile } from './IListItemAttachmentFile' ;
12
12
import {
13
13
DocumentCard ,
@@ -23,6 +23,8 @@ import SPservice from "../../services/SPService";
23
23
import { TooltipHost , DirectionalHint } from 'office-ui-fabric-react/lib/Tooltip' ;
24
24
import { Spinner , SpinnerSize } from 'office-ui-fabric-react/lib/Spinner' ;
25
25
import utilities from './utilities' ;
26
+ import { Placeholder } from "../placeholder" ;
27
+
26
28
export class ListItemAttachments extends React . Component < IListItemAttachmentsProps , IListItemAttachmentsState > {
27
29
private _spservice : SPservice ;
28
30
private previewImages : IDocumentCardPreviewImage [ ] ;
@@ -37,7 +39,9 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
37
39
dialogMessage : '' ,
38
40
attachments : [ ] ,
39
41
deleteAttachment : false ,
40
- disableButton : false
42
+ disableButton : false ,
43
+ showPlaceHolder : false ,
44
+ fireUpload : false
41
45
} ;
42
46
// Get SPService Factory
43
47
this . _spservice = new SPservice ( this . props . context ) ;
@@ -69,7 +73,9 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
69
73
this . setState ( {
70
74
hideDialog : true ,
71
75
dialogMessage : '' ,
72
- attachments : files
76
+ attachments : files ,
77
+ showPlaceHolder : files . length === 0 ? true : false
78
+
73
79
} ) ;
74
80
}
75
81
catch ( error ) {
@@ -81,6 +87,7 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
81
87
}
82
88
// LoadAttachments
83
89
public componentDidMount ( ) {
90
+
84
91
this . _loadAttachments ( ) ;
85
92
}
86
93
@@ -95,49 +102,60 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
95
102
disabled = { this . props . disabled }
96
103
context = { this . props . context }
97
104
onAttachmentUpload = { this . _onAttachmentpload }
105
+ fireUpload = { this . state . fireUpload }
98
106
/>
99
107
100
- { this . state . attachments . map ( ( _file , i : number ) => {
101
- return (
102
- < div className = { styles . documentCardWrapper } >
103
- < TooltipHost
104
- content = { _file . FileName }
105
- calloutProps = { { gapSpace : 0 , isBeakVisible : true } }
106
- closeDelay = { 200 }
107
- directionalHint = { DirectionalHint . rightCenter } >
108
-
109
- < DocumentCard
110
- onClickHref = { `${ _file . ServerRelativeUrl } ?web=1` }
111
- className = { styles . documentCard } >
112
- < DocumentCardPreview previewImages = { [ this . previewImages [ i ] ] } />
113
- < Label className = { styles . fileLabel } >
114
- { _file . FileName }
115
- </ Label >
116
- < DocumentCardActions
117
- actions = {
118
- [
119
- {
120
- iconProps : {
121
- iconName : 'Delete' ,
122
- title : strings . ListItemAttachmentsActionDeleteIconTitle ,
123
- } ,
124
- title : strings . ListItemAttachmentsactionDeleteTitle ,
125
- text : strings . ListItemAttachmentsactionDeleteTitle ,
126
- disabled : this . props . disabled ,
127
- onClick : ( ev ) => {
128
- ev . preventDefault ( ) ;
129
- ev . stopPropagation ( ) ;
130
- this . _onDeleteAttachment ( _file ) ;
131
- }
132
- } ,
133
- ]
134
- }
135
- />
136
- </ DocumentCard >
137
- </ TooltipHost >
138
- </ div >
139
- ) ;
140
- } ) }
108
+ {
109
+ this . state . showPlaceHolder ?
110
+ < Placeholder
111
+ iconName = 'Upload'
112
+ iconText = { strings . ListItemAttachmentslPlaceHolderIconText }
113
+ description = { strings . ListItemAttachmentslPlaceHolderDescription }
114
+ buttonLabel = { strings . ListItemAttachmentslPlaceHolderButtonLabel }
115
+ onConfigure = { ( ) => this . setState ( { fireUpload : true } ) } />
116
+ :
117
+
118
+ this . state . attachments . map ( ( _file , i : number ) => {
119
+ return (
120
+ < div className = { styles . documentCardWrapper } >
121
+ < TooltipHost
122
+ content = { _file . FileName }
123
+ calloutProps = { { gapSpace : 0 , isBeakVisible : true } }
124
+ closeDelay = { 200 }
125
+ directionalHint = { DirectionalHint . rightCenter } >
126
+
127
+ < DocumentCard
128
+ onClickHref = { `${ _file . ServerRelativeUrl } ?web=1` }
129
+ className = { styles . documentCard } >
130
+ < DocumentCardPreview previewImages = { [ this . previewImages [ i ] ] } />
131
+ < Label className = { styles . fileLabel } >
132
+ { _file . FileName }
133
+ </ Label >
134
+ < DocumentCardActions
135
+ actions = {
136
+ [
137
+ {
138
+ iconProps : {
139
+ iconName : 'Delete' ,
140
+ title : strings . ListItemAttachmentsActionDeleteIconTitle ,
141
+ } ,
142
+ title : strings . ListItemAttachmentsactionDeleteTitle ,
143
+ text : strings . ListItemAttachmentsactionDeleteTitle ,
144
+ disabled : this . props . disabled ,
145
+ onClick : ( ev ) => {
146
+ ev . preventDefault ( ) ;
147
+ ev . stopPropagation ( ) ;
148
+ this . _onDeleteAttachment ( _file ) ;
149
+ }
150
+ } ,
151
+ ]
152
+ }
153
+ />
154
+ </ DocumentCard >
155
+ </ TooltipHost >
156
+ </ div >
157
+ ) ;
158
+ } ) }
141
159
{
142
160
143
161
< Dialog
0 commit comments