aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/comment/comment.component.ts
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-03-22 19:48:49 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-03-22 19:48:49 +0200
commit75594e7eac044e9398fd1b74246f22cabe6ddeba (patch)
treea9b05434a71eee3bdd3919e0e01b301b2eb9ebe0 /src/app/components/comment/comment.component.ts
parent10171cb09663e01507500e9c6a6a1622182664e4 (diff)
downloadDevHive-Angular-75594e7eac044e9398fd1b74246f22cabe6ddeba.tar
DevHive-Angular-75594e7eac044e9398fd1b74246f22cabe6ddeba.tar.gz
DevHive-Angular-75594e7eac044e9398fd1b74246f22cabe6ddeba.zip
Implemented comment share functionality
Diffstat (limited to 'src/app/components/comment/comment.component.ts')
-rw-r--r--src/app/components/comment/comment.component.ts31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/app/components/comment/comment.component.ts b/src/app/components/comment/comment.component.ts
index 0096c18..2a54f92 100644
--- a/src/app/components/comment/comment.component.ts
+++ b/src/app/components/comment/comment.component.ts
@@ -1,5 +1,5 @@
-import { Component, Input, OnInit } from '@angular/core';
-import {FormBuilder, FormControl, FormGroup} from '@angular/forms';
+import { AfterViewInit, Component, ElementRef, Input, OnInit, Renderer2, ViewChild } from '@angular/core';
+import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
import { Guid } from 'guid-typescript';
import { CommentService } from 'src/app/services/comment.service';
@@ -13,7 +13,7 @@ import { User } from 'src/models/identity/user.model';
templateUrl: './comment.component.html',
styleUrls: ['./comment.component.css']
})
-export class CommentComponent implements OnInit {
+export class CommentComponent implements OnInit, AfterViewInit {
public loaded = false;
public loggedInAuthor = false;
public editingComment = false;
@@ -22,8 +22,11 @@ export class CommentComponent implements OnInit {
public timeCreated: string;
@Input() paramId: string;
public editCommentFormGroup: FormGroup;
+ @ViewChild('share') shareBtn: ElementRef;
+ private _defaultShareBtnInnerHTML: string;
+ private _linkShared = false;
- constructor(private _router: Router, private _commentService: CommentService, private _userService: UserService, private _tokenService: TokenService, private _fb: FormBuilder)
+ constructor(private _router: Router, private _commentService: CommentService, private _userService: UserService, private _tokenService: TokenService, private _fb: FormBuilder, private _elem: ElementRef, private _renderer: Renderer2)
{ }
ngOnInit(): void {
@@ -59,6 +62,10 @@ export class CommentComponent implements OnInit {
});
}
+ ngAfterViewInit(): void {
+ this._defaultShareBtnInnerHTML = this.shareBtn.nativeElement.innerHTML;
+ }
+
goToAuthorProfile(): void {
this._router.navigate(['/profile/' + this.comment.issuerUsername]);
}
@@ -100,4 +107,20 @@ export class CommentComponent implements OnInit {
this._router.onSameUrlNavigation = 'reload';
this._router.navigate([this._router.url]);
}
+
+ resetShareBtn(): void {
+ if (this._linkShared) {
+ this._renderer.setProperty(this.shareBtn.nativeElement, 'innerHTML', this._defaultShareBtnInnerHTML);
+ this._linkShared = false;
+ }
+ }
+
+ showCopiedMessage(): void {
+ this._renderer.setProperty(this.shareBtn.nativeElement, 'innerHTML', 'Link copied to clipboard!');
+ this._linkShared = true;
+ }
+
+ getPostLink(): string {
+ return location.origin + '/comment/' + this.paramId;
+ }
}