Skip to content

Commit ba328d3

Browse files
committed
fix lint issues
1 parent a43f944 commit ba328d3

File tree

2 files changed

+73
-42
lines changed

2 files changed

+73
-42
lines changed

client/src/views/PostFormView.vue

+68-31
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,48 @@
1111
</div>
1212

1313
<div class="form-floating mb-3">
14-
<textarea v-model="form.description" style="overflow-y: scroll; height: 6rem" class="form-control"
15-
id="description"></textarea>
14+
<textarea
15+
v-model="form.description"
16+
style="overflow-y: scroll; height: 6rem"
17+
class="form-control"
18+
id="description"
19+
></textarea>
1620
<label for="description">{{ t("posts.form.description") }}</label>
1721
</div>
1822

1923
<div class="form-floating mb-3">
2024
<label for="stringTags">{{ t("posts.form.tags.tags") }}</label>
21-
<vue-tags-input v-model="tag" :tags="tags" :autocomplete-items="tagList"
22-
:placeholder="t('posts.form.tags.enter')" @tags-changed="handleTagsChanged"
23-
@input="handleAutocompletion" @before-adding-tag="checkTag" />
25+
<vue-tags-input
26+
v-model="tag"
27+
:tags="tags"
28+
:autocomplete-items="tagList"
29+
:placeholder="t('posts.form.tags.enter')"
30+
@tags-changed="handleTagsChanged"
31+
@input="handleAutocompletion"
32+
@before-adding-tag="checkTag"
33+
/>
2434
</div>
2535

2636
<div class="mb-3">
27-
<ai-summaries :full-text="form.markdown" :onSetDescription="setDescription" :onAddTag="addTag"
28-
:onSetKeyvisual="setKeyvisual"></ai-summaries>
37+
<ai-summaries
38+
:full-text="form.markdown"
39+
:onSetDescription="setDescription"
40+
:onAddTag="addTag"
41+
:onSetKeyvisual="setKeyvisual"
42+
></ai-summaries>
2943
</div>
3044

