Added option to change sorting on homepage to upcoming
(cherry picked from commit f09ede2b820dbce04c036abf582260eafba02795) upstream PR is https://framagit.org/framasoft/mobilizon/-/merge_requests/1236
This commit is contained in:
parent
a2d12990a4
commit
3aa10b77b3
|
@ -184,6 +184,7 @@ export const ADMIN_SETTINGS_FRAGMENT = gql`
|
||||||
instanceLongDescription
|
instanceLongDescription
|
||||||
instanceSlogan
|
instanceSlogan
|
||||||
contact
|
contact
|
||||||
|
InstanceHomepageSorting
|
||||||
instanceTerms
|
instanceTerms
|
||||||
instanceTermsType
|
instanceTermsType
|
||||||
instanceTermsUrl
|
instanceTermsUrl
|
||||||
|
@ -212,6 +213,7 @@ export const SAVE_ADMIN_SETTINGS = gql`
|
||||||
$instanceLongDescription: String
|
$instanceLongDescription: String
|
||||||
$instanceSlogan: String
|
$instanceSlogan: String
|
||||||
$contact: String
|
$contact: String
|
||||||
|
$InstanceHomepageSorting: InstanceHomepageSorting
|
||||||
$instanceTerms: String
|
$instanceTerms: String
|
||||||
$instanceTermsType: InstanceTermsType
|
$instanceTermsType: InstanceTermsType
|
||||||
$instanceTermsUrl: String
|
$instanceTermsUrl: String
|
||||||
|
@ -228,6 +230,7 @@ export const SAVE_ADMIN_SETTINGS = gql`
|
||||||
instanceLongDescription: $instanceLongDescription
|
instanceLongDescription: $instanceLongDescription
|
||||||
instanceSlogan: $instanceSlogan
|
instanceSlogan: $instanceSlogan
|
||||||
contact: $contact
|
contact: $contact
|
||||||
|
InstanceHomepageSorting: $InstanceHomepageSorting
|
||||||
instanceTerms: $instanceTerms
|
instanceTerms: $instanceTerms
|
||||||
instanceTermsType: $instanceTermsType
|
instanceTermsType: $instanceTermsType
|
||||||
instanceTermsUrl: $instanceTermsUrl
|
instanceTermsUrl: $instanceTermsUrl
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { IEvent } from "@/types/event.model";
|
import type { IEvent } from "@/types/event.model";
|
||||||
import type { IGroup } from "./actor";
|
import type { IGroup } from "./actor";
|
||||||
import { InstanceTermsType } from "./enums";
|
import { InstanceTermsType, InstanceHomepageSorting } from "./enums";
|
||||||
|
|
||||||
export interface IDashboard {
|
export interface IDashboard {
|
||||||
lastPublicEventPublished: IEvent;
|
lastPublicEventPublished: IEvent;
|
||||||
|
@ -25,6 +25,7 @@ export interface IAdminSettings {
|
||||||
instanceSlogan: string;
|
instanceSlogan: string;
|
||||||
instanceLongDescription: string;
|
instanceLongDescription: string;
|
||||||
contact: string;
|
contact: string;
|
||||||
|
InstanceHomepageSorting: InstanceHomepageSorting;
|
||||||
instanceTerms: string;
|
instanceTerms: string;
|
||||||
instanceTermsType: InstanceTermsType;
|
instanceTermsType: InstanceTermsType;
|
||||||
instanceTermsUrl: string | null;
|
instanceTermsUrl: string | null;
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import { InstancePrivacyType, InstanceTermsType, RoutingType } from "./enums";
|
import {
|
||||||
|
InstancePrivacyType,
|
||||||
|
InstanceTermsType,
|
||||||
|
InstanceHomepageSorting,
|
||||||
|
RoutingType
|
||||||
|
} from "./enums";
|
||||||
import type { IProvider } from "./resource";
|
import type { IProvider } from "./resource";
|
||||||
|
|
||||||
export interface IOAuthProvider {
|
export interface IOAuthProvider {
|
||||||
|
@ -79,6 +84,7 @@ export interface IConfig {
|
||||||
provider: string;
|
provider: string;
|
||||||
autocomplete: boolean;
|
autocomplete: boolean;
|
||||||
};
|
};
|
||||||
|
instanceHomepageSorting: InstanceHomepageSorting;
|
||||||
terms: {
|
terms: {
|
||||||
bodyHtml: string;
|
bodyHtml: string;
|
||||||
type: InstanceTermsType;
|
type: InstanceTermsType;
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
|
export enum InstanceHomepageSorting {
|
||||||
|
DEFAULT = "DEFAULT",
|
||||||
|
UPCOMING = "UPCOMING",
|
||||||
|
}
|
||||||
|
|
||||||
export enum InstanceTermsType {
|
export enum InstanceTermsType {
|
||||||
DEFAULT = "DEFAULT",
|
DEFAULT = "DEFAULT",
|
||||||
URL = "URL",
|
URL = "URL",
|
||||||
|
|
|
@ -64,6 +64,24 @@
|
||||||
<p class="content" v-else>{{ $t("Registration is closed.") }}</p>
|
<p class="content" v-else>{{ $t("Registration is closed.") }}</p>
|
||||||
</b-switch>
|
</b-switch>
|
||||||
</b-field>
|
</b-field>
|
||||||
|
<b-field :label="$t('Home Page Sorting')">
|
||||||
|
<b-field>
|
||||||
|
<b-radio
|
||||||
|
v-model="adminSettings.InstanceHomepageSorting"
|
||||||
|
name="InstanceHomepageSorting"
|
||||||
|
:native-value="InstanceHomepageSorting.DEFAULT"
|
||||||
|
>{{ $t("Recently Created") }}</b-radio
|
||||||
|
>
|
||||||
|
</b-field>
|
||||||
|
<b-field>
|
||||||
|
<b-radio
|
||||||
|
v-model="adminSettings.InstanceHomepageSorting"
|
||||||
|
name="InstanceHomepageSorting"
|
||||||
|
:native-value="InstanceHomepageSorting.UPCOMING"
|
||||||
|
>{{ $t("Upcoming") }}</b-radio
|
||||||
|
>
|
||||||
|
</b-field>
|
||||||
|
</b-field>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label has-help" for="instance-languages">{{
|
<label class="label has-help" for="instance-languages">{{
|
||||||
$t("Instance languages")
|
$t("Instance languages")
|
||||||
|
@ -375,7 +393,11 @@ import {
|
||||||
SAVE_ADMIN_SETTINGS,
|
SAVE_ADMIN_SETTINGS,
|
||||||
LANGUAGES,
|
LANGUAGES,
|
||||||
} from "@/graphql/admin";
|
} from "@/graphql/admin";
|
||||||
import { InstancePrivacyType, InstanceTermsType } from "@/types/enums";
|
import {
|
||||||
|
InstanceHomepageSorting,
|
||||||
|
InstancePrivacyType,
|
||||||
|
InstanceTermsType,
|
||||||
|
} from "@/types/enums";
|
||||||
import { IAdminSettings, ILanguage } from "../../types/admin.model";
|
import { IAdminSettings, ILanguage } from "../../types/admin.model";
|
||||||
import RouteName from "../../router/name";
|
import RouteName from "../../router/name";
|
||||||
|
|
||||||
|
@ -419,6 +441,8 @@ export default class Settings extends Vue {
|
||||||
|
|
||||||
filteredLanguages: string[] = [];
|
filteredLanguages: string[] = [];
|
||||||
|
|
||||||
|
InstanceHomepageSorting = InstanceHomepageSorting;
|
||||||
|
|
||||||
InstanceTermsType = InstanceTermsType;
|
InstanceTermsType = InstanceTermsType;
|
||||||
|
|
||||||
InstancePrivacyType = InstancePrivacyType;
|
InstancePrivacyType = InstancePrivacyType;
|
||||||
|
|
|
@ -226,7 +226,12 @@
|
||||||
/>
|
/>
|
||||||
<section class="events-recent">
|
<section class="events-recent">
|
||||||
<h2 class="title">
|
<h2 class="title">
|
||||||
{{ $t("Last published events") }}
|
{{
|
||||||
|
adminSettings.instanceHomepageSorting ===
|
||||||
|
InstanceHomepageSorting.DEFAULT
|
||||||
|
? $t("Last published events")
|
||||||
|
: $t("Upcoming Events")
|
||||||
|
}}
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
<i18n tag="span" path="On {instance} and other federated instances">
|
<i18n tag="span" path="On {instance} and other federated instances">
|
||||||
|
@ -258,7 +263,12 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue, Watch } from "vue-property-decorator";
|
import { Component, Vue, Watch } from "vue-property-decorator";
|
||||||
import { EventSortField, ParticipantRole, SortDirection } from "@/types/enums";
|
import {
|
||||||
|
EventSortField,
|
||||||
|
InstanceHomepageSorting,
|
||||||
|
ParticipantRole,
|
||||||
|
SortDirection,
|
||||||
|
} from "@/types/enums";
|
||||||
import { Paginate } from "@/types/paginate";
|
import { Paginate } from "@/types/paginate";
|
||||||
import { supportsWebPFormat } from "@/utils/support";
|
import { supportsWebPFormat } from "@/utils/support";
|
||||||
import { IParticipant, Participant } from "../types/participant.model";
|
import { IParticipant, Participant } from "../types/participant.model";
|
||||||
|
@ -274,6 +284,7 @@ import {
|
||||||
} from "../types/current-user.model";
|
} from "../types/current-user.model";
|
||||||
import { CURRENT_USER_CLIENT } from "../graphql/user";
|
import { CURRENT_USER_CLIENT } from "../graphql/user";
|
||||||
import { CLOSE_CONTENT, HOME_USER_QUERIES } from "../graphql/home";
|
import { CLOSE_CONTENT, HOME_USER_QUERIES } from "../graphql/home";
|
||||||
|
import { ADMIN_SETTINGS } from "../graphql/admin";
|
||||||
import RouteName from "../router/name";
|
import RouteName from "../router/name";
|
||||||
import { IEvent } from "../types/event.model";
|
import { IEvent } from "../types/event.model";
|
||||||
import DateComponent from "../components/Event/DateCalendarIcon.vue";
|
import DateComponent from "../components/Event/DateCalendarIcon.vue";
|
||||||
|
@ -284,11 +295,20 @@ import Subtitle from "../components/Utils/Subtitle.vue";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
apollo: {
|
apollo: {
|
||||||
|
adminSettings: ADMIN_SETTINGS,
|
||||||
events: {
|
events: {
|
||||||
query: FETCH_EVENTS,
|
query: FETCH_EVENTS,
|
||||||
variables: {
|
variables() {
|
||||||
orderBy: EventSortField.INSERTED_AT,
|
return this.adminSettings?.InstanceHomepageSorting ===
|
||||||
direction: SortDirection.DESC,
|
InstanceHomepageSorting.UPCOMING
|
||||||
|
? {
|
||||||
|
orderBy: EventSortField.BEGINS_ON,
|
||||||
|
direction: SortDirection.ASC,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
orderBy: EventSortField.INSERTED_AT,
|
||||||
|
direction: SortDirection.DESC,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
currentActor: {
|
currentActor: {
|
||||||
|
|
|
@ -114,6 +114,7 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
|
||||||
field(:instance_long_description, :string, description: "The instance's long description")
|
field(:instance_long_description, :string, description: "The instance's long description")
|
||||||
field(:instance_slogan, :string, description: "The instance's slogan")
|
field(:instance_slogan, :string, description: "The instance's slogan")
|
||||||
field(:contact, :string, description: "The instance's contact details")
|
field(:contact, :string, description: "The instance's contact details")
|
||||||
|
field(:instance_homepage_sorting, :instance_homepage_sorting, description: "The instance's homepage sorting")
|
||||||
field(:instance_terms, :string, description: "The instance's terms body text")
|
field(:instance_terms, :string, description: "The instance's terms body text")
|
||||||
field(:instance_terms_type, :instance_terms_type, description: "The instance's terms type")
|
field(:instance_terms_type, :instance_terms_type, description: "The instance's terms type")
|
||||||
field(:instance_terms_url, :string, description: "The instance's terms URL")
|
field(:instance_terms_url, :string, description: "The instance's terms URL")
|
||||||
|
@ -139,6 +140,12 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
|
||||||
value(:custom, as: "CUSTOM", description: "Custom terms text")
|
value(:custom, as: "CUSTOM", description: "Custom terms text")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@desc "The acceptable values for the instance's homepage type"
|
||||||
|
enum :instance_homepage_sorting do
|
||||||
|
value(:default, as: "DEFAULT", description: "Sort by recently created")
|
||||||
|
value(:upcoming, as: "UPCOMING", description: "Sort by upcoming")
|
||||||
|
end
|
||||||
|
|
||||||
@desc """
|
@desc """
|
||||||
The acceptable values for the instance privacy policy type
|
The acceptable values for the instance privacy policy type
|
||||||
"""
|
"""
|
||||||
|
@ -389,6 +396,7 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
|
||||||
arg(:instance_terms, :string, description: "The instance's terms body text")
|
arg(:instance_terms, :string, description: "The instance's terms body text")
|
||||||
arg(:instance_terms_type, :instance_terms_type, description: "The instance's terms type")
|
arg(:instance_terms_type, :instance_terms_type, description: "The instance's terms type")
|
||||||
arg(:instance_terms_url, :string, description: "The instance's terms URL")
|
arg(:instance_terms_url, :string, description: "The instance's terms URL")
|
||||||
|
arg(:instance_homepage_sorting, :instance_homepage_sorting, description: "The instance's homepage sorting")
|
||||||
|
|
||||||
arg(:instance_privacy_policy, :string,
|
arg(:instance_privacy_policy, :string,
|
||||||
description: "The instance's privacy policy body text"
|
description: "The instance's privacy policy body text"
|
||||||
|
|
|
@ -58,6 +58,8 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do
|
||||||
resolve(&Config.terms/3)
|
resolve(&Config.terms/3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
field(:instance_homepage_sorting, :instance_homepage_sorting, description: "The instance's homepage sorting")
|
||||||
|
|
||||||
field(:privacy, :privacy, description: "The instance's privacy policy") do
|
field(:privacy, :privacy, description: "The instance's privacy policy") do
|
||||||
arg(:locale, :string,
|
arg(:locale, :string,
|
||||||
default_value: "en",
|
default_value: "en",
|
||||||
|
|
|
@ -63,6 +63,11 @@ defmodule Mobilizon.Config do
|
||||||
Mobilizon.Admin.get_admin_setting_value("instance", "contact")
|
Mobilizon.Admin.get_admin_setting_value("instance", "contact")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec instance_homepage_sorting :: String.t()
|
||||||
|
def instance_homepage_sorting do
|
||||||
|
Mobilizon.Admin.get_admin_setting_value("instance", "instance_homepage_sorting", "DEFAULT")
|
||||||
|
end
|
||||||
|
|
||||||
@spec instance_terms(String.t()) :: String.t()
|
@spec instance_terms(String.t()) :: String.t()
|
||||||
def instance_terms(locale \\ "en") do
|
def instance_terms(locale \\ "en") do
|
||||||
Mobilizon.Admin.get_admin_setting_value("instance", "instance_terms", generate_terms(locale))
|
Mobilizon.Admin.get_admin_setting_value("instance", "instance_terms", generate_terms(locale))
|
||||||
|
@ -409,6 +414,7 @@ defmodule Mobilizon.Config do
|
||||||
instance_terms: instance_terms(),
|
instance_terms: instance_terms(),
|
||||||
instance_terms_type: instance_terms_type(),
|
instance_terms_type: instance_terms_type(),
|
||||||
instance_terms_url: instance_terms_url(),
|
instance_terms_url: instance_terms_url(),
|
||||||
|
instance_homepage_sorting: instance_homepage_sorting(),
|
||||||
instance_privacy_policy: instance_privacy(),
|
instance_privacy_policy: instance_privacy(),
|
||||||
instance_privacy_policy_type: instance_privacy_type(),
|
instance_privacy_policy_type: instance_privacy_type(),
|
||||||
instance_privacy_policy_url: instance_privacy_url(),
|
instance_privacy_policy_url: instance_privacy_url(),
|
||||||
|
|
|
@ -229,6 +229,9 @@ type Config {
|
||||||
locale: String
|
locale: String
|
||||||
): Terms
|
): Terms
|
||||||
|
|
||||||
|
"The instance's homepage sorting"
|
||||||
|
instanceHomepageSorting: InstanceHomepageSorting
|
||||||
|
|
||||||
"The instance's privacy policy"
|
"The instance's privacy policy"
|
||||||
privacy(
|
privacy(
|
||||||
"The user's locale. The privacy policy will be translated in their language, if available."
|
"The user's locale. The privacy policy will be translated in their language, if available."
|
||||||
|
@ -269,6 +272,15 @@ type Tag {
|
||||||
related: [Tag]
|
related: [Tag]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"The acceptable values for the instance's homepage type"
|
||||||
|
enum InstanceHomepageSorting {
|
||||||
|
"Sort by recently created"
|
||||||
|
DEFAULT
|
||||||
|
|
||||||
|
"Sort by upcoming"
|
||||||
|
UPCOMING
|
||||||
|
}
|
||||||
|
|
||||||
"Instance map routing configuration"
|
"Instance map routing configuration"
|
||||||
type Routing {
|
type Routing {
|
||||||
"The instance's routing type"
|
"The instance's routing type"
|
||||||
|
@ -1950,6 +1962,9 @@ type RootMutationType {
|
||||||
"The instance's terms URL"
|
"The instance's terms URL"
|
||||||
instanceTermsUrl: String
|
instanceTermsUrl: String
|
||||||
|
|
||||||
|
"The instance's homepage sorting"
|
||||||
|
instanceHomepageSorting: InstanceHomepageSorting
|
||||||
|
|
||||||
"The instance's privacy policy body text"
|
"The instance's privacy policy body text"
|
||||||
instancePrivacyPolicy: String
|
instancePrivacyPolicy: String
|
||||||
|
|
||||||
|
@ -3805,6 +3820,9 @@ type AdminSettings {
|
||||||
"The instance's contact details"
|
"The instance's contact details"
|
||||||
contact: String
|
contact: String
|
||||||
|
|
||||||
|
"The instance's homepage sorting"
|
||||||
|
instanceHomepageSorting: InstanceHomepageSorting
|
||||||
|
|
||||||
"The instance's terms body text"
|
"The instance's terms body text"
|
||||||
instanceTerms: String
|
instanceTerms: String
|
||||||
|
|
||||||
|
|
|
@ -337,6 +337,7 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
|
||||||
instanceDescription
|
instanceDescription
|
||||||
instanceLongDescription
|
instanceLongDescription
|
||||||
contact
|
contact
|
||||||
|
InstanceHomepageSorting
|
||||||
instanceTerms
|
instanceTerms
|
||||||
instanceTermsType
|
instanceTermsType
|
||||||
instanceTermsUrl
|
instanceTermsUrl
|
||||||
|
@ -419,6 +420,7 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
|
||||||
$instanceDescription: String
|
$instanceDescription: String
|
||||||
$instanceLongDescription: String
|
$instanceLongDescription: String
|
||||||
$contact: String
|
$contact: String
|
||||||
|
$InstanceHomepageSorting: InstanceHomepageSorting
|
||||||
$instanceTerms: String
|
$instanceTerms: String
|
||||||
$instanceTermsType: InstanceTermsType
|
$instanceTermsType: InstanceTermsType
|
||||||
$instanceTermsUrl: String
|
$instanceTermsUrl: String
|
||||||
|
@ -433,6 +435,7 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
|
||||||
instanceDescription: $instanceDescription
|
instanceDescription: $instanceDescription
|
||||||
instanceLongDescription: $instanceLongDescription
|
instanceLongDescription: $instanceLongDescription
|
||||||
contact: $contact
|
contact: $contact
|
||||||
|
InstanceHomepageSorting: $InstanceHomepageSorting
|
||||||
instanceTerms: $instanceTerms
|
instanceTerms: $instanceTerms
|
||||||
instanceTermsType: $instanceTermsType
|
instanceTermsType: $instanceTermsType
|
||||||
instanceTermsUrl: $instanceTermsUrl
|
instanceTermsUrl: $instanceTermsUrl
|
||||||
|
|
Loading…
Reference in a new issue