Merge branch 'small-fixes' into 'master'

Small fixes

See merge request framasoft/mobilizon!864
This commit is contained in:
Thomas Citharel 2021-03-17 08:20:24 +00:00
commit 0f1c174614
7 changed files with 45 additions and 8 deletions

View File

@ -91,6 +91,8 @@ config :mobilizon, :instance,
# config :mobilizon, :activitypub, sign_object_fetches: false
config :mobilizon, Mobilizon.Web.Upload.Uploader.Local, uploads: "uploads"
config :mobilizon, :anonymous,
reports: [
allowed: true

View File

@ -193,8 +193,8 @@ export const FETCH_EVENT_BASIC = gql`
`;
export const FETCH_EVENTS = gql`
query {
events {
query FetchEvents($orderBy: EventOrderBy, $direction: SortDirection) {
events(orderBy: $orderBy, direction: $direction) {
total
elements {
id

View File

@ -239,3 +239,14 @@ export enum ActivityGroupSubject {
GROUP_CREATED = "group_created",
GROUP_UPDATED = "group_updated",
}
export enum EventSortField {
BEGINS_ON = "BEGINS_ON",
INSERTED_AT = "INSERTED_AT",
UPDATED_AT = "UPDATED_AT",
}
export enum SortDirection {
ASC = "ASC",
DESC = "DESC",
}

View File

@ -320,7 +320,7 @@
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import { ParticipantRole } from "@/types/enums";
import { EventSortField, ParticipantRole, SortDirection } from "@/types/enums";
import { Paginate } from "@/types/paginate";
import { supportsWebPFormat } from "@/utils/support";
import { IParticipant, Participant } from "../types/participant.model";
@ -347,6 +347,10 @@ import Subtitle from "../components/Utils/Subtitle.vue";
events: {
query: FETCH_EVENTS,
fetchPolicy: "no-cache", // Debug me: https://github.com/apollographql/apollo-client/issues/3030
variables: {
orderBy: EventSortField.INSERTED_AT,
direction: SortDirection.DESC,
},
},
currentActor: {
query: CURRENT_ACTOR_CLIENT,

View File

@ -59,9 +59,7 @@
<b-field grouped>
<b-field :label="$t('City or region')" expanded>
<address-auto-complete
v-if="
loggedUser && loggedUser.settings && loggedUser.settings.location
"
v-if="loggedUser && loggedUser.settings"
:type="AddressSearchType.ADMINISTRATIVE"
:doGeoLocation="false"
v-model="address"

View File

@ -59,9 +59,13 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
end
end
def list_events(_parent, %{page: page, limit: limit}, _resolution)
def list_events(
_parent,
%{page: page, limit: limit, order_by: order_by, direction: direction},
_resolution
)
when limit < @event_max_limit do
{:ok, Events.list_events(page, limit)}
{:ok, Events.list_events(page, limit, order_by, direction)}
end
def list_events(_parent, %{page: _page, limit: _limit}, _resolution) do

View File

@ -297,11 +297,29 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
field(:id, :string, description: "The Contact Actor ID")
end
@desc "Available event sort fields"
enum :event_order_by do
value(:begins_on, description: "Sort by the date the event starts")
value(:inserted_at, description: "Sort by the date the event was created")
value(:updated_at, description: "Sort by the date the event was updated")
end
object :event_queries do
@desc "Get all events"
field :events, :paginated_event_list do
arg(:page, :integer, default_value: 1, description: "The page in the paginated event list")
arg(:limit, :integer, default_value: 10, description: "The limit of events per page")
arg(:order_by, :event_order_by,
default_value: :begins_on,
description: "Order the list of events by field"
)
arg(:direction, :sort_direction,
default_value: :asc,
description: "Direction for the sort"
)
resolve(&Event.list_events/3)
end