3145
<div class="form-floating mb-3">
32-
<textarea v-model="form.markdown" class="form-control" placeholder="Blogpost" ref="markdownArea"
33-
style="height: 40vh; min-height: 200px" aria-describedby="markdownHelp"
34-
v-on:drop="dropMarkdown($event)" required></textarea>
46+
<textarea
47+
v-model="form.markdown"
48+
class="form-control"
49+
placeholder="Blogpost"
50+
ref="markdownArea"
51+
style="height: 40vh; min-height: 200px"
52+
aria-describedby="markdownHelp"
53+
v-on:drop="dropMarkdown($event)"
54+
required
55+
></textarea>
3556
<label for="markdown">{{ t("posts.form.message.label") }}</label>
3657
<div id="markdownHelp" class="form-text">{{ t("posts.form.message.hint") }}</div>
3758
</div>
@@ -54,12 +75,15 @@
5475
<h2 class="display-6">{{ (form?.title?.length ?? 0) > 0 ? form?.title : t("posts.form.preview.title") }}</h2>
5576
<div class="card flex-md-row mb-4 box-shadow h-md-250">
5677
<div class="card-body" style="max-width: 100%">
57-
<div v-if="loading" style="position: absolute; width: 100%; margin-top: 10vh; text-align: center"
58-
class="text-primary">
78+
<div v-if="loading" style="position: absolute; width: 100%; margin-top: 10vh; text-align: center" class="text-primary">
5979
<loading-spinner />
6080
</div>
61-
<mark-down :markdown="md" v-bind:custom-image-urls="files" @loading="loading = $event"
62-
:style="loading ? 'opacity:0.2' : 'opacity:1'"></mark-down>
81+
<mark-down
82+
:markdown="md"
83+
v-bind:custom-image-urls="files"
84+
@loading="loading = $event"
85+
:style="loading ? 'opacity:0.2' : 'opacity:1'"
86+
></mark-down>
6387
</div>
6488
</div>
6589
</div>
@@ -68,22 +92,41 @@
6892
<div class="card-body">
6993
<h3>
7094
{{ tc("posts.form.imageupload", Object.keys(files).length) }}
71-
<small class="text-body-secondary f-4" v-if="Object.keys(files).length > 0">({{
72-
convertToHumanReadableFileSize(totalBytesInFiles) }})</small>
95+
<small class="text-body-secondary f-4" v-if="Object.keys(files).length > 0"
96+
>({{ convertToHumanReadableFileSize(totalBytesInFiles) }})</small
97+
>
7398
</h3>
7499
<!-- Hidden file input, used to open the file dialog, when the dropzone is clicked -->
75-
<input style="display: none" type="file" id="file" multiple v-on:change="handleFileChange($event)"
76-
accept=".png, .gif, .jpg, .jpeg, image/png, image/jpeg, image/gif" />
77-
<div id="dropzone" v-on:click="openFileDialog()" v-on:drop="handleFileChange($event)"
78-
v-on:dragover="highlightDropzone($event, true)" v-on:dragleave="highlightDropzone($event, false)"
79-
:class="{ active: dropzoneHighlight }">
100+
<input
101+
style="display: none"
102+
type="file"
103+
id="file"
104+
multiple
105+
v-on:change="handleFileChange($event)"
106+
accept=".png, .gif, .jpg, .jpeg, image/png, image/jpeg, image/gif"
107+
/>
108+
<div
109+
id="dropzone"
110+
v-on:click="openFileDialog()"
111+
v-on:drop="handleFileChange($event)"
112+
v-on:dragover="highlightDropzone($event, true)"
113+
v-on:dragleave="highlightDropzone($event, false)"
114+
:class="{ active: dropzoneHighlight }"
115+
>
80116
<div class="plus"><fa-icon :icon="faUpload"></fa-icon></div>
81117
<span class="label" v-if="dropzoneHighlight">Dateien fallen lassen</span>
82118
<span class="label" v-else>Neue Dateien hierher ziehen oder hier klicken um Dateien auszuwählen</span>
83119
</div>
84120
<Suspense v-for="hash in Object.keys(files)" v-bind:key="hash">
85-
<ImagePreview :value="files[hash]" :hash="hash" @paste="pasteImageFileToMarkdown($event, 'afterCursor')"
86-
@delete="removeImageFileFromMarkdown(files[hash]); delete files[hash]">
121+
<ImagePreview
122+
:value="files[hash]"
123+
:hash="hash"
124+
@paste="pasteImageFileToMarkdown($event, 'afterCursor')"
125+
@delete="
126+
removeImageFileFromMarkdown(files[hash]);
127+
delete files[hash];
128+
"
129+
>
87130
</ImagePreview>
88131
</Suspense>
89132
</div>
@@ -204,7 +247,6 @@
204247
}
205248
206249
@keyframes shake {
207-
208250
10%,
209251
90% {
210252
transform: scale(0.9) translate3d(-1px, 0, 0);
@@ -251,8 +293,6 @@ import { computed, onMounted, reactive, ref, watch } from "vue";
251293
import { useRoute, useRouter } from "vue-router";
252294
import VueTagsInput from "@sipec/vue3-tags-input";
253295
254-
255-
256296
const tag = ref<string>("");
257297
const tags = ref<{ text: string; tiClasses?: string[] }[]>([]); // vue-tags-input internal format
258298
const md = ref<string | null>(null);
@@ -279,7 +319,6 @@ const props = defineProps({
279319
},
280320
});
281321
282-
283322
const totalBytesInFiles = computed(() =>
284323
Object.values(files)
285324
.map((it) => it.size)
@@ -309,7 +348,6 @@ onMounted(async () => {
309348
// ADD already existing attachments to files
310349
processAttachments(resJson.attachments);
311350
}
312-
313351
} catch (e) {
314352
postHasError.value = true;
315353
}
@@ -321,15 +359,14 @@ onMounted(async () => {
321359
}, 1000);
322360
});
323361
324-
325362
// Function to process attachments and populate the files object
326363
const processAttachments = (attachments: Attachment[]) => {
327364
attachments.forEach((attachment) => {
328365
const blob = new Uint8Array((attachment.file.binaryData as any).data);
329366
const file = new File([blob], attachment.filename, { type: attachment.file.mimeType });
330367
files[attachment.file.sha256] = file;
331368
});
332-
}
369+
};
333370
334371
// Create a computed property to generate URLs for the files
335372
const filesWithUrls = computed(() => {
@@ -350,7 +387,7 @@ const removeImageFileFromMarkdown = (file: File) => {
350387
setTimeout(() => {
351388
form.markdown = markDownBeforeRemove.replace(strToRemove, "");
352389
}, 0);
353-
}
390+
};
354391
355392
const dropMarkdown = (evt: DragEvent) => {
356393
const items = evt.dataTransfer?.items;

server/src/routes/posts.ts

+5-11
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ router.post(
174174
} else {
175175
return { postId: post.id, attachments: [] };
176176
}
177-
178-
179177
})
180178
.catch((err) => {
181179
throw new InternalServerError(true, "Could not create post " + err);
@@ -186,7 +184,6 @@ router.post(
186184
},
187185
);
188186

189-
190187
// EDIT EXISTING POST
191188
router.post("/:id(\\d+$)", authMiddleware, multipleFilesUpload, async (req: Request, res: Response, next) => {
192189
const postId = +req.params.id;
@@ -227,7 +224,6 @@ router.post("/:id(\\d+$)", authMiddleware, multipleFilesUpload, async (req: Requ
227224
// tags: tagsToUseInPost,
228225
})
229226
.then(async (updateResult) => {
230-
231227
manager.getRepository(AttachmentEntity).delete({ post: { id: post.id } });
232228

233229
const attachmentEntities: AttachmentEntity[] = await Promise.all(
@@ -277,11 +273,11 @@ async function getPersistedTagsForPost(post: PostEntity, bodyJson: PostRequestDt
277273
const alreadySavedTags =
278274
bodyJson.stringTags?.length > 0
279275
? await AppDataSource.manager
280-
.getRepository(TagEntity)
281-
.createQueryBuilder("tagEntity")
282-
.select()
283-
.where("tagEntity.name IN(:...names)", { names: bodyJson.stringTags })
284-
.getMany()
276+
.getRepository(TagEntity)
277+
.createQueryBuilder("tagEntity")
278+
.select()
279+
.where("tagEntity.name IN(:...names)", { names: bodyJson.stringTags })
280+
.getMany()
285281
: await Promise.all([]);
286282
tagsToUseInPost.push(...alreadySavedTags);
287283

@@ -318,8 +314,6 @@ router.get("/tags/:search", async (req: Request, res: Response, next) => {
318314
.catch(next);
319315
});
320316

321-
322-
323317
// DELETE POST
324318
router.get("/delete/:id(\\d+$)", async (req: Request, res: Response, next) => {
325319
await AppDataSource.manager.transaction(async (manager) => {

0 commit comments

Comments
 (0)