2021-03-14 03:54:43 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
v-if="user"
|
|
|
|
class="user"
|
|
|
|
>
|
|
|
|
<div class="header">
|
|
|
|
<h2 class="username">{{ user.username }}</h2>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<section
|
2021-03-15 02:30:47 +00:00
|
|
|
v-if="user.stashes?.length > 0"
|
2021-03-14 03:54:43 +00:00
|
|
|
class="section"
|
|
|
|
>
|
2021-03-21 02:23:58 +00:00
|
|
|
<div class="section-header">
|
|
|
|
<h3 class="section-heading">Stashes</h3>
|
2021-03-14 03:54:43 +00:00
|
|
|
|
2021-03-21 02:23:58 +00:00
|
|
|
<Icon
|
|
|
|
icon="plus3"
|
|
|
|
class="header-add"
|
|
|
|
@click="showAddStash = true"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<ul class="section-body stashes nolist">
|
2021-03-14 03:54:43 +00:00
|
|
|
<li
|
2021-03-15 02:30:47 +00:00
|
|
|
v-for="stash in user.stashes"
|
2021-03-14 03:54:43 +00:00
|
|
|
:key="stash.id"
|
2021-03-20 15:47:01 +00:00
|
|
|
class="stashes-stash"
|
2021-03-14 03:54:43 +00:00
|
|
|
>
|
2021-03-20 01:49:17 +00:00
|
|
|
<Stash
|
|
|
|
:stash="stash"
|
|
|
|
:is-me="isMe"
|
|
|
|
@publish="() => fetchUser()"
|
2021-03-20 22:03:13 +00:00
|
|
|
@remove="() => fetchUser()"
|
2021-03-20 01:49:17 +00:00
|
|
|
/>
|
2021-03-14 03:54:43 +00:00
|
|
|
</li>
|
2021-03-20 02:22:08 +00:00
|
|
|
|
|
|
|
<li
|
|
|
|
v-if="isMe"
|
2021-03-20 15:47:01 +00:00
|
|
|
class="stashes-stash stashes-add"
|
2021-03-20 02:22:08 +00:00
|
|
|
@click="showAddStash = true"
|
|
|
|
>
|
|
|
|
<Icon icon="plus2" />
|
|
|
|
</li>
|
2021-03-14 03:54:43 +00:00
|
|
|
</ul>
|
2021-04-04 22:48:03 +00:00
|
|
|
|
|
|
|
<AddStash
|
|
|
|
v-if="showAddStash"
|
|
|
|
@close="closeAddStash"
|
|
|
|
/>
|
2021-03-14 03:54:43 +00:00
|
|
|
</section>
|
2021-03-20 02:22:08 +00:00
|
|
|
|
2021-04-04 22:48:03 +00:00
|
|
|
<section
|
|
|
|
v-if="user.alerts?.length > 0"
|
|
|
|
class="section"
|
|
|
|
>
|
|
|
|
<div class="section-header">
|
|
|
|
<h3 class="section-heading">Alerts</h3>
|
|
|
|
|
|
|
|
<Icon
|
|
|
|
icon="plus3"
|
|
|
|
class="header-add"
|
|
|
|
@click="showAddAlert = true"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<ul class="section-body alerts nolist">
|
|
|
|
<li
|
|
|
|
v-for="alert in user.alerts"
|
|
|
|
:key="`alert-${alert.id}`"
|
|
|
|
class="alert"
|
|
|
|
>
|
|
|
|
<Alert
|
|
|
|
:alert="alert"
|
|
|
|
:is-me="isMe"
|
|
|
|
@remove="() => fetchUser()"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li
|
|
|
|
class="alerts-add"
|
|
|
|
@click="showAddAlert = true"
|
|
|
|
>
|
|
|
|
<Icon icon="plus2" />
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<AddAlert
|
|
|
|
v-if="showAddAlert"
|
|
|
|
@close="closeAddAlert"
|
|
|
|
>Alert</AddAlert>
|
|
|
|
</section>
|
2021-03-14 03:54:43 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-03-20 01:49:17 +00:00
|
|
|
import Stash from './stash.vue';
|
2021-04-04 22:48:03 +00:00
|
|
|
import Alert from './alert.vue';
|
|
|
|
import AddStash from '../stashes/add.vue';
|
|
|
|
import AddAlert from '../alerts/add.vue';
|
2021-03-14 03:54:43 +00:00
|
|
|
|
2021-03-19 01:36:31 +00:00
|
|
|
async function fetchUser() {
|
2021-03-15 02:30:47 +00:00
|
|
|
this.user = await this.$store.dispatch('fetchUser', this.$route.params.username);
|
2021-03-20 01:03:30 +00:00
|
|
|
this.isMe = this.user.id === this.$store.state.auth.user?.id;
|
|
|
|
|
2021-03-15 02:30:47 +00:00
|
|
|
this.pageTitle = this.user?.username;
|
2021-03-14 03:54:43 +00:00
|
|
|
}
|
|
|
|
|
2021-03-20 02:33:29 +00:00
|
|
|
async function closeAddStash(addedStash) {
|
|
|
|
this.showAddStash = false;
|
|
|
|
|
|
|
|
if (addedStash) {
|
|
|
|
await this.fetchUser();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-04 22:48:03 +00:00
|
|
|
async function closeAddAlert(addedAlert) {
|
|
|
|
this.showAddAlert = false;
|
|
|
|
|
|
|
|
if (addedAlert) {
|
|
|
|
await this.fetchUser();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-19 01:36:31 +00:00
|
|
|
async function mounted() {
|
|
|
|
await this.fetchUser();
|
|
|
|
}
|
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
export default {
|
|
|
|
components: {
|
2021-04-04 22:48:03 +00:00
|
|
|
AddAlert,
|
2021-03-20 02:22:08 +00:00
|
|
|
AddStash,
|
2021-04-04 22:48:03 +00:00
|
|
|
Alert,
|
2021-03-20 01:49:17 +00:00
|
|
|
Stash,
|
2021-03-14 03:54:43 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
user: this.$route.params.username === this.$store.state.auth.user?.username
|
|
|
|
? this.$store.state.auth.user
|
|
|
|
: null,
|
2021-03-20 01:03:30 +00:00
|
|
|
isMe: false,
|
2021-03-15 02:30:47 +00:00
|
|
|
pageTitle: null,
|
2021-03-20 02:22:08 +00:00
|
|
|
showAddStash: false,
|
2021-04-04 22:48:03 +00:00
|
|
|
showAddAlert: false,
|
2021-03-14 03:54:43 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted,
|
2021-03-19 01:36:31 +00:00
|
|
|
methods: {
|
2021-04-04 22:48:03 +00:00
|
|
|
closeAddAlert,
|
2021-03-20 02:33:29 +00:00
|
|
|
closeAddStash,
|
2021-03-19 01:36:31 +00:00
|
|
|
fetchUser,
|
|
|
|
},
|
2021-03-14 03:54:43 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-03-19 23:41:21 +00:00
|
|
|
@import 'breakpoints';
|
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
.header {
|
2021-03-21 02:23:58 +00:00
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
2021-03-14 03:54:43 +00:00
|
|
|
background: var(--profile);
|
|
|
|
}
|
|
|
|
|
|
|
|
.username {
|
2021-03-21 02:23:58 +00:00
|
|
|
padding: .5rem 1rem;
|
2021-03-14 03:54:43 +00:00
|
|
|
margin: 0;
|
|
|
|
font-size: 1.5rem;
|
|
|
|
color: var(--text-light);
|
2021-03-20 17:12:06 +00:00
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
2021-03-14 03:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.section {
|
2021-03-21 02:23:58 +00:00
|
|
|
padding: 1rem 0;
|
2021-03-14 03:54:43 +00:00
|
|
|
margin: 0 0 1rem 0;
|
|
|
|
}
|
|
|
|
|
2021-04-04 22:48:03 +00:00
|
|
|
.stashes,
|
|
|
|
.alerts {
|
2021-03-19 01:36:31 +00:00
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 1fr 1fr;
|
2021-03-20 02:22:08 +00:00
|
|
|
grid-auto-rows: 15fr;
|
|
|
|
grid-gap: 1rem;
|
2021-03-19 01:36:31 +00:00
|
|
|
}
|
|
|
|
|
2021-03-21 02:23:58 +00:00
|
|
|
.section-header {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
margin: 0 0 1rem 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.section-body {
|
|
|
|
padding: 0 1rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.section-heading {
|
2021-03-14 03:54:43 +00:00
|
|
|
color: var(--primary);
|
2021-03-21 02:23:58 +00:00
|
|
|
padding: 0 1rem;
|
|
|
|
margin: 0;
|
|
|
|
font-size: 1.25rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header-add {
|
|
|
|
height: auto;
|
|
|
|
padding: .5rem 1rem;
|
|
|
|
fill: var(--shadow);
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
fill: var(--primary);
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2021-03-14 03:54:43 +00:00
|
|
|
}
|
|
|
|
|
2021-03-20 15:47:01 +00:00
|
|
|
.stashes-stash {
|
|
|
|
min-width: 0;
|
|
|
|
}
|
|
|
|
|
2021-04-04 22:48:03 +00:00
|
|
|
.stashes-add,
|
|
|
|
.alerts-add {
|
2021-03-20 02:22:08 +00:00
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2021-03-20 22:03:13 +00:00
|
|
|
background: var(--shadow-touch);
|
2021-03-20 02:22:08 +00:00
|
|
|
|
|
|
|
.icon {
|
|
|
|
width: 1.5rem;
|
|
|
|
height: 1.5rem;
|
2021-03-20 22:03:13 +00:00
|
|
|
fill: var(--shadow-hint);
|
2021-03-20 02:22:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
2021-03-20 22:03:13 +00:00
|
|
|
background: var(--shadow-hint);
|
2021-03-20 02:22:08 +00:00
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
.icon {
|
2021-03-20 22:03:13 +00:00
|
|
|
fill: var(--shadow-weak);
|
2021-03-20 02:22:08 +00:00
|
|
|
}
|
|
|
|
}
|
2021-03-14 03:54:43 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 23:41:21 +00:00
|
|
|
@media(max-width: $breakpoint-kilo) {
|
2021-04-04 22:48:03 +00:00
|
|
|
.stashes,
|
|
|
|
.alerts {
|
2021-03-19 23:41:21 +00:00
|
|
|
grid-template-columns: 1fr;
|
|
|
|
}
|
|
|
|
}
|
2021-03-14 03:54:43 +00:00
|
|
|
</style>
|