Skip to content

Commit

Permalink
Merge branch 'main' into three-pane-okrs
Browse files Browse the repository at this point in the history
  • Loading branch information
simenheg committed Sep 28, 2023
2 parents 2c438ad + f1d9320 commit ddcf659
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 57 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ All notable changes to this project will be documented in this file. The format
version of the app was deployed.
- Fixed cropping of dropdown menus when creating new
organizations/departments/products.
- Unauthorized users can no longer attempt to drag and drop reorder
measurements.

### Changed

Expand Down
74 changes: 17 additions & 57 deletions src/components/KpiWidgetGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,44 @@
</pkt-button>
</template>
</div>
<draggable v-model="orderedKpis" animation="200">
<draggable v-if="hasEditRights" v-model="orderedKpis" animation="200">
<transition-group class="kpi-widget-group__kpis">
<router-link
<kpi-widget-group-link
v-for="kpi in orderedKpis"
:key="kpi.id"
:to="{
name: 'ItemMeasurements',
params: { ...$route.params, kpiId: kpi.id },
query: { resultIndicatorPeriod: selectedPeriod?.key },
}"
class="kpi-widget-group__link"
>
<widget-kpi-card :kpi="kpi" :compact="compact" />
</router-link>
:kpi="kpi"
:compact="compact"
/>
</transition-group>
</draggable>
<kpi-widget-group-link
v-for="kpi in orderedKpis"
v-else
:key="kpi.id"
:kpi="kpi"
:compact="compact"
/>
</div>
</template>

<script>
import draggable from 'vuedraggable';
import html2canvas from 'html2canvas';
import { mapState } from 'vuex';
import { mapGetters, mapState } from 'vuex';
import { periodDates } from '@/util';
import { PktButton } from '@oslokommune/punkt-vue2';
import downloadFile from '@/util/downloadFile';
import Kpi from '@/db/Kpi';
import WidgetKpiCard from '@/components/widgets/WidgetKpiCard/WidgetKpiCard.vue';
import KpiWidgetGroupLink from '@/components/KpiWidgetGroupLink.vue';
import { compareKPIs } from '@/util/kpiHelpers';
export default {
name: 'KpiWidgetGroup',
components: {
PktButton,
WidgetKpiCard,
draggable,
KpiWidgetGroupLink,
PktButton,
},
props: {
Expand All @@ -85,6 +86,7 @@ export default {
computed: {
...mapState(['activeItem', 'selectedPeriod']),
...mapGetters(['hasEditRights']),
itemSlug() {
if (this.kpis.length && this.kpis[0]?.parent?.slug) {
Expand Down Expand Up @@ -165,48 +167,6 @@ export default {
gap: 0.25rem;
}
&__link {
text-decoration: none;
border: 2px solid transparent;
&.router-link-active {
border-color: var(--color-hover);
.kpi-card-widget {
border-color: var(--color-white);
}
::v-deep .widget__header h3,
::v-deep .period-trend-tag__value {
color: var(--color-hover);
}
}
.kpi-card-widget {
&:hover {
background: var(--color-gray-light);
border-color: var(--color-gray);
::v-deep {
.widget__header h3,
.period-trend-tag__value {
color: var(--color-hover);
}
.period-trend-tag__trend {
&:before {
border-left-color: var(--color-gray-light);
}
&:after {
border-top-color: var(--color-gray-light);
border-bottom-color: var(--color-gray-light);
}
}
}
}
}
}
&--compact {
gap: 0.125rem;
margin-bottom: 1rem;
Expand Down
88 changes: 88 additions & 0 deletions src/components/KpiWidgetGroupLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<template>
<router-link
:key="kpi.id"
:to="{
name: 'ItemMeasurements',
params: { ...$route.params, kpiId: kpi.id },
query: { resultIndicatorPeriod: selectedPeriod?.key },
}"
class="kpi-widget-group-link"
>
<widget-kpi-card :kpi="kpi" :compact="compact" />
</router-link>
</template>

<script>
import { mapState } from 'vuex';
import WidgetKpiCard from '@/components/widgets/WidgetKpiCard/WidgetKpiCard.vue';
export default {
name: 'KpiWidgetGroupLink',
components: {
WidgetKpiCard,
},
props: {
kpi: {
type: Object,
required: true,
},
compact: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
...mapState(['selectedPeriod']),
},
};
</script>

<style lang="scss" scoped>
@use '@oslokommune/punkt-css/dist/scss/abstracts/mixins/typography' as *;
.kpi-widget-group-link {
text-decoration: none;
border: 2px solid transparent;
&.router-link-active {
border-color: var(--color-hover);
.kpi-card-widget {
border-color: var(--color-white);
}
::v-deep .widget__header h3,
::v-deep .period-trend-tag__value {
color: var(--color-hover);
}
}
.kpi-card-widget {
&:hover {
background: var(--color-gray-light);
border-color: var(--color-gray);
::v-deep {
.widget__header h3,
.period-trend-tag__value {
color: var(--color-hover);
}
.period-trend-tag__trend {
&:before {
border-left-color: var(--color-gray-light);
}
&:after {
border-top-color: var(--color-gray-light);
border-bottom-color: var(--color-gray-light);
}
}
}
}
}
}
</style>

0 comments on commit ddcf659

Please sign in to comment.