|
7 | 7 |
|
8 | 8 | <div class="row">
|
9 | 9 | <span class="fs-3 ">Your Stories
|
10 |
| - <button class="btn btn-secondary float-end" (click)="listing=false;createStory=true;">Add |
| 10 | + <button class="btn btn-secondary float-end" (click)="openCreateForm()">Add |
11 | 11 | New</button></span>
|
12 | 12 | </div>
|
13 |
| - <div class="mx-5 py-3" *ngFor="let story of stories"> |
| 13 | + <div class="mx-5 py-3" *ngFor=" |
| 14 | + let story of stories | sortByDate |
| 15 | + | paginate |
| 16 | + : { |
| 17 | + itemsPerPage: tableSize, |
| 18 | + currentPage: page, |
| 19 | + totalItems: count |
| 20 | + }; |
| 21 | + let i = index |
| 22 | +
|
| 23 | + "> |
14 | 24 |
|
15 | 25 | <div class="row pb-2">
|
16 | 26 | <div>
|
17 | 27 | <span class="float-start fs-3"> {{story.title}}</span>
|
18 |
| - <span class="float-end text-primary"> Date :- {{story.created_at}}</span> |
| 28 | + <span class="float-end text-primary"> Date :- {{story.created_at | date:'mediumDate'}}</span> |
19 | 29 |
|
20 | 30 | </div>
|
21 | 31 | </div>
|
|
26 | 36 | <button class="btn btn-outline-secondary me-2" (click)="listing=!listing">Edit</button>
|
27 | 37 | <button class="btn btn-outline-danger">Delete</button>
|
28 | 38 | </div>
|
29 |
| - |
| 39 | + <div class="d-flex justify-content-center"> |
| 40 | + <pagination-controls previousLabel="Prev" nextLabel="Next" (pageChange)="onTableDataChange($event)"> |
| 41 | + </pagination-controls> |
| 42 | + </div> |
30 | 43 | </div>
|
31 | 44 | <div *ngIf="createStory" class="mx-5 my-4">
|
32 |
| - <p class="fs-3 text-center">Add Your Story</p> |
| 45 | + <p class="fs-3 text-center"> |
| 46 | + <button class="btn btn-warning float-start" (click)="listing=true;createStory=false;">Go Back</button> |
| 47 | + Add Your Story |
| 48 | + </p> |
| 49 | + <form [formGroup]="storyForm" (ngSubmit)="addStory()"> |
| 50 | + <div class="form-floating mb-3"> |
| 51 | + <input type="text" class="form-control" id="floatingInputValue" formControlName="title"> |
| 52 | + <label for="floatingInputValue">Title</label> |
| 53 | + <p *ngIf="( |
| 54 | + storyForm.controls['title'].dirty || |
| 55 | + storyForm.controls['title'].touched || |
| 56 | + storyForm.controls['title'].pristine) && |
| 57 | + storyForm.controls['title'].errors |
| 58 | + " class="alert alert-danger">This Field is Required</p> |
| 59 | + </div> |
| 60 | + <ckeditor #editor formControlName="content"> |
| 61 | + </ckeditor> |
| 62 | + <p *ngIf="( |
| 63 | + storyForm.controls['content'].dirty || |
| 64 | + storyForm.controls['content'].touched || |
| 65 | + storyForm.controls['content'].pristine) && |
| 66 | + storyForm.controls['content'].errors |
| 67 | + " class="alert alert-danger">This Field is Required</p> |
| 68 | + <div class="form-floating my-3"> |
| 69 | + <input type="date" class="form-control" id="floatingInputValue" formControlName="created_at"> |
| 70 | + <label for="floatingInputValue">Completion Date</label> |
| 71 | + <p *ngIf="( |
| 72 | + storyForm.controls['created_at'].dirty || |
| 73 | + storyForm.controls['created_at'].touched || |
| 74 | + storyForm.controls['created_at'].pristine) && |
| 75 | + storyForm.controls['created_at'].errors |
| 76 | + " class="alert alert-danger">This Field is Required</p> |
| 77 | + </div> |
| 78 | + |
| 79 | + <button type="submit" class="btn btn-primary" [disabled]="!storyForm.valid">Submit |
| 80 | + </button> |
| 81 | + |
| 82 | + </form> |
| 83 | + </div> |
| 84 | + <div *ngIf="editStory" class="mx-5 my-4"> |
| 85 | + <p class="fs-3 text-center"> |
| 86 | + <button class="btn btn-warning float-start" (click)="listing=true;editStory=false;">Go Back</button> |
| 87 | + Edit Your Story |
| 88 | + </p> |
33 | 89 | <form [formGroup]="storyForm">
|
34 | 90 | <div class="form-floating mb-3">
|
35 | 91 | <input type="text" class="form-control" id="floatingInputValue" formControlName="title">
|
|
0 commit comments