Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

Commit 4a48fae

Browse files
author
Søren Howe Gersager
committed
Merge branch 'hotfix/3.2.5' into 'master'
Hotfix/3.2.5 - master See merge request bevillingsplatform/bevillingsplatform!1008
2 parents 1ab72be + 9861295 commit 4a48fae

File tree

4 files changed

+51
-20
lines changed

4 files changed

+51
-20
lines changed

NEWS.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Version 3.2.5, 2020-12-02
2+
-------------------------
3+
4+
Hotfix release
5+
6+
Bug fixes
7+
^^^^^^^^^
8+
9+
* Use correct date limits for supplementary activity creation.
10+
111
Version 3.2.4, 2020-11-24
212
-------------------------
313

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.4
1+
3.2.5

frontend-tests/utils/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function createDate(offset) {
2727
local_offset = Math.floor(Math.random()*180)
2828
}
2929
today.setDate(today.getDate() + parseInt(local_offset))
30-
return `2020-${ leadZero(today.getMonth() + 1) }-${ leadZero(today.getDate()) }`
30+
return `${ today.getFullYear() }-${ leadZero(today.getMonth() + 1) }-${ leadZero(today.getDate()) }`
3131
}
3232

3333
async function useSelectBox(t, select_id, select_option) {

frontend/src/components/mixins/ActivityDateEditMixin.js

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ import { epoch2DateStr, tenYearsAgo, inEighteenYears, json2jsDate } from '../fil
99

1010
export default {
1111
computed: {
12+
acts: function() {
13+
return this.$store.getters.getActivities
14+
},
15+
main_activities: function() {
16+
if (this.acts) {
17+
return this.acts.filter(function(act) {
18+
return act.activity_type === 'MAIN_ACTIVITY'
19+
})
20+
}
21+
},
1222
act: function() {
1323
return this.$store.getters.getActivity
1424
},
@@ -51,26 +61,37 @@ export default {
5161
return json2jsDate(dt)
5262
},
5363
getMainActStartDate: function() {
54-
let start_date
55-
if (this.appropriation.granted_from_date) {
56-
start_date = this.appropriation.granted_from_date
57-
} else if (this.appropriation.main_activity && this.appropriation.main_activity.start_date) {
58-
start_date = this.appropriation.main_activity.start_date
59-
} else {
60-
start_date = null
61-
}
62-
return start_date
64+
let acts = this.sortMainActs()
65+
return this.getBestDate(acts,'start')
6366
},
6467
getMainActEndDate: function() {
65-
let end_date
66-
if (this.appropriation.granted_to_date) {
67-
end_date = this.appropriation.granted_to_date
68-
} else if (this.appropriation.main_activity && this.appropriation.main_activity.end_date) {
69-
end_date = this.appropriation.main_activity.end_date
70-
} else {
71-
end_date = null
68+
let acts = this.sortMainActs()
69+
return this.getBestDate(acts,'end')
70+
},
71+
getBestDate(arr, criteria) {
72+
if (arr.length) {
73+
let best_date = null
74+
if (criteria === 'start') {
75+
best_date = arr[0].start_date
76+
} else {
77+
best_date = arr[arr.length - 1].end_date
78+
}
79+
return best_date
7280
}
73-
return end_date
81+
},
82+
sortMainActs() {
83+
// Sort mainActs list by start date
84+
return this.main_activities.sort(function(a,b) {
85+
const a_start_date = new Date(a.start_date).getTime(),
86+
b_start_date = new Date(b.start_date).getTime()
87+
if (a_start_date > b_start_date) {
88+
return 1
89+
} else if (b_start_date > a_start_date) {
90+
return -1
91+
} else {
92+
return 0
93+
}
94+
})
7495
}
7596
}
76-
}
97+
}

0 commit comments

Comments
 (0)