From f4b22cdfbc55e22f41ceac4ef2fe71b02444e4f4 Mon Sep 17 00:00:00 2001
From: Johannes Millan
Date: Wed, 11 Jan 2017 12:28:58 +0100
Subject: [PATCH] make transitions configurable in settings
---
.../jira-set-in-progress-c.html | 5 +-
.../jira-set-in-progress-c.js | 2 +-
app/scripts/main/global-services/jira-s.js | 14 ++++-
app/scripts/routes/settings/settings-c.html | 58 ++++++++++++++++---
app/scripts/routes/settings/settings-c.js | 4 +-
5 files changed, 68 insertions(+), 15 deletions(-)
diff --git a/app/scripts/dialogs/jira-set-in-progress/jira-set-in-progress-c.html b/app/scripts/dialogs/jira-set-in-progress/jira-set-in-progress-c.html
index 292dccb4d8..f8a650e4c5 100644
--- a/app/scripts/dialogs/jira-set-in-progress/jira-set-in-progress-c.html
+++ b/app/scripts/dialogs/jira-set-in-progress/jira-set-in-progress-c.html
@@ -3,7 +3,8 @@
Open
In progress
- Done: Do you want to update the task '{{ vm.task.title }}' on jira?
+ Done: Do you want to update the task '{{ vm.task.title }}' on jira?
+
Move to:
@@ -23,7 +24,7 @@
This will be set then always, when a task is changed to
open
in progress
- done.
+ done. You can change that later in the project settings.
diff --git a/app/scripts/dialogs/jira-set-in-progress/jira-set-in-progress-c.js b/app/scripts/dialogs/jira-set-in-progress/jira-set-in-progress-c.js
index 2de8cdf391..6658a1a848 100644
--- a/app/scripts/dialogs/jira-set-in-progress/jira-set-in-progress-c.js
+++ b/app/scripts/dialogs/jira-set-in-progress/jira-set-in-progress-c.js
@@ -31,7 +31,7 @@
if (!$localStorage.jiraSettings.transitions) {
$localStorage.jiraSettings.transitions = {};
}
- $localStorage.jiraSettings.transitions[type] = transition;
+ $localStorage.jiraSettings.transitions[type] = transition.id;
$localStorage.jiraSettings.allTransitions = transitions;
}
diff --git a/app/scripts/main/global-services/jira-s.js b/app/scripts/main/global-services/jira-s.js
index 202a1bedfb..9bade01885 100644
--- a/app/scripts/main/global-services/jira-s.js
+++ b/app/scripts/main/global-services/jira-s.js
@@ -50,14 +50,26 @@
this.updateStatus = (task, type) => {
if (task.originalKey && task.originalType === ISSUE_TYPE) {
if ($localStorage.jiraSettings.transitions && $localStorage.jiraSettings.transitions[type]) {
- return this.transitionIssue(task.originalId, $localStorage.jiraSettings.transitions[type]);
+ if ($localStorage.jiraSettings.transitions[type] === 'DO_NOT') {
+ return $q.reject('DO_NOT chosen');
+ } else {
+ console.log($localStorage.jiraSettings.transitions[type]);
+
+ return this.transitionIssue(task.originalId, {
+ id: $localStorage.jiraSettings.transitions[type]
+ });
+ }
} else {
+ // TODO the promise handling and setting up should be better
+ let defer = $q.defer();
this.getTransitionsForIssue(task).then((response) => {
let transitions = response.response.transitions;
return Dialogs('JIRA_SET_IN_PROGRESS', { transitions, task, type }).then((transition) => {
+ defer.resolve(transition);
this.transitionIssue(task.originalId, transition);
});
});
+ return defer.promise;
}
}
};
diff --git a/app/scripts/routes/settings/settings-c.html b/app/scripts/routes/settings/settings-c.html
index aa0a8247ae..a7acdd6cbf 100644
--- a/app/scripts/routes/settings/settings-c.html
+++ b/app/scripts/routes/settings/settings-c.html
@@ -74,37 +74,77 @@
Jira-Setup for Task Suggestion
-
diff --git a/app/scripts/routes/settings/settings-c.js b/app/scripts/routes/settings/settings-c.js
index 53c8e75000..f6a724b5af 100644
--- a/app/scripts/routes/settings/settings-c.js
+++ b/app/scripts/routes/settings/settings-c.js
@@ -14,7 +14,7 @@
.controller('SettingsCtrl', SettingsCtrl);
/* @ngInject */
- function SettingsCtrl($localStorage, $rootScope, $scope, Projects, Dialogs, DEFAULT_THEME, THEMES, IS_ELECTRON, SimpleToast, $mdDialog) {
+ function SettingsCtrl($localStorage, $rootScope, $scope, Projects, Dialogs, DEFAULT_THEME, THEMES, IS_ELECTRON, SimpleToast, $mdDialog, $window) {
let vm = this;
vm.IS_ELECTRON = IS_ELECTRON;
@@ -22,7 +22,6 @@
function init() {
vm.r = $rootScope.r;
vm.allProjects = Projects.getList();
- vm.jiraSettings = angular.copy($rootScope.r.jiraSettings);
$rootScope.r.theme = $localStorage.theme || DEFAULT_THEME;
vm.isDarkTheme = $rootScope.r.theme && $rootScope.r.theme.indexOf('dark') > -1;
@@ -93,6 +92,7 @@
// theme stuff
vm.themes = THEMES;
+ // TODO that's kind of bad
// update on global model changes
$rootScope.$watch('r', () => {
init();