Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { ref } from "vue";
import { mount } from "@vue/test-utils";
import { describe, expect, it, vi } from "vitest";

import Checkbox from "openvue/checkbox";
import OpenVue from "openvue/config";

import OverlayRow from "@/arches_vue_components/components/MapComponent/components/OverlayPanel/components/OverlayRow.vue";

import type { MapLayer } from "@/arches_vue_components/components/MapComponent/types.ts";

vi.mock(
"@/arches_vue_components/components/MapComponent/composables/useMapContext.ts",
() => ({
useResolvedMapContext: () => ({
overlays: ref([]),
overlayOpacities: ref({}),
moveOverlay: vi.fn(),
setOverlayOpacity: vi.fn(),
}),
}),
);

describe("OverlayRow visibility", () => {
it.each([true, false])(
"reflects visibility %s and emits a toggle without mutating the overlay",
async (addtomap) => {
const overlay: MapLayer = {
id: 1,
maplayerid: "test-overlay",
name: "Test overlay",
addtomap,
layerdefinitions: [],
};
const wrapper = mount(OverlayRow, {
global: {
plugins: [OpenVue],
},
props: {
overlay,
isReorderDisabled: false,
isDragTarget: false,
},
});
const checkbox = wrapper.getComponent(Checkbox);
const input = checkbox.get<HTMLInputElement>(
'input[type="checkbox"]',
);

expect(input.element.checked).toBe(addtomap);
expect(
wrapper.get(".overlay-reorder-buttons").element
.nextElementSibling,
).toBe(checkbox.element);
expect(wrapper.get("label").attributes("for")).toBe(
input.attributes("id"),
);
expect(wrapper.get("label").text()).toBe(overlay.name);
expect(wrapper.find(".overlay-visibility-toggle").exists()).toBe(
false,
);

await input.setValue(!addtomap);

expect(wrapper.emitted("toggle-visibility")).toEqual([[]]);
expect(overlay.addtomap).toBe(addtomap);

await wrapper.setProps({
overlay: { ...overlay, addtomap: !addtomap },
});

expect(input.element.checked).toBe(!addtomap);
wrapper.unmount();
},
);
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { computed, ref, useId } from "vue";

import { useGettext } from "vue3-gettext";

import Button from "openvue/button";
import Checkbox from "openvue/checkbox";
import Slider from "openvue/slider";

import OverlaySwatch from "@/arches_vue_components/components/MapComponent/components/OverlaySwatch.vue";
Expand Down Expand Up @@ -45,6 +46,7 @@ const { overlays, overlayOpacities, moveOverlay, setOverlayOpacity } =
useResolvedMapContext(context, "OverlayRow");

const { $gettext } = useGettext();
const visibilityInputId = useId();

const isOpacityExpanded = ref(false);

Expand Down Expand Up @@ -121,11 +123,15 @@ function updateOpacity(value: number | number[]): void {
@click="moveBy(1)"
/>
</div>
<Button
class="overlay-visibility-toggle"
:text="true"
:aria-pressed="overlay.addtomap"
@click="emit(TOGGLE_VISIBILITY_EVENT)"
<Checkbox
:input-id="visibilityInputId"
:model-value="overlay.addtomap"
:binary="true"
@update:model-value="emit(TOGGLE_VISIBILITY_EVENT)"
/>
<label
class="overlay-details"
:for="visibilityInputId"
>
<OverlaySwatch
:overlay="overlay"
Expand All @@ -137,7 +143,7 @@ function updateOpacity(value: number | number[]): void {
>
{{ overlay.name }}
</span>
</Button>
</label>
<Button
v-if="isOpacityControlVisible"
class="overlay-opacity-button"
Expand Down Expand Up @@ -201,10 +207,6 @@ function updateOpacity(value: number | number[]): void {
background: var(--p-content-hover-background);
}

.overlay-row-off {
background: var(--p-content-hover-background);
color: var(--p-text-muted-color);
}

.overlay-row-drag-target {
box-shadow: inset 0 0.3rem 0 var(--p-primary-color);
Expand Down Expand Up @@ -246,13 +248,16 @@ function updateOpacity(value: number | number[]): void {
padding: 0;
}

.overlay-visibility-toggle {
.overlay-details {
display: flex;
align-items: center;
flex: 1;
justify-content: flex-start;
gap: 0.65rem;
min-width: 0;
padding: 0;
padding: 0.6rem;
color: inherit;
cursor: pointer;
}

.overlay-label {
Expand Down
1 change: 1 addition & 0 deletions releases/8.2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
- Fix `__arches_slugify` keeping hyphens, which produced node aliases that could not be used as attribute names (e.g. in arches-querysets `aliased_data`); relational views and their columns are now named by node alias [#12773](https://github.com/archesproject/arches/pull/12773)
- Fix relational view columns for `reference` nodes being typed as `text` instead of `jsonb`, which stored values written through the view as JSON strings; `__arches_get_node_display_value` now returns labels for `reference` nodes [#13064](https://github.com/archesproject/arches/issues/13064)
- Fix the maplibre-gl "Critical dependency: the request of a dependency is an expression" webpack warning; webpack had replaced maplibre's worker URL code with a lookup that throws when static files are served from another origin [#13038](https://github.com/archesproject/arches/issues/13038)
- Use a checkbox in the overlay panel to denote if a layer is selected or not [#13035](https://github.com/archesproject/arches/issues/13035)
- Fix saving long controlled-list values failing with PostgreSQL's B-tree index size limit. The uniqueness constraint now indexes an MD5 hashed value instead of the value itself while preserving the full text [#13086](https://github.com/archesproject/arches/issues/13086)

### Deprecations
Expand Down
Loading