mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-08-02 04:22:32 +00:00
add basic dialog for jira worklog
This commit is contained in:
parent
0be6ec14a6
commit
f58deaa2ff
10 changed files with 221 additions and 47 deletions
|
|
@ -113,6 +113,7 @@ TODO configure more restrictive Content-Security-Policy
|
|||
<script src="scripts/dialogs/create-project/create-project-c.js"></script>
|
||||
<script src="scripts/dialogs/dialogs-constant.js"></script>
|
||||
<script src="scripts/dialogs/dialogs-s.js"></script>
|
||||
<script src="scripts/dialogs/jira-add-worklog/jira-add-worklog-c.js"></script>
|
||||
<script src="scripts/dialogs/jira-set-in-progress/jira-set-in-progress-c.js"></script>
|
||||
<script src="scripts/dialogs/task-selection/task-selection-c.js"></script>
|
||||
<script src="scripts/dialogs/time-estimate/time-estimate-c.js"></script>
|
||||
|
|
|
|||
|
|
@ -94,11 +94,6 @@
|
|||
$mdThemingProvider.theme('default')
|
||||
.primaryPalette('blue');
|
||||
//.dark();
|
||||
//$mdThemingProvider.enableBrowserColor({
|
||||
// theme: 'default', // Default is 'default'
|
||||
// palette: 'accent', // Default is 'primary', any basic material palette and extended palettes are available
|
||||
// hue: '200' // Default is '800'
|
||||
//});
|
||||
|
||||
let themes = THEMES;
|
||||
for (let index = 0; index < themes.length; ++index) {
|
||||
|
|
@ -174,7 +169,13 @@
|
|||
});
|
||||
}
|
||||
|
||||
function handleCurrentTaskUpdates($rootScope, $window, $q, Jira, Tasks, IS_ELECTRON, $state, Notifier, $interval, SimpleToast, JIRA_UPDATE_POLL_INTERVAL) {
|
||||
function handleCurrentTaskUpdates($rootScope, $window, $q, Jira, Tasks, IS_ELECTRON, $state, Notifier, $interval, SimpleToast, JIRA_UPDATE_POLL_INTERVAL, Dialogs, $timeout) {
|
||||
|
||||
$timeout(() => {
|
||||
Dialogs('JIRA_ADD_WORKLOG', { task: $rootScope.r.currentTask })
|
||||
$rootScope.r.currentTask.started = $window.moment().subtract('days', 1);
|
||||
Jira.addWorklog($rootScope.r.currentTask);
|
||||
}, 10);
|
||||
|
||||
function doAsyncSeries(arr) {
|
||||
return arr.reduce(function (promise, item) {
|
||||
|
|
@ -206,7 +207,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
// handle updates that need to be made on jira
|
||||
$rootScope.$watch('r.currentTask', (newCurrent, prevCurrent) => {
|
||||
//console.log(newCurrent && newCurrent.title, $localStorage.currentTask && $localStorage.currentTask.title);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@
|
|||
JIRA_SET_IN_PROGRESS: {
|
||||
controller: 'JiraSetInProgressCtrl',
|
||||
templateUrl: 'scripts/dialogs/jira-set-in-progress/jira-set-in-progress-c.html'
|
||||
},
|
||||
JIRA_ADD_WORKLOG: {
|
||||
controller: 'JiraAddWorklogCtrl',
|
||||
templateUrl: 'scripts/dialogs/jira-add-worklog/jira-add-worklog-c.html'
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
|
|
|||
106
app/scripts/dialogs/jira-add-worklog/jira-add-worklog-c.html
Normal file
106
app/scripts/dialogs/jira-add-worklog/jira-add-worklog-c.html
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<md-dialog aria-label="Submit worklog to jira">
|
||||
<md-toolbar>
|
||||
<div class="md-toolbar-tools">
|
||||
<h2>Submit worklog to jira for "{{ vm.taskCopy.originalKey }}"</h2>
|
||||
<span flex></span>
|
||||
<md-button class="md-icon-button"
|
||||
ng-click="vm.cancel()">
|
||||
<ng-md-icon icon="close"></ng-md-icon>
|
||||
</md-button>
|
||||
</div>
|
||||
</md-toolbar>
|
||||
|
||||
<form ng-submit="vm.addWorklog()"
|
||||
novalidate
|
||||
name="worklogForm">
|
||||
|
||||
<md-dialog-content>
|
||||
<div class="md-dialog-content">
|
||||
<p>Submit a worklog for "{{ vm.taskCopy.title }}".</p>
|
||||
<p>The current logged work amount is <strong>{{ vm.taskCopy.originalTimeSpent }}</strong>.</p>
|
||||
|
||||
|
||||
<!--<md-input-container class="md-block">-->
|
||||
<!--<label>Started (date)</label>-->
|
||||
<!--<md-datepicker ng-model="vm.taskCopy.started"-->
|
||||
<!--required-->
|
||||
<!--name="startedDate"-->
|
||||
<!--md-placeholder="Enter date"></md-datepicker>-->
|
||||
<!--<div class="validation-messages"-->
|
||||
<!--ng-messages="worklogForm.startedDate.$error">-->
|
||||
<!--<div ng-message="valid">The entered value is not a date!</div>-->
|
||||
<!--<div ng-message="required">This date is required!</div>-->
|
||||
<!--</div>-->
|
||||
<!--</md-input-container>-->
|
||||
|
||||
|
||||
|
||||
<md-input-container class="md-block">
|
||||
<ng-md-icon icon="event"></ng-md-icon>
|
||||
<input type="date"
|
||||
ng-model="vm.taskCopy.started"
|
||||
required
|
||||
name="startedDate"
|
||||
placeholder="Started (date)">
|
||||
<div class="validation-messages"
|
||||
ng-messages="worklogForm.startedDate.$error">
|
||||
<div ng-message="valid">The entered value is not a date!</div>
|
||||
<div ng-message="required">This date is required!</div>
|
||||
</div>
|
||||
</md-input-container>
|
||||
|
||||
<md-input-container class="md-block">
|
||||
<ng-md-icon icon="access_time"></ng-md-icon>
|
||||
<input type="time"
|
||||
required
|
||||
name="startedTime"
|
||||
ng-model="vm.taskCopy.started"
|
||||
placeholder="Started (time)">
|
||||
<div class="validation-messages"
|
||||
ng-messages="worklogForm.startedTime.$error">
|
||||
<div ng-message="required">This is required!</div>
|
||||
</div>
|
||||
</md-input-container>
|
||||
|
||||
|
||||
<md-input-container class="md-block">
|
||||
<ng-md-icon icon="timer"></ng-md-icon>
|
||||
<input type="text"
|
||||
required
|
||||
name="timeSpent"
|
||||
placeholder="Time spent"
|
||||
input-duration
|
||||
ng-model="vm.taskCopy.timeSpent">
|
||||
<div class="hint">Current values is {{ vm.taskCopy.originalTimeSpent }}</div>
|
||||
<div class="validation-messages"
|
||||
ng-messages="worklogForm.timeSpent.$error">
|
||||
<div ng-message="required">This is required!</div>
|
||||
</div>
|
||||
</md-input-container>
|
||||
|
||||
<md-input-container class="md-block">
|
||||
<label>Coment</label>
|
||||
<textarea ng-model="vm.comment"></textarea>
|
||||
</md-input-container>
|
||||
|
||||
<md-switch ng-model="vm.isUpdateLocalTaskSettings"
|
||||
aria-label="Update local task with values entered here">
|
||||
Update local task with values entered here
|
||||
</md-switch>
|
||||
</div>
|
||||
</md-dialog-content>
|
||||
|
||||
|
||||
<md-dialog-actions>
|
||||
<md-button ng-click="vm.cancel()"
|
||||
type="button"
|
||||
class="md-primary md-raised">
|
||||
Cancel
|
||||
</md-button>
|
||||
<md-button type="submit"
|
||||
class="md-raised">
|
||||
Add worklog on Jira
|
||||
</md-button>
|
||||
</md-dialog-actions>
|
||||
</form>
|
||||
</md-dialog>
|
||||
37
app/scripts/dialogs/jira-add-worklog/jira-add-worklog-c.js
Normal file
37
app/scripts/dialogs/jira-add-worklog/jira-add-worklog-c.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* @ngdoc function
|
||||
* @name superProductivity.controller:JiraAddWorklogCtrl
|
||||
* @description
|
||||
* # JiraAddWorklogCtrl
|
||||
* Controller of the superProductivity
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('superProductivity')
|
||||
.controller('JiraAddWorklogCtrl', JiraAddWorklogCtrl);
|
||||
|
||||
/* @ngInject */
|
||||
function JiraAddWorklogCtrl($mdDialog, task, $window) {
|
||||
let vm = this;
|
||||
vm.taskCopy = angular.copy(task);
|
||||
console.log(vm.taskCopy);
|
||||
|
||||
vm.taskCopy.started = new Date(task.started);
|
||||
|
||||
vm.isUpdateLocalTaskSettings = false;
|
||||
|
||||
vm.addWorklog = () => {
|
||||
if (vm.isUpdateLocalTaskSettings) {
|
||||
angular.extend(task, vm.taskCopy);
|
||||
}
|
||||
$mdDialog.hide(vm.taskCopy.originalKey, vm.taskCopy.started, vm.taskCopy.timeSpent, vm.comment);
|
||||
};
|
||||
|
||||
vm.cancel = () => {
|
||||
$mdDialog.cancel();
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
describe('Controller: JiraAddWorklogCtrl', function () {
|
||||
|
||||
// load the controller's module
|
||||
beforeEach(module('superProductivity'));
|
||||
|
||||
let JiraAddWorklogCtrl;
|
||||
let scope;
|
||||
|
||||
// Initialize the controller and a mock scope
|
||||
beforeEach(inject(function ($controller, $rootScope) {
|
||||
scope = $rootScope.$new();
|
||||
JiraAddWorklogCtrl = $controller('JiraAddWorklogCtrl', {
|
||||
$scope: scope
|
||||
// place mocked dependencies here
|
||||
});
|
||||
}));
|
||||
|
||||
it('should ...', function () {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
@ -121,9 +121,6 @@
|
|||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// TODO think about if promise should be resolved or rejected when dialog is canceled
|
||||
|
||||
let defer = $q.defer();
|
||||
this.getTransitionsForIssue(task)
|
||||
.then((response) => {
|
||||
|
|
@ -169,20 +166,20 @@
|
|||
}
|
||||
};
|
||||
|
||||
this.updateWorklog = (task) => {
|
||||
this.addWorklog = (task) => {
|
||||
console.log(task);
|
||||
|
||||
if (task.originalKey && task.originalType === ISSUE_TYPE) {
|
||||
if ($localStorage.jiraSettings.isWorklogEnabled) {
|
||||
if ($localStorage.jiraSettings.isAutoWorklog) {
|
||||
return this._updateWorklog(task.originalKey, task.started, task.timeSpent);
|
||||
return this._addWorklog(task.originalKey, task.started, task.timeSpent);
|
||||
} else {
|
||||
|
||||
// TODO think about if promise should be resolved or rejected when dialog is canceled
|
||||
|
||||
let defer = $q.defer();
|
||||
|
||||
Dialogs('JIRA_ADD_WORKLOG', { task })
|
||||
.then((originalKey, started, timeSpent, comment) => {
|
||||
this._updateWorklog(originalKey, started, timeSpent, comment)
|
||||
this._addWorklog(originalKey, started, timeSpent, comment)
|
||||
.then(defer.resolve, defer.reject);
|
||||
}, defer.reject);
|
||||
|
||||
|
|
@ -192,7 +189,7 @@
|
|||
}
|
||||
};
|
||||
|
||||
this._updateWorklog = (originalKey, started, timeSpent, comment) => {
|
||||
this._addWorklog = (originalKey, started, timeSpent, comment) => {
|
||||
if (originalKey && started && started.toISOString && timeSpent && timeSpent.asSeconds) {
|
||||
let request = {
|
||||
config: $localStorage.jiraSettings,
|
||||
|
|
|
|||
|
|
@ -53,20 +53,6 @@ ng-md-icon svg {
|
|||
pointer-events: none;
|
||||
}
|
||||
|
||||
md-input-container > ng-md-icon {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
left: 2px;
|
||||
}
|
||||
|
||||
md-input-container > ng-md-icon + input {
|
||||
margin-left: 56px;
|
||||
}
|
||||
|
||||
md-input-container.md-default-theme > ng-md-icon {
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
md-tabs-wrapper md-prev-button ng-md-icon,
|
||||
md-tabs-wrapper md-next-button ng-md-icon {
|
||||
position: absolute;
|
||||
|
|
@ -81,23 +67,41 @@ md-tabs-wrapper md-next-button ng-md-icon {
|
|||
transform: translate3d(-50%, -50%, 0) rotate(180deg);
|
||||
}
|
||||
|
||||
md-input-container > ng-md-icon {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
left: 2px;
|
||||
}
|
||||
|
||||
md-input-container > ng-md-icon + input {
|
||||
margin-left: 56px;
|
||||
}
|
||||
|
||||
md-input-container {
|
||||
|
||||
> ng-md-icon{
|
||||
position: relative;
|
||||
top: auto;
|
||||
left: auto;
|
||||
}
|
||||
|
||||
&.md-default-theme > ng-md-icon {
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
$this-float-ml: 32px;
|
||||
&.md-icon-float {
|
||||
margin-left: 30px;
|
||||
display: block;
|
||||
padding-left: $this-float-ml;
|
||||
label {
|
||||
margin-left: $this-float-ml;
|
||||
width: calc(100% - #{$this-float-ml}) !important;
|
||||
}
|
||||
.hint{
|
||||
margin-left: $this-float-ml;
|
||||
width: calc(100% - #{$this-float-ml}) !important;
|
||||
}
|
||||
> ng-md-icon {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
left: 0;
|
||||
vertical-align: middle;
|
||||
+ input {
|
||||
margin-left: 0;
|
||||
//width: calc(100% - #{$this-float-ml});
|
||||
}
|
||||
}
|
||||
}
|
||||
ng-md-icon {
|
||||
position: absolute;
|
||||
left: -30px !important;
|
||||
top: 6px !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -51,6 +51,8 @@ IMPORTANT NOTE:
|
|||
|
||||
@import '../scripts/dialogs/create-project/_create-project-c.scss';
|
||||
|
||||
@import '../scripts/dialogs/jira-add-worklog/_jira-add-worklog-c.scss';
|
||||
|
||||
@import '../scripts/dialogs/jira-set-in-progress/_jira-set-in-progress-c.scss';
|
||||
|
||||
@import '../scripts/dialogs/task-selection/_task-selection-c.scss';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue