Skip to content

Commit 73daebc

Browse files
author
hung.pv
committed
refactor(map-dataset): change to base-button, remove useless
1 parent 6d23db0 commit 73daebc

26 files changed

Lines changed: 106 additions & 346 deletions

libs/map/dataset/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export * from './interfaces';
22
export * from './model';
33
export * from './modules';
4-
export * from './parts/dataset.handlers';
54
export * from './store';
65
export * from './utils/check';
76
export * from './utils/layer-simple-builder';

libs/map/dataset/src/model/dataset.handler.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

libs/map/dataset/src/model/identify/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { isIdentifyMergeView, isMapboxLayerView } from '../../utils/check';
1414
import { convertFeatureToItem } from '../../utils/convert';
1515
import { createNamedComponent } from '../base';
1616
import { createDatasetLeaf } from '../dataset.base.function';
17-
import { createDatasetMenu } from '../part-menu.model';
17+
import { createDatasetMenu } from '../menu';
1818
import {
1919
findSiblingOrNearestLeaf,
2020
runAllComponentsWithCheck,
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
export * from './data-management';
22
export * from './dataset.base';
3-
export * from './dataset.handler';
43
export * from './highlight';
54
export * from './identify';
65
export * from './layer';
6+
export * from './menu';
77
export * from './part-list-view-ui.model';
8-
export * from './part-menu.model';
98
export * from './part-metadata.model';
109
export * from './source';
1110
export * from './visitors';
11+
12+
export { createBase, createNamedComponent } from './base';
13+
export {
14+
createDatasetComponent,
15+
createDatasetLeaf,
16+
} from './dataset.base.function';

libs/map/dataset/src/model/layer/base.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import type { MapSimple } from '@hungpvq/shared-map';
22
import type { IDataset, IMapboxLayerView } from '../../interfaces';
33
import { createNamedComponent } from '../base';
44
import { createDatasetLeaf } from '../dataset.base.function';
5-
import { createDatasetMenu } from '../part-menu.model';
5+
import { createDatasetMenu } from '../menu';
66

77
export function createDatasetPartMapboxLayerComponent<T = any>(
88
name: string,
9-
data: T
9+
data: T,
1010
): IMapboxLayerView & IDataset<T> {
1111
const base = createDatasetLeaf<T>(name, data);
1212
const menu = createDatasetMenu();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './handle';
2+
export * from './items';
23
export * from './store';

libs/map/dataset/src/model/part-menu.model.ts renamed to libs/map/dataset/src/model/menu/items.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import type {
1010
MenuAction,
1111
MenuItemBottomOrExtra,
1212
MenuItemCustomComponentBottomOrExtra,
13-
} from '../interfaces';
14-
import LayerDetail from '../modules/LayerDetail/LayerDetail.vue';
15-
import StyleControl from '../modules/StyleControl/style-control.vue';
16-
import ToggleShow from './menu/toggle-show.vue';
17-
import { findSiblingOrNearestLeaf } from './visitors';
13+
} from '../../interfaces';
14+
import LayerDetail from '../../modules/LayerDetail/LayerDetail.vue';
15+
import StyleControl from '../../modules/StyleControl/style-control.vue';
16+
import { findSiblingOrNearestLeaf } from '../visitors';
17+
import ToggleShow from './toggle-show.vue';
1818

1919
export function createDatasetMenu<
2020
T extends IDataset = IDataset,

libs/map/dataset/src/model/menu/toggle-show.vue

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
<template lang="">
22
<div v-if="isMulti" class="toggle-buttons-container">
3-
<button
4-
class="layer-item__button"
3+
<BaseButton
54
:class="{ _active: getShow(0) }"
65
@click.stop="onToggleShowIndex(0)"
76
>
87
<span>#1</span>
9-
</button>
10-
<button
11-
class="layer-item__button"
8+
</BaseButton>
9+
<BaseButton
1210
@click.stop="onToggleShowIndex(1)"
1311
:class="{ _active: getShow(1) }"
1412
>
1513
<span>#2</span>
16-
</button>
14+
</BaseButton>
1715
</div>
18-
<button class="layer-item__button" @click.stop="onToggleShow" v-else>
16+
<BaseButton @click.stop="onToggleShow" v-else>
1917
<SvgIcon size="14" type="mdi" :path="path.show" v-if="data.show" />
2018
<SvgIcon size="14" type="mdi" :path="path.hide" v-else />
21-
</button>
19+
</BaseButton>
2220
</template>
2321
<script setup lang="ts">
2422
import { MapSimple } from '@hungpvq/shared-map';
25-
import { getIsMulti, getMaps, useMap } from '@hungpvq/vue-map-core';
23+
import { BaseButton, getIsMulti, getMaps, useMap } from '@hungpvq/vue-map-core';
2624
import SvgIcon from '@jamescoyle/vue-icon';
2725
import { mdiEye, mdiEyeOff } from '@mdi/js';
2826
import { onMounted, ref } from 'vue';
@@ -104,14 +102,7 @@ function getShow(index: number) {
104102
opacity: 0.5;
105103
z-index: -1;
106104
}
107-
.layer-control .layer-item__button.toggle-buttons-container {
108-
display: flex;
109-
gap: 2px;
110-
}
111105
.toggle-buttons-container span {
112106
font-size: 0.7rem;
113107
}
114-
.toggle-buttons-container .layer-item__button {
115-
height: 100%;
116-
}
117108
</style>

libs/map/dataset/src/model/part-list-view-ui.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { IListViewUI } from '../interfaces/dataset.parts';
22
import { createNamedComponent } from './base';
33
import { createDatasetLeaf } from './dataset.base.function';
4-
import { createDatasetMenu } from './part-menu.model';
4+
import { createDatasetMenu } from './menu';
55
export function createDatasetPartListViewUiComponent<T = any>(
66
name: string,
7-
data?: T
7+
data?: T,
88
): IListViewUI<any> {
99
const base = createDatasetLeaf<T>(name, data);
1010
const menu = createDatasetMenu();

libs/map/dataset/src/modules/DatasetControl/DatasetControl.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
withMapProps,
1818
} from '@hungpvq/vue-map-core';
1919
import SvgIcon from '@jamescoyle/vue-icon';
20-
import { mdiDatabaseOutline, mdiInformation } from '@mdi/js';
20+
import { mdiDatabaseOutline, mdiDelete, mdiInformation } from '@mdi/js';
2121
import { computed, onMounted, shallowRef, watch } from 'vue';
2222
import type { IDataset } from '../../interfaces/dataset.base';
2323
import { handleMenuActionClick } from '../../model/menu';
@@ -39,9 +39,12 @@ setLocaleDefault({
3939
const path = {
4040
icon: mdiDatabaseOutline,
4141
detail: mdiInformation,
42+
delete: mdiDelete,
4243
};
4344
const [show, toggleShow] = useShow(props.show);
44-
const { getDatasets, getDatasetIds } = useMapDataset(mapId.value);
45+
const { getDatasets, getDatasetIds, removeDataset } = useMapDataset(
46+
mapId.value,
47+
);
4548
const datasetIds = computed(() => {
4649
return getDatasetIds().value;
4750
});
@@ -82,6 +85,9 @@ function onShowDetail(view: IDataset) {
8285
view,
8386
);
8487
}
88+
function onRemove(view: IDataset) {
89+
removeDataset(view);
90+
}
8591
onMounted(() => {
8692
updateList();
8793
});
@@ -118,6 +124,10 @@ defineSlots<{
118124
<BaseButton @click.stop="onShowDetail(view)">
119125
<SvgIcon size="16" type="mdi" :path="path.detail" />
120126
</BaseButton>
127+
128+
<BaseButton @click.stop="onRemove(view)">
129+
<SvgIcon size="16" type="mdi" :path="path.delete" />
130+
</BaseButton>
121131
</div>
122132
</div>
123133
</slot>

0 commit comments

Comments
 (0)