-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(citSci): fixed text label component for use with binary label qu…
…estion
- Loading branch information
Showing
16 changed files
with
223 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
angular.module("bawApp.components.citizenScienceTextLabels.label", | ||
[ | ||
"bawApp.citizenScience.sampleLabels" | ||
]) | ||
.component("citizenScienceTextLabel", { | ||
templateUrl: "citizenScience/labels/textLabels/label.tpl.html", | ||
controller: [ | ||
"$scope", | ||
"SampleLabels", | ||
function ($scope, SampleLabels) { | ||
|
||
var self = this; | ||
|
||
$scope.isSelected = function() { | ||
return SampleLabels.getValue(self.label.id); | ||
}; | ||
|
||
/** | ||
* callback when this label is either attached or detached from the current sample | ||
* @param isSelected Boolean | ||
*/ | ||
self.onToggleSelected = function (isSelected) { | ||
SampleLabels.setValue(isSelected, self.label.id); | ||
}; | ||
|
||
}], | ||
bindings: { | ||
label: "=", | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<label-check | ||
is-checked="isSelected" | ||
on-toggle-selected="$ctrl.onToggleSelected" | ||
text="$ctrl.label.name" | ||
></label-check> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,80 @@ | ||
angular.module("bawApp.components.citizenScienceTextLabels", ["bawApp.citizenScience.common"]) | ||
angular.module("bawApp.components.citizenScienceTextLabels", | ||
[ | ||
"bawApp.components.citizenScienceTextLabels.label", | ||
"bawApp.citizenScience.sampleLabels" | ||
]) | ||
.component("citizenScienceTextLabels", { | ||
templateUrl: "citizenScience/labels/textLabels/labels.tpl.html", | ||
controller: [ | ||
"$scope", | ||
"$http", | ||
"CitizenScienceCommon", | ||
function ($scope, $http, CitizenScienceCommon) { | ||
"SampleLabels", | ||
function ($scope, SampleLabels) { | ||
//console.log("dataset progress component scope");console.log($scope); | ||
|
||
var self = this; | ||
|
||
/** | ||
* Add or remove the lable num to the list of selected labels for this sample | ||
* Send the new set of labels to the dataset | ||
* Note, we can't guarantee the order that the api calls will reach the google sheet. | ||
* if the user adds and removes a label in quick succession, they might arrive out of order | ||
* resulting in the wrong labels being applied. | ||
* @param label string | ||
*/ | ||
$scope.toggleLabel = function (labelNum) { | ||
console.log(self); | ||
|
||
var currentSample = self.samples[self.currentSampleNum]; | ||
//////////////// | ||
|
||
currentSample.labels[labelNum] = !currentSample.labels[labelNum]; | ||
|
||
currentSample.done = true; | ||
|
||
var tags = self.labels.filter(function (value, index) { | ||
return currentSample.labels[index]; | ||
}).map(function (value) { | ||
return value.tags; | ||
}); | ||
|
||
var url = CitizenScienceCommon.apiUrl("setLabels", | ||
self.csProject, | ||
currentSample.name, | ||
currentSample.recordingId, | ||
currentSample.startOffset, | ||
CitizenScienceCommon.labelsAsString(tags)); | ||
$http.get(url).then(function (response) { | ||
console.log(response.data); | ||
}); | ||
//////////////// | ||
|
||
}; | ||
|
||
/** | ||
* Whether the label has been attached to the current sample | ||
* @param label Object | ||
* @returns Boolean | ||
*/ | ||
$scope.labelSelected = function (labelNum) { | ||
if(self.currentSampleNum === -1) { | ||
return false; | ||
} | ||
var currentSample = self.samples[self.currentSampleNum]; | ||
|
||
return currentSample.labels[labelNum]; | ||
|
||
}; | ||
|
||
/** | ||
* Toggles whether the examples are showing for the given label number | ||
* hides examples from other labels. | ||
* TODO: move this into examples component | ||
* @param key int | ||
*/ | ||
$scope.toggleShowExamples = function (key) { | ||
self.labels.forEach(function (el, index) { | ||
if (index !== key) { | ||
el.showExamples = false; | ||
} else if (el.hasOwnProperty("showExamples")) { | ||
el.showExamples = !el.showExamples; | ||
} else { | ||
el.showExamples = true; | ||
} | ||
}); | ||
}; | ||
// /** | ||
// * Add or remove the lable num to the list of selected labels for this sample | ||
// * Send the new set of labels to the dataset | ||
// * Note, we can't guarantee the order that the api calls will reach the google sheet. | ||
// * if the user adds and removes a label in quick succession, they might arrive out of order | ||
// * resulting in the wrong labels being applied. | ||
// * @param label string | ||
// */ | ||
// $scope.toggleLabel = function (labelNum) { | ||
// | ||
// var currentSample = self.samples[self.currentSampleNum]; | ||
// | ||
// currentSample.labels[labelNum] = !currentSample.labels[labelNum]; | ||
// | ||
// currentSample.done = true; | ||
// | ||
// var tags = self.labels.filter(function (value, index) { | ||
// return currentSample.labels[index]; | ||
// }).map(function (value) { | ||
// return value.tags; | ||
// }); | ||
// | ||
// var url = CitizenScienceCommon.apiUrl("setLabels", | ||
// self.csProject, | ||
// currentSample.name, | ||
// currentSample.recordingId, | ||
// currentSample.startOffset, | ||
// CitizenScienceCommon.labelsAsString(tags)); | ||
// $http.get(url).then(function (response) { | ||
// console.log(response.data); | ||
// }); | ||
// | ||
// }; | ||
// | ||
// /** | ||
// * Whether the label has been attached to the current sample | ||
// * @param label Object | ||
// * @returns Boolean | ||
// */ | ||
// $scope.labelSelected = function (labelNum) { | ||
// if(self.currentSampleNum === -1) { | ||
// return false; | ||
// } | ||
// var currentSample = self.samples[self.currentSampleNum]; | ||
// | ||
// return currentSample.labels[labelNum]; | ||
// | ||
// }; | ||
// | ||
|
||
|
||
}], | ||
bindings: { | ||
labels: "=labels", | ||
samples: "=samples", | ||
currentSampleNum: "=currentSampleNum", | ||
csProject: "=csProject" | ||
labels: "=labels" | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
<div id="label-buttons"> | ||
<span ng-repeat="(key,label) in $ctrl.labels" ng-class="{selected : (labelSelected(key) > -1)}"> | ||
<a ng-click="toggleLabel(key)" class="main-button"> | ||
<i class="fa" | ||
ng-class="{true: 'fa-check-square-o', false : 'fa-square-o'}[labelSelected(key)]" | ||
aria-hidden="true"></i><span>{{label.label}}</span> | ||
<a><a class="fa fa-eye example-toggle" aria-hidden="true" ng-click="toggleShowExamples(key)" ng-class="{selected : (label.showExamples)}" ng-if="label.examples.length"></a> | ||
</span> | ||
<citizen-science-text-label | ||
ng-repeat="label in $ctrl.labels" | ||
label="label" | ||
></citizen-science-text-label> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<div class="thumb-labels-container"> | ||
|
||
<citizen-science-label | ||
<citizen-science-thumb-label | ||
ng-repeat="label in $ctrl.labels" | ||
class="label-thumbs" | ||
ng-if="label.examples.length" | ||
label="label" | ||
current-details-label-id="currentDetailsLabelId" | ||
|
||
></citizen-science-label> | ||
></citizen-science-thumb-label> | ||
|
||
</div> | ||
|
Oops, something went wrong.