<div>
    <h2>
        <span jhiTranslate="baeldungApp.comment.home.title">Comments</span>
        <button class="btn btn-primary float-right create-comment" [routerLink]="['/', { outlets: { popup: ['comment-new'] } }]">
            <span class="fa fa-plus"></span>
            <span  jhiTranslate="baeldungApp.comment.home.createLabel">
            Create new Comment
            </span>
        </button>
    </h2>
    <jhi-alert></jhi-alert>
    <div class="row">
    </div>
    <br/>
    <div class="table-responsive" *ngIf="comments">
        <table class="table table-striped">
            <thead>
            <tr jhiSort [(predicate)]="predicate" [(ascending)]="reverse" [callback]="reset.bind(this)">
            <th jhiSortBy="id"><span jhiTranslate="global.field.id">ID</span> <span class="fa fa-sort"></span></th>
            <th jhiSortBy="text"><span jhiTranslate="baeldungApp.comment.text">Text</span> <span class="fa fa-sort"></span></th>
            <th jhiSortBy="creationDate"><span jhiTranslate="baeldungApp.comment.creationDate">Creation Date</span> <span class="fa fa-sort"></span></th>
            <th jhiSortBy="post.title"><span jhiTranslate="baeldungApp.comment.post">Post</span> <span class="fa fa-sort"></span></th>
            <th></th>
            </tr>
            </thead>
            <tbody infinite-scroll (scrolled)="loadPage(page + 1)" [infiniteScrollDisabled]="page >= links['last']" [infiniteScrollDistance]="0">
            <tr *ngFor="let comment of comments ;trackBy: trackId">
                <td><a [routerLink]="['../comment', comment.id ]">{{comment.id}}</a></td>
                <td>{{comment.text}}</td>
                <td>{{comment.creationDate | date:'mediumDate'}}</td>
                <td>
                    <div *ngIf="comment.post">
                        <a [routerLink]="['../post', comment.post?.id ]" >{{comment.post?.title}}</a>
                    </div>
                </td>
                <td class="text-right">
                    <div class="btn-group flex-btn-group-container">
                        <button type="submit"
                                [routerLink]="['../comment', comment.id ]"
                                class="btn btn-info btn-sm">
                            <span class="fa fa-eye"></span>
                            <span class="hidden-md-down" jhiTranslate="entity.action.view">View</span>
                        </button>
                        <button type="submit"
                                [routerLink]="['/', { outlets: { popup: 'comment/'+ comment.id + '/edit'} }]"
                                replaceUrl="true"
                                class="btn btn-primary btn-sm">
                            <span class="fa fa-pencil"></span>
                            <span class="hidden-md-down" jhiTranslate="entity.action.edit">Edit</span>
                        </button>
                        <button type="submit"
                                [routerLink]="['/', { outlets: { popup: 'comment/'+ comment.id + '/delete'} }]"
                                replaceUrl="true"
                                class="btn btn-danger btn-sm">
                            <span class="fa fa-remove"></span>
                            <span class="hidden-md-down" jhiTranslate="entity.action.delete">Delete</span>
                        </button>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
