Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7eff3a2
feat(plugins/toast): migrate plugin
oeninghe-dataport Aug 21, 2025
ea1e366
style(toast): sort alphanumerical
oeninghe-dataport Aug 27, 2025
bb3966f
style(toast): sort alphanumerical
oeninghe-dataport Aug 27, 2025
a89f8bb
style(core): fix typo
oeninghe-dataport Aug 27, 2025
bb01595
style(core): sort alphanumerical
oeninghe-dataport Aug 27, 2025
986921f
style(core): fix typo
oeninghe-dataport Aug 27, 2025
5bcbed7
style(core): fix typo
oeninghe-dataport Aug 27, 2025
658a373
docs(core): fix example for locales
oeninghe-dataport Aug 27, 2025
9c94914
style(toast): use implicit closing tag
oeninghe-dataport Aug 27, 2025
ed51b5b
fix(toast): do not define plugin-specific default options
oeninghe-dataport Aug 27, 2025
ffe2b75
docs(toast): fix store description
oeninghe-dataport Aug 27, 2025
42e4a38
docs(toast): improve general plugin description
oeninghe-dataport Aug 27, 2025
e24c89f
docs(toast): fix store module name
oeninghe-dataport Aug 27, 2025
3bb757c
style: enable rule curly[all] with prettier
oeninghe-dataport Aug 27, 2025
a1db617
style: introduce linting for interface member order
oeninghe-dataport Aug 27, 2025
945c875
refactor(core): default-considering getter for layout
oeninghe-dataport Aug 27, 2025
75308d2
Merge branch 'next' into vue3/migrate-plugin-toast
oeninghe-dataport Aug 27, 2025
f2fbccb
fix(core): not-so-perfect fix for plugin store type
oeninghe-dataport Aug 27, 2025
243df40
chore: make the linter happy
oeninghe-dataport Aug 27, 2025
0cc612f
chore: make the typescript compiler happy
oeninghe-dataport Aug 27, 2025
6c60629
Merge branch 'next' into vue3/migrate-plugin-toast
oeninghe-dataport Aug 27, 2025
2d47f85
refactor(iconMenu): rename back to pluginComponent
oeninghe-dataport Aug 28, 2025
ad58497
Merge branch 'next' into vue3/migrate-plugin-toast
oeninghe-dataport Aug 28, 2025
dd6ce29
fix(core): pass layout getter reactive
oeninghe-dataport Aug 28, 2025
ebb5a3a
chore: show toast in snowbox
oeninghe-dataport Aug 28, 2025
9fe6bfc
refactor(toast): remove flex-1-wrapper
oeninghe-dataport Aug 28, 2025
7a78cb0
fix(toast): reduce toast padding
oeninghe-dataport Aug 28, 2025
b67532e
Merge branch 'next' into vue3/migrate-plugin-toast
oeninghe-dataport Aug 28, 2025
a478d2d
refactor: remove redundant if
dopenguin Aug 29, 2025
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
12 changes: 6 additions & 6 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"semi": false,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"useTabs": true
"semi": false,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"useTabs": true
}
29 changes: 18 additions & 11 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ import vueConfig from '@dataport/eslint-config-geodev/vue'
import jsonConfig from '@dataport/eslint-config-geodev/json'
import markdownConfig from '@dataport/eslint-config-geodev/markdown'
import prettierConfig from 'eslint-plugin-prettier/recommended'
import perfectionist from 'eslint-plugin-perfectionist'

