Moved urlFromCoreModel into ConfigHelpers
Change-Id: Ida841fb362a2cc6dbf7f080d71687db4e9ad996d
diff --git a/src/app/datasources/helpers/model.helpers.spec.ts b/src/app/datasources/helpers/model.helpers.spec.ts
deleted file mode 100644
index ee23b28..0000000
--- a/src/app/datasources/helpers/model.helpers.spec.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import * as angular from 'angular';
-import 'angular-mocks';
-import 'angular-ui-router';
-
-import {IXosModelHelpersService, ModelHelpers} from './model.helpers';
-
-let service: IXosModelHelpersService;
-describe('The ModelHelpers service', () => {
-
- beforeEach(() => {
- angular
- .module('test', [])
- .service('ModelHelpers', ModelHelpers);
-
- angular.mock.module('test');
- });
-
- beforeEach(angular.mock.inject((
- ModelHelpers: IXosModelHelpersService,
- ) => {
- service = ModelHelpers;
- }));
-
- it('should convert a core model name in an URL', () => {
- expect(service.urlFromCoreModel('Slice')).toBe('/core/slices');
- });
-
-});
diff --git a/src/app/datasources/helpers/model.helpers.ts b/src/app/datasources/helpers/model.helpers.ts
deleted file mode 100644
index 81825d3..0000000
--- a/src/app/datasources/helpers/model.helpers.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export interface IXosModelHelpersService {
- urlFromCoreModel(name: string): string;
-}
-
-export class ModelHelpers {
- urlFromCoreModel(name: string): string {
- return `/core/${name.toLowerCase()}s`;
- }
-}
diff --git a/src/app/datasources/helpers/store.helpers.spec.ts b/src/app/datasources/helpers/store.helpers.spec.ts
index b2085e3..f0168b6 100644
--- a/src/app/datasources/helpers/store.helpers.spec.ts
+++ b/src/app/datasources/helpers/store.helpers.spec.ts
@@ -2,10 +2,10 @@
import 'angular-mocks';
import 'angular-ui-router';
import {StoreHelpers, IStoreHelpersService} from './store.helpers';
-import {ModelHelpers} from './model.helpers';
import {ModelRest} from '../rest/model.rest';
import {BehaviorSubject} from 'rxjs';
import {IWSEvent} from '../websocket/global';
+import {ConfigHelpers} from '../../core/services/helpers/config.helpers';
let service: IStoreHelpersService;
let subject: BehaviorSubject<any>;
@@ -16,8 +16,8 @@
beforeEach(() => {
angular
- .module('test', ['ngResource'])
- .service('ModelHelpers', ModelHelpers) // NOTE evaluate mock
+ .module('test', ['ngResource', 'toastr'])
+ .service('ConfigHelpers', ConfigHelpers) // NOTE evaluate mock
.service('ModelRest', ModelRest) // NOTE evaluate mock
.service('StoreHelpers', StoreHelpers);
diff --git a/src/app/datasources/helpers/store.helpers.ts b/src/app/datasources/helpers/store.helpers.ts
index 99662da..1458d81 100644
--- a/src/app/datasources/helpers/store.helpers.ts
+++ b/src/app/datasources/helpers/store.helpers.ts
@@ -1,18 +1,18 @@
import {BehaviorSubject} from 'rxjs';
import * as _ from 'lodash';
import {IWSEvent} from '../websocket/global';
-import {IXosModelHelpersService} from './model.helpers';
import {IXosResourceService} from '../rest/model.rest';
+import {IXosConfigHelpersService} from '../../core/services/helpers/config.helpers';
export interface IStoreHelpersService {
updateCollection(event: IWSEvent, subject: BehaviorSubject<any>): BehaviorSubject<any>;
}
export class StoreHelpers {
- static $inject = ['ModelHelpers', 'ModelRest'];
+ static $inject = ['ConfigHelpers', 'ModelRest'];
constructor (
- private modelHelpers: IXosModelHelpersService,
+ private configHelpers: IXosConfigHelpersService,
private modelRest: IXosResourceService
) {
}
@@ -27,7 +27,7 @@
const isDeleted: boolean = _.includes(event.msg.changed_fields, 'deleted');
// generate a resource for the model
- const endpoint = this.modelHelpers.urlFromCoreModel(event.model);
+ const endpoint = this.configHelpers.urlFromCoreModel(event.model);
const resource = this.modelRest.getResource(endpoint);
const model = new resource(event.msg.object);