Skip to content

Commit

Permalink
create some base components
Browse files Browse the repository at this point in the history
  • Loading branch information
OlliL committed Nov 24, 2024
1 parent 30f4239 commit c3ae4de
Show file tree
Hide file tree
Showing 11 changed files with 419 additions and 515 deletions.
18 changes: 18 additions & 0 deletions src/components/DivContentTable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<div class="row justify-content-md-center">
<div :class="class">
<table class="table table-striped table-bordered table-hover">
<slot name="default"></slot>
</table>
</div>
</div>
</template>

<script lang="ts" setup>
defineProps({
class: {
type: String,
default: "col-xxl-9 col-xs-12",
},
});
</script>
2 changes: 1 addition & 1 deletion src/components/DivError.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div v-if="serverErrors">
<div v-if="serverErrors && serverErrors.length > 0">
<div
class="alert alert-danger text-center"
v-for="(error, index) in serverErrors"
Expand Down
78 changes: 78 additions & 0 deletions src/components/DivFilter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<template>
<div class="row justify-content-md-center">
<div class="col-md-auto mb-3">
<div class="row">
<div class="col-md-auto mb-3">
<button
type="button"
class="btn btn-primary"
@click="$emit('createClicked')"
>
{{ $t("General.new") }}
</button>
</div>
<div class="col">
<div class="input-group">
<button
type="button"
class="btn btn-primary"
@click="emit('update:modelValue', '')"
>
{{ $t("General.all") }}
</button>
<input
class="form-control"
type="text"
:placeholder="placeholder"
:value="props.modelValue"
@input="emit('update:modelValue', $event.target.value)"

Check failure on line 28 in src/components/DivFilter.vue

View workflow job for this annotation

GitHub Actions / Analyze (javascript-typescript)

'$event.target' is possibly 'null'.

Check failure on line 28 in src/components/DivFilter.vue

View workflow job for this annotation

GitHub Actions / Analyze (javascript-typescript)

Property 'value' does not exist on type 'EventTarget'.
/>
<div
class="form-check form-switch align-self-center ms-2"
v-if="showValidToggle"
>
<input
class="form-check-input"
type="checkbox"
id="validInput"
v-model="validNow"
@change="emit('validNowToggled', validNow)"
/>
<label class="form-check-label" for="validInput">{{
$t("General.validNow")
}}</label>
</div>
</div>
</div>
</div>
</div>
</div>
</template>

<script setup lang="ts">
import { ref } from "vue";
const searchString = ref("");
const validNow = ref(true);
const emit = defineEmits([
"update:modelValue",
"validNowToggled",
"createClicked",
]);
const props = defineProps({
placeholder: {
type: String,
default: "",
},
modelValue: {
type: String,
required: true,
},
showValidToggle: {
type: Boolean,
default: true,
},
});
</script>
135 changes: 53 additions & 82 deletions src/views/capitalsource/ListCapitalsources.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,82 +17,39 @@
</div>
</div>

<div class="row justify-content-md-center">
<div class="col-md-auto mb-3">
<div class="row">
<div class="col-md-auto mb-3">
<button
type="button"
class="btn btn-primary"
@click="showCreateCapitalsourceModal"
>
{{ $t("General.new") }}
</button>
</div>
<div class="col">
<div class="input-group">
<button
type="button"
class="btn btn-primary"
@click="searchAllContent"
>
{{ $t("General.all") }}
</button>
<input
class="form-control"
type="text"
:placeholder="$t('Capitalsource.searchBy')"
v-model="searchString"
@input="searchContent"
/>
<div class="form-check form-switch align-self-center ms-2">
<input
class="form-check-input"
type="checkbox"
id="capitalsourcesValid"
v-model="validNow"
@change="searchContent"
/>
<label class="form-check-label" for="capitalsourcesValid">{{
$t("General.validNow")
}}</label>
</div>
</div>
</div>
</div>
</div>
</div>

