Populating select field in forms
Change-Id: I78306706c4ad9560286d27fa1c2879916eb07614
diff --git a/src/app/datasources/helpers/store.helpers.spec.ts b/src/app/datasources/helpers/store.helpers.spec.ts
index 82a5e7a..4e45070 100644
--- a/src/app/datasources/helpers/store.helpers.spec.ts
+++ b/src/app/datasources/helpers/store.helpers.spec.ts
@@ -43,6 +43,11 @@
it('should convert a core model name in an URL', () => {
expect(service.urlFromCoreModel('Slice')).toBe('/core/slices');
expect(service.urlFromCoreModel('Xos')).toBe('/core/xosses');
+
+ // handling exceptions
+ expect(service.urlFromCoreModel('SiteRole')).toBe('/core/site_roles');
+ expect(service.urlFromCoreModel('SliceRole')).toBe('/core/slice_roles');
+ expect(service.urlFromCoreModel('SlicePrivilege')).toBe('/core/slice_privileges');
});
describe('when updating a collection', () => {
diff --git a/src/app/datasources/helpers/store.helpers.ts b/src/app/datasources/helpers/store.helpers.ts
index aa18bd8..7792590 100644
--- a/src/app/datasources/helpers/store.helpers.ts
+++ b/src/app/datasources/helpers/store.helpers.ts
@@ -18,7 +18,15 @@
}
public urlFromCoreModel(name: string): string {
- return `/core/${pluralize(name.toLowerCase())}`;
+ switch (name) {
+ // FIXME handling exceptions, understand why these 3 endpoints are autogenerated with an _f
+ case 'SiteRole':
+ case 'SliceRole':
+ case 'SlicePrivilege':
+ return `/core/${pluralize(name.split(/(?=[A-Z])/).map(w => w.toLowerCase()).join('_'))}`;
+ default:
+ return `/core/${pluralize(name.toLowerCase())}`;
+ }
}
public updateCollection(event: IWSEvent, subject: BehaviorSubject<any>): BehaviorSubject<any> {