mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-08-01 04:01:01 +00:00
add simplest toast and messages for it
This commit is contained in:
parent
2df609e654
commit
80be8bcbf8
7 changed files with 58 additions and 17 deletions
|
|
@ -124,6 +124,7 @@ TODO configure more restrictive Content-Security-Policy
|
|||
<script src="scripts/main/global-filters/duration-filter.js"></script>
|
||||
<script src="scripts/main/global-services/jira-s.js"></script>
|
||||
<script src="scripts/main/global-services/projects-s.js"></script>
|
||||
<script src="scripts/main/global-services/simple-toast-s.js"></script>
|
||||
<script src="scripts/main/global-services/tasks-s.js"></script>
|
||||
<script src="scripts/main/global-services/uid-s.js"></script>
|
||||
<script src="scripts/main-header/main-header-d.js"></script>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
.controller('AddTaskCtrl', AddTaskCtrl);
|
||||
|
||||
/* @ngInject */
|
||||
function AddTaskCtrl($mdDialog, Tasks) {
|
||||
function AddTaskCtrl($mdDialog, Tasks, SimpleToast) {
|
||||
let vm = this;
|
||||
vm.task = {};
|
||||
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
let success = Tasks.addToday(vm.task);
|
||||
|
||||
if (success) {
|
||||
SimpleToast('Created task "' + vm.task.title + '"');
|
||||
$mdDialog.hide();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
}
|
||||
|
||||
/* @ngInject */
|
||||
function MainHeaderCtrl(Dialogs, $rootScope, Tasks, Projects) {
|
||||
function MainHeaderCtrl(Dialogs, $rootScope, Tasks, Projects, SimpleToast) {
|
||||
let vm = this;
|
||||
let lastCurrentTask;
|
||||
|
||||
|
|
@ -32,8 +32,7 @@
|
|||
|
||||
vm.allProjects = Projects.getList();
|
||||
|
||||
|
||||
this.openMenu = function($mdOpenMenu, ev) {
|
||||
this.openMenu = function ($mdOpenMenu, ev) {
|
||||
$mdOpenMenu(ev);
|
||||
};
|
||||
|
||||
|
|
@ -51,8 +50,10 @@
|
|||
if (vm.isOnBreak) {
|
||||
lastCurrentTask = $rootScope.r.currentTask;
|
||||
Tasks.updateCurrent(null);
|
||||
SimpleToast('On break!');
|
||||
} else {
|
||||
Tasks.updateCurrent(lastCurrentTask);
|
||||
SimpleToast('Off break!');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
.service('Projects', Projects);
|
||||
|
||||
/* @ngInject */
|
||||
function Projects(LS_DEFAULTS, $localStorage, $rootScope, Uid, $window, $log) {
|
||||
function Projects(LS_DEFAULTS, $localStorage, $rootScope, Uid, $window, SimpleToast) {
|
||||
const OMITTED_LS_FIELDS = ['currentProject', 'projects', '$$hashKey', '$$mdSelectId'];
|
||||
|
||||
this.getList = () => {
|
||||
|
|
@ -51,8 +51,8 @@
|
|||
};
|
||||
|
||||
this.createNewFromCurrent = (projectTitle) => {
|
||||
if ($localStorage.projects.length !== 0) {
|
||||
$log.error('there is already a project');
|
||||
if ($localStorage.projects.length > 0) {
|
||||
SimpleToast('ERROR: There is already a project');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
27
app/scripts/main/global-services/simple-toast-s.js
Normal file
27
app/scripts/main/global-services/simple-toast-s.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* @ngdoc service
|
||||
* @name superProductivity.SimpleToast
|
||||
* @description
|
||||
* # SimpleToast
|
||||
* Service in the superProductivity.
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('superProductivity')
|
||||
.service('SimpleToast', SimpleToast);
|
||||
|
||||
/* @ngInject */
|
||||
function SimpleToast($mdToast) {
|
||||
|
||||
return (textContent) => {
|
||||
return $mdToast.show($mdToast.simple()
|
||||
.textContent(textContent)
|
||||
.position('bottom'));
|
||||
};
|
||||
// AngularJS will instantiate a singleton by calling "new" on this function
|
||||
}
|
||||
|
||||
})();
|
||||
17
app/scripts/main/global-services/simple-toast-s.spec.js
Normal file
17
app/scripts/main/global-services/simple-toast-s.spec.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
describe('Service: SimpleToast', function() {
|
||||
// load the service's module
|
||||
beforeEach(module('superProductivity'));
|
||||
|
||||
// instantiate service
|
||||
var SimpleToast;
|
||||
beforeEach(inject(function (_SimpleToast_) {
|
||||
SimpleToast = _SimpleToast_;
|
||||
}));
|
||||
|
||||
it('should be defined', function() {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
.controller('SettingsCtrl', SettingsCtrl);
|
||||
|
||||
/* @ngInject */
|
||||
function SettingsCtrl($localStorage, $rootScope, $scope, Projects, Dialogs, DEFAULT_THEME, $mdToast) {
|
||||
function SettingsCtrl($localStorage, $rootScope, $scope, Projects, Dialogs, DEFAULT_THEME, SimpleToast) {
|
||||
let vm = this;
|
||||
|
||||
function init() {
|
||||
|
|
@ -33,9 +33,7 @@
|
|||
vm.createNewProjectFromCurrent = (projectTitle) => {
|
||||
Projects.createNewFromCurrent(projectTitle);
|
||||
|
||||
$mdToast.show($mdToast.simple()
|
||||
.textContent('Project "' + projectTitle + '" successfully saved')
|
||||
.position('bottom'));
|
||||
SimpleToast('Project "' + projectTitle + '" successfully saved');
|
||||
};
|
||||
|
||||
vm.createNewProject = () => {
|
||||
|
|
@ -58,9 +56,7 @@
|
|||
$localStorage.projects = $rootScope.r.projects = [];
|
||||
}
|
||||
|
||||
$mdToast.show($mdToast.simple()
|
||||
.textContent('Settings successfully imported')
|
||||
.position('bottom'));
|
||||
SimpleToast('Settings successfully imported');
|
||||
};
|
||||
|
||||
// jira stuff
|
||||
|
|
@ -71,9 +67,7 @@
|
|||
$rootScope.r.currentProject.data.jiraSettings = settings;
|
||||
}
|
||||
|
||||
$mdToast.show($mdToast.simple()
|
||||
.textContent('Jira settigns saved')
|
||||
.position('bottom'));
|
||||
SimpleToast('Jira settigns saved');
|
||||
};
|
||||
|
||||
// theme stuff
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue