Skip to content

Commit 9711a75

Browse files
committed
💚 linter
1 parent e96e8e6 commit 9711a75

File tree

3 files changed

+47
-41
lines changed

3 files changed

+47
-41
lines changed

personalization-webcomponents/src/ChecklistDetail.ce.vue

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
<script setup lang="ts">
6363
import type Checklist from "@/api/persservice/Checklist.ts";
64+
import type ChecklistItem from "@/api/persservice/ChecklistItem.ts";
6465
import type AuthorizationEventDetails from "@/types/AuthorizationEventDetails.ts";
6566
6667
import { MucBanner } from "@muenchen/muc-patternlab-vue";
@@ -74,7 +75,6 @@ import ChecklistList from "@/components/ChecklistList.vue";
7475
import SkeletonLoader from "@/components/common/SkeletonLoader.vue";
7576
import { useDBSLoginWebcomponentPlugin } from "@/composables/DBSLoginWebcomponentPlugin.ts";
7677
import { QUERY_PARAM_CHECKLIST_ID, setAccessToken } from "@/util/Constants.ts";
77-
import type ChecklistItem from "@/api/persservice/ChecklistItem.ts";
7878
7979
const checklist = ref<Checklist | null>(null);
8080
const loading = ref(true);
@@ -205,39 +205,39 @@ function onCheckedClosed(serviceID: string) {
205205
*
206206
* @param evt Sort-Event which contains the old and new index of the checklist-item.
207207
*/
208-
function onSortOpen(evt: { oldIndex: number, newIndex: number }) {
209-
let elementToSort = openCheckList.value[evt.oldIndex] as ChecklistItem;
210-
let oldIndex = checklist.value?.checklistItems.findIndex(item => {return item.serviceID === elementToSort.serviceID}) as number;
211-
if(oldIndex >= 0 && checklist.value) {
208+
function onSortOpen(evt: { oldIndex: number; newIndex: number }) {
209+
const elementToSort = openCheckList.value[evt.oldIndex] as ChecklistItem;
210+
const oldIndex = checklist.value?.checklistItems.findIndex((item) => {
211+
return item.serviceID === elementToSort.serviceID;
212+
}) as number;
213+
if (oldIndex >= 0 && checklist.value) {
212214
loading.value = true;
213215
214216
const newIndex = oldIndex + (evt.newIndex - evt.oldIndex);
215-
const element = checklist.value.checklistItems[oldIndex];
217+
const element = checklist.value.checklistItems[oldIndex] as ChecklistItem;
216218
checklist.value.checklistItems.splice(oldIndex, 1);
217-
checklist.value.checklistItems.splice(newIndex, 0, element!)
219+
checklist.value.checklistItems.splice(newIndex, 0, element);
218220
219221
const service = new ChecklistService();
220222
service
221-
.updateChecklist(checklist.value)
222-
.then((resp) => {
223-
if (resp.ok) {
224-
resp.json().then((newChecklist) => {
225-
checklist.value = newChecklist;
226-
});
227-
} else {
228-
resp.text().then((errBody) => {
229-
throw Error(errBody);
230-
});
231-
}
232-
})
233-
.catch((err) => {
234-
console.debug(err);
235-
})
236-
.finally(() => (loading.value = false));
237-
223+
.updateChecklist(checklist.value)
224+
.then((resp) => {
225+
if (resp.ok) {
226+
resp.json().then((newChecklist) => {
227+
checklist.value = newChecklist;
228+
});
229+
} else {
230+
resp.text().then((errBody) => {
231+
throw Error(errBody);
232+
});
233+
}
234+
})
235+
.catch((err) => {
236+
console.debug(err);
237+
})
238+
.finally(() => (loading.value = false));
238239
}
239240
}
240-
241241
</script>
242242

243243
<style>

personalization-webcomponents/src/api/persservice/ChecklistService.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { getAccessToken, getAPIBaseURL } from "@/util/Constants.ts";
21
import type Checklist from "@/api/persservice/Checklist.ts";
32

3+
import { getAccessToken, getAPIBaseURL } from "@/util/Constants.ts";
4+
45
export default class ChecklistService {
56
getChecklists(): Promise<Response> {
67
//todo replace with openapi generated client when backend is finished
@@ -32,7 +33,10 @@ export default class ChecklistService {
3233

3334
updateChecklist(newChecklist: Checklist): Promise<Response> {
3435
//todo replace with openapi generated client when backend is finished
35-
const url = getAPIBaseURL() + "/clients/api/p13n-backend/checklist/" + newChecklist.id;
36+
const url =
37+
getAPIBaseURL() +
38+
"/clients/api/p13n-backend/checklist/" +
39+
newChecklist.id;
3640

3741
return fetch(url, {
3842
method: "PUT",

personalization-webcomponents/src/components/ChecklistList.vue

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
aria-roledescription="sortierbares Listenelement"
2020
:class="{
2121
muted: element.checked !== null,
22-
'keyboard-dragging': draggedIndex === index
22+
'keyboard-dragging': draggedIndex === index,
2323
}"
2424
:aria-grabbed="draggedIndex === index ? 'true' : 'false'"
2525
:aria-label="`${element.title}, Position ${index + 1} von ${checklistItems.length}`"
@@ -78,9 +78,9 @@
7878
<script lang="ts" setup>
7979
import type ChecklistItem from "@/api/persservice/ChecklistItem.ts";
8080
81-
import {MucIcon} from "@muenchen/muc-patternlab-vue";
82-
import {Sortable} from "sortablejs-vue3";
83-
import {computed, onBeforeUnmount, onMounted, ref} from "vue";
81+
import { MucIcon } from "@muenchen/muc-patternlab-vue";
82+
import { Sortable } from "sortablejs-vue3";
83+
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
8484
8585
const props = withDefaults(
8686
defineProps<{
@@ -130,11 +130,11 @@ function closeDialog() {
130130
dialogVisible.value = false;
131131
}
132132
133-
function onSortEnd(evt: { oldIndex: number, newIndex: number }) {
133+
function onSortEnd(evt: { oldIndex: number; newIndex: number }) {
134134
const oldIndex = evt.oldIndex;
135135
const newIndex = evt.newIndex;
136-
if(oldIndex !== newIndex) {
137-
emit('sort', {oldIndex, newIndex});
136+
if (oldIndex !== newIndex) {
137+
emit("sort", { oldIndex, newIndex });
138138
}
139139
}
140140
@@ -153,16 +153,18 @@ function handleArrowKeyDown(event: KeyboardEvent) {
153153
154154
const maxIndex = props.checklistItems.length - 1;
155155
const move = (direction: number) => {
156-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
157-
const newIndex = draggedIndex.value! + direction;
158-
if (newIndex < 0 || newIndex > maxIndex) return;
156+
if (draggedIndex.value) {
157+
158+
const newIndex = draggedIndex.value + direction;
159+
if (newIndex < 0 || newIndex > maxIndex) return;
159160
160-
event.preventDefault();
161+
event.preventDefault();
161162
162-
emit("sort", {oldIndex: draggedIndex.value!, newIndex});
163+
emit("sort", { oldIndex: draggedIndex.value, newIndex });
163164
164-
draggedIndex.value = newIndex;
165-
focusedIndex.value = newIndex;
165+
draggedIndex.value = newIndex;
166+
focusedIndex.value = newIndex;
167+
}
166168
};
167169
168170
if (event.key === "ArrowUp") move(-1);

0 commit comments

Comments
 (0)