const polarConfig = {
plugins: {
perfectionist,
},
rules: {
'prettier/prettier': [
'error',
{
semi: false,
trailingComma: 'es5',
singleQuote: true,
printWidth: 80,
tabWidth: 2,
useTabs: true,
},
],
'prettier/prettier': 'error',

// Re-enable rules that are disabled by prettier but do not collide
curly: ['error', 'all'],

// POLAR-specific rules
'no-warning-comments': 'warn',
Expand All @@ -28,6 +25,7 @@ const polarConfig = {

const polarTsConfig = {
rules: {
// Relaxed rules
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
Expand All @@ -40,6 +38,15 @@ const polarTsConfig = {
allowNumber: true,
},
],

// POLAR-specific rules
'perfectionist/sort-interfaces': [
'error',
{
type: 'natural',
groups: ['required-member', 'unknown'],
},
],
},
}

Expand Down
22 changes: 21 additions & 1 deletion examples/snowbox/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { changeLanguage } from 'i18next'
import pluginToast from '@polar/polar/plugins/toast'
import { useToastStore } from '@polar/polar/plugins/toast/store'
import pluginFullscreen from '@polar/polar/plugins/fullscreen'
import pluginIconMenu from '@polar/polar/plugins/iconMenu'
import { addPlugin, createMap, removePlugin, subscribe } from '@polar/polar'
import { addPlugin, createMap, subscribe } from '@polar/polar'
import EmptyComponent from './EmptyComponent.vue'
import styleJsonUrl from './style.json?url'
import AnotherEmptyComponent from './AnotherEmptyComponent.vue'
Expand All @@ -11,6 +13,7 @@
const ausgleichsflaechen = '1454'
const reports = '6059'

// eslint-disable-next-line no-unused-vars
const dataportTheme = {
brandColor: {
l: '0.4671',
Expand Down Expand Up @@ -43,7 +46,7 @@
},
}

// TODO: Re-enable with isSelectable

Check warning on line 49 in examples/snowbox/index.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected 'todo' comment: 'TODO: Re-enable with isSelectable'
/*
// arbitrary condition for testing
const isEvenId = (mmlid) => Number(mmlid.slice(-1)) % 2 === 0
Expand Down Expand Up @@ -109,14 +112,14 @@
stroke: '#FFFFFF',
fill: '#333333',
},
// TODO(dopenguin): Has some HMR issues, needs to be fixed

Check warning on line 115 in examples/snowbox/index.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected 'todo' comment: 'TODO(dopenguin): Has some HMR issues,...'
// isSelectable: isReportSelectable,
},
],
clusterClickZoom: true,
},
// theme: dataportTheme,
/*

Check warning on line 122 in examples/snowbox/index.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected 'todo' comment: 'TODO(dopenguin): Surrounding application...'
TODO(dopenguin): Surrounding application should be able give information about dark or light mode via update of a state parameter; light mode by default
*/
locales: [
Expand Down Expand Up @@ -170,7 +173,7 @@
plugin: pluginFullscreen(),
hint: 'Full of yourself',
},
// TODO: Delete these two including the component once another plugin is implemented

Check warning on line 176 in examples/snowbox/index.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected 'todo' comment: 'TODO: Delete these two including the...'
{
plugin: {
component: EmptyComponent,
Expand All @@ -193,6 +196,23 @@
})
)

addPlugin(
pluginToast({
displayComponent: true,
layoutTag: 'BOTTOM_MIDDLE',
})
)

const toastStore = useToastStore()
toastStore.addToast({
text: 'Hallo Welt',
severity: 'info',
})
toastStore.addToast({
text: 'Achtung! Dies ist ein Toast!',
severity: 'error',
})

subscribe(
'markers',
'selectedCoordinates',
Expand Down
37 changes: 33 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@cesium/engine": "^15.0.0",
"@commitlint/cli": "^19.8.1",
"@commitlint/config-conventional": "^19.8.1",
"@dataport/eslint-config-geodev": "^0.3.3",
"@dataport/eslint-config-geodev": "^0.4.0",
"@kern-ux/native": "^2.3.0",
"@masterportal/masterportalapi": "2.48.0",
"@material-symbols/svg-400": "^0.34.1",
Expand All @@ -97,6 +97,7 @@
"es-toolkit": "^1.39.8",
"eslint": "^9.31.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-perfectionist": "^4.15.0",
"eslint-plugin-prettier": "^5.5.3",
"events": "^3.3.0",
"hammerjs": "2.0.8",
Expand Down
8 changes: 4 additions & 4 deletions src/architecture.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ describe('Architectural checks', () => {
files = filesOfProject(resolve(__dirname, 'tsconfig.json'))
})

test('POLAR should be cycle-free (except for types)', async () => {
test('POLAR should be cycle-free', async () => {
const violations = await files
.matchingPattern('^(?!.*/types\\.ts$).*')
.matchingPattern('.*')
.should()
.beFreeOfCycles()
.check()
expect(violations).toEqual([])
})

test('Core should not depend on plugins (except for types)', async () => {
test('Core should not depend on plugins (except for plugin types)', async () => {
const violations = await files
.matchingPattern('^core/(?!types\\.ts$).*$')
.matchingPattern('^core/(?!types/.*\\.ts$).*$')
.shouldNot()
.dependOnFiles()
.matchingPattern('^plugins/.*$')
Expand Down
16 changes: 12 additions & 4 deletions src/core/components/PolarMap.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const overlay = useTemplateRef<typeof PolarMapOverlay>('polar-map-overlay')
let map: Map | null = null

function onMove() {
if (!map) return
if (!map) {
return
}
center.value = map.getView().getCenter() || center.value
zoom.value = map.getView().getZoom() || zoom.value
}
Expand Down Expand Up @@ -71,12 +73,16 @@ function createMap() {
// NOTE: Updates can happen if a user resizes the window or the fullscreen plugin is used.
// Added as a watcher to trigger the update at the correct time.
watch(hasWindowSize, (value) => {
if (!map) return
if (!map) {
return
}
updateDragAndZoomInteractions(map, value, hasSmallDisplay.value)
})

watch(center, (center) => {
if (!map) return
if (!map) {
return
}
map.getView().animate({
center,
duration: 400,
Expand All @@ -86,7 +92,9 @@ watch(center, (center) => {

const isMacOS = navigator.userAgent.indexOf('Mac') !== -1
function wheelEffect(event: WheelEvent) {
if (hasWindowSize.value) return
if (hasWindowSize.value) {
return
}
const condition = computed(() => !hasWindowSize.value)
if (isMacOS && !event.metaKey) {
overlay.value?.show('overlay.noCommandOnZoom', condition)
Expand Down
4 changes: 3 additions & 1 deletion src/core/components/PolarMapOverlay.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ function show(
conditionWatcher.value = watch(
condition,
(value) => {
if (!value) hide()
if (!value) {
hide()
}
},
{ immediate: true }
)
Expand Down
11 changes: 4 additions & 7 deletions src/core/components/PolarUI.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,21 @@
</template>

<script lang="ts" setup>
import { storeToRefs } from 'pinia'
import { computed } from 'vue'
import { useMainStore } from '../stores/main.ts'
import NineLayout from './layouts/NineLayout.ce.vue'
import StandardLayout from './layouts/StandardLayout.ce.vue'

const { configuration } = storeToRefs(useMainStore())
const mainStore = useMainStore()

const layout = computed(() => {
const configuredLayout = configuration.value.layout

if (!configuredLayout || configuredLayout === 'standard') {
if (mainStore.layout === 'standard') {
return StandardLayout
}
if (configuredLayout === 'nineRegions') {
if (mainStore.layout === 'nineRegions') {
return NineLayout
}
return configuredLayout
return mainStore.layout
})
</script>

Expand Down
10 changes: 5 additions & 5 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,20 @@

export function removePlugin(pluginId: string) {
const coreStore = useMainStore()
const plugin = coreStore.plugins.find((p) => p.id === pluginId)
const plugin = coreStore.plugins.find(({ id }) => id === pluginId)

if (!plugin) {
console.error(`Plugin "${pluginId}" not found.`)
return
}
const store = plugin.storeModule?.()
if (store) {
store.teardownPlugin()
if (typeof store.teardownPlugin === 'function') {
store.teardownPlugin()
}
store.$reset()
}
coreStore.plugins = coreStore.plugins.filter(
(plugin) => plugin.id !== pluginId
)
coreStore.plugins = coreStore.plugins.filter(({ id }) => id !== pluginId)
}

/**
Expand Down Expand Up @@ -160,7 +160,7 @@

const coreStore = useMainStore()

// TODO(oeninghe-dataport): Pass configuration as CE properties.

Check warning on line 163 in src/core/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected 'todo' comment: 'TODO(oeninghe-dataport): Pass...'
// createMap may survive as a convenience wrapper.
coreStore.configuration = mapZoomOffset({
...defaults,
Expand Down
36 changes: 36 additions & 0 deletions src/core/stores/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

import { defineStore } from 'pinia'
import { computed } from 'vue'
import type {
PluginId,
BundledPluginId,
BundledPluginStores,
PolarPluginStore,
} from '../types'
import { useMainStore } from './main'

/* eslint-disable tsdoc/syntax */
Expand All @@ -18,6 +24,18 @@ import { useMainStore } from './main'
export const useCoreStore = defineStore('core', () => {
const mainStore = useMainStore()

function getPluginStore<T extends PluginId>(
id: T
): ReturnType<
T extends BundledPluginId
? BundledPluginStores<typeof id>
: PolarPluginStore
> | null {
const plugin = mainStore.plugins.find((plugin) => plugin.id === id)
// @ts-expect-error | We trust that our internal IDs work.
return plugin?.storeModule?.() || null
}

return {
/**
* The current height of the map.
Expand Down Expand Up @@ -61,6 +79,15 @@ export const useCoreStore = defineStore('core', () => {
* @readonly
*/
hasWindowSize: computed(() => mainStore.hasWindowSize),
/**
* Returns a plugin's store by its ID.
*
* For bundled plugins, the return value is typed.
*
* If no plugin with the specified ID is loaded, `null` is returned instead.
*/
getPluginStore,

/**
* Allows reading or setting the OIDC token used for service accesses.
*/
Expand All @@ -72,6 +99,15 @@ export const useCoreStore = defineStore('core', () => {
* @alpha
*/
lightElement: computed(() => mainStore.lightElement),
/**
* The currently used layout.
* Either a string indicating `standard` or `nineRegions` or a custom Vue component.
*
* @readonly
* @alpha
*/
layout: computed(() => mainStore.layout),

/**
* Allows accessing the OpenLayers Map element.
*
Expand Down
Loading
Loading