-
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): reorganised folder structure for label components
- Loading branch information
Showing
24 changed files
with
137 additions
and
252 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,43 @@ | ||
// var csLabels = angular.module("bawApp.citizenScience.csLabels", ["bawApp.citizenScience.common"]); | ||
// | ||
// | ||
// /** | ||
// * Manages the data for labels that will be applied to cs samples | ||
// */ | ||
// csLabels.factory("CsLabels", [ | ||
// "CitizenScienceCommon", | ||
// "$http", | ||
// function CsLabels(CitizenScienceCommon, $http) { | ||
// | ||
// var self = this; | ||
// self.useLocalData = true; | ||
// self.sheets_api_url = "http://" + window.location.hostname + ":8081"; | ||
// self.local_api_url = "/public/citizen_science"; | ||
// | ||
// | ||
// /** | ||
// * Constructs a url for the request by concatenating the arguments, joined by "/" | ||
// * and appending to the relevant baseURL. Allows experimenting with different sources | ||
// * for the data without changing everything | ||
// * @returns {string|*} | ||
// */ | ||
// self.apiUrl = function () { | ||
// // convert to array | ||
// var base_url, url; | ||
// if (self.useLocalData) { | ||
// base_url = self.local_api_url; | ||
// } else { | ||
// base_url = self.sheets_api_url; | ||
// } | ||
// var args = Array.prototype.slice.call(arguments); | ||
// | ||
// url = [base_url].concat(args).join("/"); | ||
// | ||
// if (self.useLocalData) { | ||
// url = url + ".json"; | ||
// } | ||
// | ||
// return url; | ||
// }; | ||
// | ||
// | ||
// self.publicFunctions = { | ||
// | ||
// | ||
// /** | ||
// * Gets all labels associated with the specified citizen science project | ||
// * @param project string | ||
// */ | ||
// getLabels: function (project) { | ||
// var response = $http.get(self.apiUrl( | ||
// "labels", | ||
// project | ||
// )); | ||
// | ||
// return response.then(function (response) { | ||
// var labels = []; | ||
// if (Array.isArray(response.data)) { | ||
// labels = response.data; | ||
// } | ||
// | ||
// return labels; | ||
// }); | ||
// }, | ||
// | ||
// }; | ||
// | ||
// return self.publicFunctions; | ||
// | ||
// }]); | ||
// | ||
// | ||
var csLabels = angular.module("bawApp.citizenScience.csLabels", [ | ||
"bawApp.citizenScience.common", | ||
"bawApp.components.citizenScienceYesnoLabels", | ||
"bawApp.components.citizenScienceThumbLabels", | ||
"bawApp.citizenScience.sampleLabels" | ||
]); | ||
|
||
|
||
csLabels.component("citizenScienceLabels", { | ||
templateUrl: "citizenScience/labels/labels.tpl.html", | ||
controller: [ | ||
"$scope", | ||
"SampleLabels", | ||
function ($scope, SampleLabels) { | ||
|
||
var self = this; | ||
|
||
console.log(self); | ||
|
||
$scope.$watch(SampleLabels.getLabels, function (newVal, oldVal) { | ||
|
||
if (typeof(newVal) === "object") { | ||
if (newVal === 1) { | ||
$scope.labelType = "yesno"; | ||
} else if (newVal.length > 0 && | ||
newVal.every(l => l.hasOwnProperty("examples") && l.examples.length > 0 )) { | ||
// if all labels have an example | ||
$scope.labelType = "thumb"; | ||
} else { | ||
// this is not yet implemented but should be just a list of checkboxes next to the label text string | ||
$scope.labelType = "text"; | ||
} | ||
|
||
$scope.labels = newVal; | ||
} | ||
|
||
}, true); | ||
|
||
}], | ||
bindings: { | ||
} | ||
}); | ||
|
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,12 @@ | ||
|
||
|
||
|
||
<citizen-science-thumb-labels ng-if="labelType=='thumb'" labels="labels"></citizen-science-thumb-labels> | ||
<!-- | ||
<citizen-science-yesno-labels ng-if="labelType=='yesno'" question-data="questionData"></citizen-science-yesno-labels> | ||
--> | ||
|
||
|
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...p/citizenScience/textLabels/labelCheck.js → ...enScience/labels/textLabels/labelCheck.js
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/app/citizenScience/textLabels/labels.js → ...itizenScience/labels/textLabels/labels.js
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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,13 @@ | ||
<div class="thumb-labels-container"> | ||
|
||
<citizen-science-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> | ||
|
||
</div> | ||
|
File renamed without changes.
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,34 @@ | ||
angular.module("bawApp.components.citizenScienceYesnoLabels", | ||
[ | ||
]) | ||
.component("citizenScienceYesnoLabels", { | ||
templateUrl: "citizenScience/labels/yesnoLabels/labels.tpl.html", | ||
controller: [ | ||
"$scope", | ||
"SampleLabels", | ||
function ($scope, SampleLabels) { | ||
|
||
var self = this; | ||
// yesno questions only have one label | ||
$scope.label = self.questionData.labels[0].name; | ||
|
||
// binary can have 3 statuses: selected yes, selected no or not selected | ||
|
||
$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(self.label.id, isSelected); | ||
}; | ||
|
||
|
||
}], | ||
bindings: { | ||
questionData: "=", | ||
} | ||
}); |
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 @@ | ||
<div class="yesno-labels-container"> | ||
|
||
|
||
</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 was deleted.
Oops, something went wrong.
Oops, something went wrong.