Skip to content

Commit

Permalink
fix(SingleSelectComponent): remove redundant 'Add All'
Browse files Browse the repository at this point in the history
  • Loading branch information
1000daysofcode committed Aug 20, 2024
1 parent 7691df6 commit e8ce240
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 50 deletions.
5 changes: 1 addition & 4 deletions packages/lib/src/components/catalogue/DataTreeElement.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,7 @@
{:else}
<div part="data-tree-element-last-child-options">
{#if "fieldType" in element && element.fieldType === "single-select"}
<SingleSelectComponent
{element}
subgrouping={subCategoryName ? true : false}
/>
<SingleSelectComponent {element} />
{:else if "fieldType" in element && element.fieldType === "autocomplete"}
<AutocompleteComponent {element} />
{:else if "fieldType" in element && element.fieldType === "number"}
Expand Down
46 changes: 0 additions & 46 deletions packages/lib/src/components/catalogue/SingleSelectComponent.svelte
Original file line number Diff line number Diff line change
@@ -1,58 +1,12 @@
<script lang="ts">
import { iconStore } from "../../stores/icons";
import { addItemToQuery } from "../../stores/query";
import type { QueryItem } from "../../types/queryData";
import type { Category } from "../../types/treeData";
import SingleSelectItemComponent from "./SingleSelectItemComponent.svelte";
import { v4 as uuidv4 } from "uuid";
export let element: Category;
export let subgrouping: boolean = false;
const addAll = (): void => {
if (!("criteria" in element)) return;
element.criteria.forEach((criterion) => {
const queryItem: QueryItem = {
id: uuidv4(),
key: element.key,
name: element.name,
type: "type" in element && element.type,
values: [
{
name: criterion.name,
value:
"aggregatedValue" in criterion
? criterion.aggregatedValue
: criterion.key,
queryBindId: uuidv4(),
},
],
};
addItemToQuery(queryItem, 0);
});
};
</script>

<div part="criterion-wrapper single-select-wrapper">
{#if "criteria" in element}
{#if subgrouping && element.criteria.length > 1}
<div part="criterion-section criterion-section-values">
<span part="criterion-single-select-name">
alle hinzufügen
</span>
</div>
<button part="query-add-button" on:click={addAll}>
{#if $iconStore.get("addIconUrl")}
<img
part="query-add-button-icon"
src={$iconStore.get("addIconUrl")}
alt="add icon"
/>
{:else}
&#8594;
{/if}
</button>
{/if}
{#each element.criteria as criterion}
<SingleSelectItemComponent {element} {criterion} />
{/each}
Expand Down

0 comments on commit e8ce240

Please sign in to comment.