Implement getType() in halResourceTypesStorage

pull/4548/head
Alex Dik 8 years ago
parent cd7c8ac26d
commit 6a44f1ff0c
  1. 2
      frontend/app/components/api/api-v3/api-v3.config.ts
  2. 7
      frontend/app/components/api/api-v3/hal-link/hal-link.service.test.ts
  3. 10
      frontend/app/components/api/api-v3/hal-resource-types/hal-resource-types-storage.value.ts

@ -26,7 +26,7 @@
// See doc/COPYRIGHT.rdoc for more details.
// ++
import {opApiModule} from "../../../angular-modules";
import {opApiModule} from '../../../angular-modules';
function apiV3Config(apiV3, HalResource) {
apiV3.addResponseInterceptor((data, operation, what) => {

@ -26,8 +26,8 @@
// See doc/COPYRIGHT.rdoc for more details.
//++
import {opApiModule, opServicesModule} from "../../../../angular-modules";
import {HalLink} from "./hal-link.service";
import {opApiModule, opServicesModule} from '../../../../angular-modules';
import {HalLink} from './hal-link.service';
const expect = chai.expect;
@ -91,7 +91,7 @@ describe('HalLink service', () => {
hello: 'world'
};
});
it('should return a promise that returns the given value', () => {
apiRequest();
@ -106,7 +106,6 @@ describe('HalLink service', () => {
apiRequest();
promise.should.be.fulfilled.then(value => {
console.log('VAAAAAAAAAAAAAAAAL', value);
expect(value.restangularized).to.not.be.ok;
});
});

@ -30,8 +30,12 @@
import {opApiModule} from '../../../../angular-modules';
opApiModule.value('halResourceTypesStorage', {
getResourceClassOfType(type?:string){
type = this[type] ? type : '__default__';
getType(type:string): string {
return type = this[type] ? type : '__default__';
},
getResourceClassOfType(type?:string) {
type = this.getType(type);
const typeConfig = this[type];
const resourceClass = typeConfig.cls;
@ -41,7 +45,7 @@ opApiModule.value('halResourceTypesStorage', {
},
getResourceClassOfAttribute(type:string, attribute:string) {
const typeConfig = this[type];
const typeConfig = this[this.getType(type)];
const resourceClass = typeConfig.attrCls[attribute];
if (typeConfig && resourceClass) {

Loading…
Cancel
Save