Skip to content

Commit 4b4b8c0

Browse files
author
Ozbej Golob
committed
Minor bugfixes
1 parent dc16459 commit 4b4b8c0

4 files changed

Lines changed: 48 additions & 20 deletions

File tree

src/components/parcoord/ParcoordComponent.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@
191191
? 100 * dimensions.length + margin.left + margin.right
192192
: originalWidth;
193193
setTimeout(() => {
194-
axesComponent.clearSVG();
195-
axesComponent.renderAxes(width);
194+
axesComponent?.clearSVG();
195+
axesComponent?.renderAxes(width);
196196
linesComponent.debounceDrawLines();
197197
}, 0);
198198
}
@@ -240,8 +240,8 @@
240240
241241
function setMarginLeft() {
242242
setTimeout(() => {
243-
axesComponent.calculateMarginLeft();
244-
}, 0);
243+
axesComponent?.calculateMarginLeft();
244+
}, 1000);
245245
}
246246
247247
function setMarginRight(histogramsVisible: boolean) {

src/components/partitions/ColorPickerModal.svelte

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
1212
export let isOpen: boolean;
1313
export let partitionColor: RgbaColor;
14+
export let partitionColorOld: RgbaColor;
1415
export let position: CoordinateType;
1516
export let setColor: (color: RgbaColor) => void;
1617
@@ -43,14 +44,21 @@
4344
4445
function addCustomColor(color: RgbaColor) {
4546
rgb = color;
47+
setColor(rgb);
4648
customColors = [...customColors, rgbaToHexString(color)];
49+
selectedCustomIndex = customColors.length;
4750
localStorage.setItem('partitionsCustomColors', JSON.stringify(customColors));
4851
}
4952
5053
function deleteCustomColor(i: number | null) {
5154
if (i === null) return;
5255
customColors = [...customColors.slice(0, i), ...customColors.slice(i + 1)];
5356
localStorage.setItem('partitionsCustomColors', JSON.stringify(customColors));
57+
const defaultColor = hexStringToRgba(PARTITION_COLORS[0]);
58+
setColor(defaultColor);
59+
rgb = defaultColor;
60+
partitionColorOld = defaultColor;
61+
selectedCustomIndex = null;
5462
}
5563
5664
onMount(() => {
@@ -80,6 +88,7 @@
8088
: ''}"
8189
on:click={() => {
8290
rgb = hexStringToRgba(color);
91+
setColor(rgb);
8392
selectedCustomIndex = null;
8493
}}
8594
on:keydown={() => {}}
@@ -101,6 +110,7 @@
101110
: ''}"
102111
on:click={() => {
103112
rgb = hexStringToRgba(color);
113+
setColor(rgb);
104114
selectedCustomIndex = i;
105115
}}
106116
on:keydown={() => {}}
@@ -121,7 +131,7 @@
121131
<Button
122132
size="xs"
123133
color="red"
124-
disabled={selectedCustomIndex === null || usedColors.includes(rgbaToHexString(rgb))}
134+
disabled={selectedCustomIndex === null}
125135
on:click={() => deleteCustomColor(selectedCustomIndex)}
126136
class="focus:ring-transparent"><TrashBinOutline /></Button
127137
>
@@ -131,11 +141,18 @@
131141
<Button
132142
size="sm"
133143
on:click={() => {
134-
setColor(rgb);
135144
isOpen = false;
136145
}}
137-
class="focus:ring-transparent">Apply</Button
146+
class="focus:ring-transparent">OK</Button
147+
>
148+
<Button
149+
size="sm"
150+
color="red"
151+
on:click={() => {
152+
setColor(partitionColorOld);
153+
isOpen = false;
154+
}}
155+
class="focus:ring-transparent">Cancel</Button
138156
>
139-
<Button size="sm" color="red" on:click={() => (isOpen = false)} class="focus:ring-transparent">Cancel</Button>
140157
</div>
141158
</div>

src/components/partitions/ContextMenu.svelte

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { addRecordsToPartition } from './util';
88
import type { PartitionType } from './types';
99
import type { CoordinateType } from '../../util/types';
10+
import { DEFAULT_PARTITION } from '../../util/util';
1011
1112
let contextMenuElement: HTMLElement;
1213
let showMenu = false;
@@ -33,7 +34,7 @@
3334
3435
let partitions: Map<string, PartitionType> = new Map();
3536
const unsubscribePartitions = partitionsStore.subscribe((value) => {
36-
partitions = value;
37+
partitions = new Map([...value].filter(([key, value]) => key !== DEFAULT_PARTITION));
3738
});
3839
3940
let partitionsData: string[] = [];
@@ -95,23 +96,30 @@
9596
on:mouseenter={handleMouseEnter}
9697
on:mouseleave={handleMouseLeave}
9798
>
99+
<DropdownItem
100+
on:click={() => addRecords(DEFAULT_PARTITION)}
101+
defaultClass="font-medium py-0.5 px-0.5 text-xs hover:bg-gray-100 flex items-center justify-between"
102+
>Move to Default Partition</DropdownItem
103+
>
98104
{#if $selectedPartitionStore !== null}
99105
<DropdownItem
100106
on:click={() => addRecords($selectedPartitionStore)}
101107
defaultClass="font-medium py-0.5 px-0.5 text-xs hover:bg-gray-100">Add to Selected Partition</DropdownItem
102108
>
103109
{/if}
104-
<DropdownItem defaultClass="font-medium py-0.5 px-0.5 text-xs hover:bg-gray-100 flex items-center justify-between"
105-
>Add to Partition<ChevronRight class="w-3 h-3 ms-2" /></DropdownItem
106-
>
107-
<Dropdown class="p-1 w-40 max-h-36 overflow-y-auto overflow-x-hidden" placement={submenuStyle}>
108-
{#each [...partitions] as [key, value]}
109-
<DropdownItem
110-
defaultClass="font-medium py-0.5 px-0.5 text-xs hover:bg-gray-100"
111-
on:click={() => addRecords(key)}>{key}</DropdownItem
112-
>
113-
{/each}
114-
</Dropdown>
110+
{#if partitions.size > 0}
111+
<DropdownItem defaultClass="font-medium py-0.5 px-0.5 text-xs hover:bg-gray-100 flex items-center justify-between"
112+
>Add to Partition<ChevronRight class="w-3 h-3 ms-2" /></DropdownItem
113+
>
114+
<Dropdown class="p-1 w-40 max-h-36 overflow-y-auto overflow-x-hidden" placement={submenuStyle}>
115+
{#each [...partitions] as [key, value]}
116+
<DropdownItem
117+
defaultClass="font-medium py-0.5 px-0.5 text-xs hover:bg-gray-100"
118+
on:click={() => addRecords(key)}>{key}</DropdownItem
119+
>
120+
{/each}
121+
</Dropdown>
122+
{/if}
115123
<DropdownDivider />
116124
<DropdownItem
117125
defaultClass="font-medium py-0.5 px-0.5 text-xs hover:bg-gray-100"

src/components/partitions/PartitionElement.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
let isColorPickerOpen = false;
3030
let colorPickerPosition = { x: 0, y: 0 };
3131
let isNameEditable = false;
32+
let partitionColorOld: RgbaColor;
3233
let partitionNameOld: string;
3334
let shapesDropdownElement: HTMLDivElement;
3435
@@ -57,6 +58,7 @@
5758
x: e.clientX,
5859
y: e.clientY
5960
};
61+
partitionColorOld = partition.color;
6062
}
6163
6264
function handleFocus(e: FocusEvent) {
@@ -131,6 +133,7 @@
131133
isOpen={isColorPickerOpen}
132134
position={colorPickerPosition}
133135
partitionColor={partition.color}
136+
{partitionColorOld}
134137
{setColor}
135138
/>
136139

0 commit comments

Comments
 (0)