Skip to content

Commit 72e6213

Browse files
authored
Merge pull request #24 from SparingSoftware/fixes
Fixes and improvements
2 parents d7dcf6a + b31ff6d commit 72e6213

13 files changed

Lines changed: 70 additions & 203 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "workometer",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"author": "Sparing Software",
55
"description": "Electron based app to track tasks time",
66
"license": null,
@@ -48,13 +48,14 @@
4848
]
4949
},
5050
"mac": {
51-
"icon": "build/icons/icon.icns"
51+
"icon": "static/icons/icon.icns",
52+
"target": "pkg"
5253
},
5354
"win": {
54-
"icon": "build/icons/icon.ico"
55+
"icon": "static/icons/icon.ico"
5556
},
5657
"linux": {
57-
"icon": "build/icons"
58+
"icon": "static/icons"
5859
}
5960
},
6061
"dependencies": {

src/main/config/menu.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,24 @@ const setDefaultApplicationMenu = () => {
1616
{
1717
label: 'Edit',
1818
submenu: [
19-
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
20-
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
19+
{ role: 'undo' },
20+
{ role: 'redo' },
2121
{ type: 'separator' },
22-
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
23-
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
24-
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
25-
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' }
22+
{ role: 'cut' },
23+
{ role: 'copy' },
24+
{ role: 'paste' },
25+
{ role: 'delete' },
26+
{ type: 'separator' },
27+
{ role: 'selectAll' }
28+
]
29+
},
30+
{
31+
label: 'View',
32+
submenu: [
33+
{ role: 'reload' },
34+
{ role: 'forcereload' },
35+
{ type: 'separator' },
36+
{ role: 'togglefullscreen' }
2637
]
2738
},
2839
{

src/renderer/components/dashboardPage/issues/contextMenu/actions/logWorkDialog/index.vue

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
<el-form :model="form">
55
<el-form-item label="Time spent">
66
<el-input
7-
v-model="form.worklog.timeSpent"
7+
v-model="form.timeSpent"
88
placeholder="1d 9h 12m"
99
autocomplete="off"
1010
@blur="handleBlur"
1111
/>
1212
</el-form-item>
1313
<el-form-item label="Date">
1414
<el-date-picker
15-
v-model="form.worklog.started"
15+
v-model="form.started"
1616
:readonly="false"
1717
type="datetime"
18-
value-format="yyyy-MM-ddTHH:mm:ss.000ZZ"
18+
format="yyyy-MM-dd HH:mm"
1919
placeholder="Started datetime"
2020
/>
2121
</el-form-item>
@@ -34,13 +34,33 @@
3434

3535
<script>
3636
import moment from 'moment'
37+
import service from '@/service'
38+
39+
const getWorkedTimeParsed = timeSpent => {
40+
const getNumberBeforeLetter = letter => {
41+
const regex = new RegExp(`(\\d+)${letter}`, 'i')
42+
return +(regex.exec(timeSpent) || [0, 0])[1]
43+
}
44+
return ['d', 'h', 'm'].map(getNumberBeforeLetter)
45+
}
46+
47+
const parseToSeconds = timeSpent => {
48+
const [days, hours, minutes] = getWorkedTimeParsed(timeSpent)
49+
50+
const minute = 60
51+
const hour = minute * 60
52+
const day = hour * 24
53+
54+
return (days * day) + (hours * hour) + (minutes * minute)
55+
}
3756
3857
export default {
3958
data () {
4059
return {
4160
dialogVisible: false,
4261
form: {
43-
worklog: {}
62+
timeSpent: null,
63+
started: null
4464
},
4565
issue: null
4666
}
@@ -50,42 +70,31 @@ export default {
5070
this.issue = issue
5171
this.dialogVisible = true
5272
this.form = {
53-
worklog: {}
73+
timeSpent: null,
74+
started: null
5475
}
5576
},
5677
submitForm () {
57-
this.$jira.issue.addWorkLog({
58-
issueId: this.issue.id,
59-
...this.form
60-
}).then(response => {
61-
this.$notify({
62-
title: 'Success',
63-
message: 'Worklog saved',
64-
type: 'success'
78+
const timeSpentSeconds = parseToSeconds(this.form.timeSpent)
79+
service.addWorkLog(this.issue.id, moment(this.form.started), timeSpentSeconds)
80+
.then(() => {
81+
this.$notify({
82+
title: 'Success',
83+
message: 'Worklog saved',
84+
type: 'success'
85+
})
86+
this.closeDialog()
6587
})
66-
this.closeDialog()
67-
}).catch(this.handleErrors)
88+
.catch(this.handleErrors)
6889
},
6990
closeDialog () {
7091
this.issue = null
7192
this.dialogVisible = false
7293
},
73-
handleBlur (event) {
74-
const inputValue = event.target.value
75-
const getNumberBeforeLetter = letter => {
76-
const regex = new RegExp(`(\\d+)${letter}`, 'i')
77-
return +(regex.exec(inputValue) || [0, 0])[1]
78-
}
79-
const [days, hours, minutes] = ['d', 'h', 'm'].map(getNumberBeforeLetter)
80-
81-
const startDate = moment().subtract({
82-
days,
83-
hours,
84-
minutes
85-
}).toDate()
86-
if (!this.form.worklog.started) {
87-
this.$set(this.form.worklog, 'started', startDate)
88-
}
94+
handleBlur () {
95+
const [days, hours, minutes] = getWorkedTimeParsed(this.form.timeSpent)
96+
const startDate = moment().subtract({ days, hours, minutes }).toDate()
97+
if (!this.form.started) this.$set(this.form, 'started', startDate)
8998
}
9099
}
91100
}

src/renderer/components/dashboardPage/issues/issue/tracker/index.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,18 @@ export default {
146146
147147
const endWorkTime = trackingStopTime || moment()
148148
const workedTime = endWorkTime.diff(this.trackingStartTime, 'seconds')
149-
const formattedWorkedTime = (moment.utc(workedTime * 1000)).format('HH:mm:ss')
149+
const formattedWorkedTime = (moment.utc(workedTime * 1000)).format('HH:mm')
150150
151151
return this.saveWorklog(workedTime)
152-
.then(response => {
152+
.then(() => {
153153
this.$notify({
154154
title: 'Success',
155155
message: `Worklog saved. You have worked ${formattedWorkedTime}`,
156156
type: 'success'
157157
})
158158
this.clearTracker()
159-
}).catch(this.handleErrors)
159+
})
160+
.catch(this.handleErrors)
160161
.finally(() => {
161162
this.loading = false
162163
})

src/renderer/components/landingPage.vue

Lines changed: 0 additions & 142 deletions
This file was deleted.

src/renderer/service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default {
6666
issueId: trackedIssueId,
6767
worklog: {
6868
started: trackingStartTime.format('YYYY-MM-DDTHH:mm:ss.SSSZZ'),
69-
timeSpentSeconds: timeSpentSeconds,
69+
timeSpentSeconds,
7070
comment
7171
}
7272
})

src/renderer/store/modules/boards.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const getters = {
5252
const actions = {
5353
async fetchBoards ({ commit, dispatch }) {
5454
dispatch('wait/start', 'boardsLoading', { root: true })
55-
const boards = await service.getAllBoards({ type: 'scrum' })
55+
const boards = await service.getAllBoards()
5656
commit('setBoards', boards)
5757
dispatch('wait/end', 'boardsLoading', { root: true })
5858
},

src/renderer/store/modules/tracker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const mutations = {
2424
}
2525

2626
const actions = {
27-
saveWorklog ({commit, state}, workedTime) {
27+
saveWorklog ({ commit, state }, workedTime) {
2828
return service.addWorkLog(state.issueTracked.id, state.trackingStartTime, workedTime)
2929
}
3030
}

static/icons/256x256.png

10.2 KB
Loading

0 commit comments

Comments
 (0)