Skip to content

Commit

Permalink
feat: unsaved action to routes & hikes
Browse files Browse the repository at this point in the history
  • Loading branch information
petrot committed Apr 6, 2018
1 parent 49f2f2d commit 8d3d8f7
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/app/shared/services/admin-map/admin-map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ export class AdminMapService extends MapService {
this.iconService,
this.mapMarkerService,
this._store,
this._gameRuleService,
this._routeService,
this._hikeEditRoutePlannerSelectors,
this._elevationService
this._hikeEditRoutePlannerSelectors
);
this._maps[_id] = _map;

Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/services/hike-data/hike-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class HikeDataService {
isRoundTrip: hikeData.isRoundTrip,
}));
this._store.dispatch(new hikeEditGeneralInfoActions.SetDifficulty({
difficulty: parseInt(hikeData.difficulty) // TODO: it will be number!
difficulty: hikeData.difficulty
}));

// Pois
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/reducer/test/hike-edit-route-planner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('RouteInfoData reducers', () => {

describe('AddRoute action', () => {
it('should set route', () => {
const routeData = 'fakeRouteData';
const routeData: any = {};
const action = new hikeEditRoutePlannerActions.AddRoute({ route: routeData });
const state = hikeEditRoutePlannerReducer(initialState, action);

Expand Down
12 changes: 10 additions & 2 deletions src/subrepos/gtrack-common-ngx/app/hike/store/hike/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export enum HikeProgramActionTypes {
LOAD_HIKE_PROGRAMS = '[HikeProgram] Load hikePrograms',
ALL_HIKE_PROGRAMS_LOADED = '[HikeProgram] All hikePrograms loaded',
SAVE_HIKE_PROGRAM = '[HikeProgram] Save hikeProgram',
HIKE_PROGRAM_SAVED = '[HikeProgram] HikeProgram saved'
HIKE_PROGRAM_SAVED = '[HikeProgram] HikeProgram saved',
HIKE_PROGRAM_UNSAVED = '[HikeProgram] HikeProgram unsaved'
}

export class LoadHikeProgram implements Action {
Expand Down Expand Up @@ -64,11 +65,18 @@ export class HikeProgramSaved implements Action {
constructor(public context: string) {}
}

export class HikeProgramUnsaved implements Action {
readonly type = HikeProgramActionTypes.HIKE_PROGRAM_UNSAVED;

constructor(public context: string) {}
}

export type AllHikeActions =
| LoadHikeProgram
| HikeProgramLoaded
| LoadHikeProgramFailed
| LoadHikePrograms
| AllHikeProgramsLoaded
| SaveHikeProgram
| HikeProgramSaved;
| HikeProgramSaved
| HikeProgramUnsaved;
8 changes: 8 additions & 0 deletions src/subrepos/gtrack-common-ngx/app/hike/store/hike/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ const contextReducer: ActionReducer<IAllHikeContextState> = (
}
}, state);

case HikeProgramActionTypes.HIKE_PROGRAM_SAVED:
return hikeContextStateAdapter.updateOne({
id: action.context,
changes: {
saved: false
}
}, state);

default:
return state;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,15 @@ describe('Hike actions', () => {
});
});

describe('HikeProgramUnsaved action', () => {
it('should create an action', () => {
let action = new actions.HikeProgramUnsaved(id);

expect({ ...action }).toEqual({
type: actions.HikeProgramActionTypes.HIKE_PROGRAM_UNSAVED,
context: id
});
});
});

});
12 changes: 10 additions & 2 deletions src/subrepos/gtrack-common-ngx/app/hike/store/route/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export enum RouteActionTypes {
LOAD_ROUTE_FAILED = '[Route] Load route failed',
ROUTE_LOADED = '[Route] Route loaded',
SAVE_ROUTE = '[Route] Save route',
ROUTE_SAVED = '[Route] Route saved'
ROUTE_SAVED = '[Route] Route saved',
ROUTE_UNSAVED = '[Route] Route unsaved'
}

export class LoadRoute implements Action {
Expand Down Expand Up @@ -46,9 +47,16 @@ export class RouteSaved implements Action {
constructor (public context: string) {}
}

export class RouteUnsaved implements Action {
readonly type = RouteActionTypes.ROUTE_UNSAVED;

constructor (public context: string) {}
}

export type AllRouteActions =
| LoadRoute
| RouteLoaded
| LoadRouteFailed
| SaveRoute
| RouteSaved;
| RouteSaved
| RouteUnsaved;
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ const contextReducer: ActionReducer<IAllRouteContextState> = (
}
}, state);

case RouteActionTypes.ROUTE_UNSAVED:
return routeContextStateAdapter.updateOne({
id: action.context,
changes: {
saved: false
}
}, state);

default:
return state;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,16 @@ describe('Route actions', () => {
});
});
});

describe('RouteUnSaved action', () => {
it('should create an action', () => {
let action = new actions.RouteUnsaved(id);

expect({ ...action }).toEqual({
type: actions.RouteActionTypes.ROUTE_UNSAVED,
context: id
});
});
});

});

0 comments on commit 8d3d8f7

Please sign in to comment.