Skip to content

Commit

Permalink
prettier fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Oct 10, 2023
1 parent 1fbb838 commit 6909bf2
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 58 deletions.
5 changes: 1 addition & 4 deletions client/src/components/Common/FilterMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ function updateFilterText(newFilterText: string) {
watch(
() => props.filterText,
(newFilterText: string) => {
const defaultBackendFilter = props.filterClass.getFilterText(
props.filterClass.defaultFilters,
true
);
const defaultBackendFilter = props.filterClass.getFilterText(props.filterClass.defaultFilters, true);
const currentBackendFilter = props.filterClass.getFilterText(filters.value, true);
const backendFilter =
Expand Down
33 changes: 16 additions & 17 deletions client/src/components/Common/FilterMenuInput.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import { capitalize } from "lodash";
import { computed, type PropType, ref, watch } from 'vue';
import { computed, type PropType, ref, watch } from "vue";
import { ValidFilter } from '@/utils/filtering';
import { ValidFilter } from "@/utils/filtering";
const props = defineProps({
name: { type: String, required: true },
Expand All @@ -25,12 +25,18 @@ const localValue = ref(propValue.value);
const helpToggle = ref(false);
const modalTitle = `${capitalize(props.filter.placeholder)} Help`;
watch(() => localValue.value, (newFilter: string) => {
emit("change", props.name, newFilter);
});
watch(() => propValue.value, (newFilter: string) => {
localValue.value = newFilter;
});
watch(
() => localValue.value,
(newFilter: string) => {
emit("change", props.name, newFilter);
}
);
watch(
() => propValue.value,
(newFilter: string) => {
localValue.value = newFilter;
}
);
function hasError(field: string) {
if (props.error && props.error.index == field) {
Expand Down Expand Up @@ -66,11 +72,7 @@ function onHelp(_: string, value: string) {
:options="props.filter.datalist"></b-form-datalist>
<!-- append Help Modal for filter if included or/and datepciker if type: Date -->
<b-input-group-append>
<b-button
v-if="props.filter.helpInfo"
:title="modalTitle"
size="sm"
@click="helpToggle = true">
<b-button v-if="props.filter.helpInfo" :title="modalTitle" size="sm" @click="helpToggle = true">
<icon icon="question" />
</b-button>
<b-form-datepicker
Expand All @@ -83,10 +85,7 @@ function onHelp(_: string, value: string) {
</b-input-group>
<!-- if a filter has help component, place it within a modal -->
<span v-if="props.filter.helpInfo">
<b-modal
v-model="helpToggle"
:title="modalTitle"
ok-only>
<b-modal v-model="helpToggle" :title="modalTitle" ok-only>
<component
:is="props.filter.helpInfo"
v-if="typeof props.filter.helpInfo == 'object'"
Expand Down
24 changes: 15 additions & 9 deletions client/src/components/Common/FilterMenuMultiTags.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed, type PropType, ref, watch } from 'vue';
import { computed, type PropType, ref, watch } from "vue";
import { ValidFilter } from '@/utils/filtering';
import { ValidFilter } from "@/utils/filtering";
import StatelessTags from "../Tags/StatelessTags.vue";
Expand All @@ -20,12 +20,18 @@ const propValue = computed(() => props.filters[props.name]);
const localValue = ref(propValue.value);
watch(() => localValue.value, (newFilter: string) => {
emit("change", props.name, newFilter);
});
watch(() => propValue.value, (newFilter: string) => {
localValue.value = newFilter;
});
watch(
() => localValue.value,
(newFilter: string) => {
emit("change", props.name, newFilter);
}
);
watch(
() => propValue.value,
(newFilter: string) => {
localValue.value = newFilter;
}
);
</script>

<template>
Expand All @@ -35,7 +41,7 @@ watch(() => propValue.value, (newFilter: string) => {
<StatelessTags
:value="localValue"
:placeholder="`any ${props.filter.placeholder}`"
@input="(tags) => localValue = tags" />
@input="(tags) => (localValue = tags)" />
</b-input-group>
</div>
</template>
60 changes: 32 additions & 28 deletions client/src/components/Common/FilterMenuRanged.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed, type PropType, ref, watch } from 'vue';
import { computed, type PropType, ref, watch } from "vue";
import { ValidFilter } from '@/utils/filtering';
import { ValidFilter } from "@/utils/filtering";
const props = defineProps({
name: { type: String, required: true },
Expand All @@ -25,18 +25,30 @@ const valueGt = computed(() => props.filters[localNameGt.value]);
const localValueGt = ref(valueGt.value);
const localValueLt = ref(valueLt.value);
watch(() => localValueGt.value, (newFilter: string) => {
emit("change", localNameGt.value, newFilter);
});
watch(() => localValueLt.value, (newFilter: string) => {
emit("change", localNameLt.value, newFilter);
});
watch(() => valueGt.value, (newFilter: string) => {
localValueGt.value = newFilter;
});
watch(() => valueLt.value, (newFilter: string) => {
localValueLt.value = newFilter;
});
watch(
() => localValueGt.value,
(newFilter: string) => {
emit("change", localNameGt.value, newFilter);
}
);
watch(
() => localValueLt.value,
(newFilter: string) => {
emit("change", localNameLt.value, newFilter);
}
);
watch(
() => valueGt.value,
(newFilter: string) => {
localValueGt.value = newFilter;
}
);
watch(
() => valueLt.value,
(newFilter: string) => {
localValueLt.value = newFilter;
}
);
const isDateType = computed(() => props.filter.type == Date);
Expand All @@ -47,12 +59,12 @@ function hasError(field: string) {
return "";
}
function localPlaceholder(comp: 'gt' | 'lt') {
if (comp == 'gt') {
const field = isDateType.value ? 'after' : 'greater';
function localPlaceholder(comp: "gt" | "lt") {
if (comp == "gt") {
const field = isDateType.value ? "after" : "greater";
return `${props.filter.placeholder} ${field}`;
} else {
const field = isDateType.value ? 'before' : 'lower';
const field = isDateType.value ? "before" : "lower";
return `${props.filter.placeholder} ${field}`;
}
}
Expand All @@ -73,11 +85,7 @@ function localPlaceholder(comp: 'gt' | 'lt') {
@keyup.enter="emit('on-enter')"
@keyup.esc="emit('on-esc')" />
<b-input-group-append v-if="isDateType">
<b-form-datepicker
v-model="localValueGt"
reset-button
button-only
size="sm" />
<b-form-datepicker v-model="localValueGt" reset-button button-only size="sm" />
</b-input-group-append>
<!--------------------------------------------------------------------->

Expand All @@ -92,11 +100,7 @@ function localPlaceholder(comp: 'gt' | 'lt') {
@keyup.enter="emit('on-enter')"
@keyup.esc="emit('on-esc')" />
<b-input-group-append v-if="isDateType">
<b-form-datepicker
v-model="localValueLt"
reset-button
button-only
size="sm" />
<b-form-datepicker v-model="localValueLt" reset-button button-only size="sm" />
</b-input-group-append>
<!--------------------------------------------------------------------->
</b-input-group>
Expand Down

0 comments on commit 6909bf2

Please sign in to comment.