add most basic work view

This commit is contained in:
Johannes Millan 2016-12-31 18:17:46 +01:00
parent 86eab5ed25
commit 9a9ac8e3f2
15 changed files with 150 additions and 11 deletions

View file

@ -63,6 +63,7 @@ TODO configure more restrictive Content-Security-Policy
<script src="bower_components/angular-messages/angular-messages.js"></script>
<script src="bower_components/angular-material/angular-material.js"></script>
<script src="bower_components/angular-material-icons/angular-material-icons.min.js"></script>
<script src="bower_components/lodash/lodash.js"></script>
<!-- endbower -->
<!-- endbuild -->
@ -76,6 +77,7 @@ TODO configure more restrictive Content-Security-Policy
<script src="scripts/dialogs/time-estimate/time-estimate-c.js"></script>
<script src="scripts/routes.js"></script>
<script src="scripts/task-list/task-list-d.js"></script>
<script src="scripts/work-view/work-view-d.js"></script>
<!-- endinject -->
<!-- endbuild -->
</body>

View file

@ -25,4 +25,5 @@
function checkIfStartedTodayAndInit($localStorage) {
}
})();

View file

@ -16,7 +16,6 @@
<ng-md-icon icon="mode_edit"></ng-md-icon>
<input class="text-input"
md-auto-focus
md-autofocus
ng-model="vm.newTask"
placeholder="Enter a task and press enter to add">

View file

@ -30,7 +30,7 @@
}
/* @ngInject */
function DailyPlannerCtrl($localStorage, Dialogs) {
function DailyPlannerCtrl($localStorage, Dialogs, $state) {
let vm = this;
$localStorage.$default({
@ -65,7 +65,10 @@
};
vm.done = () => {
Dialogs('TASK_SELECTION', {tasks: vm.tasks});
Dialogs('TASK_SELECTION', {tasks: vm.tasks})
.then(() => {
$state.go('work-view');
});
};
}

View file

@ -2,12 +2,12 @@
class="dialog-task-selection">
<md-dialog-content layout-padding>
<form ng-submit="vm.submit()">
<p>Select a task to start with or just press enter to start with</p><p><strong>{{ vm.tasks[0].title }}</strong></p>
<p>Select a task to start with or just press enter to start with</p><p><strong>{{ vm.undoneTasks[0].title }}</strong></p>
<md-autocomplete
md-selected-item="vm.currentTask.title"
md-search-text="vm.searchText"
md-items="task in vm.tasks"
md-items="task in vm.undoneTasks"
md-item-text="task.title"
md-min-length="0"
md-autofocus

View file

@ -21,12 +21,14 @@
currentTask: null
});
vm.currentTask = $localStorage.currentTask;
vm.tasks = tasks;
vm.currentTask = $localStorage.currentTask
vm.undoneTasks = _.filter(tasks, (task) => {
return task && !task.isDone;
});
vm.submit = (task) => {
if (!task) {
task = vm.tasks[0];
task = vm.undoneTasks[0];
}
vm.currentTask = $localStorage.currentTask = task;
$mdDialog.hide();

View file

@ -20,10 +20,14 @@
$urlRouterProvider.otherwise('/');
$stateProvider
.state('home', {
.state('daily-planner', {
url: '/',
template: '<daily-planner></daily-planner>'
})
.state('work-view', {
url: '/work-view',
template: '<work-view></work-view>'
})
/* STATES-NEEDLE - DO NOT REMOVE THIS */;
}
})();

View file

@ -5,7 +5,7 @@
* # taskList
*/
(function () {
(function() {
'use strict';
angular

View file

@ -0,0 +1,14 @@
work-view {
}
.work-view-table {
tr {
&.is-done {
text-decoration: line-through;
}
&.is-current {
border: 1px solid red;
}
}
}

View file

@ -0,0 +1,39 @@
<div class="work-view-current-task">
<p>You're current working on: <strong>{{ vm.currentTask.title }}</strong></p>
</div>
<table class="work-view-table">
<thead>
<tr>
<th></th>
<th>Title</th>
<th>Estimated</th>
<th>Currently Worked</th>
<th>Done</th>
</tr>
</thead>
<tbody dnd-list="vm.tasks">
<tr ng-repeat="task in vm.tasks"
dnd-draggable="task"
dnd-effect-allowed="move"
dnd-moved="vm.tasks.splice($index, 1);"
ng-class="{'is-current': vm.currentTask === task, 'is-done':task.isDone}">
<td>
<ng-md-icon class="handle"
flex="none"
icon="drag_handle"></ng-md-icon>
</td>
<td ng-click="task.isCurrent = true;">{{ task.title }}</td>
<td>{{ task.timeEstimate}}</td>
<td>{{ task.timeWorked}}</td>
<td>
<input type="checkbox"
ng-model="task.isDone">
</td>
</tr>
</tbody>
</table>
<md-button ui-sref="daily-planner"
class="md-primary md-raised">Add new Tasks
</md-button>

View file

@ -0,0 +1,50 @@
/**
* @ngdoc directive
* @name superProductivity.directive:workView
* @description
* # workView
*/
(function () {
'use strict';
angular
.module('superProductivity')
.directive('workView', workView);
/* @ngInject */
function workView() {
return {
templateUrl: 'scripts/work-view/work-view-d.html',
bindToController: true,
controller: WorkViewCtrl,
controllerAs: 'vm',
restrict: 'E',
scope: {}
};
}
/* @ngInject */
function WorkViewCtrl($localStorage, $scope, $state) {
let vm = this;
vm.tasks = $localStorage.tasks;
vm.currentTask = $localStorage.currentTask;
$scope.$watch('vm.currentTask', (mVal) => {
if (mVal && mVal.isDone) {
let undoneTasks = _.filter(vm.tasks, (task) => {
return task && !task.isDone;
});
// go to daily planner if there are no undone tasks left
if (!undoneTasks || undoneTasks.length === 0) {
$state.go('daily-planner');
} else {
vm.currentTask = undoneTasks[0];
}
}
}, true);
}
})();

View file

@ -0,0 +1,21 @@
'use strict';
describe('Directive: workView', function() {
// load the directive's module
beforeEach(module('superProductivity'));
beforeEach(module('templates'));
var element,
scope;
beforeEach(inject(function($rootScope) {
scope = $rootScope.$new();
}));
it('should do something', inject(function($compile) {
element = $compile('<work-view></work-view>')(scope);
scope.$digest();
expect(true).toBe(true);
}));
});

View file

@ -41,4 +41,6 @@ IMPORTANT NOTE:
@import '../scripts/task-list/_task-list-d.scss';
@import '../scripts/work-view/_work-view-d.scss';
// endinject

View file

@ -24,7 +24,8 @@
"angular-drag-and-drop-lists": "^2.0.0",
"ngstorage": "^0.3.11",
"angular-material": "^1.1.1",
"angular-material-icons": "^0.7.1"
"angular-material-icons": "^0.7.1",
"lodash": "^4.17.3"
},
"devDependencies": {
"angular-mocks": "^1.5.0"

View file

@ -25,6 +25,7 @@ module.exports = function(config) {
'app/bower_components/angular-messages/angular-messages.js',
'app/bower_components/angular-material/angular-material.js',
'app/bower_components/angular-material-icons/angular-material-icons.min.js',
'app/bower_components/lodash/lodash.js',
'app/bower_components/angular-mocks/angular-mocks.js',
// endbower