Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add app-wide loading mask component #308

Merged
merged 2 commits into from
Dec 14, 2022
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
6 changes: 6 additions & 0 deletions app-starter/WguAppTemplate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@

<slot name="wgu-after-footer" />

<!-- app wide loading mask,
use WguEventBus.$emit('app-loading-mask-toggle', newViz) to show/hide -->
<wgu-app-loading-mask />

<slot name="wgu-app-end" />

</v-app>
Expand All @@ -72,6 +76,7 @@
import AppFooter from './components/AppFooter'
import AppSidebar from './components/AppSidebar'
import AppLogo from '../src/components/AppLogo'
import AppLoadingMask from '../src/components/AppLoadingMask'
import BgLayerSwitcher from '../src/components/bglayerswitcher/BgLayerSwitcher.vue'
import OverviewMap from '../src/components/overviewmap/OverviewMap.vue'
import MeasureWin from '../src/components/measuretool/MeasureWin'
Expand All @@ -92,6 +97,7 @@
'wgu-app-footer': AppFooter,
'wgu-app-sidebar': AppSidebar,
'wgu-app-logo': AppLogo,
'wgu-app-loading-mask': AppLoadingMask,
'wgu-bglayerswitcher': BgLayerSwitcher,
'wgu-overviewmap': OverviewMap,
'wgu-measuretool-win': MeasureWin,
Expand Down
35 changes: 35 additions & 0 deletions src/components/AppLoadingMask.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<template>

<v-overlay :value="show" :opacity="0.25">
<v-progress-circular
indeterminate
color="primary"
>
</v-progress-circular>
</v-overlay>

</template>

<script>
import { WguEventBus } from '../WguEventBus';

export default {
name: 'wgu-app-loading-mask',
components: {},
data () {
return {
show: false
}
},
created () {
WguEventBus.$on('app-loading-mask-toggle', (visible) => {
// toggle or force a visibility of the loading mask
if (typeof visible === 'boolean') {
this.show = visible;
} else {
this.show = !this.show;
}
});
}
}
</script>
36 changes: 36 additions & 0 deletions test/unit/specs/components/AppLoadingMask.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import AppLoadingMask from '@/components/AppLoadingMask';
import { WguEventBus } from '@/WguEventBus';
import { shallowMount } from '@vue/test-utils';

describe('AppLoadingMask.vue', () => {
it('sets the correct default data', () => {
AppLoadingMask.$appConfig = {};
expect(typeof AppLoadingMask.data).to.equal('function');
const data = AppLoadingMask.data();
expect(data.show).to.equal(false);
});

describe('events', () => {
let comp;
let vm;
beforeEach(() => {
comp = shallowMount(AppLoadingMask, {});
vm = comp.vm;
});

it('event "app-loading-mask-toggle" forces correct visibility', done => {
// force showing by adding 'true' parameter
WguEventBus.$emit('app-loading-mask-toggle', true);
vm.$nextTick(() => {
expect(vm.show).to.equal(true);

// toggle visibility by skipping parameter
WguEventBus.$emit('app-loading-mask-toggle');
vm.$nextTick(() => {
expect(vm.show).to.equal(false);
done();
});
});
});
});
});