Skip to content

Commit

Permalink
feat(citizenScienceLabels): implement selected label for examples out…
Browse files Browse the repository at this point in the history
…side of label component
  • Loading branch information
peichins committed May 17, 2017
1 parent 23dc426 commit 35b6568
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 25 deletions.
7 changes: 0 additions & 7 deletions src/app/citizenScience/thumbLabels/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,8 @@ angular.module("bawApp.components.citizenScienceThumbLabels.examples",

$scope.$watch("currentExample", function (newVal, oldVal) {



console.log("self.examples[$scope.currentExample].annotation",self.examples[$scope.currentExample].annotation);






});


Expand Down
30 changes: 23 additions & 7 deletions src/app/citizenScience/thumbLabels/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,43 @@ angular.module("bawApp.components.citizenScienceThumbLabels.label",

var self = this;

$scope.selected = false;



$scope.toggleSelected = function () {
var newVal = !self.showInfo;
self.onToggleShowInfo(self.labelNum);
self.showInfo = newVal;

console.log("toggling state for label number", self.labelNum);

//$scope.selected = self.onToggleSelected(self.labelNum);

if (self.selectedLabelNum.value === self.labelNum) {
self.selectedLabelNum.value = -1;
$scope.selected = false;
} else {
self.selectedLabelNum.value = self.labelNum;
$scope.selected = true;
}

};

}],
bindings: {

// tags that this event type are associated with
tags: "=tags",
tags: "=",

// the label for this thumb (friendly name for label)
name: "=",

examples: "<",

labelNum: "<",

// whether this thumb is currently selected for more info
showInfo: "=",
onToggleSelected: "<",

selectedLabelNum: "="

onToggleShowInfo: "<"

}
});
3 changes: 2 additions & 1 deletion src/app/citizenScience/thumbLabels/label.tpl.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class="citizen-science-thumb-label" ng-class="{selected : ($ctrl.showInfo)}">
<div class="citizen-science-thumb-label" ng-class="{selected : selected}">

<!-- stuff to show thumb image -->
image
<div class="citizen-science-thumb" ng-click="toggleSelected()">
<img ng-src="{{$ctrl.examples[0].annotation.media.available.image.png.url}}" alt="{{$ctrl.label}}">
</div>
Expand Down
22 changes: 15 additions & 7 deletions src/app/citizenScience/thumbLabels/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,27 @@ angular.module("bawApp.components.citizenScienceThumbLabels",

var self = this;

$scope.selectedLabelNum = {value: -1};

$scope.$watch(function () {
return self.labels;
}, function (newVal, oldVal) {
self.fetchAnnotationData(newVal);
$scope.onToggleSelected = function (labelNum) {
console.log("onToggleSelected", labelNum);

self.hideAllLabelInfos();
if ($scope.selectedLabelNum.value === labelNum) {
$scope.selectedLabelNum.value = -1;
} else {
$scope.selectedLabelNum.value = labelNum;
}

});
//$scope.$broadcast('selected-label-num-changed', $scope.selectedLabelNum);

};


$scope.$watch(function () {
return self.labels;
}, function (newVal, oldVal) {
self.fetchAnnotationData(newVal);
});

/**
* fetches site/project/media data for all label examples
Expand All @@ -52,7 +61,6 @@ angular.module("bawApp.components.citizenScienceThumbLabels",

var annotations = [];


AudioEventService
.getAudioEventsByIds(annotationIds)
.then(function (response) {
Expand Down
7 changes: 4 additions & 3 deletions src/app/citizenScience/thumbLabels/labels.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
ng-if="label.examples.length"
tags="label.tags"
name="label.name"
examples="label.examples"
label-num="key"
show-info="label.showInfo"
on-toggle-show-info="$ctrl.hideAllLabelInfos"></citizen-science-label>
selected-label-num="selectedLabelNum"
on-toggle-selected="onToggleSelected"></citizen-science-label>


<citizen-science-label-examples
examples="$ctrl.labels[selectedLabel].examples" ng-if="selectedLabel > -1" ></citizen-science-label-examples>
examples="$ctrl.labels[selectedLabelNum.value].examples" ng-if="selectedLabelNum > -1" ></citizen-science-label-examples>

</div>

0 comments on commit 35b6568

Please sign in to comment.