mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-23 13:50:24 +08:00
Add pickings and simplify poems service
This commit is contained in:
@@ -1,26 +1,38 @@
|
||||
angular.module("sideBySide.controllers", [])
|
||||
.controller "AppController", [
|
||||
'$routeParams', '$scope', 'poems'
|
||||
($routeParams, $scope, poems) ->
|
||||
'$location', '$scope', 'poems'
|
||||
($location, $scope, poems) ->
|
||||
$scope.$on "$routeChangeSuccess", ($currentRoute, $previousRoute) ->
|
||||
$scope.base = if $previousRoute.params.base \
|
||||
then '/' + $previousRoute.params.base
|
||||
else ''
|
||||
|
||||
poems.load $routeParams.base
|
||||
base = $location.url().replace(/\/(.*)\/.*/, '$1')
|
||||
poems.load base
|
||||
]
|
||||
|
||||
.controller "ComparisonController", [
|
||||
'$scope', 'poems', 'transformer'
|
||||
($scope, poems, transformer) ->
|
||||
$scope.$watch () ->
|
||||
poems.active.length
|
||||
(poem for poem in poems.all when poem.meta.Active is true).length
|
||||
, () ->
|
||||
$scope.columns = poems.active.length
|
||||
transformed = transformer(poems.active)
|
||||
active = (poem for poem in poems.all when poem.meta.Active is true)
|
||||
|
||||
$scope.columns = active.length
|
||||
transformed = transformer(active)
|
||||
$scope.verses = transformed.verses
|
||||
$scope.meta = transformed.meta
|
||||
|
||||
headingKey = poems.heading or "Author"
|
||||
$scope.headings = (version[headingKey] for version in transformed.meta)
|
||||
]
|
||||
|
||||
.controller "PickController", [
|
||||
'$scope', 'poems'
|
||||
($scope, poems) ->
|
||||
$scope.$watch () ->
|
||||
(poem for poem in poems.all when poem.meta.Active is true).length
|
||||
, () ->
|
||||
$scope.poems = poems.all
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user