mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Ported over UI code
This commit is contained in:
@@ -3,6 +3,58 @@
|
||||
habitrpg.controller('NotificationCtrl',
|
||||
['$scope', '$rootScope', 'Shared', 'Content', 'User', 'Guide', 'Notification', 'Analytics', 'Achievement', 'Social', 'Tasks',
|
||||
function ($scope, $rootScope, Shared, Content, User, Guide, Notification, Analytics, Achievement, Social, Tasks) {
|
||||
$scope.yesterDailiesModalOpen = false;
|
||||
$rootScope.$watch('user.yesterDailies', function (after, before) {
|
||||
if (!after || after.length === 0 || $scope.yesterDailiesModalOpen) return;
|
||||
|
||||
var yesterDailies = [];
|
||||
after.forEach(function (taskId) {
|
||||
var dailyFound = _.find(User.user.dailys, function (task) {
|
||||
return taskId === task._id;
|
||||
});
|
||||
|
||||
if (dailyFound && dailyFound.group.approval && dailyFound.group.approval.requested) return;
|
||||
if (dailyFound) yesterDailies.push(dailyFound);
|
||||
});
|
||||
|
||||
if (yesterDailies.length === 0) return;
|
||||
|
||||
var modalScope = $rootScope.$new();
|
||||
modalScope.obj = User.user;
|
||||
modalScope.taskList = yesterDailies;
|
||||
modalScope.list = {
|
||||
showCompleted: false,
|
||||
type: 'daily',
|
||||
};
|
||||
|
||||
$scope.yesterDailiesModalOpen = true;
|
||||
$rootScope.openModal('yesterDailies', {
|
||||
scope: modalScope,
|
||||
controller: ['$scope', 'Tasks', 'User', '$rootScope', function ($scope, Tasks, User, $rootScope) {
|
||||
$rootScope.$on('task:scored', function (event, data) {
|
||||
var task = data.task;
|
||||
var indexOfTask = _.findIndex($scope.taskList, function (taskInList) {
|
||||
return taskInList._id === task._id;
|
||||
});
|
||||
if (!$scope.taskList[indexOfTask]) return;
|
||||
$scope.taskList[indexOfTask].group.approval.requested = task.group.approval.requested;
|
||||
if ($scope.taskList[indexOfTask].group.approval.requested) return;
|
||||
$scope.taskList[indexOfTask].completed = task.completed;
|
||||
});
|
||||
|
||||
$scope.ageDailies = function () {
|
||||
Tasks.ageDailies()
|
||||
.then(function () {
|
||||
$scope.yesterDailiesModalOpen = false;
|
||||
User.sync();
|
||||
});
|
||||
};
|
||||
}],
|
||||
})
|
||||
.result.catch(function() {
|
||||
$scope.yesterDailiesModalOpen = false;
|
||||
});
|
||||
});
|
||||
|
||||
$rootScope.$watch('user.stats.hp', function (after, before) {
|
||||
if (after <= 0){
|
||||
|
||||
@@ -36,6 +36,9 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
},
|
||||
});
|
||||
Analytics.updateUser();
|
||||
|
||||
if (task.group.approval.required) task.group.approval.requested = true;
|
||||
$rootScope.$broadcast('task:scored', {task: task});
|
||||
}
|
||||
|
||||
$scope.score = function(task, direction) {
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
'$state',
|
||||
'User',
|
||||
'$rootScope',
|
||||
'Tasks',
|
||||
];
|
||||
|
||||
function taskList($state, User, $rootScope) {
|
||||
function taskList($state, User, $rootScope, Tasks) {
|
||||
return {
|
||||
restrict: 'EA',
|
||||
templateUrl: 'templates/task-list.html',
|
||||
@@ -24,6 +25,11 @@
|
||||
// user: "=",
|
||||
// },
|
||||
link: function($scope, element, attrs) {
|
||||
$scope.checklistCompletion = Tasks.checklistCompletion;
|
||||
|
||||
$scope.completeChecklistItem = function completeChecklistItem(task) {
|
||||
User.updateTask(task, {body: task});
|
||||
};
|
||||
// @TODO: The use of scope with tasks is incorrect. We need to fix all task ctrls to use directives/services
|
||||
// $scope.obj = {};
|
||||
function setObj (obj, force) {
|
||||
|
||||
@@ -169,5 +169,10 @@
|
||||
"yearlyRepeatHelpContent": "This task will be due every X years",
|
||||
"resets": "Resets",
|
||||
"summaryStart": "Repeats <%= frequency %> every <%= everyX %> <%= frequencyPlural %> ",
|
||||
"nextDue": "Next Due Dates"
|
||||
"nextDue": "Next Due Dates",
|
||||
"yesterDailiesTitle": "Did you complete any of these?",
|
||||
"yesterDailiesSubTitle": "(Check any you have)",
|
||||
"yesterDailiesCallToAction": "That's All",
|
||||
"yesterDailiesOptionTitle": "Prompt to check off if missed",
|
||||
"yesterDailiesDescription": "Prompt to check off if missed"
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ include ./tasks-edit.jade
|
||||
include ./task-notes.jade
|
||||
include ./task-extra-notes.jade
|
||||
include ./testing.jade
|
||||
include ./yester-dailies.jade
|
||||
|
||||
//- Settings
|
||||
script(type='text/ng-template', id='modals/change-day-start.html')
|
||||
|
||||
12
website/views/shared/modals/yester-dailies.jade
Normal file
12
website/views/shared/modals/yester-dailies.jade
Normal file
@@ -0,0 +1,12 @@
|
||||
script(type='text/ng-template', id='modals/yesterDailies.html')
|
||||
.modal-header
|
||||
h3.text-center=env.t('yesterDailiesTitle')
|
||||
h5.text-center=env.t('yesterDailiesSubTitle')
|
||||
.modal-body
|
||||
.container-fluid
|
||||
.row
|
||||
.col-md-6.col-md-offset-3
|
||||
.task-column.dailys
|
||||
task-list
|
||||
.modal-footer
|
||||
a.btn.btn-info.btn-lg.flex-column.btn-wrap(ng-click='ageDailies();$close()')=env.t('yesterDailiesCallToAction')
|
||||
@@ -11,6 +11,12 @@ div(ng-if='(task.type !== "reward") || task.userId || (!obj.auth && obj.purchase
|
||||
|
||||
include ./habits/frequency
|
||||
|
||||
fieldset.option-group.advanced-option(ng-if='task.type === "daily" && task._edit._advanced')
|
||||
.form-group
|
||||
input(type='checkbox', ng-model='task._edit.yesterDaily')
|
||||
legend.option-title
|
||||
a.hint(href='http://habitica.wikia.com/wiki/Task_Alias', target='_blank', popover-trigger='mouseenter', popover="{{::env.t('yesterDailiesDescription')}}")=env.t('yesterDailiesOptionTitle')
|
||||
|
||||
fieldset.option-group.advanced-option(ng-show="task._edit._advanced", ng-if="!obj.auth && obj.purchased && obj.purchased.active")
|
||||
group-tasks-actions(task='task', group='obj')
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ script(id='templates/task.html', type="text/ng-template")
|
||||
class='task {{getClasses(task, user, list, main)}}',
|
||||
ng-class='{"cast-target":spell && (list.type != "reward"), "locked-task":obj._locked === true}',
|
||||
ng-click='spell && (list.type != "reward") && castEnd(task, "task", $event)',
|
||||
ng-show='shouldShow(task, list, user.preferences)',
|
||||
ng-show='!shouldShow || shouldShow(task, list, user.preferences)',
|
||||
popover-trigger='mouseenter', popover-placement="top", popover-append-to-body='{{::modal ? "false":"true"}}',
|
||||
data-popover-html="{{taskPopover(task) | markdown}}")
|
||||
|
||||
data-popover-html="{{taskPopover(task) | markdown}}"
|
||||
)
|
||||
ng-form(name='taskForm')
|
||||
include ./meta_controls
|
||||
|
||||
|
||||
Reference in New Issue
Block a user