forked from potsda.mn/mobilizon
Merge branch 'fixes' into 'main'
Various fixes Closes #1236, #1280 et #1277 See merge request framasoft/mobilizon!1381
This commit is contained in:
commit
94a51fbcab
|
@ -78,3 +78,5 @@ config :mobilizon, :exports,
|
|||
|
||||
config :tz_world,
|
||||
data_dir: System.get_env("MOBILIZON_TIMEZONES_DIR", "/var/lib/mobilizon/timezones")
|
||||
|
||||
config :tzdata, :data_dir, System.get_env("MOBILIZON_TIMEZONES_DIR", "/var/lib/mobilizon/tzdata")
|
||||
|
|
|
@ -272,11 +272,14 @@ button.menubar__button {
|
|||
@apply px-3 dark:text-black;
|
||||
}
|
||||
.pagination-link-current {
|
||||
@apply bg-primary cursor-not-allowed pointer-events-none border-primary text-white dark:text-zinc-900;
|
||||
@apply bg-primary dark:bg-primary cursor-not-allowed pointer-events-none border-primary text-white dark:text-zinc-900;
|
||||
}
|
||||
.pagination-ellipsis {
|
||||
@apply text-center m-1 text-gray-300;
|
||||
}
|
||||
.pagination-link-disabled {
|
||||
@apply bg-gray-200 dark:bg-gray-400;
|
||||
}
|
||||
|
||||
/** Tabs */
|
||||
.tabs-nav {
|
||||
|
|
|
@ -194,6 +194,8 @@
|
|||
has-modal-card
|
||||
ref="reportModal"
|
||||
:close-button-aria-label="t('Close')"
|
||||
:autoFocus="false"
|
||||
:trapFocus="false"
|
||||
>
|
||||
<ReportModal
|
||||
:on-confirm="reportComment"
|
||||
|
|
|
@ -190,6 +190,8 @@
|
|||
has-modal-card
|
||||
ref="reportModal"
|
||||
:close-button-aria-label="t('Close')"
|
||||
:autoFocus="false"
|
||||
:trapFocus="false"
|
||||
>
|
||||
<ReportModal
|
||||
:on-confirm="reportEvent"
|
||||
|
|
|
@ -39,7 +39,7 @@ import { IAddress } from "@/types/address.model";
|
|||
import { AddressSearchType } from "@/types/enums";
|
||||
import { computed, defineAsyncComponent } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import RouteName from "@/router/name";
|
||||
|
||||
const FullAddressAutoComplete = defineAsyncComponent(
|
||||
|
@ -53,6 +53,7 @@ const props = defineProps<{
|
|||
}>();
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: "update:location", location: IAddress | null): void;
|
||||
|
@ -89,6 +90,7 @@ const submit = () => {
|
|||
router.push({
|
||||
name: RouteName.SEARCH,
|
||||
query: {
|
||||
...route.query,
|
||||
locationName: location.value?.locality ?? location.value?.region,
|
||||
lat,
|
||||
lon,
|
||||
|
|
|
@ -20,38 +20,40 @@
|
|||
}}
|
||||
</p>
|
||||
</div>
|
||||
<div class="">
|
||||
<div class="" v-if="comment">
|
||||
<article class="">
|
||||
<div class="">
|
||||
<figure class="h-8 w-8" v-if="comment?.actor?.avatar">
|
||||
<img
|
||||
:src="comment.actor.avatar.url"
|
||||
alt=""
|
||||
width="48"
|
||||
height="48"
|
||||
/>
|
||||
</figure>
|
||||
<AccountCircle v-else :size="48" />
|
||||
</div>
|
||||
<div class="">
|
||||
<div class="prose dark:prose-invert">
|
||||
<strong>{{ comment?.actor?.name }}</strong>
|
||||
<small v-if="comment.actor"
|
||||
>@{{ usernameWithDomain(comment?.actor) }}</small
|
||||
>
|
||||
<br />
|
||||
<p v-html="comment.text"></p>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<div>
|
||||
<article v-if="comment">
|
||||
<div>
|
||||
<figure class="h-8 w-8" v-if="comment?.actor?.avatar">
|
||||
<img
|
||||
:src="comment.actor.avatar.url"
|
||||
alt=""
|
||||
width="48"
|
||||
height="48"
|
||||
/>
|
||||
</figure>
|
||||
<AccountCircle v-else :size="48" />
|
||||
</div>
|
||||
<div class="prose dark:prose-invert">
|
||||
<strong>{{ comment?.actor?.name }}</strong>
|
||||
<small v-if="comment.actor"
|
||||
>@{{ usernameWithDomain(comment?.actor) }}</small
|
||||
>
|
||||
<br />
|
||||
<p v-html="comment.text"></p>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<o-field
|
||||
:label="t('Additional comments')"
|
||||
label-for="additional-comments"
|
||||
>
|
||||
<o-input v-model="content" type="textarea" id="additional-comments" />
|
||||
<o-input
|
||||
v-model="content"
|
||||
type="textarea"
|
||||
id="additional-comments"
|
||||
autofocus
|
||||
ref="reportAdditionalCommentsInput"
|
||||
/>
|
||||
</o-field>
|
||||
|
||||
<div class="control" v-if="outsideDomain">
|
||||
|
@ -91,6 +93,7 @@ import { useI18n } from "vue-i18n";
|
|||
import { IComment } from "../../types/comment.model";
|
||||
import { usernameWithDomain } from "@/types/actor";
|
||||
import AccountCircle from "vue-material-design-icons/AccountCircle.vue";
|
||||
import { useFocus } from "@vueuse/core";
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
|
@ -108,18 +111,17 @@ const props = withDefaults(
|
|||
|
||||
const emit = defineEmits(["close"]);
|
||||
|
||||
// @Component({
|
||||
// mounted() {
|
||||
// this.$data.isActive = true;
|
||||
// },
|
||||
// })
|
||||
|
||||
// isActive = false;
|
||||
|
||||
const content = ref("");
|
||||
|
||||
const forward = ref(false);
|
||||
|
||||
const reportAdditionalCommentsInput = ref();
|
||||
// https://github.com/oruga-ui/oruga/issues/339
|
||||
const reportAdditionalCommentsInputComp = computed(
|
||||
() => reportAdditionalCommentsInput.value?.$refs.textarea
|
||||
);
|
||||
useFocus(reportAdditionalCommentsInputComp, { initialValue: true });
|
||||
|
||||
const { t } = useI18n({ useScope: "global" });
|
||||
|
||||
const translatedCancelText = computed((): string => {
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
ref="input"
|
||||
v-bind="inputAttrs"
|
||||
@keydown.enter="confirm"
|
||||
autofocus
|
||||
/>
|
||||
</o-field>
|
||||
</div>
|
||||
|
@ -48,6 +49,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useFocus } from "@vueuse/core";
|
||||
import { computed, nextTick, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
|
@ -87,6 +89,12 @@ const { t } = useI18n({ useScope: "global" });
|
|||
const prompt = ref<string>(props.hasInput ? props.inputAttrs?.value ?? "" : "");
|
||||
const input = ref();
|
||||
|
||||
// https://github.com/oruga-ui/oruga/issues/339
|
||||
const promptInputComp = computed(() => input.value?.$refs.input);
|
||||
if (props.hasInput) {
|
||||
useFocus(promptInputComp, { initialValue: true });
|
||||
}
|
||||
|
||||
// const dialogClass = computed(() => {
|
||||
// return [props.size];
|
||||
// });
|
||||
|
|
|
@ -230,6 +230,8 @@ const icons: Record<string, () => Promise<any>> = {
|
|||
import(
|
||||
`../../../node_modules/vue-material-design-icons/InboxArrowDown.vue`
|
||||
),
|
||||
InboxArrowUp: () =>
|
||||
import(`../../../node_modules/vue-material-design-icons/InboxArrowUp.vue`),
|
||||
LanDisconnect: () =>
|
||||
import(`../../../node_modules/vue-material-design-icons/LanDisconnect.vue`),
|
||||
CloudQuestion: () =>
|
||||
|
|
|
@ -48,6 +48,7 @@ export class Dialog {
|
|||
inputAttrs,
|
||||
hasInput,
|
||||
},
|
||||
autoFocus: false,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
/>
|
||||
</o-field>
|
||||
</div>
|
||||
<div v-if="instances && instances.elements.length > 0" class="mt-3">
|
||||
<div v-if="instances && instances.elements.length > 0" class="my-3">
|
||||
<router-link
|
||||
:to="{
|
||||
name: RouteName.INSTANCE,
|
||||
|
@ -133,7 +133,7 @@
|
|||
<o-pagination
|
||||
v-show="instances.total > INSTANCES_PAGE_LIMIT"
|
||||
:total="instances.total"
|
||||
v-model="instancePage"
|
||||
v-model:current="instancePage"
|
||||
:per-page="INSTANCES_PAGE_LIMIT"
|
||||
:aria-next-label="t('Next page')"
|
||||
:aria-previous-label="t('Previous page')"
|
||||
|
|
|
@ -617,7 +617,12 @@
|
|||
</div>
|
||||
</o-modal>
|
||||
</div>
|
||||
<o-modal v-if="group" v-model:active="isReportModalActive">
|
||||
<o-modal
|
||||
v-if="group"
|
||||
v-model:active="isReportModalActive"
|
||||
:autoFocus="false"
|
||||
:trapFocus="false"
|
||||
>
|
||||
<report-modal
|
||||
ref="reportModalRef"
|
||||
:on-confirm="reportGroup"
|
||||
|
|
|
@ -218,6 +218,8 @@
|
|||
v-model:active="isReportModalActive"
|
||||
has-modal-card
|
||||
ref="reportModal"
|
||||
:autoFocus="false"
|
||||
:trapFocus="false"
|
||||
>
|
||||
<ReportModal
|
||||
:on-confirm="reportPost"
|
||||
|
|
|
@ -818,6 +818,7 @@ enum ViewMode {
|
|||
|
||||
enum EventSortValues {
|
||||
MATCH_DESC = "MATCH_DESC",
|
||||
START_TIME_ASC = "START_TIME_ASC",
|
||||
START_TIME_DESC = "START_TIME_DESC",
|
||||
CREATED_AT_DESC = "CREATED_AT_DESC",
|
||||
CREATED_AT_ASC = "CREATED_AT_ASC",
|
||||
|
@ -831,6 +832,7 @@ enum GroupSortValues {
|
|||
|
||||
enum SortValues {
|
||||
MATCH_DESC = "MATCH_DESC",
|
||||
START_TIME_ASC = "START_TIME_ASC",
|
||||
START_TIME_DESC = "START_TIME_DESC",
|
||||
CREATED_AT_DESC = "CREATED_AT_DESC",
|
||||
CREATED_AT_ASC = "CREATED_AT_ASC",
|
||||
|
@ -1157,7 +1159,7 @@ const sortOptions = computed(() => {
|
|||
if (contentType.value == ContentType.EVENTS) {
|
||||
options.push(
|
||||
{
|
||||
key: SortValues.START_TIME_DESC,
|
||||
key: SortValues.START_TIME_ASC,
|
||||
label: t("Event date"),
|
||||
},
|
||||
{
|
||||
|
@ -1239,6 +1241,9 @@ const sortByForType = (
|
|||
value: SortValues,
|
||||
allowed: typeof EventSortValues | typeof GroupSortValues
|
||||
): SortValues | undefined => {
|
||||
if (value === SortValues.START_TIME_ASC && when.value === "past") {
|
||||
value = SortValues.START_TIME_DESC;
|
||||
}
|
||||
return Object.values(allowed).includes(value) ? value : undefined;
|
||||
};
|
||||
|
||||
|
|
|
@ -102,7 +102,8 @@ defmodule Mobilizon.Federation.ActivityPub.Actor do
|
|||
end
|
||||
|
||||
@spec find_or_make_group_from_nickname(nick :: String.t()) ::
|
||||
{:error, make_actor_errors | WebFinger.finger_errors()}
|
||||
{:ok, Mobilizon.Actors.Actor.t()}
|
||||
| {:error, make_actor_errors | WebFinger.finger_errors()}
|
||||
def find_or_make_group_from_nickname(nick), do: find_or_make_actor_from_nickname(nick, :Group)
|
||||
|
||||
@doc """
|
||||
|
|
|
@ -527,6 +527,12 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
|
|||
Instances.refresh()
|
||||
get_instance(parent, args, resolution)
|
||||
|
||||
{:error, :follow_pending} ->
|
||||
{:error, dgettext("errors", "This instance is pending follow approval")}
|
||||
|
||||
{:error, :already_following} ->
|
||||
{:error, dgettext("errors", "You are already following this instance")}
|
||||
|
||||
{:error, :http_error} ->
|
||||
{:error, dgettext("errors", "Unable to find an instance to follow at this address")}
|
||||
|
||||
|
|
|
@ -174,7 +174,8 @@ defmodule Mobilizon.GraphQL.Schema.SearchType do
|
|||
|
||||
enum :search_event_sort_options do
|
||||
value(:match_desc, description: "The pertinence of the result")
|
||||
value(:start_time_desc, description: "The start date of the result")
|
||||
value(:start_time_asc, description: "The start date of the result, ordered ascending")
|
||||
value(:start_time_desc, description: "The start date of the result, ordered descending")
|
||||
value(:created_at_desc, description: "When the event was published")
|
||||
value(:created_at_asc, description: "When the event was published")
|
||||
value(:participant_count_desc, description: "With the most participants")
|
||||
|
|
|
@ -1226,12 +1226,16 @@ defmodule Mobilizon.Actors do
|
|||
approved :: boolean | nil
|
||||
) ::
|
||||
{:ok, Follower.t()}
|
||||
| {:error, :already_following | :followed_suspended | Ecto.Changeset.t()}
|
||||
| {:error,
|
||||
:already_following | :follow_pending | :followed_suspended | Ecto.Changeset.t()}
|
||||
def follow(%Actor{} = followed, %Actor{} = follower, url \\ nil, approved \\ true) do
|
||||
if followed.suspended do
|
||||
{:error, :followed_suspended}
|
||||
else
|
||||
case check_follow(follower, followed) do
|
||||
%Follower{approved: false} ->
|
||||
{:error, :follow_pending}
|
||||
|
||||
%Follower{} ->
|
||||
{:error, :already_following}
|
||||
|
||||
|
|
|
@ -562,11 +562,12 @@ defmodule Mobilizon.Events do
|
|||
"""
|
||||
@spec build_events_for_search(map(), integer | nil, integer | nil) :: Page.t(Event.t())
|
||||
def build_events_for_search(%{term: term} = args, page \\ nil, limit \\ nil) do
|
||||
term
|
||||
|> normalize_search_string()
|
||||
search_string = normalize_search_string(term)
|
||||
|
||||
search_string
|
||||
|> events_for_search_query()
|
||||
|> events_for_begins_on(args)
|
||||
|> events_for_ends_on(args)
|
||||
|> events_for_begins_on(Map.get(args, :begins_on, DateTime.utc_now()))
|
||||
|> events_for_ends_on(Map.get(args, :ends_on))
|
||||
|> events_for_category(args)
|
||||
|> events_for_categories(args)
|
||||
|> events_for_languages(args)
|
||||
|
@ -579,7 +580,7 @@ defmodule Mobilizon.Events do
|
|||
|> filter_draft()
|
||||
|> filter_local_or_from_followed_instances_events()
|
||||
|> filter_public_visibility()
|
||||
|> event_order(Map.get(args, :sort_by, :match_desc))
|
||||
|> event_order(Map.get(args, :sort_by, :match_desc), search_string)
|
||||
|> Page.build_page(page, limit, :begins_on)
|
||||
end
|
||||
|
||||
|
@ -1321,18 +1322,16 @@ defmodule Mobilizon.Events do
|
|||
end
|
||||
end
|
||||
|
||||
defp events_for_search_query(""), do: Event
|
||||
|
||||
defp events_for_search_query(search_string) do
|
||||
Event
|
||||
|> distinct(:id)
|
||||
|> join(:inner, [e], id_and_rank in matching_event_ids_and_ranks(search_string),
|
||||
join(Event, :inner, [e], id_and_rank in matching_event_ids_and_ranks(search_string),
|
||||
on: id_and_rank.id == e.id
|
||||
)
|
||||
end
|
||||
|
||||
@spec events_for_begins_on(Ecto.Queryable.t(), map()) :: Ecto.Query.t()
|
||||
defp events_for_begins_on(query, args) do
|
||||
begins_on = Map.get(args, :begins_on, DateTime.utc_now())
|
||||
|
||||
@spec events_for_begins_on(Ecto.Queryable.t(), DateTime.t() | nil) :: Ecto.Query.t()
|
||||
defp events_for_begins_on(query, begins_on) do
|
||||
if is_nil(begins_on) do
|
||||
query
|
||||
else
|
||||
|
@ -1345,10 +1344,8 @@ defmodule Mobilizon.Events do
|
|||
end
|
||||
end
|
||||
|
||||
@spec events_for_ends_on(Ecto.Queryable.t(), map()) :: Ecto.Query.t()
|
||||
defp events_for_ends_on(query, args) do
|
||||
ends_on = Map.get(args, :ends_on)
|
||||
|
||||
@spec events_for_ends_on(Ecto.Queryable.t(), DateTime.t() | nil) :: Ecto.Query.t()
|
||||
defp events_for_ends_on(query, ends_on) do
|
||||
if is_nil(ends_on) do
|
||||
query
|
||||
else
|
||||
|
@ -1759,7 +1756,6 @@ defmodule Mobilizon.Events do
|
|||
|> distinct([e], e.id)
|
||||
|> join(:left, [e], et in "events_tags", on: e.id == et.event_id)
|
||||
|> join(:left, [e], a in Address, on: e.physical_address_id == a.id)
|
||||
|> events_for_begins_on(%{})
|
||||
|> filter_draft()
|
||||
|> filter_local_or_from_followed_instances_events()
|
||||
|> filter_public_visibility()
|
||||
|
@ -1948,17 +1944,49 @@ defmodule Mobilizon.Events do
|
|||
|
||||
defp event_order_by(query, _order_by, _direction), do: event_order_by(query, :begins_on, :asc)
|
||||
|
||||
defp event_order(query, :match_desc),
|
||||
do: order_by(query, [e, f], desc: f.rank, asc: e.begins_on)
|
||||
defp event_order(query, :match_desc, "") do
|
||||
query
|
||||
|> distinct([e], desc: e.begins_on, asc: e.id)
|
||||
|> order_by([e], desc: e.begins_on)
|
||||
end
|
||||
|
||||
defp event_order(query, :start_time_desc), do: order_by(query, [e], asc: e.begins_on)
|
||||
defp event_order(query, :created_at_desc), do: order_by(query, [e], desc: e.publish_at)
|
||||
defp event_order(query, :created_at_asc), do: order_by(query, [e], asc: e.publish_at)
|
||||
defp event_order(query, :match_desc, _) do
|
||||
query
|
||||
|> distinct([e, f], desc: f.rank, asc: e.begins_on, asc: e.id)
|
||||
|> order_by([e, f], desc: f.rank, asc: e.begins_on)
|
||||
end
|
||||
|
||||
defp event_order(query, :participant_count_desc),
|
||||
do: order_by(query, [e], fragment("participant_stats->>'participant' DESC"))
|
||||
defp event_order(query, :start_time_desc, _) do
|
||||
query
|
||||
|> distinct([e], desc: e.begins_on, asc: e.id)
|
||||
|> order_by([e], desc: e.begins_on)
|
||||
end
|
||||
|
||||
defp event_order(query, _), do: query
|
||||
defp event_order(query, :start_time_asc, _) do
|
||||
query
|
||||
|> distinct([e], asc: e.begins_on, asc: e.id)
|
||||
|> order_by([e], asc: e.begins_on)
|
||||
end
|
||||
|
||||
defp event_order(query, :created_at_desc, _) do
|
||||
query
|
||||
|> distinct([e], desc: e.publish_at, asc: e.id)
|
||||
|> order_by([e], desc: e.publish_at)
|
||||
end
|
||||
|
||||
defp event_order(query, :created_at_asc, _) do
|
||||
query
|
||||
|> distinct([e], asc: e.publish_at, asc: e.id)
|
||||
|> order_by([e], asc: e.publish_at)
|
||||
end
|
||||
|
||||
defp event_order(query, :participant_count_desc, _) do
|
||||
query
|
||||
|> distinct(:id)
|
||||
|> order_by([e], fragment("participant_stats->>'participant' DESC"))
|
||||
end
|
||||
|
||||
defp event_order(query, _, _), do: query
|
||||
|
||||
defp participation_filter_begins_on(query, nil, nil),
|
||||
do: participation_order_begins_on_desc(query)
|
||||
|
|
|
@ -17,6 +17,7 @@ defmodule Mobilizon.Service.GlobalSearch.SearchMobilizon do
|
|||
|
||||
@sort_by_options %{
|
||||
match_desc: "-match",
|
||||
start_time_asc: "startTime",
|
||||
start_time_desc: "-startTime",
|
||||
created_at_desc: "-createdAt",
|
||||
created_at_asc: "createdAt",
|
||||
|
|
Loading…
Reference in a new issue