Skip to content

Commit

Permalink
feat(citizenScienceExamples): load labels from google sheet, rather t…
Browse files Browse the repository at this point in the history
…han hardcoded
  • Loading branch information
peichins committed Feb 16, 2017
1 parent 0eb30eb commit f1333aa
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 34 deletions.
62 changes: 37 additions & 25 deletions src/app/citizenScience/bristlebird/bristlebird.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,34 @@ class BristlebirdController {

/**
* Labels that the user can select.
* applies one or more tags which are not shown to the user
* applies one or more tags which are not shown to the user.
* example response from server
* [{
* "tags": ["ebb", "type1"],
* "label": "Eastern Bristlebird",
* "examples": [{
* "annotationId": 124730
* },{
* "annotationId": 124727
* },{
* "annotationId": 98378
* }]
* },
* {
* "tags": ["ground_parrot", "type1"],
* "label": "Ground Parrot",
* "examples": [{
* "annotationId": 124622
* }]
* },
* {
* "tags": ["quoll", "type1"],
* "label": "Spotted Quoll",
* "examples": []
* }];
*/
$scope.labels = [{
"tags": ["ebb", "type1"],
"label": "Eastern Bristlebird",
"examples": [{
"annotationId": 124730
},{
"annotationId": 124727
},{
"annotationId": 98378
}]
},
{
"tags": ["ground_parrot", "type1"],
"label": "Ground Parrot",
"examples": [{
"annotationId": 124622
}]
},
{
"tags": ["quoll", "type1"],
"label": "Spotted Quoll",
"examples": []
}];

$scope.labels = [];

self.getSamples = CitizenScienceCommon.bindGetSamples($scope);

Expand All @@ -91,7 +94,16 @@ class BristlebirdController {

this.showAudio = CitizenScienceCommon.bindShowAudio($scope);


$http.get(CitizenScienceCommon.apiUrl(
"labels",
$scope.csProject
)).then(function (response) {
if (Array.isArray(response.data)) {
$scope.labels = response.data;
} else {
$scope.labels = [];
}
});



Expand Down
2 changes: 2 additions & 0 deletions src/app/citizenScience/examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ angular.module("bawApp.components.citizenScienceExample", ["bawApp.citizenScienc

console.log("hello example");

$scope.myName = "example";

var self = this;

// based on stuff in library item. may be able to make this more DRY
Expand Down
23 changes: 14 additions & 9 deletions src/app/citizenScience/examples/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@ angular.module("bawApp.components.citizenScienceExamples", ["bawApp.citizenScien
};


/**
* Initialize current example for all labels
*/
self.labels.forEach(function (label, index) {

if (label.examples.length) {
label.curExample = 0;
} else {
label.curExample = -1;
$scope.$watch(function () { return self.labels; }, function (newValue, oldValue) {

if (Array.isArray(newValue)) {
self.labels.forEach(function (label, index) {

if (label.examples.length) {
label.curExample = 0;
} else {
label.curExample = -1;
}

});
}



});


Expand Down

0 comments on commit f1333aa

Please sign in to comment.