diff --git a/source/documents/partials/pick.html.jade b/source/documents/partials/pick.html.jade
index 2e5528f..4596207 100644
--- a/source/documents/partials/pick.html.jade
+++ b/source/documents/partials/pick.html.jade
@@ -1 +1,8 @@
-div Here you can pick which versions are displayed.
+table
+ tr
+ th Active
+ th(ng-repeat="(attribute, value) in poems[0].meta" ng-if="attribute != 'Active'" ng-bind-html="attribute")
+ tr(ng-repeat="poem in poems" ng-class="{disabled: !poem.meta.Active}")
+ td
+ input(type="checkbox" ng-model="poem.meta.Active")
+ td(ng-repeat="(attribute, value) in poem.meta" ng-if="attribute != 'Active'" ng-bind-html="value")
diff --git a/source/documents/scripts/app.js.coffee b/source/documents/scripts/app.js.coffee
index c42589a..ef5e4a4 100644
--- a/source/documents/scripts/app.js.coffee
+++ b/source/documents/scripts/app.js.coffee
@@ -3,6 +3,7 @@ angular.module('sideBySide', ['sideBySide.controllers', 'ngRoute', 'ngSanitize']
$routeProvider
.when '/:base?/pick', {
templateUrl: 'partials/pick.html'
+ controller: 'PickController'
}
.when '/:base?', {
templateUrl: 'partials/comparison.html'
diff --git a/source/documents/scripts/controllers.js.coffee b/source/documents/scripts/controllers.js.coffee
index 20dddec..6c94433 100644
--- a/source/documents/scripts/controllers.js.coffee
+++ b/source/documents/scripts/controllers.js.coffee
@@ -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
+]
diff --git a/source/documents/scripts/services/poems.js.coffee b/source/documents/scripts/services/poems.js.coffee
index c7931b4..acbc2bc 100644
--- a/source/documents/scripts/services/poems.js.coffee
+++ b/source/documents/scripts/services/poems.js.coffee
@@ -1,7 +1,8 @@
angular.module("sideBySide").service "poems", ['$q', 'fetch', ($q, fetch) ->
- all = []
- @active = [{
- meta: {}
+ @all = [{
+ meta: {
+ Active: true
+ }
content: [{
section: 'Loading...'
text: 'Please be patient!'
@@ -9,29 +10,18 @@ angular.module("sideBySide").service "poems", ['$q', 'fetch', ($q, fetch) ->
}]
@heading = undefined
- updateActive = () =>
- @active = (poem for poem in all when poem.meta.Active is true)
-
@load = (base = '') =>
config = base.replace(/\./g, '/') + "/config.json"
fetch(config).then (result) =>
$q.all(result.promises).then (results) =>
+ @all = []
for poem in results
if not poem.meta.Active?
poem.meta.Active = true
- all.push poem
+ @all.push poem
@heading = result.heading
- updateActive()
-
- @show = (id) ->
- all[id].meta.Active = true
- updateActive()
-
- @hide = (id) ->
- all[id].meta.Active = false
- updateActive()
@
]
diff --git a/source/documents/styles/style.css.styl b/source/documents/styles/style.css.styl
index 048baa5..fdc06a2 100644
--- a/source/documents/styles/style.css.styl
+++ b/source/documents/styles/style.css.styl
@@ -60,6 +60,9 @@ body
left: 0px
top: -6px
+.disabled
+ color: #997
+
max_columns = 6
for columns in 1 .. max_columns
.cols-{columns}