1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

Add content to properties table

Entity's properties are now displayed. The entity id is shown in
the properties route. The serializer's normalize functions are
cleaned up.
This commit is contained in:
Markus Grigull 2015-10-01 14:34:07 +02:00
parent 64d1c6e479
commit b82e92a5be
5 changed files with 33 additions and 44 deletions

View file

@ -0,0 +1,5 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'h2'
});

View file

@ -4,6 +4,26 @@ export default DS.RESTSerializer.extend({
normalizeFindAllResponse: function(store, primaryModelClass, payload, id, requestType) {
var json = { data: [] };
this._normalizePayload(payload, function(entity) {
json.data.push(entity);
return true;
});
return json;
},
normalizeFindRecordResponse: function(store, primaryModelClass, payload, id, requestType) {
var json = { data: {} };
this._normalizePayload(payload, function(entity) {
json.data = entity;
return false;
});
return json;
},
_normalizePayload: function(payload, handleEntity) {
// check if payload has context responses
if (payload.contextResponses) {
payload.contextResponses.forEach(function(item) {
@ -29,50 +49,13 @@ export default DS.RESTSerializer.extend({
entity.attributes.properties.push(property);
});
// add entity to data
json.data.push(entity);
}
});
}
console.log(json);
return json;
},
normalizeFindRecordResponse: function(store, primaryModelClass, payload, id, requestType) {
var json = { data: {} };
// check if payload has context responses
if (payload.contextResponses) {
payload.contextResponses.forEach(function(item) {
// check if item has context element
if (item.contextElement) {
// create new entity object
json.data = {
type: 'entity',
id: item.contextElement.id,
attributes: {
type: item.contextElement.type,
properties: []
}
// pass entity to caller function
if (handleEntity(entity) == false) {
// if false returned the caller needs no more entites
return;
}
item.contextElement.attributes.forEach(function(attribute) {
var property = {
name: attribute.name,
value: attribute.value,
type: attribute.type
}
json.data.attributes.properties.push(property);
});
}
});
}
console.log(json);
return json;
}
});

View file

@ -0,0 +1 @@
{{entity.id}}

View file

@ -2,7 +2,7 @@
<th>Name</th>
<th>Value</th>
</tr>
{{#each properties as |property|}}
{{#each entity.properties as |property|}}
<tr>
<td>{{property.name}}</td>
<td>{{property.value}} {{property.type}}</td>

View file

@ -1,5 +1,5 @@
<h2></h2>
{{entity-title entity=model}}
{{properties-table}}
{{properties-table entity=model}}
{{#link-to 'lab-mashup'}}Entities{{/link-to}}