-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ #133 refactor some stuff around user preferences
- Loading branch information
Showing
16 changed files
with
124 additions
and
120 deletions.
There are no files selected for viewing
19 changes: 0 additions & 19 deletions
19
src/application/components/menu/ConfigurationTab/ConfigurationListItemSwitch.vue
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
src/application/components/menu/ConfigurationTab/ConfigurationTab.vue
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/application/components/menu/UserPreferencesTab/UserPreferenceListItemSwitch.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<template> | ||
<UserPreferenceListItem :configuration-id="configurationId"> | ||
<Switch /> | ||
</UserPreferenceListItem> | ||
</template> | ||
|
||
<script setup> | ||
import UserPreferenceListItem from "@/application/components/menu/UserPreferencesTab/UserPreferenceListItem.vue"; | ||
import Switch from '@/application/ui/Switch/Switch.vue'; | ||
defineProps({ | ||
configurationId: { | ||
type: String, | ||
required: true | ||
} | ||
}); | ||
</script> | ||
|
||
<style lang="scss" scoped></style> |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
src/application/components/menu/UserPreferencesTab/UserPreferenceTab.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<template> | ||
<div> | ||
<UserPreferenceSearchBar /> | ||
<UserPreferenceList /> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import UserPreferenceList from "@/application/components/menu/UserPreferencesTab/UserPreferenceList.vue"; | ||
import UserPreferenceSearchBar from "@/application/components/menu/UserPreferencesTab/UserPreferenceSearchBar.vue"; | ||
</script> | ||
|
||
<style lang="scss"></style> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
applyFiltersToPreferenceEntriesList, | ||
convertJsonObjectToPreferenceEntry | ||
} from '@/domain/user-preferences/preference-entry.util.js'; | ||
import { computed, reactive, readonly } from 'vue'; | ||
import map from '@/domain/user-preferences/map.json'; | ||
|
||
const state = reactive({ | ||
search: '' | ||
}); | ||
|
||
const getters = { | ||
search: computed(() => state.search), | ||
configurationMatchWithSearch: computed(() => | ||
applyFiltersToPreferenceEntriesList( | ||
{ | ||
label: state.search | ||
}, | ||
map.map((configurationItem) => | ||
convertJsonObjectToPreferenceEntry(configurationItem) | ||
) | ||
) | ||
) | ||
}; | ||
|
||
const actions = {}; | ||
|
||
export const usePreferencesEntryLibrary = () => ({ | ||
state: readonly(state), | ||
...getters, | ||
...actions | ||
}); |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...nfiguration/configurationLibrary.model.js → ...omain/user-preferences/PreferenceEntry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import map from '@/domain/user-preferences/map.json'; | ||
import { PreferenceEntry } from '@/domain/user-preferences/PreferenceEntry.js'; | ||
|
||
export const findPreferenceEntryById = (preferenceEntryId) => { | ||
const matches = map.filter( | ||
(preferenceEntry) => preferenceEntry.id === preferenceEntryId | ||
); | ||
|
||
if (matches.length !== 1) | ||
throw new Error( | ||
`Unable to find ${preferenceEntryId} on preference entries list` | ||
); | ||
|
||
return matches.at(0); | ||
}; | ||
|
||
export const applyFiltersToPreferenceEntriesList = (filters, list) => { | ||
return list.filter((preferenceEntry) => { | ||
const filterMatches = [true]; | ||
|
||
if (Object.hasOwn(filters, 'label') && filters.label.length !== 0) { | ||
filterMatches.push( | ||
preferenceEntry.label | ||
.toLowerCase() | ||
.includes(filters.label.toLowerCase()) | ||
); | ||
} | ||
|
||
if (Object.hasOwn(filters, 'target') && filters.target.length !== 0) { | ||
filterMatches.push( | ||
preferenceEntry.target.includes(filters.target.toLowerCase()) | ||
); | ||
} | ||
|
||
return filterMatches.every((match) => match); | ||
}); | ||
}; | ||
|
||
export const convertJsonObjectToPreferenceEntry = (json) => | ||
Object.assign(new PreferenceEntry(), json); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters