Add global search

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-08-26 16:08:58 +02:00
parent bfc936f57c
commit 48935e2168
216 changed files with 3646 additions and 2806 deletions

View File

@@ -83,12 +83,13 @@
<div class="container mx-auto">
<div class="navbar-menu flex flex-wrap py-2">
<div class="flex flex-wrap justify-end ml-auto gap-1">
<o-button type="is-text" @click="$router.go(-1)">{{
<o-button variant="text" @click="$router.go(-1)">{{
$t("Cancel")
}}</o-button>
<o-button
v-if="isUpdate"
type="is-danger is-outlined"
variant="danger"
outlined
@click="openDeletePostModal"
>{{ $t("Delete post") }}</o-button
>
@@ -140,7 +141,7 @@ import {
} from "../../graphql/post";
import { IPost } from "../../types/post.model";
import Editor from "../../components/Editor.vue";
import Editor from "../../components/TextEditor.vue";
import { displayName, IActor, usernameWithDomain } from "../../types/actor";
import TagInput from "../../components/Event/TagInput.vue";
import RouteName from "../../router/name";
@@ -191,11 +192,13 @@ onMounted(async () => {
pictureFile.value = await buildFileFromIMedia(post.value?.picture);
});
watch(post, async (newPost: IPost, oldPost: IPost) => {
if (oldPost?.picture !== newPost.picture) {
watch(post, async (newPost: IPost | undefined, oldPost: IPost | undefined) => {
if (oldPost?.picture !== newPost?.picture) {
pictureFile.value = await buildFileFromIMedia(post.value?.picture);
}
editablePost.value = { ...post.value };
if (newPost) {
editablePost.value = { ...newPost };
}
});
const router = useRouter();
@@ -370,7 +373,7 @@ const dialog = inject<Dialog>("dialog");
const openDeletePostModal = async (): Promise<void> => {
dialog?.confirm({
type: "danger",
variant: "danger",
title: t("Delete post"),
message: t(
"Are you sure you want to delete this post? This action cannot be reverted."
@@ -382,11 +385,8 @@ const openDeletePostModal = async (): Promise<void> => {
});
};
const {
mutate: deletePost,
onDone: onDeletePostDone,
onError: onDeletePostError,
} = useMutation(DELETE_POST);
const { mutate: deletePost, onDone: onDeletePostDone } =
useMutation(DELETE_POST);
onDeletePostDone(({ data }) => {
if (data && post.value?.attributedTo) {
@@ -405,27 +405,3 @@ useHead({
),
});
</script>
<style lang="scss" scoped>
@use "@/styles/_mixins" as *;
form {
nav.navbar {
// min-height: 2rem !important;
.container {
// min-height: 2rem;
.navbar-menu,
.navbar-end {
// display: flex !important;
// flex-wrap: wrap;
}
.navbar-end {
// justify-content: flex-end;
// @include margin-left(auto);
}
}
}
}
</style>

View File

@@ -11,12 +11,12 @@
>
<div class="flex-1">
<div class="inline">
<b-tag
<tag
class="mr-2"
variant="warning"
size="is-medium"
size="medium"
v-if="post.draft"
>{{ $t("Draft") }}</b-tag
>{{ $t("Draft") }}</tag
>
<h1 class="inline" :lang="post.language">
{{ post.title }}
@@ -191,7 +191,7 @@
has-modal-card
ref="reportModal"
>
<report-modal
<ReportModal
:on-confirm="reportPost"
:title="$t('Report this post')"
:outside-domain="groupDomain"
@@ -224,7 +224,6 @@ import LazyImageWrapper from "@/components/Image/LazyImageWrapper.vue";
import ActorInline from "@/components/Account/ActorInline.vue";
import { formatDistanceToNowStrict, Locale } from "date-fns";
import SharePostModal from "@/components/Post/SharePostModal.vue";
import { CREATE_REPORT } from "@/graphql/report";
import ReportModal from "@/components/Report/ReportModal.vue";
import { useAnonymousReportsConfig } from "@/composition/apollo/config";
import {
@@ -283,13 +282,6 @@ const isShareModalActive = ref(false);
const isReportModalActive = ref(false);
const reportModal = ref();
const isCurrentActorMember = computed((): boolean => {
if (!post.value?.attributedTo || !memberships.value) return false;
return memberships.value.elements
.map(({ parent: { id } }) => id)
.includes(post.value?.attributedTo.id);
});
const isInstanceModerator = computed((): boolean => {
return (
currentUser.value?.role !== undefined &&
@@ -313,8 +305,8 @@ const triggerShare = (): void => {
title: post.value?.title,
url: post.value?.url,
})
.then(() => console.log("Successful share"))
.catch((error: any) => console.log("Error sharing", error));
.then(() => console.debug("Successful share"))
.catch((error: any) => console.debug("Error sharing", error));
} else {
isShareModalActive.value = true;
// send popup
@@ -382,7 +374,7 @@ const dialog = inject<Dialog>("dialog");
const openDeletePostModal = async (): Promise<void> => {
dialog?.confirm({
type: "danger",
variant: "danger",
title: t("Delete post"),
message: t(
"Are you sure you want to delete this post? This action cannot be reverted."
@@ -396,11 +388,8 @@ const openDeletePostModal = async (): Promise<void> => {
const router = useRouter();
const {
mutate: deletePost,
onDone: onDeletePostDone,
onError: onDeletePostError,
} = useMutation(DELETE_POST);
const { mutate: deletePost, onDone: onDeletePostDone } =
useMutation(DELETE_POST);
onDeletePostDone(({ data }) => {
if (data && post.value?.attributedTo) {