Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(attachments): u#3728 download attachment #487

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(attachments): u#3728 download attachment
juanfran committed Sep 6, 2023
commit 5667823c808bcfbb69a4fc994bfd04b7f9151db9
Original file line number Diff line number Diff line change
@@ -15,6 +15,12 @@ Copyright (c) 2023-present Kaleidos INC
.row {
block-size: var(--spacing-32);
padding-block: var(--spacing-4);

&:hover {
background-color: var(--color-gray20);
border-radius: var(--spacing-4);
cursor: pointer;
}
}

.name-column {
Original file line number Diff line number Diff line change
@@ -17,7 +17,8 @@
(confirm)="onConfirmDeleteFile()">
<tg-ui-dtable-row
class="row"
data-test="attachment-row">
data-test="attachment-row"
(click)="downloadAttachment()">
<tg-ui-dtable-cell
class="name-column"
[attr.title]="attachment.name">
@@ -53,6 +54,7 @@
</tg-ui-dtable-cell>
<tg-ui-dtable-cell class="actions-column">
<a
#download
cocotime marked this conversation as resolved.
Show resolved Hide resolved
[download]="attachment.name"
[href]="attachment.file"
target="_blank"
@@ -75,7 +77,7 @@
[tgUiTooltip]="t('attachments.delete')"
[tgUiTooltipStaysOpenOnHover]="false"
tgUiTooltipPosition="bottom-right"
(click)="deleteAttachment()"
(click)="deleteAttachment($event)"
icon="trash"
type="button"></button>
</tg-ui-dtable-cell>
Original file line number Diff line number Diff line change
@@ -6,7 +6,14 @@
* Copyright (c) 2023-present Kaleidos INC
*/

import { Component, Input, OnChanges, inject } from '@angular/core';
import {
Component,
ElementRef,
Input,
OnChanges,
ViewChild,
inject,
} from '@angular/core';
import { CommonModule } from '@angular/common';
import { TranslocoModule } from '@ngneat/transloco';
import { TuiButtonModule, TuiSvgModule } from '@taiga-ui/core';
@@ -51,6 +58,9 @@ export class AttachmentComponent implements OnChanges {
@Input()
public canEdit = true;

@ViewChild('download', { read: ElementRef })
public download!: ElementRef<HTMLElement>;

public extension = 'paperclip';
public state = inject(AttachmentsState);
#initUndo$ = new Subject<void>();
@@ -103,7 +113,8 @@ export class AttachmentComponent implements OnChanges {
return 'progress' in attachment;
};

public deleteAttachment() {
public deleteAttachment(event: Event) {
event.stopPropagation();
this.#initUndo$.next();
}

@@ -113,6 +124,10 @@ export class AttachmentComponent implements OnChanges {
}
}

public downloadAttachment() {
this.download.nativeElement.click();
}

public ngOnChanges() {
this.calculateExtension();
}