Skip to content

Commit

Permalink
Fix hide option showing when it shouldn't
Browse files Browse the repository at this point in the history
  • Loading branch information
f-osorio committed Jan 16, 2025
1 parent 5a51a0a commit 63ad82b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/panels/edit/fields/helpers/ActionButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</button>
</template>

<template v-if="preferenceStore.returnValue('--c-general-ad-hoc') && this.profileStore.isEmptyComponent(this.structure)">
<template v-if="showHideElementButton()">
<button style="width:100%" :id="`action-button-command-${fieldGuid}-0`" class="" @click="hideElement()">
<span class="">🙈</span>Hide Element
</button>
Expand Down Expand Up @@ -848,6 +848,12 @@
this.profileStore.deleteComponent(this.guid)
},
showHideElementButton: function(){
let component = this.profileStore.returnStructureByComponentGuid(this.guid)
let empty = this.profileStore.isEmptyComponent(component)
return empty
},
// Hide empty element in ad hoc mode
hideElement: function(){
let structure = this.profileStore.returnStructureByComponentGuid(this.guid)
Expand Down
2 changes: 2 additions & 0 deletions src/stores/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4538,13 +4538,15 @@ export const useProfileStore = defineStore('profile', {

//Check if the component's userValue is empty
isEmptyComponent: function(c){
console.info("isEmpty? ", c)
const component = c
const emptyArray = new Array("@root")
const userValue = JSON.parse(JSON.stringify(component["userValue"]))


// if there is only a @root
if (JSON.stringify(Object.keys(component.userValue)) == JSON.stringify(emptyArray)){
console.info("only has root")
return true
} else {
// if the children only have "@..." properties
Expand Down

0 comments on commit 63ad82b

Please sign in to comment.