Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New dashboard #3150

Merged
merged 34 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
19f936b
Create new dashboard mockup
manuelmeister Oct 8, 2022
50a0385
Refine design
manuelmeister Oct 22, 2022
e69c379
Refine dashboard design
manuelmeister Oct 29, 2022
87ee437
Rename components
carlobeltrame Nov 7, 2022
c42bb76
Use translations
carlobeltrame Nov 7, 2022
27653d2
Use computed v-model for quick filter button
carlobeltrame Nov 7, 2022
1cd702c
Simplify SelectFilter
carlobeltrame Nov 8, 2022
6ff5111
Fix the button for selecting own activities
carlobeltrame Nov 8, 2022
ecd99ba
Fix avatars in select
carlobeltrame Nov 8, 2022
220991c
Adapt category filter to multiselect and real data
carlobeltrame Nov 8, 2022
23e52cd
Adapt period filter to real data
carlobeltrame Nov 8, 2022
cd42b08
The button is a filter preset for all filters
carlobeltrame Nov 8, 2022
2d57eda
Reimplement filtering and clean up dashboard
carlobeltrame Nov 8, 2022
afc6c25
Fix ActivityRow
carlobeltrame Nov 8, 2022
9328499
Make activity title clickable
carlobeltrame Nov 8, 2022
cddbce2
Fix avatar display
carlobeltrame Nov 8, 2022
0c82861
Fix responsibles filter
carlobeltrame Nov 8, 2022
a0066a4
Fix display of date
carlobeltrame Nov 8, 2022
b14e5b1
Fix relevance detection of period filter
carlobeltrame Nov 8, 2022
22c1b56
Remove old dashboard implementation
carlobeltrame Nov 8, 2022
7853f8b
Fix n+1 query and API documentation
carlobeltrame Nov 9, 2022
18bb96a
Make duration more visually distinct
carlobeltrame Nov 9, 2022
267ea90
Use built-in ListFormat for formatting lists of values
carlobeltrame Nov 9, 2022
682851b
Add an underline on hover for now
carlobeltrame Nov 9, 2022
064ba96
Pass tc as argument to avoid console errors
carlobeltrame Nov 9, 2022
d6738b8
Fix various console errors due to partially loaded data
carlobeltrame Nov 9, 2022
e886736
Change label
carlobeltrame Nov 9, 2022
b704de4
Make period filter more intuitive and add fallback messages
carlobeltrame Nov 9, 2022
6bc4f1d
Add back a component for baseline alignment
carlobeltrame Nov 9, 2022
922b797
Remove unused css style
carlobeltrame Nov 10, 2022
702e699
Clean up and add skeleton loaders
carlobeltrame Nov 11, 2022
8a37d7b
Add multiple modes of duration display
carlobeltrame Nov 11, 2022
b0c7047
Visually distinguish clear option using an icon
carlobeltrame Nov 11, 2022
8cb5b01
Make clear option have less visual weight
carlobeltrame Nov 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/src/Entity/Camp.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Camp extends BaseEntity implements BelongsToCampInterface, CopyFromPrototy
* All the programme that will be carried out during the camp. An activity may be carried out
* multiple times in the same camp.
*/
#[ApiProperty(writable: false, example: '["/activities/1a2b3c4d"]')]
#[ApiProperty(writable: false, example: '/activities?camp=%2Fcamps%2F1a2b3c4d')]
#[Groups(['read'])]
#[ORM\OneToMany(targetEntity: Activity::class, mappedBy: 'camp', orphanRemoval: true)]
public Collection $activities;
Expand Down
23 changes: 22 additions & 1 deletion common/helpers/dateHelperUTCFormatted.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ function hourShort(dateTimeString) {
return dayjs.utc(dateTimeString).format(i18n.tc('global.datetime.hourShort'))
}

function timeDurationShort(start, end) {
const startTime = dayjs.utc(start)
const endTime = dayjs.utc(end)
const duration = dayjs(endTime.diff(startTime))
const durationInMinutes = duration.valueOf() / 1000 / 60
if (durationInMinutes < 60) {
return i18n.tc('global.datetime.duration.minutesOnly', 0, {
minutes: durationInMinutes,
})
}
if (durationInMinutes % 60 === 0) {
return i18n.tc('global.datetime.duration.hoursOnly', 0, {
hours: durationInMinutes / 60,
})
}
return i18n.tc('global.datetime.duration.hoursAndMinutes', 0, {
hours: Math.floor(durationInMinutes / 60.0),
minutes: durationInMinutes % 60,
})
}

// short format of dateTime range
// doesn't repeat end date if on the same day
function rangeShort(start, end) {
Expand Down Expand Up @@ -42,4 +63,4 @@ function dateRange(start, end) {
return `${dateShort(start)} - ${dateLong(end)}`
}

export { dateShort, dateLong, hourShort, dateRange, rangeShort }
export { dateShort, dateLong, timeDurationShort, hourShort, dateRange, rangeShort }
5 changes: 5 additions & 0 deletions common/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@
"dateLong": "dd L",
"dateShort": "dd D.M.",
"dateTimeLong": "dd L HH:mm",
"duration": {
"hoursAndMinutes": "{hours}h {minutes}min",
"hoursOnly": "{hours}h",
"minutesOnly": "{minutes}min"
},
"hourLong": "HH:mm",
"hourShort": "H:mm"
}
Expand Down
5 changes: 5 additions & 0 deletions common/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
"dateLong": "dd L",
"dateShort": "dd M/D",
"dateTimeLong": "dd L HH:mm",
"duration": {
"hoursAndMinutes": "{hours}h {minutes}m",
"hoursOnly": "{hours}h",
"minutesOnly": "{minutes}m"
},
"hourLong": "HH:mm",
"hourShort": "h:mm A"
}
Expand Down
128 changes: 128 additions & 0 deletions frontend/src/components/dashboard/ActivityRow.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<template>
<tr class="row">
<th style="text-align: left" class="tabular-nums" scope="row">
<TextAlignBaseline
><span class="smaller">{{ scheduleEntry.number }}</span></TextAlignBaseline
>
<br />
<CategoryChip small dense :category="category" class="d-sm-none" />
</th>
<td class="d-none d-sm-table-cell">
<CategoryChip small dense :category="category" />
</td>
<td class="nowrap">
{{ start }}<br />
<span class="e-subtitle">{{ duration }}</span>
</td>
<td style="width: 100%" class="contentrow">
<router-link
:to="routerLink"
class="text-decoration-none text-decoration-hover-underline black--text"
>
{{ title }}<br />
</router-link>
<span class="e-subtitle">{{ location }}</span>
</td>
<td class="contentrow avatarrow overflow-visible">
<AvatarRow :camp-collaborations="collaborators" size="28" class="ml-auto" />
</td>
</tr>
</template>

<script>
import AvatarRow from './AvatarRow.vue'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When do we relative import components and when via the @ notation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do so more or less at random. I try to avoid too many ../../../../, and especially try to import from the symlinked common instead of the common folder outside the frontend folder. But most of the time I let phpstorm manage this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just my 2 cents:

  • Relative paths make refactoring easy, if the components are tightly coupled (mostly for components in the same folder or subfolders). In this example I could rename or move the dashboard folder, and things just work (1 path only to fix).
  • For anything else (usage of generic components, base components, etc.) I normally use @ because it's easier to search & replace in case of refactoring. Any ../../../../ thing is super difficult to catch and relies a lot on IDE magic for refactoring.

import CategoryChip from '@/components/generic/CategoryChip.vue'
import {
hourShort,
timeDurationShort,
} from '../../common/helpers/dateHelperUTCFormatted.js'
import TextAlignBaseline from '@/components/layout/TextAlignBaseline.vue'

export default {
name: 'ActivityRow',
components: { CategoryChip, AvatarRow, TextAlignBaseline },
props: {
scheduleEntry: { type: Object, required: true },
},
computed: {
collaborators() {
return this.scheduleEntry
.activity()
.activityResponsibles()
.items.map((responsible) => responsible.campCollaboration())
},
category() {
return this.scheduleEntry.activity().category()
},
title() {
return this.scheduleEntry.activity().title
},
location() {
return this.scheduleEntry.activity().location
},
start() {
return hourShort(this.scheduleEntry.start)
},
duration() {
return timeDurationShort(this.scheduleEntry.start, this.scheduleEntry.end)
},
routerLink() {
return {
name: 'activity',
params: {
campId: this.scheduleEntry.period().camp().id,
scheduleEntryId: this.scheduleEntry.id,
},
}
},
},
}
</script>

<style scoped>
.row {
display: table-row;
vertical-align: baseline;
}

tr + tr :is(td, th) {
border-top: 1px solid #ddd;
}

:is(td, th) {
padding-top: 0.25rem;
padding-bottom: 0.25rem;
}

:is(td, th) + :is(td, th) {
padding-left: 0.5rem;
}

.contentrow {
max-width: 100px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.avatarrow {
vertical-align: middle;
}

.e-subtitle {
font-size: 0.9em;
color: #666;
}

.nowrap {
white-space: nowrap;
}

.smaller {
font-size: 0.75em;
}

.text-decoration-hover-underline:hover {
text-decoration: underline !important;
}
</style>
66 changes: 66 additions & 0 deletions frontend/src/components/dashboard/AvatarRow.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<template>
<div class="avatarrow" :style="avatarrow">
<div
v-for="campCollaboration in campCollaborations"
:key="campCollaboration && campCollaboration._meta.self"
class="avataritem"
>
<UserAvatar :size="Number(size)" :camp-collaboration="campCollaboration" />
</div>
</div>
</template>

<script>
import UserAvatar from '@/components/user/UserAvatar.vue'

export default {
name: 'AvatarRow',
components: { UserAvatar },
props: {
campCollaborations: { type: Array, default: () => [] },
size: { type: [Number, String], default: 20 },
},
computed: {
maxWidth() {
return (
(this.campCollaborations?.length - 1) * (Number(this.size) * 0.25) +
Number(this.size)
)
},
avatarrow() {
return {
'max-width': `${this.maxWidth}px`,
'font-size': `${this.size}px`,
}
},
},
}
</script>

<style scoped lang="scss">
.avatarrow {
display: flex;
flex-direction: row-reverse;
gap: 0.75em;
padding-left: 0.5em;
padding-right: 0.5em;
transition: gap 0.25s ease;
}

@media #{map-get($display-breakpoints, 'md-and-up')} {
.avatarrow {
gap: 1.1em;
}
}

.avatarrow:hover {
gap: 1.1em;
}

.avataritem {
display: grid;
width: 0;
place-content: center;
text-decoration: none;
}
</style>
21 changes: 21 additions & 0 deletions frontend/src/components/dashboard/BooleanFilter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<v-chip
label
outlined
:color="value ? 'primary' : null"
@click="$emit('input', !value)"
>{{ label }}</v-chip
>
</template>

<script>
export default {
name: 'BooleanFilter',
props: {
value: Boolean,
label: { type: String, required: true },
},
}
</script>

<style scoped></style>
16 changes: 16 additions & 0 deletions frontend/src/components/dashboard/FilterDivider.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<span>|</span>
</template>

<script>
export default {
name: 'FilterDivider',
}
</script>

<style scoped>
span {
color: rgba(0, 0, 0, 0.12);
align-self: center;
}
</style>
Loading