Merge branch 'fixes' into 'main'

Improve actor cards integration

See merge request framasoft/mobilizon!1216
This commit is contained in:
Thomas Citharel 2022-04-22 10:38:42 +00:00
commit 030a149a61
6 changed files with 60 additions and 31 deletions

View File

@ -31,7 +31,11 @@
</p> </p>
<div <div
v-if="full" v-if="full"
:class="{ 'line-clamp-3': limit }" class="only-first-child"
:class="{
'line-clamp-3': limit,
'line-clamp-10': !limit,
}"
v-html="actor.summary" v-html="actor.summary"
/> />
</div> </div>
@ -95,3 +99,8 @@ export default class ActorCard extends Vue {
displayName = displayName; displayName = displayName;
} }
</script> </script>
<style scoped>
.only-first-child ::v-deep :not(:first-child) {
display: none;
}
</style>

View File

@ -14,8 +14,8 @@
}, },
]" ]"
/> />
<div class="actor-card"> <div>
<p v-if="group.suspended"> <p v-if="group.suspended" class="mx-auto max-w-sm block mb-2">
<actor-card <actor-card
:actor="group" :actor="group"
:full="true" :full="true"
@ -24,6 +24,7 @@
/> />
</p> </p>
<router-link <router-link
class="mx-auto max-w-sm block mb-2"
v-else v-else
:to="{ :to="{
name: RouteName.GROUP, name: RouteName.GROUP,
@ -572,16 +573,3 @@ export default class AdminGroupProfile extends Vue {
} }
} }
</script> </script>
<style lang="scss" scoped>
table,
section {
margin: 2rem 0;
}
.actor-card {
background: #fff;
padding: 1.5rem;
border-radius: 10px;
}
</style>

View File

@ -24,10 +24,14 @@
:actor="event.organizerActor" :actor="event.organizerActor"
:inline="true" :inline="true"
> >
<i18n path="By {username}" dir="auto"> <i18n
<span dir="ltr" slot="username" path="By {username}"
>@{{ usernameWithDomain(event.organizerActor) }}</span dir="auto"
> class="block truncate max-w-xs md:max-w-sm"
>
<span dir="ltr" slot="username">{{
displayName(event.organizerActor)
}}</span>
</i18n> </i18n>
</popover-actor-card> </popover-actor-card>
</div> </div>
@ -36,9 +40,23 @@
:actor="event.attributedTo" :actor="event.attributedTo"
:inline="true" :inline="true"
> >
<i18n path="By {group}" dir="auto"> <i18n
<span dir="ltr" slot="group" path="By {group}"
>@{{ usernameWithDomain(event.attributedTo) }}</span dir="auto"
class="block truncate max-w-xs md:max-w-sm"
>
<router-link
:to="{
name: RouteName.GROUP,
params: {
preferredUsername: usernameWithDomain(
event.attributedTo
),
},
}"
dir="ltr"
slot="group"
>{{ displayName(event.attributedTo) }}</router-link
> >
</i18n> </i18n>
</popover-actor-card> </popover-actor-card>
@ -474,7 +492,13 @@ import {
} from "../../graphql/event"; } from "../../graphql/event";
import { CURRENT_ACTOR_CLIENT, PERSON_STATUS_GROUP } from "../../graphql/actor"; import { CURRENT_ACTOR_CLIENT, PERSON_STATUS_GROUP } from "../../graphql/actor";
import { EventModel, IEvent } from "../../types/event.model"; import { EventModel, IEvent } from "../../types/event.model";
import { IActor, IPerson, Person, usernameWithDomain } from "../../types/actor"; import {
displayName,
IActor,
IPerson,
Person,
usernameWithDomain,
} from "../../types/actor";
import { GRAPHQL_API_ENDPOINT } from "../../api/_entrypoint"; import { GRAPHQL_API_ENDPOINT } from "../../api/_entrypoint";
import DateCalendarIcon from "../../components/Event/DateCalendarIcon.vue"; import DateCalendarIcon from "../../components/Event/DateCalendarIcon.vue";
import MultiCard from "../../components/Event/MultiCard.vue"; import MultiCard from "../../components/Event/MultiCard.vue";
@ -659,6 +683,8 @@ export default class Event extends EventMixin {
usernameWithDomain = usernameWithDomain; usernameWithDomain = usernameWithDomain;
displayName = displayName;
RouteName = RouteName; RouteName = RouteName;
observer!: IntersectionObserver; observer!: IntersectionObserver;

View File

@ -16,6 +16,9 @@ module.exports = {
secondary: withOpacityValue("--color-secondary"), secondary: withOpacityValue("--color-secondary"),
"violet-title": withOpacityValue("--color-violet-title"), "violet-title": withOpacityValue("--color-violet-title"),
}, },
lineClamp: {
10: "10",
},
}, },
}, },
plugins: [require("@tailwindcss/line-clamp")], plugins: [require("@tailwindcss/line-clamp")],

View File

@ -213,12 +213,6 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
_ -> nil _ -> nil
end end
last_group_created =
case Actors.list_actors(:Group) do
%Page{elements: [group | _]} -> group
_ -> nil
end
{:ok, {:ok,
%{ %{
number_of_users: Statistics.get_cached_value(:local_users), number_of_users: Statistics.get_cached_value(:local_users),
@ -231,7 +225,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
number_of_followers: Statistics.get_cached_value(:instance_followers), number_of_followers: Statistics.get_cached_value(:instance_followers),
number_of_followings: Statistics.get_cached_value(:instance_followings), number_of_followings: Statistics.get_cached_value(:instance_followings),
last_public_event_published: last_public_event_published, last_public_event_published: last_public_event_published,
last_group_created: last_group_created last_group_created: Actors.last_group_created()
}} }}
end end

View File

@ -444,6 +444,15 @@ defmodule Mobilizon.Actors do
|> Repo.preload(:organized_events) |> Repo.preload(:organized_events)
end end
@spec last_group_created :: Actor.t() | nil
def last_group_created do
Actor
|> where(type: :Group, suspended: false)
|> order_by(desc: :inserted_at)
|> limit(1)
|> Repo.one()
end
@doc """ @doc """
Builds a page struct for actors by their name or displayed name. Builds a page struct for actors by their name or displayed name.
""" """