before lunch commit
This commit is contained in:
@@ -1,20 +1,25 @@
|
||||
import Ember from 'ember'
|
||||
#import PagedArray from 'ember-cli-pagination/local/paged-array'
|
||||
import PagedArray from 'ember-cli-dunlop/utils/paged-remote-array'
|
||||
|
||||
export default Ember.Route.extend
|
||||
model: (params) ->
|
||||
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')
|
||||
])
|
||||
#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 = PagedArray.create
|
||||
modelName: 'dunlop/user-filter'
|
||||
store: @store
|
||||
filters: filters
|
||||
otherParams:
|
||||
scope_key_matches: 'panda/%'
|
||||
#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,2 +1,10 @@
|
||||
h1 user-filters-manager
|
||||
table.ui.compact.celled.table
|
||||
thead
|
||||
tr
|
||||
th Name
|
||||
tbody
|
||||
each model as |user_filter|
|
||||
tr
|
||||
td= user_filter.name
|
||||
.ui.segment= user-filters-manager scope_key='panda/action-list' content=model
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
config = ->
|
||||
@get '/dunlop/user_filters', (schema, request) ->
|
||||
#q = {}
|
||||
#for key, value of request.queryParams
|
||||
# continue unless match = key.match /^q\[(\w+)\]$/
|
||||
# q[match[1]] = value
|
||||
#switch q.f_eq
|
||||
# when 4 then schema.dunlopUserFilters.all()
|
||||
# else schema.loadFixtures('dunlop-user-filters')
|
||||
result = schema.dunlopUserFilters.all()
|
||||
if filter = request.queryParams.scope_key_matches
|
||||
match = new RegExp(filter.replace(/%$/, '.*$'))
|
||||
result = result.filter (model) ->
|
||||
model.scope_key.match match
|
||||
result
|
||||
@post '/dunlop/user_filters', (schema, request) ->
|
||||
attributes = JSON.parse(request.requestBody)['dunlop/user_filter']
|
||||
schema.dunlopUserFilters.create(attributes)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export default [
|
||||
{id: 1, name: 'panda/action-list-1', scope_key: 'panda/action-list', filters: {a: 44}, is_default: false, desription: 'I describe<br>Filter1-2'}
|
||||
{id: 2, name: 'panda/action-list-2', scope_key: 'panda/action-list', filters: {a: 42}, is_default: true, desription: 'I describe<br>Filter1-1'}
|
||||
{id: 3, name: 'migration-adapter/blurp-1', scope_key: 'migration-adapter/blurp', filters: {a: 44}, is_default: true, desription: 'I describe<br>Filter2-1'}
|
||||
{id: 4, name: 'panda/project-1', scope_key: 'panda/project', filters: {a: 42}, is_default: true, desription: 'I describe<br>Filter1-1'}
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
scenario = (server) ->
|
||||
server.loadFixtures('dunlop-user-filters')
|
||||
|
||||
export default scenario
|
||||
@@ -1,9 +0,0 @@
|
||||
export default function(/* server */) {
|
||||
|
||||
/*
|
||||
Seed your development database using your factories.
|
||||
This data will not be loaded in your tests.
|
||||
*/
|
||||
|
||||
// server.createList('post', 10);
|
||||
}
|
||||
Reference in New Issue
Block a user