Skip to content

Commit

Permalink
Merge pull request #840 from oslokommune/allowed-to-edit-period
Browse files Browse the repository at this point in the history
Allow updating key results within ended periods
  • Loading branch information
petterhj authored Aug 25, 2023
2 parents 2caa251 + feea11c commit a80c6ad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ All notable changes to this project will be documented in this file. The format
sorting).
- Fixed the API base URL on the API spec page.
- Fixed outside click detection for dropdown menus.
- Regular team members are now also allowed to update key results within ended
periods. This is a simplification and fixes a bug where some users couldn't
update key results for objectives with an individual start and end date.

### Security

Expand Down
18 changes: 0 additions & 18 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,6 @@ export const storeGetters = {
return activeItem.team.map(({ id }) => id).includes(user.id);
},

allowedToEditPeriod: (state) => {
const { user, activePeriod, activeItem } = state;
const { organization } = activeItem;

const isAdminOfOrganization = organization
? user.admin && user.admin.includes(organization.id)
: user.admin && user.admin.includes(activeItem.id);

if (user && user.superAdmin) {
return true;
}
if (isAdminOfOrganization) {
return true;
}

return activePeriod.endDate.toDate() > new Date();
},

sidebarGroups: (state) => {
const { organizations, departments, products, activeItem } = state;

Expand Down
25 changes: 15 additions & 10 deletions src/views/KeyResultHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</div>
</widget>

<widget v-if="allowedToEditPeriod" class="key-result-summary__value">
<widget v-if="hasEditRights" class="key-result-summary__value">
<key-result-value-form
:key-result="activeKeyResult"
:loading="isSaving"
Expand Down Expand Up @@ -175,7 +175,7 @@ export default {
'user',
'activeItem',
]),
...mapGetters(['hasEditRights', 'allowedToEditPeriod']),
...mapGetters(['hasEditRights']),
startDate() {
return this.activeKeyResult.objective.startDate || this.activePeriod.startDate;
Expand Down Expand Up @@ -272,10 +272,6 @@ export default {
},
async saveProgress(value, comment) {
if (!this.allowedToEditPeriod) {
return;
}
this.isSaving = true;
try {
await Progress.create(db.collection('keyResults'), this.activeKeyResult.id, {
Expand Down Expand Up @@ -315,10 +311,6 @@ export default {
.key-result-summary {
grid-template-columns: 1fr;
@include bp('tablet-up') {
grid-template-columns: 1fr 20rem;
}
&__progress {
height: 100%;
Expand All @@ -342,6 +334,19 @@ export default {
}
}
}
@include bp('tablet-up') {
grid-auto-columns: 1fr;
grid-auto-flow: column;
.key-result-summary__progress {
grid-column: span 7;
}
.key-result-summary__value {
grid-column: span 5;
}
}
}
.keyResult__edit {
Expand Down

0 comments on commit a80c6ad

Please sign in to comment.