Skip to content

Commit

Permalink
Final attempt at generalization for now
Browse files Browse the repository at this point in the history
- Create a "Config" in the top-level survey module for the multi-label survey
- Switch the list views to use the configurations to figure the service and filters
- Switch the HTML to use the configurations to the extent possible. This extent
  is the linkedtag attribute of the `verifycheck` element. Alas, we can't
  appear to set the element directive tag name directly (see )
    e-mission/e-mission-docs#674 (comment)
    to
    e-mission/e-mission-docs#674 (comment)

+ move the one-click `verifycheck` button outside of `multilabel` since it is explicitly designed for use with other kinds of surveys as well
  • Loading branch information
shankari committed Oct 5, 2021
1 parent 5ac9e71 commit 3d315a3
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 9 deletions.
2 changes: 1 addition & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
<script src="js/main.js"></script>
<script src="js/recent.js"></script>
<script src="js/survey/survey.js"></script>
<script src="js/survey/one-click-button.js"></script>
<script src="js/incident/post-trip-manual.js"></script>
<script src="js/survey/multilabel/infinite_scroll_filters.js"></script>
<script src="js/survey/multilabel/post-trip-prompt.js"></script>
<script src="js/survey/multilabel/post-trip-map-display.js"></script>
<script src="js/survey/multilabel/trip-confirm-services.js"></script>
<script src="js/survey/multilabel/multi-label-ui.js"></script>
<script src="js/survey/multilabel/one-click-button.js"></script>
<script src="js/diary.js"></script>
<script src="js/diary/list.js"></script>
<script src="js/diary/infinite_scroll_list.js"></script>
Expand Down
7 changes: 4 additions & 3 deletions www/js/diary/infinite_scroll_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@ angular.module('emission.main.diary.infscrolllist',['ui-leaflet',
$ionicLoading,
$ionicActionSheet,
$timeout,
ionicDatePicker,
leafletData, Timeline, CommonGraph, DiaryHelper,
SurveyOptions,
Config, PostTripManualMarker, nzTour, KVStore, Logger, UnifiedDataLoader, $ionicPopover, $ionicModal, $translate) {

// TODO: load only a subset of entries instead of everything

console.log("controller InfiniteDiaryListCtrl called");
$scope.surveyOpt = SurveyOptions.MULTILABEL;
// Add option

const placeLimiter = new Bottleneck({ maxConcurrent: 2, minTime: 500 });

$scope.data = {};
$scope.tripFilterFactory = $injector.get("InfScrollFilters");
$scope.tripFilterFactory = $injector.get($scope.surveyOpt.filter);
$scope.filterInputs = $scope.tripFilterFactory.configuredFilters;

$scope.labelPopulateFactory = $injector.get("MultiLabelService");
$scope.labelPopulateFactory = $injector.get($scope.surveyOpt.service);

$scope.getActiveFilters = function() {
return $scope.filterInputs.filter(sf => sf.state).map(sf => sf.key);
Expand Down
4 changes: 3 additions & 1 deletion www/js/diary/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ angular.module('emission.main.diary.list',['ui-leaflet',
$ionicActionSheet,
ionicDatePicker,
leafletData, Timeline, CommonGraph, DiaryHelper,
SurveyOptions,
Config, PostTripManualMarker, nzTour, KVStore, Logger, UnifiedDataLoader, $ionicPopover, $translate) {
console.log("controller DiaryListCtrl called");
$scope.surveyOpt = SurveyOptions.MULTILABEL;
ClientStats.addReading(ClientStats.getStatKeys().LABEL_TAB_SWITCH,
{"source": null, "dest": $scope.data? $scope.data.currDay : undefined});
// Add option
$scope.labelPopulateFactory = $injector.get("MultiLabelService");
$scope.labelPopulateFactory = $injector.get($scope.surveyOpt.service);

var readAndUpdateForDay = function(day) {
// This just launches the update. The update can complete in the background
Expand Down
4 changes: 2 additions & 2 deletions www/js/survey/multilabel/one-click-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ angular.module('emission.survey.multilabel.verifycheck',
invokedfrom: "="
},
controller: "OneClickButtonCtrl",
templateUrl: 'templates/survey/multilabel/one-click-button.html'
templateUrl: 'templates/survey/one-click-button.html'
};
})
.controller("OneClickButtonCtrl", function($scope, $element, $attrs) {
var findLinkedLabelScope = function() {
console.log("$element is ", $element);
console.log("$element is ", $element, "linkedtag is ",$scope.linkedTag);
console.log("parent row is", $element.parents("ion-item"));
let rowElement = $element.parents("ion-item")
console.log("row Element is", rowElement);
Expand Down
32 changes: 32 additions & 0 deletions www/js/survey/one-click-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
angular.module('emission.survey.multilabel.verifycheck',
['emission.survey.multilabel.services',
'emission.main.diary.services'])
.directive('verifycheck', function($timeout) {
return {
scope: {
linkedtag: "@",
trip: "=",
invokedfrom: "="
},
controller: "OneClickButtonCtrl",
templateUrl: 'templates/survey/multilabel/one-click-button.html'
};
})
.controller("OneClickButtonCtrl", function($scope, $element, $attrs) {
var findLinkedLabelScope = function() {
console.log("$element is ", $element, "linkedtag is ",$scope.linkedTag);
console.log("parent row is", $element.parents("ion-item"));
let rowElement = $element.parents("ion-item")
console.log("row Element is", rowElement);
let linkedlabel = rowElement.find($scope.linkedtag);
console.log("child linkedlabel is", linkedlabel);
let linkedlabelScope = angular.element(linkedlabel).isolateScope();
console.log("linkedlabel scope is", linkedlabelScope);
return linkedlabelScope;
};

$scope.verifyTrip = function() {
let linkedLabelScope = findLinkedLabelScope();
linkedLabelScope.verifyTrip();
}
});
6 changes: 6 additions & 0 deletions www/js/survey/survey.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
angular.module('emission.survey', [
"emission.survey.external.launch",
"emission.survey.multilabel.buttons",
"emission.survey.multilabel.verifycheck",
"emission.survey.multilabel.infscrollfilters",
])

.factory("SurveyOptions", function() {
var surveyoptions = {};
console.log("This is currently a NOP; we load the individual components dynamically");
surveyoptions.MULTILABEL = {
filter: "InfScrollFilters",
service: "MultiLabelService",
elementTag: "multilabel"
}

return surveyoptions;
});
2 changes: 1 addition & 1 deletion www/templates/diary/infinite_scroll_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h3 ng-if="!infScrollControl.reachedEnd">{{'diary.scroll-to-load-more' | transla
{{trip.end_display_name}}
</div>
</div>
<verifycheck linkedtag="multilabel" trip="trip"
<verifycheck linkedtag="{{surveyOpt.elementTag}}" trip="trip"
class="col-10 diarycheckmark-container center-vert center-horiz"></verifycheck>
</div>
<div class="row" style="margin-top: 0px">
Expand Down
2 changes: 1 addition & 1 deletion www/templates/diary/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
</div>
</div>
<div class="col-10 center-vert center-horiz">
<verifycheck linkedtag="multilabel" trip="trip" invokedfrom="diary" class="row"></verifycheck>
<verifycheck linkedtag="{{surveyOpt.elementTag}}" trip="trip" invokedfrom="diary" class="row"></verifycheck>
</div>
</div>
</div>
Expand Down
File renamed without changes.

0 comments on commit 3d315a3

Please sign in to comment.