<div class="row justify-content-md-center">
<div class="col-xxl-9 col-xs-12">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>{{ $t("General.name") }}</th>
<th>{{ $t("Capitalsource.type") }}</th>
<th>{{ $t("Capitalsource.state") }}</th>
<th>{{ $t("General.iban") }}</th>
<th>{{ $t("General.bic") }}</th>
<th>{{ $t("General.validFrom") }}</th>
<th>{{ $t("General.validTil") }}</th>
<th>{{ $t("Capitalsource.groupUse") }}</th>
<th>{{ $t("Capitalsource.importAllowed") }}</th>
<th colspan="2"></th>
</tr>
</thead>
<tbody>
<ListCapitalsourceRowVue
v-for="mcs in capitalsources"
:key="mcs.id"
:mcs="mcs"
:owner="mcs.userId === userId"
@delete-capitalsource="deleteCapitalsource"
@edit-capitalsource="editCapitalsource"
/>
</tbody>
</table>
</div>
</div>
<DivFilter
v-model="searchString"
:placeholder="$t('Capitalsource.searchBy')"
@validNowToggled="validNowToggled"
@createClicked="showCreateCapitalsourceModal"
/>

<DivContentTable>
<thead>
<tr>
<th>{{ $t("General.name") }}</th>
<th>{{ $t("Capitalsource.type") }}</th>
<th>{{ $t("Capitalsource.state") }}</th>
<th>{{ $t("General.iban") }}</th>
<th>{{ $t("General.bic") }}</th>
<th>{{ $t("General.validFrom") }}</th>
<th>{{ $t("General.validTil") }}</th>
<th>{{ $t("Capitalsource.groupUse") }}</th>
<th>{{ $t("Capitalsource.importAllowed") }}</th>
<th colspan="2"></th>
</tr>
</thead>
<tbody>
<ListCapitalsourceRowVue
v-for="mcs in capitalsources"
:key="mcs.id"
:mcs="mcs"
:owner="mcs.userId === userId"
@delete-capitalsource="deleteCapitalsource"
@edit-capitalsource="editCapitalsource"
/>
</tbody>
</DivContentTable>
</div>
</template>

Expand All @@ -102,6 +59,8 @@ import { onMounted, ref, useTemplateRef, watch } from "vue";
import { useCapitalsourceStore } from "@/stores/CapitalsourceStore";
import { useUserSessionStore } from "@/stores/UserSessionStore";
import DivContentTable from "@/components/DivContentTable.vue";
import DivFilter from "@/components/DivFilter.vue";
import CreateCapitalsourceModalVue from "@/components/capitalsource/CreateCapitalsourceModal.vue";
import DeleteCapitalsourceModalVue from "@/components/capitalsource/DeleteCapitalsourceModal.vue";
import ListCapitalsourceRowVue from "@/components/capitalsource/ListCapitalsourceRow.vue";
Expand All @@ -113,19 +72,18 @@ const validNow = ref(true);
const capitalsources = ref(new Array<Capitalsource>());
const searchString = ref("");
const createCapitalsourceModalList = useTemplateRef<typeof CreateCapitalsourceModalVue>('createCapitalsourceModalList');
const deleteModal = useTemplateRef<typeof DeleteCapitalsourceModalVue>('deleteModal');
const createCapitalsourceModalList = useTemplateRef<
typeof CreateCapitalsourceModalVue
>("createCapitalsourceModalList");
const deleteModal =
useTemplateRef<typeof DeleteCapitalsourceModalVue>("deleteModal");
const userId = useUserSessionStore().getUserId;
const capitalsourceStore = useCapitalsourceStore();
const searchCapitalsources = capitalsourceStore.searchCapitalsources;
const { capitalsource } = storeToRefs(capitalsourceStore);
watch(capitalsource, () => {
searchAllContent();
});
const showCreateCapitalsourceModal = () => {
createCapitalsourceModalList.value?._show();
};
Expand All @@ -138,6 +96,19 @@ const editCapitalsource = (mcs: Capitalsource) => {
createCapitalsourceModalList.value?._show(mcs);
};
watch(capitalsource, () => {
searchAllContent();
});
watch(searchString, () => {
searchContent();
});
const validNowToggled = (myValidNow: boolean) => {
validNow.value = myValidNow;
searchContent();
};
const searchAllContent = () => {
searchString.value = "";
searchContent();
Expand Down
Loading

0 comments on commit c3ae4de

Please sign in to comment.