Updated oauth lib. TravelDto no longer necessary.
This commit is contained in:
2221
package-lock.json
generated
2221
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,7 @@
|
||||
"zone.js": "~0.10.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "~0.1002.1",
|
||||
"@angular-devkit/build-angular": "^0.1002.2",
|
||||
"@angular/cli": "^11.1.2",
|
||||
"@angular/compiler-cli": "~11.1.1",
|
||||
"@types/jasmine": "~3.5.0",
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import { User, UserId } from './user';
|
||||
|
||||
export type TravelId = number;
|
||||
|
||||
export class TravelDto {
|
||||
constructor(
|
||||
public id: TravelId = -1,
|
||||
public driverInfo: User = null,
|
||||
public travelersInfo: User[] = [],
|
||||
public departureDate: string = '',
|
||||
public origin: string = '',
|
||||
public destination: string = '',
|
||||
public places: number = 0,
|
||||
public matrixRoomId: string = '',
|
||||
public description?: string
|
||||
) { }
|
||||
}
|
||||
@@ -1,20 +1,19 @@
|
||||
import { TravelDto } from './travel-dto';
|
||||
import { User, UserId } from './user';
|
||||
|
||||
export type TravelId = number;
|
||||
|
||||
export class Travel extends TravelDto {
|
||||
constructor(travelDto: TravelDto = null) {
|
||||
super(travelDto?.id,
|
||||
travelDto?.driverInfo,
|
||||
travelDto?.travelersInfo,
|
||||
travelDto?.departureDate,
|
||||
travelDto?.origin,
|
||||
travelDto?.destination,
|
||||
travelDto?.places,
|
||||
travelDto?.matrixRoomId,
|
||||
travelDto?.description);
|
||||
}
|
||||
export class Travel {
|
||||
constructor(
|
||||
public id: TravelId = -1,
|
||||
public driverInfo: User = null,
|
||||
public travelersInfo: User[] = [],
|
||||
public departureDate: string = '',
|
||||
public origin: string = '',
|
||||
public destination: string = '',
|
||||
public places: number = 0,
|
||||
public matrixRoomId: string = '',
|
||||
public description?: string
|
||||
) { }
|
||||
|
||||
availablePlaces(): number {
|
||||
return this.places - this.travelersInfo.length;
|
||||
|
||||
@@ -28,7 +28,7 @@ export class EditTravelComponent implements OnInit {
|
||||
this.apiService.getTravel(travelId)
|
||||
.subscribe(res => {
|
||||
if (res.success) {
|
||||
this.travel = new Travel(res.data);
|
||||
this.travel = Object.assign( new Travel(), res.data );
|
||||
}
|
||||
else {
|
||||
console.error('Error getting travel ' + travelId + ': ' + res.error.code + ' ' + res.error.msg);
|
||||
|
||||
@@ -79,7 +79,7 @@ export class TravelComponent implements OnInit {
|
||||
this.apiService.getTravel(this.travelId)
|
||||
.subscribe(res => {
|
||||
if (res.success) {
|
||||
this.travel = new Travel(res.data);
|
||||
this.travel = Object.assign( new Travel(), res.data );
|
||||
}
|
||||
else {
|
||||
console.error('Error getting travel ' + this.travelId + ': ' + res.error);
|
||||
|
||||
@@ -32,7 +32,7 @@ export class AbilityService {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (travel.driverInfo.id !== user.id) && (! travel.hasTraveler(user.id));
|
||||
return (travel.driverInfo.id !== user.id) && (! travel.hasTraveler(user.id)) && (travel.availablePlaces() > 0);
|
||||
}
|
||||
|
||||
canLeaveTravel(travel: Travel): boolean {
|
||||
|
||||
@@ -8,7 +8,6 @@ import { PUBLIC_API_URL, TRAVEL_API_URL, USER_API_URL } from '../app.config';
|
||||
import { ListDto } from '../entities/list-dto';
|
||||
import { User } from '../entities/user';
|
||||
import { AuthService } from './auth.service';
|
||||
import { TravelDto } from '../entities/travel-dto';
|
||||
|
||||
export type ApiCall<T> = (params?: { [param: string]: any }) => (Observable<ApiResponse<ListDto<T>>>);
|
||||
|
||||
@@ -29,7 +28,7 @@ export class ApiService {
|
||||
}
|
||||
|
||||
getTravel = (travelId: TravelId) => {
|
||||
return this.callApi<TravelDto>(PUBLIC_API_URL + '/travel', { travelId });
|
||||
return this.callApi<Travel>(PUBLIC_API_URL + '/travel', { travelId });
|
||||
}
|
||||
|
||||
getTravels = (params?: { [param: string]: any }) => {
|
||||
|
||||
Reference in New Issue
Block a user