Skip to content

Commit

Permalink
Merge pull request #882 from oslokommune/key-result-history-list
Browse files Browse the repository at this point in the history
Pane design adjustments
  • Loading branch information
petterhj authored Oct 9, 2023
2 parents 0257809 + 1e0efd1 commit c1ec159
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 30 deletions.
213 changes: 213 additions & 0 deletions src/components/KeyResultValuesList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
<template>
<div class="key-result-values-list">
<table class="key-result-values-list__table">
<thead>
<tr>
<th>{{ $t('widget.history.value') }}</th>
<th>{{ $t('widget.history.date') }}</th>
<th>{{ $t('widget.history.comment') }}</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="record in progress" :key="record.id">
<td>
{{ formatValue(record.value) }}
</td>
<td>
{{ dateExtraShort(record.timestamp.toDate()) }}
</td>
<td>
<div>
<p v-if="record.comment">{{ record.comment }}</p>
<div>
<user-link
v-if="record.editedBy || record.createdBy"
:user="record.editedBy || record.createdBy"
@open-user-modal="openProfileModal"
/>
<pkt-button
v-if="hasEditRights"
v-tooltip="$t('tooltip.editProgress')"
size="small"
skin="tertiary"
variant="icon-only"
icon-name="edit"
@onClick="$emit('edit-value', record)"
/>
</div>
</div>
</td>
<td>
<div>
<user-link
v-if="record.editedBy || record.createdBy"
:user="record.editedBy || record.createdBy"
@open-user-modal="openProfileModal"
/>
<pkt-button
v-if="hasEditRights"
v-tooltip="$t('tooltip.editProgress')"
size="small"
skin="tertiary"
variant="icon-only"
icon-name="edit"
@onClick="$emit('edit-value', record)"
/>
</div>
</td>
</tr>
</tbody>
</table>

<profile-modal
v-if="showProfileModal"
:id="chosenProfileId"
@close="closeProfileModal"
/>
</div>
</template>

<script>
import { mapGetters } from 'vuex';
import { dateExtraShort } from '@/util';
import { formatValue } from '@/util/keyResultProgress';
import { PktButton } from '@oslokommune/punkt-vue2';
import ProfileModal from '@/components/modals/ProfileModal.vue';
import UserLink from '@/components/widgets/WidgetProgressHistory/UserLink.vue';
export default {
name: 'KeyResultValuesList',
components: {
PktButton,
ProfileModal,
UserLink,
},
props: {
progress: {
type: Array,
required: true,
},
},
data: () => ({
showProfileModal: false,
chosenProfileId: null,
}),
computed: {
...mapGetters(['hasEditRights']),
},
methods: {
formatValue,
dateExtraShort,
openProfileModal(profileId) {
this.showProfileModal = true;
this.chosenProfileId = profileId;
},
closeProfileModal() {
this.showProfileModal = false;
this.chosenProfileId = null;
},
},
};
</script>

<style lang="scss" scoped>
@use '@oslokommune/punkt-css/dist/scss/abstracts/mixins/breakpoints' as *;
@use '@oslokommune/punkt-css/dist/scss/abstracts/mixins/typography' as *;
@mixin table-cell-desktop-up {
display: none;
@include bp('desktop-up') {
display: table-cell;
}
}
.key-result-values-list__table {
border-spacing: 0 0.5rem;
th {
padding: 0 2rem;
text-align: left;
@include get-text('pkt-txt-14-medium');
&:nth-child(1),
&:nth-child(2) {
text-align: center;
}
&:nth-child(4) {
@include table-cell-desktop-up;
}
}
td {
padding: 1rem 2rem;
text-align: left;
background-color: var(--color-white);
@include get-text('pkt-txt-14');
&:nth-child(1) {
@include get-text('pkt-txt-16-bold');
color: var(--color-yellow-100);
text-align: center;
text-wrap: nowrap;
background: var(--color-yellow-50);
}
&:nth-child(2) {
padding-right: 1rem;
text-align: center;
}
&:nth-child(3) {
padding-left: 1rem;
> div {
display: flex;
flex-direction: column;
gap: 0.5rem;
> p {
@include get-text('pkt-txt-14-light');
}
> div {
display: flex;
gap: 1rem;
align-items: center;
.pkt-btn {
margin-left: auto;
}
@include bp('desktop-up') {
display: none;
}
}
}
}
&:nth-child(4) {
@include table-cell-desktop-up;
> div {
display: flex;
gap: 0.5rem;
align-items: center;
.pkt-btn {
margin-left: auto;
}
}
}
}
}
</style>
9 changes: 2 additions & 7 deletions src/components/ObjectiveLinkCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,11 @@ export default {
padding: 1rem;
}
&__header {
&__heading {
display: flex;
gap: 0.5rem;
align-items: center;
justify-content: space-between;
white-space: nowrap;
}
Expand All @@ -199,12 +200,6 @@ export default {
}
}
.objective-link-card__heading {
display: flex;
gap: 0.5rem;
justify-content: space-between;
}
.objective-link-card__tags {
display: flex;
flex: 1 0 auto;
Expand Down
8 changes: 7 additions & 1 deletion src/components/modals/ProgressModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
</div>

<template #actions="{ handleSubmit, submitDisabled }">
<btn-delete v-if="record" :disabled="loading" @click="deleteRecord" />
<btn-save :disabled="submitDisabled || loading" @click="handleSubmit(save)" />
</template>
</form-section>
</modal-wrapper>
</template>

<script>
import { FormSection, BtnSave } from '@/components/generic/form';
import { FormSection, BtnDelete, BtnSave } from '@/components/generic/form';
import ModalWrapper from './ModalWrapper.vue';
export default {
Expand All @@ -61,6 +62,7 @@ export default {
components: {
ModalWrapper,
FormSection,
BtnDelete,
BtnSave,
},
Expand Down Expand Up @@ -132,6 +134,10 @@ export default {
this.loading = true;
this.$emit('update-record', this.record.id, this.formattedData, this.close);
},
async deleteRecord() {
this.loading = true;
this.$emit('delete-record', this.record.id, this.close);
},
close() {
this.loading = false;
this.$emit('close');
Expand Down
35 changes: 22 additions & 13 deletions src/components/panes/KeyResultPane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
size="small"
variant="icon-left"
icon-name="plus-sign"
@onClick="showValueModal = true"
@onClick="openValueModal(null)"
/>
</div>

Expand All @@ -66,12 +66,12 @@
{{ $t('general.loading') }}
</div>

<widget-progress-history
<key-result-values-list
v-else-if="progress.length"
:progress="progress"
:is-loading="isLoading"
@update-record="updateHistoryRecord"
@delete-record="deleteHistoryRecord"
class="key-result-pane__table"
@edit-value="openValueModal"
@delete-value="(record) => deleteHistoryRecord(record.id)"
/>

<empty-state
Expand Down Expand Up @@ -107,7 +107,10 @@

<progress-modal
v-if="showValueModal"
:record="chosenProgressValue"
@create-record="createHistoryRecord"
@update-record="updateHistoryRecord"
@delete-record="deleteHistoryRecord"
@close="showValueModal = false"
/>
</pane-wrapper>
Expand All @@ -126,9 +129,9 @@ import { getKeyResultProgressDetails } from '@/util/keyResultProgress';
import { PktAlert, PktBreadcrumbs, PktButton, PktTag } from '@oslokommune/punkt-vue2';
import PaneWrapper from '@/components/panes/PaneWrapper.vue';
import WidgetWrapper from '@/components/widgets/WidgetWrapper.vue';
import WidgetProgressHistory from '@/components/widgets/WidgetProgressHistory/WidgetProgressHistory.vue';
// import WidgetKeyResultNotes from '@/components/widgets/WidgetKeyResultNotes.vue';
import WidgetKeyResultDetails from '@/components/widgets/WidgetKeyResultDetails.vue';
import KeyResultValuesList from '@/components/KeyResultValuesList.vue';
import HTMLOutput from '@/components/HTMLOutput.vue';
import ProgressModal from '@/components/modals/ProgressModal.vue';
import ProgressBar from '@/components/ProgressBar.vue';
Expand All @@ -145,9 +148,9 @@ export default {
PktTag,
PaneWrapper,
Widget: WidgetWrapper,
WidgetProgressHistory,
// WidgetKeyResultNotes,
WidgetKeyResultDetails,
KeyResultValuesList,
HTMLOutput,
ProgressModal,
ProgressBar,
Expand All @@ -161,6 +164,7 @@ export default {
isLoading: false,
showKeyResultDrawer: false,
showValueModal: false,
chosenProgressValue: null,
}),
computed: {
Expand Down Expand Up @@ -282,12 +286,14 @@ export default {
}
},
async deleteHistoryRecord(id) {
async deleteHistoryRecord(id, modalCloseHandler) {
try {
await Progress.remove(db.collection('keyResults'), this.activeKeyResult.id, id);
this.$toasted.show(this.$t('toaster.delete.progress'));
} catch {
this.$toasted.error(this.$t('toaster.error.deleteProgress'));
} finally {
modalCloseHandler();
}
},
Expand All @@ -312,6 +318,11 @@ export default {
}
},
openValueModal(record) {
this.showValueModal = true;
this.chosenProgressValue = record;
},
randomCompletedMessage() {
const messages = Object.values(this.$t('progress.completedMessages'));
const randomIndex = getRandomInt(messages.length);
Expand Down Expand Up @@ -364,12 +375,10 @@ export default {
justify-content: space-between;
margin-bottom: 1rem;
}
}
::v-deep .widget__header {
// Temporarily hide the history widget header. The table is
// to be replaced
display: none;
}
&__table {
margin-top: 1rem;
}
&__graph {
Expand Down
Loading

0 comments on commit c1ec159

Please sign in to comment.