Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Vue] rename PluginSetting component to GroupedSetting component and …
…refactor condition handling (#18628) * rename PluginSetting component to GroupedSetting component, export and refactor angularjs condition handling in vue * Add GroupedSettings component to encapsulate for loop and better scope computed properties + get to work in the UI
- Loading branch information
Showing
7 changed files
with
245 additions
and
155 deletions.
There are no files selected for viewing
254 changes: 154 additions & 100 deletions
254
plugins/CorePluginsAdmin/vue/dist/CorePluginsAdmin.umd.js
Large diffs are not rendered by default.
Oops, something went wrong.
22 changes: 11 additions & 11 deletions
22
plugins/CorePluginsAdmin/vue/dist/CorePluginsAdmin.umd.min.js
Large diffs are not rendered by default.
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
53 changes: 53 additions & 0 deletions
53
plugins/CorePluginsAdmin/vue/src/GroupedSettings/GroupedSettings.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,53 @@ | ||
<template> | ||
<div | ||
v-for="setting in settings" | ||
:key="`${groupName}.${setting.name}`" | ||
> | ||
<GroupedSetting | ||
:model-value="allSettingValues[`${groupName}.${setting.name}`]" | ||
@update:model-value="$emit('change', { name: setting.name, value: $event })" | ||
:setting="setting" | ||
:condition-values="settingValues" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue'; | ||
import GroupedSetting from './GroupedSetting.vue'; | ||
export default defineComponent({ | ||
props: { | ||
groupName: String, | ||
settings: { | ||
type: Array, | ||
required: true, | ||
}, | ||
allSettingValues: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
emits: ['change'], | ||
components: { | ||
GroupedSetting, | ||
}, | ||
computed: { | ||
settingValues() { | ||
const entries = Object.entries(this.allSettingValues as Record<string, unknown>) | ||
.filter(([key]) => { | ||
if (this.groupName) { | ||
const [groupName] = key.split('.'); | ||
if (groupName !== this.groupName) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}) | ||
.map(([key, value]) => (this.groupName ? [key.split('.')[1], value] : [key, value])); | ||
return Object.fromEntries(entries); | ||
}, | ||
}, | ||
}); | ||
</script> |
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