Skip to content
Open
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
2 changes: 1 addition & 1 deletion app/components/FileUploader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ watch(
@folders-ignored="warnFoldersIgnored"
/>

<v-card-text v-if="internal_files.length" class="mt-6 pa-0">
<v-card-text v-if="!mini && internal_files.length" class="mt-6 pa-0">
<v-sheet class="d-flex align-center mb-4" color="transparent">
<v-icon icon="mdi-file-check" class="mr-3" color="primary" size="24" />
<span class="text-subtitle-1 font-weight-bold text-white"> Selected files </span>
Expand Down
7 changes: 4 additions & 3 deletions app/components/Viewer/Options/TextureItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,17 @@ watch(textureId, (value) => {
</style>

<template>
<v-col cols="8" class="pa-1">
<v-col class="pa-1">
<v-select
data-testid="textureNameSelector"
v-model="textureName"
:items="textureCoordinates"
label="Select a texture"
density="compact"
hide-details
/>
</v-col>
<v-col cols="1" class="ma-1 d-flex justify-center align-center">
<v-col cols="auto" class="pa-1 d-flex justify-center align-center">
<v-badge :model-value="textureId !== ''" color="white" floating dot offset-x="10" offset-y="10">
<FileUploader
@files_uploaded="files_uploaded_event($event)"
Expand All @@ -116,7 +117,7 @@ watch(textureId, (value) => {
/>
</v-badge>
</v-col>
<v-col v-if="textureName === '' || textureId === ''" cols="1">
<v-col v-if="textureName === '' || textureId === ''" cols="auto">
<v-icon size="20" icon="mdi-close-circle" v-tooltip:bottom="'Invalid texture'" />
</v-col>
</template>
14 changes: 6 additions & 8 deletions app/utils/default_styles/meshes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { MeshApplyTexturesParams } from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";

import {
type AttributeConfig,
CELLS_DEFAULT_COLOR,
Expand Down Expand Up @@ -32,13 +34,11 @@ interface MeshEdgesColoring extends MeshComponentColoring {

interface MeshCellsColoring extends MeshComponentColoring {
cell: AttributeConfig;
// oxlint-disable-next-line unicorn/no-null
textures: null;
textures: MeshApplyTexturesParams["textures"];
}

interface MeshPolygonsColoring extends MeshComponentColoring {
// oxlint-disable-next-line unicorn/no-null
textures: null;
textures: MeshApplyTexturesParams["textures"];
polygon: AttributeConfig;
}

Expand Down Expand Up @@ -157,8 +157,7 @@ function meshCellsDefaultStyle(
active: MESH_DEFAULT_ACTIVE_COLORING,
cell: emptyAttributeConfig(),
constant,
// oxlint-disable-next-line unicorn/no-null
textures: null,
textures: [],
vertex: emptyAttributeConfig(),
},
};
Expand All @@ -173,8 +172,7 @@ function meshPolygonsDefaultStyle(
coloring: {
active: MESH_DEFAULT_ACTIVE_COLORING,
constant,
// oxlint-disable-next-line unicorn/no-null
textures: null,
textures: [],
polygon: emptyAttributeConfig(),
vertex: emptyAttributeConfig(),
},
Expand Down
10 changes: 6 additions & 4 deletions internal/stores/data_style/mesh/cells/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ async function setMeshCellsActiveColoring(
return result;
}
if (type === "textures") {
const result = await whenDefined(deps.texturesStyle.meshCellsTextures(id), async (value) => {
const applied = await deps.texturesStyle.setMeshCellsTextures(id, value);
return applied;
});
const textures = deps.texturesStyle.meshCellsTextures(id);
// The viewer requires at least one texture: nothing to apply until one is picked.
if (textures === undefined || textures.length === 0) {
return undefined;
}
const result = await deps.texturesStyle.setMeshCellsTextures(id, textures);
return result;
}
if (type === "vertex") {
Expand Down
10 changes: 6 additions & 4 deletions internal/stores/data_style/mesh/polygons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ async function setMeshPolygonsActiveColoring(
return result;
}
if (type === "textures") {
const result = await whenDefined(deps.texturesStyle.meshPolygonsTextures(id), async (value) => {
const applied = await deps.texturesStyle.setMeshPolygonsTextures(id, value);
return applied;
});
const textures = deps.texturesStyle.meshPolygonsTextures(id);
// The viewer requires at least one texture: nothing to apply until one is picked.
if (textures === undefined || textures.length === 0) {
return undefined;
}
const result = await deps.texturesStyle.setMeshPolygonsTextures(id, textures);
return result;
}
if (type === "vertex") {
Expand Down
18 changes: 18 additions & 0 deletions tests/integration/stores/data_style/mesh/polygons.nuxt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,24 @@ describe("mesh polygons", () => {
expect(dataStyleStore.meshPolygonsActiveColoring(id)).toBe(coloringName);
expect(viewerStore.status).toBe(Status.CONNECTED);
});

test("coloring textures without textures", async () => {
const dataStyleStore = useDataStyleStore();
const viewerStore = useViewerStore();
const spy = vi.spyOn(viewerStore, "request");
const coloringName = "textures";
const result = dataStyleStore.setMeshPolygonsActiveColoring(id, coloringName);
expect(result).toBeInstanceOf(Promise);
await result;
expect(spy).not.toHaveBeenCalledWith(
// oxlint-disable-next-line no-unsafe-assignment -- expect.objectContaining is untyped by design, this is a vitest matcher.
expect.objectContaining({ schema: viewer_schemas.opengeodeweb_viewer.mesh.apply_textures }),
// oxlint-disable-next-line no-unsafe-assignment -- expect.anything is untyped by design, this is a vitest matcher.
expect.anything(),
);
expect(dataStyleStore.meshPolygonsActiveColoring(id)).toBe(coloringName);
expect(viewerStore.status).toBe(Status.CONNECTED);
});
});

test("polygons apply default style", async () => {
Expand Down
Loading