setup basics of user-filters-manager

This commit is contained in:
2018-11-28 13:36:16 -03:00
parent bcd683a81b
commit db0bd80635
17 changed files with 150 additions and 9 deletions
@@ -0,0 +1,8 @@
import DunlopAdapter from 'ember-cli-dunlop/adapters/application'
## Override the default adapter with the `DS.ActiveModelAdapter` which
window.client_id ||= "client#{Math.round(Math.random() * 100000)}"
Ember.$.ajaxPrefilter (options, oriOpt, jqXHR)->
jqXHR.setRequestHeader 'client-id', window.client_id
export default DunlopAdapter.extend()
+1 -1
View File
@@ -103,7 +103,7 @@ initialize = (application) ->
application.inject 'component', 'globals', 'service:globals'
application.inject 'component', 'router', 'router:main'
#application.inject 'component', 'store', 'store:main'
#application.inject 'component', 'store', 'service:store'
application.inject 'component', 'store', 'service:store'
application.inject 'view', 'globals', 'service:globals'
application.inject 'router', 'globals', 'service:globals'
@@ -1,11 +1,20 @@
import Ember from 'ember'
import PagedArray from 'ember-cli-pagination/local/paged-array'
#import PagedArray from 'ember-cli-pagination/local/paged-array'
export default Ember.Route.extend
model: (params) ->
Ember.A([
@store.createRecord('dunlop/user-filter', scope_key: 'panda/action-list', filters: {a: 42}, is_default: true)
@store.createRecord('dunlop/user-filter', scope_key: 'panda/action-list', filters: {a: 44}, is_default: false)
@store.createRecord('dunlop/user-filter', scope_key: 'migration-adapter/blurp', filters: {a: 44}, is_default: true)
result = Ember.A([
@store.createRecord('dunlop/user-filter', name: 'Filter1-2', scope_key: 'panda/action-list', filters: {a: 44}, is_default: false, desription: 'I describe<br>Filter1-2')
@store.createRecord('dunlop/user-filter', name: 'Filter1-1', scope_key: 'panda/action-list', filters: {a: 42}, is_default: true, desription: 'I describe<br>Filter1-1')
@store.createRecord('dunlop/user-filter', name: 'Filter2-1', scope_key: 'migration-adapter/blurp', filters: {a: 44}, is_default: true, desription: 'I describe<br>Filter2-1')
])
filters = Ember.Object.create
key1_eq: 45
key2_matches: 'blah%'
result.filters = filters
result.reload = ->
console.log "REALOADING FILTERS VIRTUALLY SINCE IT IS NOT AN ember-cli-dunlop/utils/paged-remote-array"
# the reference to filters should be kept intact, so outputting filters should work, the component should mutate it
console.log filters.toProperties() #TODO: console.log is not the eventual desired way of testing
result
@@ -1 +1,2 @@
h1 user-filters-manager
.ui.segment= user-filters-manager scope_key='panda/action-list' content=model
+29
View File
@@ -0,0 +1,29 @@
config = ->
@post '/dunlop/user_filters', (schema, request) ->
attributes = JSON.parse(request.requestBody)['dunlop/user_filter']
schema.dunlopUserFilters.create(attributes)
# These comments are here to help you get started. Feel free to delete them.
###
Config (with defaults).
Note: these only affect routes defined *after* them!
###
# this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
# this.namespace = ''; // make this `/api`, for example, if your API is namespaced
# this.timing = 400; // delay for each request, automatically set to 0 during testing
###
Shorthand cheatsheet:
this.get('/posts');
this.post('/posts');
this.get('/posts/:id');
this.put('/posts/:id'); // or this.patch
this.del('/posts/:id');
http://www.ember-cli-mirage.com/docs/v0.3.x/shorthands/
###
export default config
@@ -0,0 +1,4 @@
import { Factory } from 'ember-cli-mirage';
export default Factory.extend({
});
@@ -0,0 +1,4 @@
import { Model } from 'ember-cli-mirage'
export default Model.extend()
+9
View File
@@ -0,0 +1,9 @@
export default function(/* server */) {
/*
Seed your development database using your factories.
This data will not be loaded in your tests.
*/
// server.createList('post', 10);
}
@@ -0,0 +1,5 @@
import { JSONAPISerializer } from 'ember-cli-mirage'
export default JSONAPISerializer.extend
typeKeyForModel: (model) ->
model.modelName.replace(/^dunlop-/, 'dunlop/')
+3
View File
@@ -2,4 +2,7 @@ import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
if (window.server) {
window.server.shutdown();
}
}