admin-config
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -138,3 +138,3 @@ import Menu from './Menu/Menu'; | ||
.map(entity => { | ||
dashboard.addCollection(entity.name(), entity.dashboardView()); // yep, a collection is a ListView, and so is a DashboardView - forgive this duck typing for BC sake | ||
dashboard.addCollection(entity.dashboardView()); // yep, a collection is a ListView, and so is a DashboardView - forgive this duck typing for BC sake | ||
}); | ||
@@ -147,3 +147,3 @@ if (!dashboard.hasCollections()) { | ||
let collection = new Collection(); | ||
let listView = entity.listView() | ||
let listView = entity.listView(); | ||
collection.setEntity(entity); | ||
@@ -156,3 +156,3 @@ collection.perPage(listView.perPage()) | ||
collection.fields(listView.fields().filter((el, index) => index < 3)); | ||
dashboard.addCollection(entity.name(), collection); | ||
dashboard.addCollection(collection); | ||
}); | ||
@@ -159,0 +159,0 @@ } |
import ListView from './View/ListView'; | ||
class Collection extends ListView { | ||
constructor(name) { | ||
super(name); | ||
this._type = 'collection'; | ||
setEntity(entity) { | ||
this.entity = entity; | ||
if (!this._name) { | ||
this._name = entity.name(); | ||
} | ||
return this; | ||
} | ||
@@ -8,0 +12,0 @@ } |
@@ -7,4 +7,4 @@ class Dashboard { | ||
addCollection(name, collection) { | ||
this._collections[name] = collection; | ||
addCollection(collection) { | ||
this._collections[collection.name()] = collection; | ||
return this; | ||
@@ -11,0 +11,0 @@ } |
import ListView from './ListView'; | ||
class DashboardView extends ListView { | ||
constructor(name) { | ||
super(name); | ||
this._type = 'DashboardView'; | ||
setEntity(entity) { | ||
this.entity = entity; | ||
if (!this._name) { | ||
this._name = entity.name(); | ||
} | ||
return this; | ||
} | ||
@@ -8,0 +11,0 @@ } |
{ | ||
"name": "admin-config", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -111,4 +111,4 @@ var assert = require('chai').assert; | ||
post.views["DashboardView"].enable(); | ||
comment.views["DashboardView"].enable(); | ||
post.views["ShowView"].enable(); | ||
comment.views["ShowView"].enable(); | ||
@@ -119,3 +119,3 @@ application | ||
let views = application.getViewsOfType('DashboardView'); | ||
let views = application.getViewsOfType('ShowView'); | ||
@@ -125,6 +125,6 @@ assert.equal(2, views.length); | ||
assert.equal('post', views[0].entity.name()); | ||
assert.equal('DashboardView', views[0].type); | ||
assert.equal('ShowView', views[0].type); | ||
assert.equal('comment', views[1].entity.name()); | ||
assert.equal('DashboardView', views[1].type); | ||
assert.equal('ShowView', views[1].type); | ||
}); | ||
@@ -237,4 +237,4 @@ | ||
let dashboard = new Dashboard(); | ||
const collection = { IAmAFakeCollection: true }; | ||
dashboard.addCollection('foo', collection) | ||
const collection = { IAmAFakeCollection: true, name: () => 'foo' }; | ||
dashboard.addCollection(collection) | ||
let application = new Application(); | ||
@@ -241,0 +241,0 @@ application.dashboard(dashboard); |
@@ -14,4 +14,4 @@ var assert = require('chai').assert; | ||
let dashboard = new Dashboard(); | ||
const collection = { IAmAFakeCollection: true }; | ||
dashboard.addCollection('foo', collection); | ||
const collection = { IAmAFakeCollection: true, name: () => 'foo' }; | ||
dashboard.addCollection(collection); | ||
assert.deepEqual(dashboard.collections(), { foo: collection }) | ||
@@ -27,3 +27,3 @@ }); | ||
let dashboard = new Dashboard(); | ||
dashboard.addCollection('foo', {}); | ||
dashboard.addCollection({ name: () => 'bar' }); | ||
assert.ok(dashboard.hasCollections()); | ||
@@ -30,0 +30,0 @@ }); |
@@ -54,5 +54,5 @@ import Factory from "../../lib/Factory"; | ||
assert.equal(collection.getEntity(), dummyEntity); | ||
assert.equal(collection.name(), 'foo_collection'); | ||
assert.equal(collection.name(), 'foo'); | ||
}) | ||
}) | ||
}); |
131671
3453