Shift Update Done, will add password next
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
<page-title title="Shift Update"></page-title>
|
||||
<app-input-form [fields]="tableHeaderList" (formValues)="addUpdate($event)"
|
||||
(clicked)="onClick()"></app-input-form>
|
||||
<!-- <div class="" (click)="clickToAdd()">Click to add</div> -->
|
||||
<div class="table-container">
|
||||
<div class="table">
|
||||
<table>
|
||||
@@ -19,7 +20,14 @@
|
||||
<td>{{updateData.Reference | shorten:getRowNumber(i)}}</td>
|
||||
<td>{{updateData.Handler}}</td>
|
||||
<td>{{updateData.Status}}</td>
|
||||
<td class="actions"><button (click)="onComplete(updateData)" class="complete"><i class="bi bi-check-lg"></i></button><button (click)="onDelete()" class="delete"><i class="bi bi-x-lg"></i></button></td>
|
||||
<td class="actions">
|
||||
<button (click)="onComplete(updateData)" class="complete">
|
||||
<i class="bi bi-check-lg"></i>
|
||||
</button>
|
||||
<button (click)="onDelete(updateData)" class="delete">
|
||||
<i class="bi bi-x-lg"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -18,7 +18,7 @@ import { ShortenPipe } from '../../../shared/pipe/shorten.pipe';
|
||||
})
|
||||
export class ShiftUpdateComponent implements OnInit, OnDestroy {
|
||||
tableHeaderList = ['Date','Details','Remarks','Sales','Reference','Handler', 'Status']
|
||||
updateDataList: Update[] = [];
|
||||
updateDataList!: Update[];
|
||||
updateListSubscription!: Subscription;
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ export class ShiftUpdateComponent implements OnInit, OnDestroy {
|
||||
ngOnInit(): void {
|
||||
this.updateListSubscription = this.updateService.allUpdate().subscribe((update)=>{
|
||||
this.updateDataList = update;
|
||||
console.log(this.updateDataList.keys)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,8 +35,12 @@ export class ShiftUpdateComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
addUpdate(newUpdate:any){
|
||||
this.updateService.addUpdate(newUpdate);
|
||||
this.updateService.addUpdate(newUpdate).subscribe((res)=>{
|
||||
console.log(res);
|
||||
this.fetchUpdates()
|
||||
})
|
||||
}
|
||||
|
||||
onClick(){
|
||||
this.updateService.allUpdate().subscribe((update)=>{
|
||||
this.updateDataList = update;
|
||||
@@ -58,7 +61,35 @@ onComplete(update: Update){
|
||||
this.updateService.updateStatus(update)
|
||||
}
|
||||
|
||||
onDelete() {
|
||||
//
|
||||
onDelete(data: any) {
|
||||
console.log(data)
|
||||
this.updateService.deleteUpdate(data).subscribe({
|
||||
next: () => this.fetchUpdates(),
|
||||
error: (err) => console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
// clickToAdd(){
|
||||
// const test_update: Update = {
|
||||
// id: "",
|
||||
// Date: '11-11-23',
|
||||
// Details: 'Test-details',
|
||||
// Remarks: 'Test-remarks',
|
||||
// Sales_Concern: 'test-concernt',
|
||||
// Reference: 'test-reference',
|
||||
// Handler: 'test-handler',
|
||||
// Status: 'test-status',
|
||||
// deleted: false
|
||||
// }
|
||||
// this.updateService.addUpdate(test_update).subscribe((res)=>{
|
||||
// console.log(res)
|
||||
// this.fetchUpdates()
|
||||
// })
|
||||
// }
|
||||
|
||||
private fetchUpdates(): void {
|
||||
this.updateService.allUpdate().subscribe((update) => {
|
||||
this.updateDataList = update;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { sample_update } from "./sample_update";
|
||||
import { Observable } from "rxjs";
|
||||
import { Update } from "../../../shared/model/update.model";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { UPDATE_ADD_URL, UPDATE_COMPLETE_URL, UPDATE_GET_URL } from "../../../shared/constants/backend";
|
||||
import { UPDATE_ADD_URL, UPDATE_COMPLETE_URL, UPDATE_DELETE_URL, UPDATE_GET_URL } from "../../../shared/constants/backend";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -19,15 +19,17 @@ export class UpdateService{
|
||||
|
||||
addUpdate(newUpdate: Update) {
|
||||
newUpdate.deleted = false;
|
||||
this.httpClient.post(UPDATE_ADD_URL,newUpdate).subscribe((log)=>{
|
||||
console.log(log)
|
||||
})
|
||||
return this.httpClient.post(UPDATE_ADD_URL,newUpdate);
|
||||
}
|
||||
|
||||
updateStatus(newUpdate: Update) {
|
||||
this.httpClient.post(UPDATE_COMPLETE_URL,newUpdate).subscribe((res)=>{
|
||||
console.log(res)
|
||||
this.httpClient.post<Update>(UPDATE_COMPLETE_URL,newUpdate).subscribe((res)=>{
|
||||
console.log(res);
|
||||
})
|
||||
}
|
||||
|
||||
deleteUpdate(deletedTask: Update) {
|
||||
return this.httpClient.post<Update>(UPDATE_DELETE_URL,deletedTask)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user