mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Task notes modals (#8521)
* Merged in develop * Show task notes modal on click * Began adding tests * Removed extra characters * Fixed lingering popup * Added markdown * Fixed line endings
This commit is contained in:
35
test/client-old/spec/directives/task.directive.js
Normal file
35
test/client-old/spec/directives/task.directive.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
describe('task Directive', () => {
|
||||||
|
var compile, scope, directiveElem, $modal;
|
||||||
|
|
||||||
|
beforeEach(function(){
|
||||||
|
module(function($provide) {
|
||||||
|
$modal = {
|
||||||
|
open: sandbox.spy(),
|
||||||
|
};
|
||||||
|
$provide.value('$modal', $modal);
|
||||||
|
});
|
||||||
|
|
||||||
|
inject(function($compile, $rootScope, $templateCache) {
|
||||||
|
compile = $compile;
|
||||||
|
scope = $rootScope.$new();
|
||||||
|
|
||||||
|
$templateCache.put('templates/task.html', '<div>Task</div>');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
directiveElem = getCompiledElement();
|
||||||
|
});
|
||||||
|
|
||||||
|
function getCompiledElement(){
|
||||||
|
var element = angular.element('<task></task>');
|
||||||
|
var compiledElement = compile(element)(scope);
|
||||||
|
scope.$digest();
|
||||||
|
return compiledElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
xit('opens task note modal', () => {
|
||||||
|
scope.showNoteDetails();
|
||||||
|
|
||||||
|
expect($modal.open).to.be.calledOnce;
|
||||||
|
});
|
||||||
|
})
|
||||||
@@ -1,24 +1,41 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
angular
|
angular
|
||||||
.module('habitrpg')
|
.module('habitrpg')
|
||||||
.directive('task', task);
|
.directive('task', task);
|
||||||
|
|
||||||
task.$inject = [
|
task.$inject = [
|
||||||
'Shared',
|
'Shared',
|
||||||
];
|
'$modal',
|
||||||
|
];
|
||||||
function task(Shared) {
|
|
||||||
return {
|
function task(Shared, $modal) {
|
||||||
restrict: 'E',
|
return {
|
||||||
templateUrl: 'templates/task.html',
|
restrict: 'E',
|
||||||
scope: true,
|
templateUrl: 'templates/task.html',
|
||||||
link: function($scope, element, attrs) {
|
scope: true,
|
||||||
$scope.getClasses = function (task, user, list, main) {
|
link: function($scope, element, attrs) {
|
||||||
return Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main);
|
$scope.getClasses = function (task, user, list, main) {
|
||||||
}
|
return Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
$scope.showNoteDetails = function (task) {
|
||||||
}());
|
task.popoverOpen = false;
|
||||||
|
|
||||||
|
$modal.open({
|
||||||
|
templateUrl: 'modals/task-extra-notes.html',
|
||||||
|
controller: function ($scope, task) {
|
||||||
|
$scope.task = task;
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
task: function() {
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
|||||||
@@ -164,6 +164,7 @@
|
|||||||
"confirmScoreNotes": "Confirm task scoring with notes",
|
"confirmScoreNotes": "Confirm task scoring with notes",
|
||||||
"taskScoreNotesTooLong": "Task score notes must be less than 256 characters",
|
"taskScoreNotesTooLong": "Task score notes must be less than 256 characters",
|
||||||
"groupTasksByChallenge": "Group tasks by challenge title",
|
"groupTasksByChallenge": "Group tasks by challenge title",
|
||||||
|
"taskNotes": "Task Notes",
|
||||||
"monthlyRepeatHelpContent": "This task will be due every X months",
|
"monthlyRepeatHelpContent": "This task will be due every X months",
|
||||||
"yearlyRepeatHelpContent": "This task will be due every X years"
|
"yearlyRepeatHelpContent": "This task will be due every X years"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ include ./login-incentives-reward-unlocked.jade
|
|||||||
include ./generic.jade
|
include ./generic.jade
|
||||||
include ./tasks-edit.jade
|
include ./tasks-edit.jade
|
||||||
include ./task-notes.jade
|
include ./task-notes.jade
|
||||||
|
include ./task-extra-notes.jade
|
||||||
|
|
||||||
//- Settings
|
//- Settings
|
||||||
script(type='text/ng-template', id='modals/change-day-start.html')
|
script(type='text/ng-template', id='modals/change-day-start.html')
|
||||||
|
|||||||
10
website/views/shared/modals/task-extra-notes.jade
Normal file
10
website/views/shared/modals/task-extra-notes.jade
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
script(id='modals/task-extra-notes.html', type='text/ng-template')
|
||||||
|
.modal-header
|
||||||
|
h4=env.t('taskNotes')
|
||||||
|
|
||||||
|
.modal-body
|
||||||
|
div
|
||||||
|
markdown(text='task.notes')
|
||||||
|
|
||||||
|
.modal-footer
|
||||||
|
.btn.btn-primary(ng-click="$close()")=env.t('close')
|
||||||
@@ -4,14 +4,14 @@
|
|||||||
span(ng-if='showDoubleTaskCounter(task, obj)')
|
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='showSingleTaskCounter(task, obj)')
|
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
|
||||||
span(ng-if='task.type=="todo" && task.date')
|
span(ng-if='task.type=="todo" && task.date')
|
||||||
span(ng-class='{"label label-danger":(moment(task.date).isBefore(_today, "days") && !task.completed)}') {{task.date | date:(user.preferences.dateFormat.indexOf('yyyy') == 0 ? user.preferences.dateFormat.substr(5) : user.preferences.dateFormat.substr(0,5))}}
|
span(ng-class='{"label label-danger":(moment(task.date).isBefore(_today, "days") && !task.completed)}') {{task.date | date:(user.preferences.dateFormat.indexOf('yyyy') == 0 ? user.preferences.dateFormat.substr(5) : user.preferences.dateFormat.substr(0,5))}}
|
||||||
|
|
||||||
// Approval requested
|
// Approval requested
|
||||||
|
|
|
|
||||||
span(ng-show='task.group.approval.requested && !task.group.approval.approved')
|
span(ng-show='task.group.approval.requested && !task.group.approval.approved')
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// Icons only available if you own the tasks (aka, hidden from challenge stats)
|
// Icons only available if you own the tasks (aka, hidden from challenge stats)
|
||||||
span(ng-if='!obj._locked')
|
span(ng-if='!obj._locked')
|
||||||
group-task-meta-actions(ng-if="!obj.auth && obj.purchased && obj.purchased.active", task='task', group='obj')
|
group-task-meta-actions(ng-if="!obj.auth && obj.purchased && obj.purchased.active", task='task', group='obj')
|
||||||
|
|
||||||
a(ng-click='pushTask(task,$index,"top")', tooltip=env.t('pushTaskToTop'), ng-class="{'push-down': ctrlPressed}")
|
a(ng-click='pushTask(task,$index,"top")', tooltip=env.t('pushTaskToTop'), ng-class="{'push-down': ctrlPressed}")
|
||||||
span(ng-hide="ctrlPressed").glyphicon.glyphicon-open
|
span(ng-hide="ctrlPressed").glyphicon.glyphicon-open
|
||||||
span(ng-show="ctrlPressed").glyphicon.glyphicon-save
|
span(ng-show="ctrlPressed").glyphicon.glyphicon-save
|
||||||
@@ -39,13 +39,13 @@
|
|||||||
a.badge(ng-if='task.checklist[0]', ng-class='{"badge-success":checklistCompletion(task.checklist) == task.checklist.length}', ng-click='collapseChecklist(task)', tooltip=env.t('expandCollapse'))
|
a.badge(ng-if='task.checklist[0]', ng-class='{"badge-success":checklistCompletion(task.checklist) == task.checklist.length}', ng-click='collapseChecklist(task)', tooltip=env.t('expandCollapse'))
|
||||||
|{{checklistCompletion(task.checklist)}}/{{task.checklist.length}}
|
|{{checklistCompletion(task.checklist)}}/{{task.checklist.length}}
|
||||||
span.glyphicon.glyphicon-tags(tooltip='{{Shared.appliedTags(user.tags, task.tags)}}', ng-hide='Shared.noTags(task.tags)')
|
span.glyphicon.glyphicon-tags(tooltip='{{Shared.appliedTags(user.tags, task.tags)}}', ng-hide='Shared.noTags(task.tags)')
|
||||||
|
|
||||||
// edit
|
// edit
|
||||||
a(ng-hide='checkGroupAccess && !checkGroupAccess(obj)', ng-click='editTask(task, user, Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main))', tooltip=env.t('edit'))
|
a(ng-hide='checkGroupAccess && !checkGroupAccess(obj)', ng-click='editTask(task, user, Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main))', tooltip=env.t('edit'))
|
||||||
|
|
|
|
||||||
span.glyphicon.glyphicon-pencil
|
span.glyphicon.glyphicon-pencil
|
||||||
|
|
|
|
||||||
|
|
||||||
//challenges
|
//challenges
|
||||||
span(ng-if='task.challenge.id')
|
span(ng-if='task.challenge.id')
|
||||||
span(ng-if='task.challenge.broken')
|
span(ng-if='task.challenge.broken')
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
span(ng-if='!task.challenge.broken')
|
span(ng-if='!task.challenge.broken')
|
||||||
span.glyphicon.glyphicon-bullhorn(tooltip=env.t('challenge'))
|
span.glyphicon.glyphicon-bullhorn(tooltip=env.t('challenge'))
|
||||||
|
|
|
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
a(ng-if='!task.challenge.id || (obj.leader && obj.leader.id === user._id)', ng-hide="(checkGroupAccess && !checkGroupAccess(obj))" ng-click='removeTask(task, obj)', tooltip=env.t('delete'))
|
a(ng-if='!task.challenge.id || (obj.leader && obj.leader.id === user._id)', ng-hide="(checkGroupAccess && !checkGroupAccess(obj))" ng-click='removeTask(task, obj)', tooltip=env.t('delete'))
|
||||||
span.glyphicon.glyphicon-trash
|
span.glyphicon.glyphicon-trash
|
||||||
@@ -67,6 +67,6 @@
|
|||||||
// notes
|
// notes
|
||||||
|
|
||||||
// Make this icon available regardless of task ownership
|
// Make this icon available regardless of task ownership
|
||||||
a.task-notes(ng-show='task.notes && !task._editing', ng-click='task.popoverOpen = !task.popoverOpen', popover-trigger='click', data-popover-html="{{task.notes | markdown}}", popover-placement="top", popover-append-to-body='{{::modal ? "false":"true"}}')
|
a.task-notes(ng-show='task.notes && !task._editing', ng-click='showNoteDetails(task);', popover-trigger='hover', data-popover-html="{{task.notes | markdown}}", popover-placement="top", popover-append-to-body='{{::modal ? "false":"true"}}')
|
||||||
span.glyphicon.glyphicon-comment
|
span.glyphicon.glyphicon-comment
|
||||||
|
|
|
|
||||||
|
|||||||
Reference in New Issue
Block a user