author | nowmad@nowmads-macbook-pro.local |
Wed, 20 Jan 2016 23:51:55 +0100 | |
changeset 92 | 3437f5191645 |
parent 91 | acfeddc7821d |
child 194 | 02c6aa9a99d7 |
permissions | -rw-r--r-- |
42
7d091abf82fd
add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
1 |
import Ember from 'ember'; |
7d091abf82fd
add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
2 |
|
7d091abf82fd
add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
3 |
export default Ember.Route.extend({ |
92 | 4 |
serializeQueryParam: function(value, urlKey) { |
81
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
5 |
if (urlKey === 'date') { |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
6 |
return value; |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
7 |
} |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
8 |
return '' + value; |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
9 |
}, |
92 | 10 |
deserializeQueryParam: function(value, urlKey) { |
81
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
11 |
if (urlKey === 'date') { |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
12 |
var arr = []; |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
13 |
for (var i = 0; i < value.length; i++) { |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
14 |
arr.push(parseInt(value[i])); |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
15 |
} |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
16 |
return arr; |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
17 |
} |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
18 |
|
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
19 |
return value; |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
74
diff
changeset
|
20 |
}, |
42
7d091abf82fd
add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
21 |
model() { |
91
acfeddc7821d
rename "sound" to "document"
nowmad@nowmads-macbook-pro.local
parents:
81
diff
changeset
|
22 |
return this.store.findAll('document'); |
74
2bd46d0b2c80
Propagate the current query param to the new route (necessary when the route change comes from outside the app)
nowmad@23.1.168.192.in-addr.arpa
parents:
42
diff
changeset
|
23 |
}, |
2bd46d0b2c80
Propagate the current query param to the new route (necessary when the route change comes from outside the app)
nowmad@23.1.168.192.in-addr.arpa
parents:
42
diff
changeset
|
24 |
actions: { |
92 | 25 |
willTransition: function() { |
74
2bd46d0b2c80
Propagate the current query param to the new route (necessary when the route change comes from outside the app)
nowmad@23.1.168.192.in-addr.arpa
parents:
42
diff
changeset
|
26 |
var _this = this; |
2bd46d0b2c80
Propagate the current query param to the new route (necessary when the route change comes from outside the app)
nowmad@23.1.168.192.in-addr.arpa
parents:
42
diff
changeset
|
27 |
var queryParams = {}; |
92 | 28 |
this.controller.get('queryParams').map(function(elt){ |
74
2bd46d0b2c80
Propagate the current query param to the new route (necessary when the route change comes from outside the app)
nowmad@23.1.168.192.in-addr.arpa
parents:
42
diff
changeset
|
29 |
queryParams[elt] = _this.controller.get(elt); |
2bd46d0b2c80
Propagate the current query param to the new route (necessary when the route change comes from outside the app)
nowmad@23.1.168.192.in-addr.arpa
parents:
42
diff
changeset
|
30 |
}); |
2bd46d0b2c80
Propagate the current query param to the new route (necessary when the route change comes from outside the app)
nowmad@23.1.168.192.in-addr.arpa
parents:
42
diff
changeset
|
31 |
this.transitionTo({ queryParams: queryParams }); |
2bd46d0b2c80
Propagate the current query param to the new route (necessary when the route change comes from outside the app)
nowmad@23.1.168.192.in-addr.arpa
parents:
42
diff
changeset
|
32 |
} |
42
7d091abf82fd
add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
33 |
} |
7d091abf82fd
add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
34 |
}); |