* maintenance by year passed correclty in frontend

This commit is contained in:
Danyi Dávid 2019-01-28 12:42:46 +01:00
parent 0ddd7c719d
commit 9d07b8ad82
7 changed files with 12 additions and 5 deletions

View File

@ -28,7 +28,7 @@
<i class="file pdf outline icon"></i>
</a>
<i *ngIf="!hasPdf(task)" class="icon {{taskIcon(task)}}"></i>
<a *ngIf="canModify()" [routerLink]="['/karbantartas/szerkesztes', task.hash]"
<a *ngIf="canModify()" [routerLink]="['/karbantartas/szerkesztes', year, task.hash]"
title="Szerkesztés">{{task?.shouldStartAt}}</a>
<ng-container *ngIf="!canModify()">{{task?.shouldStartAt}}</ng-container>
</div>

View File

@ -15,7 +15,7 @@ import { RoleGuardService } from "../../auth/role-guard.service";
})
export class ListAllMaintenancesComponent implements OnInit {
public year: number = 2018;
public year: number = 2019;
private today: string = "";
constructor(private maintenanceManager: MaintenanceManagerService,

View File

@ -51,6 +51,10 @@ export class MaintenanceManagerService {
return this.httpClient.get<MaintenanceEntity>(`${MaintenanceManagerService.apiEndpoint}/${hash}`);
}
public getByIdAndYear(hash: string, year: number): Observable<MaintenanceEntity> {
return this.httpClient.get<MaintenanceEntity>(`${MaintenanceManagerService.apiEndpoint}/${year}/${hash}`);
}
public update(maintenance: MaintenanceEntity) {
return this.httpClient.put<MaintenanceEntity>(`${MaintenanceManagerService.apiEndpoint}/${maintenance.hash}`, maintenance);
}

View File

@ -17,6 +17,7 @@ export class MaintenanceResolverService {
* @returns {Promise<MaintenanceEntity>}
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<MaintenanceEntity> {
return this.maintenanceManager.get(route.params.id).toPromise();
// return this.maintenanceManager.get(route.params.id).toPromise();
return this.maintenanceManager.getByIdAndYear(route.params.id, route.params.year).toPromise();
}
}

View File

@ -72,7 +72,7 @@ const routes: Routes = [
filter: 'calendar',
},
}, {
path: 'karbantartas/szerkesztes/:id',
path: 'karbantartas/szerkesztes/:year/:id',
component: EditMaintenanceComponent,
canActivate: [AuthGuardService, RoleGuardService],
resolve: {

View File

@ -18,7 +18,7 @@
<td *ngIf="canModify()" class="collapsing icon">
<a *ngIf="hasMaintenanceSheet(task)" title="PDF letöltés"
[href]="maintenancePdfUrl(task)" target="_blank"><i class="file pdf outline icon"></i></a>
<a [routerLink]="['/karbantartas/szerkesztes', task.hash]"
<a [routerLink]="['/karbantartas/szerkesztes', year, task.hash]"
title="Szerkesztés"><i class="fitted pencil icon"></i></a>
</td>
<td class="collapsing">{{device.name}}</td>

View File

@ -17,12 +17,14 @@ export class UpcomingMaintenancesComponent implements OnInit {
@Input() warnWhenPast: boolean = true;
@Input() maintenances: Array<DeviceGroup> = [];
private today: string = "";
public year: number;
constructor(
private roleGuard: RoleGuardService,
private maintenanceManager: MaintenanceManagerService
) {
this.today = (new Date()).toISOString().substring(0, 10);
this.year = new Date().getFullYear();
}
ngOnInit() {