diff --git a/www/index.html b/www/index.html index 0d0c19f00..99aae8c85 100644 --- a/www/index.html +++ b/www/index.html @@ -79,13 +79,13 @@ + - diff --git a/www/js/diary/infinite_scroll_list.js b/www/js/diary/infinite_scroll_list.js index f1455ca57..7c8b851ec 100644 --- a/www/js/diary/infinite_scroll_list.js +++ b/www/js/diary/infinite_scroll_list.js @@ -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); diff --git a/www/js/diary/list.js b/www/js/diary/list.js index f77dc9ca1..ad8a008ca 100644 --- a/www/js/diary/list.js +++ b/www/js/diary/list.js @@ -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 diff --git a/www/js/survey/multilabel/one-click-button.js b/www/js/survey/multilabel/one-click-button.js index a31074c6a..0426585a6 100644 --- a/www/js/survey/multilabel/one-click-button.js +++ b/www/js/survey/multilabel/one-click-button.js @@ -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); diff --git a/www/js/survey/one-click-button.js b/www/js/survey/one-click-button.js new file mode 100644 index 000000000..cb8ac73a5 --- /dev/null +++ b/www/js/survey/one-click-button.js @@ -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(); + } +}); diff --git a/www/js/survey/survey.js b/www/js/survey/survey.js index 053b1a196..95fa6fb33 100644 --- a/www/js/survey/survey.js +++ b/www/js/survey/survey.js @@ -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; }); diff --git a/www/templates/diary/infinite_scroll_list.html b/www/templates/diary/infinite_scroll_list.html index f950c85f7..689c8efb3 100644 --- a/www/templates/diary/infinite_scroll_list.html +++ b/www/templates/diary/infinite_scroll_list.html @@ -72,7 +72,7 @@