admin-config
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -28,3 +28,6 @@ import stringUtils from "../Utils/stringUtils"; | ||
this._updateMethod = null; // manually set the HTTP-method for update operation, defaults to put | ||
this._retrieveMethod = null; // manually set the HTTP-method for the get operation, defaults to get | ||
this._deleteMethod = null; // manually set the HTTP-method for the delete operation, defaults to delete | ||
this._initViews(); | ||
@@ -188,4 +191,16 @@ } | ||
} | ||
retrieveMethod(retrieveMethod) { | ||
if (!arguments.length) return this._retrieveMethod; | ||
this._retrieveMethod = retrieveMethod; | ||
return this; | ||
} | ||
deleteMethod(deleteMethod) { | ||
if (!arguments.length) return this._deleteMethod; | ||
this._deleteMethod = deleteMethod; | ||
return this; | ||
} | ||
} | ||
export default Entity; |
@@ -18,3 +18,3 @@ import Queries from './Queries' | ||
return this._restWrapper | ||
.getOne(entity.name(), this._application.getRouteFor(entity, url, viewType, identifierValue, identifierName)); | ||
.getOne(entity.name(), this._application.getRouteFor(entity, url, viewType, identifierValue, identifierName), entity.retrieveMethod()); | ||
} | ||
@@ -105,3 +105,3 @@ | ||
return this._restWrapper | ||
.getList(params, entity.name(), this._application.getRouteFor(entity, url, viewType)); | ||
.getList(params, entity.name(), this._application.getRouteFor(entity, url, viewType), entity.retrieveMethod()); | ||
} | ||
@@ -108,0 +108,0 @@ |
@@ -48,3 +48,3 @@ import Queries from './Queries' | ||
return this._restWrapper | ||
.deleteOne(view.entity.name(), this._application.getRouteFor(view.entity, view.getUrl(entityId), view.type, entityId, view.identifier())); | ||
.deleteOne(view.entity.name(), this._application.getRouteFor(view.entity, view.getUrl(entityId), view.type, entityId, view.identifier()), view.entity.deleteMethod()); | ||
} | ||
@@ -51,0 +51,0 @@ |
@@ -8,7 +8,6 @@ import View from "./View"; | ||
this._icon = null; | ||
this._enabled = true; | ||
} | ||
get enabled() { | ||
return this._enabled && this.entity.views['ListView'].enabled; | ||
return this._enabled || this.entity.views['ListView'].enabled; | ||
} | ||
@@ -15,0 +14,0 @@ |
@@ -68,2 +68,5 @@ import Entry from "../Entry"; | ||
/** | ||
* @deprecated Use getter "entity" instead | ||
*/ | ||
getEntity() { | ||
@@ -73,2 +76,5 @@ return this.entity; | ||
/** | ||
* @deprecated Specify entity at view creation or use "entity" setter instead | ||
*/ | ||
setEntity(entity) { | ||
@@ -75,0 +81,0 @@ this.entity = entity; |
{ | ||
"name": "admin-config", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -90,2 +90,26 @@ var assert = require('chai').assert; | ||
describe('retrieveMethod', function() { | ||
it('should return given retrieveMethod if already set', function() { | ||
var post = new Entity('post').retrieveMethod('post'); | ||
assert.equal('post', post.retrieveMethod()); | ||
}); | ||
it('should return null if no retrieveMethod has been set', function() { | ||
var post = new Entity('post'); | ||
assert.equal(null, post.retrieveMethod()); | ||
}); | ||
}); | ||
describe('deleteMethod', function() { | ||
it('should return given deleteMethod if already set', function() { | ||
var post = new Entity('post').deleteMethod('post'); | ||
assert.equal('post', post.deleteMethod()); | ||
}); | ||
it('should return null if no deleteMethod has been set', function() { | ||
var post = new Entity('post'); | ||
assert.equal(null, post.deleteMethod()); | ||
}); | ||
}); | ||
describe('identifier', function() { | ||
@@ -92,0 +116,0 @@ it('should set default identifier', function() { |
@@ -7,26 +7,2 @@ var assert = require('chai').assert; | ||
describe('MenuView', function() { | ||
describe('enabled', function() { | ||
var entity, menuView; | ||
beforeEach(function() { | ||
entity = new Entity('post'); | ||
entity.listView().enable(); | ||
menuView = entity.menuView().enable(); | ||
}); | ||
it('should be considered as enable if enabled AND if related list view is enabled', function() { | ||
assert.equal(menuView.enabled, true); | ||
}); | ||
it('should not be enabled if no related list view is enabled', function() { | ||
entity.listView().disable(); | ||
assert.equal(menuView.enabled, false); | ||
}); | ||
it('should not be enabled if disabled', function() { | ||
menuView.disable(); | ||
assert.equal(menuView.enabled, false); | ||
}); | ||
}); | ||
describe('icon', function() { | ||
@@ -33,0 +9,0 @@ it('should default to list glyphicon', function() { |
150359
3910
70