Last active
May 18, 2016 16:18
-
-
Save paridin/8a113f8fedfc5a570b0fbef3447e46d6 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import JSONAPIAdapter from 'ember-data/adapters/json-api'; | |
export default JSONAPIAdapter.extend({}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export function limit(params, { limitObject, size }) { | |
return limitObject.slice(0, size); | |
} | |
export default Ember.Helper.helper(limit); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function returnJSON(status, body) { | |
return json(...arguments); | |
}; | |
export function json(status, body) { | |
if (arguments.length === 1) { | |
body = status; | |
status = 200; | |
} | |
return [ | |
status, | |
{ "Content-Type": "application/vnd.api+json" }, | |
JSON.stringify(body) | |
]; | |
}; | |
export const server = new Pretender(); | |
export function initialize() { | |
server.handledRequest = function(verb, path, request) { | |
console.log(`handled request to ${verb} ${path}`); | |
} | |
server.unhandledRequest = function(verb, path, request) { | |
console.log(`undhandled request ${verb} ${path}`); | |
} | |
}; | |
export default { | |
name: 'pretender', | |
initialize | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
export default DS.Model.extend({ | |
expediente: DS.attr('string'), | |
titular: DS.attr('string'), | |
trademark: DS.belongsTo('trademark') | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
import Ember from 'ember'; | |
export default DS.Model.extend({ | |
title: DS.attr('string'), | |
marcanet: DS.hasMany('marcanet'), | |
relatedTotal: Ember.computed('marcanet', function(){ | |
return this.get('marcanet.length'); | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import { server, json } from '../initializers/pretender'; | |
server.map(function() { | |
this.get('trademarks', function() { | |
return json({ | |
data: [ | |
{ | |
attributes: { | |
id: "P020409", | |
title: "INVESTRONICA SISTEMAS", | |
}, | |
id: "P020409", | |
relationships: { | |
marcanet: { | |
data: [ | |
{ | |
"id": "1715739", | |
"type": "marcanet" | |
}, | |
{ | |
"id": "1715736", | |
"type": "marcanet" | |
}, | |
{ | |
"id": "1709761", | |
"type": "marcanet" | |
} | |
] | |
} | |
}, | |
type: "trademarks" | |
}, | |
], | |
included: [ | |
{ | |
attributes: { | |
expediente: "1715739", | |
titular: "SOLICITUD EN PROCESO DE CAPTURA RECIBIDA EN LA OFICINA REGIONAL NORTE (ORN)" | |
}, | |
id: "1715739", | |
type: "marcanet" | |
}, | |
{ | |
attributes: { | |
expediente: "1715736", | |
titular: "SOLICITUD EN PROCESO DE CAPTURA RECIBIDA EN LA OFICINA REGIONAL NORTE (ORN)" | |
}, | |
id: "1715736", | |
type: "marcanet" | |
}, | |
{ | |
attributes: { | |
expediente: "1709761", | |
titular: "HECTOR GERARDO AGUILAR RAZO" | |
}, | |
id: "1709761", | |
type: "marcanet" | |
} | |
] | |
}); | |
}); | |
}); | |
export default Ember.Route.extend({ | |
model: function(params) { | |
return this.store.query('trademark', params); | |
}, | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.7.2", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.5.1/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.5.2/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.5.1/ember-template-compiler.js", | |
"route-recognizer": "https://npmcdn.com/[email protected]/dist/route-recognizer.js", | |
"fake-xml-http-request": "https://npmcdn.com/[email protected]/fake_xml_http_request.js", | |
"pretender": "https://npmcdn.com/[email protected]/pretender.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment