mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-07 17:10:46 +08:00
Assemble correct display url part
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
angular.module("sideBySide").service "poems", ['fetch', (fetch) ->
|
||||
angular.module("sideBySide").service "poems", ['fetch', 'route', (fetch, route) ->
|
||||
@all = [{
|
||||
meta: {
|
||||
Active: true
|
||||
@@ -36,7 +36,8 @@ angular.module("sideBySide").service "poems", ['fetch', (fetch) ->
|
||||
@load = (base) =>
|
||||
fetch(base).then (config) =>
|
||||
config.fetchPoems.then (poems) =>
|
||||
@all = (activize(poem, config.display) for poem in poems)
|
||||
display = route.params.display or config.display
|
||||
@all = (activize(poem, display) for poem in poems)
|
||||
@heading = config.heading
|
||||
|
||||
@
|
||||
|
||||
@@ -22,9 +22,16 @@ angular.module("sideBySide").service "route", ['$location', ($location) ->
|
||||
@appUrl = $location.absUrl()
|
||||
.substring(0, $location.absUrl().length - $location.url().length)
|
||||
|
||||
getValue = (value) ->
|
||||
if (typeof value == 'object')
|
||||
for key, val of value
|
||||
# only works for one key...
|
||||
return key + ":" + val.join(',')
|
||||
value
|
||||
|
||||
@update = (key, value) ->
|
||||
@params[key] = value
|
||||
$location.path (property + ':' + value for property, value of @params).join('/')
|
||||
$location.path (property + ':' + getValue(value) for property, value of @params).join('/')
|
||||
|
||||
@
|
||||
]
|
||||
|
||||
@@ -2,7 +2,10 @@ poems = {}
|
||||
|
||||
module "poems", {
|
||||
setup: () ->
|
||||
poems = injector.get "poems"
|
||||
angular.module("sideBySide").service("route", () ->
|
||||
@params = { 'display': 'asdf' }
|
||||
)
|
||||
poems = angular.injector(['ng', 'sideBySide']).get('poems')
|
||||
}
|
||||
|
||||
test "has default content", () ->
|
||||
|
||||
Reference in New Issue
Block a user