update backlog when project changes

This commit is contained in:
Johannes Millan 2017-05-03 16:43:03 +02:00
parent cb5daf7379
commit 4ce72ab368
3 changed files with 34 additions and 27 deletions

View file

@ -18,13 +18,14 @@
'keys',
'isShowWelcomeDialog'
])
.constant('ON_DEMAND_LS_FIELDS',[
.constant('ON_DEMAND_LS_FIELDS', [
'doneBacklogTasks',
'backlogTasks',
])
.constant('ON_DEMAND_LS_FIELDS_FOR_PROJECT',[
.constant('ON_DEMAND_LS_FIELDS_FOR_PROJECT', [
'data',
])
.constant('EV_PROJECT_CHANGED', 'EV_PROJECT_CHANGED')
.constant('LS_DEFAULTS', {
note: undefined,
theme: undefined,

View file

@ -25,35 +25,38 @@
}
/* @ngInject */
function DailyPlannerCtrl($localStorage, $window, $scope, Tasks, TasksUtil, Dialogs, $state, Jira, $filter, IS_ELECTRON, Git, $mdDialog) {
function DailyPlannerCtrl($localStorage, $window, $scope, Tasks, TasksUtil, Dialogs, $state, Jira, $filter, IS_ELECTRON, Git, $mdDialog, EV_PROJECT_CHANGED) {
let vm = this;
const _ = $window._;
vm.limitBacklogTo = 3;
vm.taskSuggestions = [];
vm.backlogTasks = Tasks.getBacklog();
vm.init = () => {
vm.limitBacklogTo = 3;
vm.taskSuggestions = [];
vm.backlogTasks = Tasks.getBacklog();
vm.getFilteredTaskSuggestions = (searchText) => {
return searchText ? $filter('filter')(vm.taskSuggestions, searchText, false, 'title') : vm.taskSuggestions;
};
vm.getFilteredTaskSuggestions = (searchText) => {
return searchText ? $filter('filter')(vm.taskSuggestions, searchText, false, 'title') : vm.taskSuggestions;
};
if (IS_ELECTRON && Jira.isSufficientJiraSettings()) {
Jira.checkForNewAndAddToBacklog();
if (IS_ELECTRON && Jira.isSufficientJiraSettings()) {
Jira.checkForNewAndAddToBacklog();
Jira.getSuggestions().then((res) => {
vm.taskSuggestions = vm.taskSuggestions.concat(Jira.transformIssues(res));
});
}
// add new git tasks
Git.checkForNewAndAddToBacklog();
if ($localStorage.git.isShowIssuesFromGit) {
Git.getIssueList()
.then((res) => {
vm.taskSuggestions = vm.taskSuggestions.concat(res.data);
Jira.getSuggestions().then((res) => {
vm.taskSuggestions = vm.taskSuggestions.concat(Jira.transformIssues(res));
});
}
}
// add new git tasks
Git.checkForNewAndAddToBacklog();
if ($localStorage.git.isShowIssuesFromGit) {
Git.getIssueList()
.then((res) => {
vm.taskSuggestions = vm.taskSuggestions.concat(res.data);
});
}
};
vm.init();
vm.addTask = () => {
if (vm.newTask) {
@ -128,6 +131,9 @@
watcher();
});
});
}
$scope.$on(EV_PROJECT_CHANGED, () => {
vm.init();
});
}
})();

View file

@ -14,7 +14,7 @@
.service('Projects', Projects);
/* @ngInject */
function Projects(LS_DEFAULTS, $localStorage, Uid, $window, SimpleToast, $injector, GLOBAL_LS_FIELDS) {
function Projects(LS_DEFAULTS, $localStorage, Uid, $window, SimpleToast, $injector, GLOBAL_LS_FIELDS, $rootScope, EV_PROJECT_CHANGED) {
const TMP_FIELDS = [
'$$hashKey',
'$$mdSelectId',
@ -143,7 +143,7 @@
// update ls $localStorage current project
$localStorage.currentProject = newCurrentProject;
$rootScope.$broadcast(EV_PROJECT_CHANGED);
// re-init all global models
InitGlobalModels();
}