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

Set favorites mode feature flag in store #409

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
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
7 changes: 0 additions & 7 deletions components/Home/Embedded.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ onMounted(() => {
//
// Computed
//
const explorerModeEnabled = computed(() => {
return settings!.themes[0]?.explorer_mode ?? true
})

const filters = computed(() => {
return route.query.menuItemIds
? route.query.menuItemIds
Expand Down Expand Up @@ -187,8 +183,6 @@ function toggleExploreAroundSelectedPoi() {
<PoiCardContent
:details-is-external="true"
:poi="selectedFeature"
:explorer-mode-enabled="explorerModeEnabled"
:favorites-mode-enabled="false"
@explore-click="toggleExploreAroundSelectedPoi"
@zoom-click="goToSelectedFeature"
/>
Expand All @@ -207,7 +201,6 @@ function toggleExploreAroundSelectedPoi() {
:features="mapFeatures"
:selected-categories-ids="selectedCategoryIds"
:style-icon-filter="poiFilters"
:explorer-mode-enabled="explorerModeEnabled"
:cooperative-gestures="false"
:boundary-area="boundaryArea || settings!.polygon.data"
/>
Expand Down
29 changes: 10 additions & 19 deletions components/Home/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ const menuStore = useMenuStore()
const { apiMenuCategory, features, selectedCategoryIds } = storeToRefs(menuStore)
const favoriteStore = useFavoriteStore()
const { favoritesIds, favoriteAddresses, favoriteFeatures, favoriteCount } = storeToRefs(favoriteStore)
const { config, settings, contents } = useSiteStore()
const siteStore = useSiteStore()
const { config, settings, contents } = siteStore
const { favoritesModeEnabled } = storeToRefs(siteStore)
const { $tracking } = useNuxtApp()
const route = useRoute()
const router = useRouter()
Expand Down Expand Up @@ -141,14 +143,6 @@ onMounted(async () => {
//
// Computed
//
const explorerModeEnabled = computed(() => {
return settings!.themes[0]?.explorer_mode ?? true
})

const favoritesModeEnabled = computed(() => {
return settings!.themes[0]?.favorites_mode ?? true
})

const isBottomMenuOpened = computed(() => {
return ((device.value.smallScreen && isPoiCardShown.value) || isMenuItemOpen.value)
})
Expand Down Expand Up @@ -288,7 +282,10 @@ watch(isModeFavorites, async (isEnabled) => {
//
// Methods
//
function goToSelectedFeature() {
function goToSelectedFeature(feature?: ApiPoi) {
if (feature)
mapStore.setSelectedFeature(feature)

if (mapFeaturesRef.value)
mapFeaturesRef.value.goToSelectedFeature()
}
Expand Down Expand Up @@ -557,12 +554,11 @@ function handlePoiCardClose() {
>
<FavoriteMenu
v-if="favoritesModeEnabled"
:explore-around-selected-poi="toggleExploreAroundSelectedPoi"
:go-to-selected-poi="goToSelectedFeature"
:toggle-favorite="toggleFavorite"
:explorer-mode-enabled="explorerModeEnabled"
@explore-click="toggleExploreAroundSelectedPoi"
@favorite-click="toggleFavorite"
@toggle-favorite-mode="toggleFavoriteMode"
@toggle-note-book-mode="toggleNoteBookMode"
@zoom-click="goToSelectedFeature"
/>
<NavMenu
id="nav-menu"
Expand All @@ -585,7 +581,6 @@ function handlePoiCardClose() {
:features="mapFeatures"
:selected-categories-ids="isModeExplorer ? [] : selectedCategoryIds"
:style-icon-filter="poiFilters"
:explorer-mode-enabled="explorerModeEnabled"
:enable-filter-route-by-categories="!isModeFavorites"
:enable-filter-route-by-features="isModeFavorites"
:boundary-area="boundaryArea || settings!.polygon.data"
Expand Down Expand Up @@ -625,8 +620,6 @@ function handlePoiCardClose() {
"
:poi="selectedFeature"
class="tw-grow-0"
:explorer-mode-enabled="explorerModeEnabled"
:favorites-mode-enabled="favoritesModeEnabled"
@explore-click="toggleExploreAroundSelectedPoi(undefined)"
@favorite-click="toggleFavorite"
@zoom-click="goToSelectedFeature"
Expand Down Expand Up @@ -656,8 +649,6 @@ function handlePoiCardClose() {
"
:poi="selectedFeature"
class="tw-grow-0 tw-text-left tw-h-full"
:explorer-mode-enabled="explorerModeEnabled"
:favorites-mode-enabled="favoritesModeEnabled"
@explore-click="toggleExploreAroundSelectedPoi(undefined)"
@favorite-click="toggleFavorite"
@zoom-click="goToSelectedFeature"
Expand Down
29 changes: 11 additions & 18 deletions components/MainMap/FavoriteMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@ import type { ApiPoi } from '~/lib/apiPois'
import { mapStore as useMapStore } from '~/stores/map'
import { favoriteStore as useFavoriteStore } from '~/stores/favorite'

const props = defineProps<{
exploreAroundSelectedPoi: Function
explorerModeEnabled: boolean
goToSelectedPoi: Function
toggleFavorite: Function
const emit = defineEmits<{
(e: 'exploreClick', poi: ApiPoi): void
(e: 'favoriteClick', poi: ApiPoi): void
(e: 'toggleFavoriteMode'): void
(e: 'toggleNoteBookMode'): void
(e: 'zoomClick', poi: ApiPoi): void
}>()

const emit = defineEmits(['toggleFavoriteMode', 'toggleNoteBookMode'])

const device = useDevice()
const notebookModal = ref<boolean>(false)

const mapStore = useMapStore()
const { isModeFavorites } = storeToRefs(mapStore)
const { favoriteCount } = storeToRefs(useFavoriteStore())

function explore(poi: ApiPoi) {
function onExploreClick(poi: ApiPoi) {
notebookModal.value = false
props.exploreAroundSelectedPoi(poi)
emit('exploreClick', poi)
}

function onClose() {
Expand All @@ -36,13 +35,8 @@ function onClose() {
}

function onZoomClick(poi: ApiPoi) {
mapStore.setSelectedFeature(poi)
notebookModal.value = false
props.goToSelectedPoi(poi)
}

function handleFavorite(poi: ApiPoi) {
props.toggleFavorite(poi)
emit('zoomClick', poi)
}

const { $tracking } = useNuxtApp()
Expand Down Expand Up @@ -108,9 +102,8 @@ async function toggleNoteBookMode() {
max-width="80rem"
>
<FavoriteNoteBook
:explorer-mode-enabled="explorerModeEnabled"
@explore-click="explore"
@favorite-click="handleFavorite"
@explore-click="onExploreClick"
@favorite-click="$emit('favoriteClick', $event)"
@zoom-click="onZoomClick"
@on-close="onClose"
/>
Expand Down
6 changes: 0 additions & 6 deletions components/MainMap/FavoriteNoteBook.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import type { ApiPoi } from '~/lib/apiPois'
import { favoriteStore as useFavoriteStore } from '~/stores/favorite'
import { siteStore as useSiteStore } from '~/stores/site'

defineProps<{
explorerModeEnabled: boolean
}>()

defineEmits<{
(e: 'onClose'): void
(e: 'exploreClick', poi: ApiPoi): void
Expand Down Expand Up @@ -131,8 +127,6 @@ function removeFavorites() {
<PoisDeck
:pois="favoriteFeatures"
:is-card-light="false"
:explorer-mode-enabled="explorerModeEnabled"
:favorites-mode-enabled="true"
class="tw-pb-4"
@explore-click="$emit('exploreClick', $event)"
@favorite-click="$emit('favoriteClick', $event)"
Expand Down
1 change: 0 additions & 1 deletion components/MainMap/MapFeatures.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const defaultProps = {
},
} as ApiMenuCategory,
],
explorerModeEnabled: false,
}

export const Default = bind(
Expand Down
1 change: 0 additions & 1 deletion components/MainMap/MapFeatures.story.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const defaultProps = {
},
} as ApiMenuCategory,
],
explorerModeEnabled: false,
}

const feature1: ApiPoi = {
Expand Down
9 changes: 4 additions & 5 deletions components/MainMap/MapFeatures.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ export default defineNuxtComponent({
type: Array as PropType<Array<string[]> | null>,
default: null,
},
explorerModeEnabled: {
type: Boolean,
required: true,
},
enableFilterRouteByCategories: {
type: Boolean,
default: true,
Expand All @@ -122,7 +118,9 @@ export default defineNuxtComponent({

setup() {
const device = useDevice()
const { config } = storeToRefs(useSiteStore())
const siteStore = useSiteStore()
const { config } = siteStore
const { explorerModeEnabled } = storeToRefs(useSiteStore())
const mapStore = useMapStore()
const { center, selectedFeature, pinMarker, teritorioCluster } = storeToRefs(mapStore)
const mapStyleLoaded = ref(false)
Expand All @@ -131,6 +129,7 @@ export default defineNuxtComponent({
center,
config,
device,
explorerModeEnabled,
mapBase: ref<InstanceType<typeof MapBase>>(),
mapStore,
mapStyleLoaded,
Expand Down
2 changes: 0 additions & 2 deletions components/PoisCard/PoiCard.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export default {

const defaultProps = {
poi,
explorerModeEnabled: false,
favoritesModeEnabled: false,
}

export const Default = bind(PoiCard, {
Expand Down
2 changes: 0 additions & 2 deletions components/PoisCard/PoiCard.story.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import type { ApiPoi } from '~/lib/apiPois'

const defaultProps = {
poi: poi as ApiPoi,
explorerModeEnabled: false,
favoritesModeEnabled: false,
}

const props = {
Expand Down
4 changes: 0 additions & 4 deletions components/PoisCard/PoiCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import type { ApiPoi } from '~/lib/apiPois'
withDefaults(defineProps<{
canClose?: boolean
poi: ApiPoi
explorerModeEnabled: boolean
favoritesModeEnabled: boolean
showImage?: boolean
}>(), {
canClose: true,
Expand Down Expand Up @@ -85,8 +83,6 @@ const closeBtnStyles = reactive({

<PoiCardContent
:poi="poi"
:explorer-mode-enabled="explorerModeEnabled"
:favorites-mode-enabled="favoritesModeEnabled"
class="tw-px-4 tw-py-5 tw-flex tw-flex-col md:tw-overflow-y-auto tw-flex-grow md:tw-max-h-full tw-box-border tw-w-full md:tw-h-80 md:tw-w-96"
@explore-click="$emit('exploreClick', $event)"
@favorite-click="$emit('favoriteClick', $event)"
Expand Down
4 changes: 2 additions & 2 deletions components/PoisCard/PoiCardContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { ApiPoi } from '~/lib/apiPois'
import { coordinatesHref } from '~/lib/coordinates'
import { favoriteStore as useFavoriteStore } from '~/stores/favorite'
import { mapStore as useMapStore } from '~/stores/map'
import { siteStore as useSiteStore } from '~/stores/site'
import ContribFieldGroup from '~/components/Fields/ContribFieldGroup.vue'
import useDevice from '~/composables/useDevice'
import IsochroneTrigger from '~/components/Isochrone/IsochroneTrigger.vue'
Expand All @@ -17,8 +18,6 @@ import IsochroneTrigger from '~/components/Isochrone/IsochroneTrigger.vue'
//
const props = withDefaults(defineProps<{
detailsIsExternal?: boolean
explorerModeEnabled: boolean
favoritesModeEnabled: boolean
poi: ApiPoi
}>(), {
detailsIsExternal: false,
Expand All @@ -43,6 +42,7 @@ const { contribMode, isContribEligible, getContributorFields } = useContrib()
const { isModeExplorer } = storeToRefs(useMapStore())
const device = useDevice()
const { enabled: isochroneEnabled } = useIsochrone()
const { explorerModeEnabled, favoritesModeEnabled } = storeToRefs(useSiteStore())

//
// Data
Expand Down
2 changes: 0 additions & 2 deletions components/PoisCard/PoisDeck.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ const defaultProps = {
),
),
selectedPoiIds: points.map(feature => feature.properties.id),
explorerModeEnabled: false,
favoritesModeEnabled: false,
}

export const Default = bind(PoisDeck, {
Expand Down
2 changes: 0 additions & 2 deletions components/PoisCard/PoisDeck.story.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const defaultProps = {
),
),
selectedPoiIds: points.map(feature => feature.properties.id as ApiPoiId),
explorerModeEnabled: false,
favoritesModeEnabled: false,
isCardLight: true,
}

Expand Down
11 changes: 2 additions & 9 deletions components/PoisCard/PoisDeck.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ import type { ApiPoi } from '~/lib/apiPois'
import PoiCard from '~/components/PoisCard/PoiCard.vue'
import PoiCardLight from '~/components/PoisCard/PoiCardLight.vue'

withDefaults(defineProps<{
explorerModeEnabled?: boolean
favoritesModeEnabled?: boolean
defineProps<{
pois: ApiPoi[]
isCardLight: boolean
}>(), {
explorerModeEnabled: false,
favoritesModeEnabled: false,
})
}>()

defineEmits<{
(e: 'exploreClick', poi: ApiPoi): void
Expand All @@ -38,8 +33,6 @@ defineEmits<{
:can-close="false"
:poi="item"
class="tw-grow-1 poi-deck"
:explorer-mode-enabled="explorerModeEnabled"
:favorites-mode-enabled="favoritesModeEnabled"
@explore-click="$emit('exploreClick', $event)"
@favorite-click="$emit('favoriteClick', $event)"
@zoom-click="$emit('zoomClick', $event)"
Expand Down
5 changes: 0 additions & 5 deletions components/PoisDetails/PoiDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ export default defineNuxtComponent({
return PropertyTranslationsContextEnum.Details
},

favoritesModeEnabled(): boolean {
return this.settings.themes[0]?.favorites_mode ?? true
},

properties(): ApiPoi['properties'] {
if (!this.isLargeLayeout) {
return this.poi.properties
Expand Down Expand Up @@ -306,7 +302,6 @@ export default defineNuxtComponent({
:route="poiDeps"
:color-fill="colorFill"
:color-line="colorLine"
:favorites-mode-enabled="favoritesModeEnabled"
/>
</template>

Expand Down
4 changes: 0 additions & 4 deletions components/PoisDetails/Route/RouteMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ export default defineNuxtComponent({
type: String as PropType<string>,
required: true,
},
favoritesModeEnabled: {
type: Boolean,
required: true,
},
},

data(): {
Expand Down
Loading