Moved show counters to directive (#8537)

* Moved show counters to directive

- hide counters on challenge page
- hide counters on group page

* Changed let to var
This commit is contained in:
Keith Holliday
2017-03-07 13:58:39 -07:00
committed by GitHub
parent 7f630f2b86
commit 28c93ea869
3 changed files with 16 additions and 4 deletions

View File

@@ -72,6 +72,18 @@
$scope.showChallengeList = function () { $scope.showChallengeList = function () {
return $state.includes("options.social.challenges"); return $state.includes("options.social.challenges");
}; };
$scope.showDoubleTaskCounter = function (task, obj) {
var objectIsGroup = obj.type && (obj.type === 'guild' || obj.type === 'party');
var objectIsChallenge = $state.includes("options.social.challenges");
return !objectIsGroup && !objectIsChallenge && task.up && task.down;
};
$scope.showSingleTaskCounter = function (task, obj) {
var objectIsGroup = obj.type && (obj.type === 'guild' || obj.type === 'party');
var objectIsChallenge = $state.includes("options.social.challenges");
return !objectIsGroup && !objectIsChallenge && task.type === "habit" && (!task.up || !task.down);
};
} }
} }
} }

View File

@@ -1,11 +1,11 @@
.task-meta-controls .task-meta-controls
// Counter // Counter
span(ng-if='task.up && task.down') span(ng-if='showDoubleTaskCounter(task, obj)')
span(tooltip=env.t('habitCounterUp')) +{{task.counterUp}}| span(tooltip=env.t('habitCounterUp')) +{{task.counterUp}}|
span(tooltip=env.t('habitCounterDown')) -{{task.counterDown}}  span(tooltip=env.t('habitCounterDown')) -{{task.counterDown}} 
span(ng-if='task.type=="habit" && (!task.up || !task.down)') span(ng-if='showSingleTaskCounter(task, obj)')
span(tooltip=env.t('habitCounter')) {{task.up ? task.counterUp : task.counterDown}}  span(tooltip=env.t('habitCounter')) {{task.up ? task.counterUp : task.counterDown}} 
// Due Date // Due Date

View File

@@ -5,7 +5,7 @@ script(id='templates/task-list.html', type="text/ng-template")
ng-if='showNormalList()') ng-if='showNormalList()')
task task
div(ng-init='setObj(obj); console.log(obj)') div(ng-init='setObj(obj);')
div( div(
ng-repeat="(key, taskList) in groupedList[list.type]", ng-repeat="(key, taskList) in groupedList[list.type]",
ng-if='user.preferences.tasks.groupByChallenge && !$state.includes("options.social.challenges")') ng-if='user.preferences.tasks.groupByChallenge && !$state.includes("options.social.challenges")')