@eqproject/eqp-attachments 3.1.2 → 3.1.3
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/README.md +112 -0
- package/esm2022/lib/eqp-attachments.component.mjs +79 -11
- package/esm2022/lib/interfaces/IAttachment.mjs +7 -1
- package/fesm2022/eqproject-eqp-attachments.mjs +84 -10
- package/fesm2022/eqproject-eqp-attachments.mjs.map +1 -1
- package/lib/eqp-attachments.component.d.ts +17 -2
- package/lib/interfaces/IAttachment.d.ts +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,6 +106,7 @@ For the best icon display, include Font Awesome in your project's styles, for ex
|
|
|
106
106
|
|
|
107
107
|
| Input | Type | Default | Description |
|
|
108
108
|
| ---------------------- | ----------- | ------------- | -------------------------------------------------------------------------------- |
|
|
109
|
+
| `layout` | `'full'` | `'compact'` | `'compact'` |
|
|
109
110
|
| `viewMode` | `'card'` | `'table'` | `'card'` |
|
|
110
111
|
| `chooseView` | `boolean` | `true` | If `true`, displays the Card/Table view switcher in the header. |
|
|
111
112
|
| `showSummary` | `boolean` | `true` | If `true`, displays the summary block with file count and total size. |
|
|
@@ -117,6 +118,14 @@ For the best icon display, include Font Awesome in your project's styles, for ex
|
|
|
117
118
|
|
|
118
119
|
---
|
|
119
120
|
|
|
121
|
+
#### **Table View Configuration**
|
|
122
|
+
|
|
123
|
+
| Input | Type | Default | Description |
|
|
124
|
+
| ---------------------- | ----------- | ------------- | -------------------------------------------------------------------------------- |
|
|
125
|
+
| `customColumns` | `'AttachmentFieldColumn'` | `[]` | Array to add custom columns to the table view. |
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
120
129
|
#### **Functional Configuration**
|
|
121
130
|
|
|
122
131
|
| Input | Type | Default | Description |
|
|
@@ -206,6 +215,39 @@ For the best icon display, include Font Awesome in your project's styles, for ex
|
|
|
206
215
|
| `isUploading` | `boolean` | (Internal State)`true`during the upload process. |
|
|
207
216
|
| `uploadError` | `boolean` | (Internal State)`true`if the upload failed. |
|
|
208
217
|
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
#### `AttachmentFieldColumn` Interface
|
|
222
|
+
|
|
223
|
+
| Property | Type | Description |
|
|
224
|
+
| ----------------------- | ------------------- | ------------------------------------------------------ |
|
|
225
|
+
| `key` | `string` | . |
|
|
226
|
+
| `display` | `string` | The property key from the IAttachmentDTO object |
|
|
227
|
+
| `type` | `TypeAttachmentColumn` | The rendering type (TEXT, DATE, TEMPLATE). Defaults to TEXT. |
|
|
228
|
+
| `externalTemplate` | `TemplateRef<any>` | The ng-template to use (required if type is TEMPLATE). |
|
|
229
|
+
| `styles` | `{ flex: string }` | Defines the column width (e.g., '1 1 0%' or '0 0 150px'). |
|
|
230
|
+
| `position` | `number` | The column's display order (Default: 99). File is 10, Actions is 100. |
|
|
231
|
+
| `class` | `string` | A custom CSS class to add to the column's cells. |
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
#### **AttachmentCardSize Type**
|
|
237
|
+
|
|
238
|
+
export type AttachmentCardSize = 'small' | 'medium' | 'large' | 'custom';
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
#### **Layout Configuration**
|
|
245
|
+
|
|
246
|
+
export type Layout = 'full' | 'compact';
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
|
|
209
251
|
## Use Cases
|
|
210
252
|
|
|
211
253
|
### Case 1: Single Image Upload
|
|
@@ -289,6 +331,76 @@ export class MyComponent {
|
|
|
289
331
|
}
|
|
290
332
|
```
|
|
291
333
|
|
|
334
|
+
### Case 3: Custom Columns
|
|
335
|
+
**HTML**
|
|
336
|
+
|
|
337
|
+
```
|
|
338
|
+
<eqp-attachments
|
|
339
|
+
[multipleAttachment]="true"
|
|
340
|
+
[attachmentsList]="documentList"
|
|
341
|
+
[allowedTypes]="[1, 2]"
|
|
342
|
+
[viewMode]="'card'"
|
|
343
|
+
[headerTitle]="'Project Documents'"
|
|
344
|
+
[showSummary]="true"
|
|
345
|
+
(localEditedAttachments)="onAttachmentsChange($event)"
|
|
346
|
+
[customColumns]="myCustomColumns">
|
|
347
|
+
</eqp-attachments>
|
|
348
|
+
|
|
349
|
+
<ng-template #statusTemplate let-att>
|
|
350
|
+
<mat-chip-listbox>
|
|
351
|
+
<mat-chip [style.background-color]="att.Status === 'Approved' ? '#c8e6c9' : '#ffcdd2'"
|
|
352
|
+
[style.color]="att.Status === 'Approved' ? '#2e7d32' : '#c62828'">
|
|
353
|
+
{{ att.Status }}
|
|
354
|
+
</mat-chip>
|
|
355
|
+
</mat-chip-listbox>
|
|
356
|
+
</ng-template>
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
**TypeScript**
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
@ViewChild('statusTemplate', { static: true }) statusTemplate: TemplateRef<any>;
|
|
363
|
+
|
|
364
|
+
documentList: IAttachmentDTO[] = [
|
|
365
|
+
{
|
|
366
|
+
ID: 1,
|
|
367
|
+
FileName: 'report.pdf',
|
|
368
|
+
FileExtension: 'pdf',
|
|
369
|
+
UploadUserName: 'Mario Rossi',
|
|
370
|
+
Status: 'Approved'
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
ID: 2,
|
|
374
|
+
FileName: 'schema.zip',
|
|
375
|
+
FileExtension: 'zip',
|
|
376
|
+
UploadUserName: 'Laura Bianchi',
|
|
377
|
+
Status: 'Pending'
|
|
378
|
+
}
|
|
379
|
+
];
|
|
380
|
+
myCustomColumns: AttachmentFieldColumn[] = [];
|
|
381
|
+
|
|
382
|
+
ngOnInit() {
|
|
383
|
+
this.myCustomColumns = [
|
|
384
|
+
{
|
|
385
|
+
key: 'UploadUserName',
|
|
386
|
+
header: 'Uploaded By',
|
|
387
|
+
type: TypeAttachmentColumn.TEXT, // Renders as plain text
|
|
388
|
+
styles: { flex: '2 1 0%' }, // Takes 2 parts of the available space
|
|
389
|
+
position: 20 // Shows after "File" (10)
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
key: 'Status', // Unique key for this column
|
|
393
|
+
header: 'Status',
|
|
394
|
+
type: TypeAttachmentColumn.TEMPLATE,
|
|
395
|
+
externalTemplate: this.statusTemplate, // Pass the ng-template
|
|
396
|
+
styles: { flex: '1 1 0%' }, // Takes 1 part of the available space
|
|
397
|
+
position: 30 // Shows after "Uploaded By" (20)
|
|
398
|
+
}
|
|
399
|
+
];
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
|
|
292
404
|
## Credits
|
|
293
405
|
|
|
294
406
|
This library has been developed by EqProject SRL. For more info, contact: info@eqproject.it
|