Added the edit button

This commit is contained in:
Mosiur Rahman
2024-12-22 10:52:31 +06:00
parent 89aa9fc0f4
commit 510394fdc7
4 changed files with 75 additions and 20 deletions

View File

@@ -12,7 +12,9 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let updateData of updateDataList; let i = index" (click)="toggleRow(i)"> <ng-container *ngFor="let updateData of updateDataList; let i = index" >
<ng-container *ngIf="editIndex!==i">
<tr (click)="toggleRow(i)">
<td>{{updateData.Date}}</td> <td>{{updateData.Date}}</td>
<td>{{updateData.Details | shorten:getRowNumber(i)}}</td> <td>{{updateData.Details | shorten:getRowNumber(i)}}</td>
<td>{{updateData.Remarks | shorten:getRowNumber(i)}}</td> <td>{{updateData.Remarks | shorten:getRowNumber(i)}}</td>
@@ -28,7 +30,25 @@
<i class="bi bi-x-lg"></i> <i class="bi bi-x-lg"></i>
</button> </button>
</td> </td>
<td>
<button (click)="onEdit(i)" class="edit">
<i class="bi bi-pencil"></i>
</button>
</td>
</tr> </tr>
</ng-container>
<ng-container *ngIf="editIndex===i">
<td class="edit-input"><input type="text" [(ngModel)]="updateData.Date"></td>
<td class="edit-input"><textarea name="text" [(ngModel)]="updateData.Details" id="">updateData.Details</textarea></td>
<td class="edit-input"><input type="text" [(ngModel)]="updateData.Remarks"></td>
<td class="edit-input"><input type="text" [(ngModel)]="updateData.Sales_Concern"></td>
<td class="edit-input"><input type="text" [(ngModel)]="updateData.Reference"></td>
<td class="edit-input"><input type="text" [(ngModel)]="updateData.Handler"></td>
<td class="edit-input"><input type="text" [(ngModel)]="updateData.Status"></td>
<td><button (click)="onEditSave()">Save</button></td>
<td><button (click)="onCancel()" >Cancel</button></td>
</ng-container>
</ng-container>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@@ -94,3 +94,23 @@ td {
background-color: darken($danger, 20); background-color: darken($danger, 20);
} }
} }
.edit{
background-color: yellowgreen;
border: none;
height: 2rem;
width: 2.5rem;
border-radius: 10px;
margin-top: 5px;
&:hover {
background-color: darken(yellowgreen, 20);
}
}
.edit-input {
input{
max-width: 100px;
}
}

View File

@@ -7,11 +7,12 @@ import { InputFormComponent } from "../../../shared/components/input-form/input-
import { Update } from '../../../shared/model/update.model'; import { Update } from '../../../shared/model/update.model';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ShortenPipe } from '../../../shared/pipe/shorten.pipe'; import { ShortenPipe } from '../../../shared/pipe/shorten.pipe';
import { FormsModule } from '@angular/forms';
@Component({ @Component({
selector: 'app-shift-update', selector: 'app-shift-update',
standalone: true, standalone: true,
imports: [TitleComponent, InputFormComponent, CommonModule, ShortenPipe], imports: [TitleComponent, InputFormComponent, CommonModule, ShortenPipe, FormsModule],
templateUrl: './shift-update.component.html', templateUrl: './shift-update.component.html',
styleUrl: './shift-update.component.scss', styleUrl: './shift-update.component.scss',
providers: [UpdateService] providers: [UpdateService]
@@ -21,7 +22,8 @@ export class ShiftUpdateComponent implements OnInit, OnDestroy {
updateDataList!: Update[]; updateDataList!: Update[];
updateListSubscription!: Subscription; updateListSubscription!: Subscription;
todayDate!: String; todayDate!: String;
editMode = false;
editIndex: number | null = null;
constructor(private updateService: UpdateService) {} constructor(private updateService: UpdateService) {}
@@ -78,6 +80,9 @@ onDelete(data: any) {
}) })
} }
onEdit(index: number) {
this.editIndex = index;
}
// clickToAdd(){ // clickToAdd(){
// const test_update: Update = { // const test_update: Update = {
// id: "", // id: "",
@@ -96,6 +101,15 @@ onDelete(data: any) {
// }) // })
// } // }
onEditSave() {
//
}
onCancel()
{
this.editIndex = null;
}
private fetchUpdates(): void { private fetchUpdates(): void {
this.updateService.allUpdate().subscribe((update) => { this.updateService.allUpdate().subscribe((update) => {
this.updateDataList = update; this.updateDataList = update;

View File

@@ -51,8 +51,9 @@
.toggle{ .toggle{
position: fixed; position: fixed;
right: 2.5rem; right: 2rem;
bottom: 0; bottom: 0;
z-index: 100;
} }
i { i {