@eqproject/eqp-attachments 3.1.2 → 3.1.4
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 +139 -0
- package/esm2022/lib/eqp-attachments.component.mjs +125 -31
- package/esm2022/lib/interfaces/IAttachment.mjs +7 -1
- package/fesm2022/eqproject-eqp-attachments.mjs +130 -30
- package/fesm2022/eqproject-eqp-attachments.mjs.map +1 -1
- package/lib/eqp-attachments.component.d.ts +27 -5
- package/lib/interfaces/IAttachment.d.ts +25 -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. |
|
|
@@ -114,7 +115,15 @@ For the best icon display, include Font Awesome in your project's styles, for ex
|
|
|
114
115
|
| `customCardHeightPx` | `number` | `180` | Sets the custom card height in pixels when `cardSize`is `'custom'`. |
|
|
115
116
|
| `showMatCard` | `boolean` | `true` | If `true`(and in table mode), the component is rendered inside a `mat-card`. |
|
|
116
117
|
| `cropDialogClass` | `string` | `undefined` | Assigns a custom CSS class to the image cropper dialog panel. |
|
|
118
|
+
| `showUploadTitle` | `boolean` | `true` | If `true`, will show title over dropbox |
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
#### **Table View Configuration**
|
|
117
122
|
|
|
123
|
+
| Input | Type | Default | Description |
|
|
124
|
+
| ---------------------- | ----------- | ------------- | -------------------------------------------------------------------------------- |
|
|
125
|
+
| `customColumns` | `'AttachmentFieldColumn[]'` | `[]` | Array to add custom columns to the table view. |
|
|
126
|
+
| `customMenuActions` | `'AttachmentMenuAction[]'` | `[]` | Array to add custom actions to the table's "more options" (...) menu.
|
|
118
127
|
---
|
|
119
128
|
|
|
120
129
|
#### **Functional Configuration**
|
|
@@ -206,6 +215,49 @@ 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
|
+
#### `AttachmentMenuAction` Interface
|
|
235
|
+
|
|
236
|
+
| Property | Type | Description |
|
|
237
|
+
| ----------------------- | ------------------- | ------------------------------------------------------ |
|
|
238
|
+
| `icon` | `string` | mat-icon name to display (e.g., 'share'). |
|
|
239
|
+
| `name` | `string` | Text to show in the menu item.object |
|
|
240
|
+
| `fn` | `(att: IAttachmentDTO) => void` | Function to execute when the item is clicked. |
|
|
241
|
+
| `disabled` | `(att: IAttachmentDTO) => boolean` | Function to dynamically disable the action for a specific row. |
|
|
242
|
+
| `position` | `number` | Display order. Preview is 10, Delete is 100. Use a number in between (e.g., 20) to add an action. |
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
#### **AttachmentCardSize Type**
|
|
247
|
+
|
|
248
|
+
export type AttachmentCardSize = 'small' | 'medium' | 'large' | 'custom';
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
#### **Layout Configuration**
|
|
255
|
+
|
|
256
|
+
export type Layout = 'full' | 'compact';
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
|
|
209
261
|
## Use Cases
|
|
210
262
|
|
|
211
263
|
### Case 1: Single Image Upload
|
|
@@ -289,6 +341,93 @@ export class MyComponent {
|
|
|
289
341
|
}
|
|
290
342
|
```
|
|
291
343
|
|
|
344
|
+
### Case 3: Custom Columns
|
|
345
|
+
**HTML**
|
|
346
|
+
|
|
347
|
+
```
|
|
348
|
+
<eqp-attachments
|
|
349
|
+
[multipleAttachment]="true"
|
|
350
|
+
[attachmentsList]="documentList"
|
|
351
|
+
[allowedTypes]="[1, 2]"
|
|
352
|
+
[viewMode]="'card'"
|
|
353
|
+
[headerTitle]="'Project Documents'"
|
|
354
|
+
[showSummary]="true"
|
|
355
|
+
(localEditedAttachments)="onAttachmentsChange($event)"
|
|
356
|
+
[customColumns]="myCustomColumns"
|
|
357
|
+
[customMenuActions]="myCustomActions">
|
|
358
|
+
</eqp-attachments>
|
|
359
|
+
|
|
360
|
+
<ng-template #statusTemplate let-att>
|
|
361
|
+
<mat-chip-listbox>
|
|
362
|
+
<mat-chip [style.background-color]="att.Status === 'Approved' ? '#c8e6c9' : '#ffcdd2'"
|
|
363
|
+
[style.color]="att.Status === 'Approved' ? '#2e7d32' : '#c62828'">
|
|
364
|
+
{{ att.Status }}
|
|
365
|
+
</mat-chip>
|
|
366
|
+
</mat-chip-listbox>
|
|
367
|
+
</ng-template>
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**TypeScript**
|
|
371
|
+
|
|
372
|
+
```
|
|
373
|
+
@ViewChild('statusTemplate', { static: true }) statusTemplate: TemplateRef<any>;
|
|
374
|
+
|
|
375
|
+
documentList: IAttachmentDTO[] = [
|
|
376
|
+
{
|
|
377
|
+
ID: 1,
|
|
378
|
+
FileName: 'report.pdf',
|
|
379
|
+
FileExtension: 'pdf',
|
|
380
|
+
UploadUserName: 'Mario Rossi',
|
|
381
|
+
Status: 'Approved'
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
ID: 2,
|
|
385
|
+
FileName: 'schema.zip',
|
|
386
|
+
FileExtension: 'zip',
|
|
387
|
+
UploadUserName: 'Laura Bianchi',
|
|
388
|
+
Status: 'Pending'
|
|
389
|
+
}
|
|
390
|
+
];
|
|
391
|
+
myCustomColumns: AttachmentFieldColumn[] = [];
|
|
392
|
+
myCustomActions: AttachmentMenuAction[] = [];
|
|
393
|
+
|
|
394
|
+
ngOnInit() {
|
|
395
|
+
this.myCustomColumns = [
|
|
396
|
+
{
|
|
397
|
+
key: 'UploadUserName',
|
|
398
|
+
header: 'Uploaded By',
|
|
399
|
+
type: TypeAttachmentColumn.TEXT, // Renders as plain text
|
|
400
|
+
styles: { flex: '2 1 0%' }, // Takes 2 parts of the available space
|
|
401
|
+
position: 20 // Shows after "File" (10)
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
key: 'Status', // Unique key for this column
|
|
405
|
+
header: 'Status',
|
|
406
|
+
type: TypeAttachmentColumn.TEMPLATE,
|
|
407
|
+
externalTemplate: this.statusTemplate, // Pass the ng-template
|
|
408
|
+
styles: { flex: '1 1 0%' }, // Takes 1 part of the available space
|
|
409
|
+
position: 30 // Shows after "Uploaded By" (20)
|
|
410
|
+
}
|
|
411
|
+
];
|
|
412
|
+
|
|
413
|
+
this.myCustomActions = [
|
|
414
|
+
{
|
|
415
|
+
icon: 'share',
|
|
416
|
+
label: 'Share',
|
|
417
|
+
onClick: (item) => this.shareAttachment(item),
|
|
418
|
+
position: 25 // Show after "Preview" (10) and before "Delete" (100)
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
icon: 'edit',
|
|
422
|
+
label: 'Edit Name',
|
|
423
|
+
onClick: (item) => this.renameAttachment(item),
|
|
424
|
+
position: 26
|
|
425
|
+
}
|
|
426
|
+
];
|
|
427
|
+
}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
|
|
292
431
|
## Credits
|
|
293
432
|
|
|
294
433
|
This library has been developed by EqProject SRL. For more info, contact: info@eqproject.it
|