-
Notifications
You must be signed in to change notification settings - Fork 113
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
Begin of the invisible elements #3574
base: master-mysterious-egg
Are you sure you want to change the base?
Conversation
This PR targets the un-managed branch odoo-dev/odoo:master-mysterious-egg, it needs to be retargeted before it can be merged. |
9c4544a
to
fa9f7b0
Compare
fa9f7b0
to
80f3b63
Compare
for (const handler of this.getResource("on_snippet_dropped")) { | ||
handler(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use this.dispatchTo("on_snippet_dropped")
} | ||
} | ||
|
||
function isSnippetVisible(snippetEl) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isVisible(el) ?
return snippetEl.dataset.invisible !== "1"; | ||
} | ||
|
||
function setSnippetVisibility(invisibleEntry, show) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setVisibility(el, visible)
for (const handler of this.getResource("on_snippet_dropped")) { | ||
handler(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use the editor config onChange
instead of a new signal on_snippet_dropped
, otherwise undo/redo will not be taken into consideration.
@@ -78,6 +78,7 @@ export class SnippetModel extends Reactive { | |||
isCustom: false, | |||
imagePreviewSrc: snippetEl.dataset.oImagePreview, | |||
}; | |||
snippetEl.children[0].dataset["name"] = snippet.title; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- that is strange to mutate the dom in a method called "compute", if necessary I would create another method.
- Why do need to duplicate the information in the same node? Either
2.1 We change the xml to change the keydata-snippet
todata-name
ordata-snippet-name
2.2 The code that reads for the name readdata-name || data-snippet
If I had to chose, I'd take 2.1, because it makes more sense to have the data only once with a consistent key. Except if there is a difference in meaning with the 2 keys (data-snippet
and data-name
).
@@ -86,6 +92,7 @@ export class SnippetsMenu extends Component { | |||
this.state.currentOptionsContainers = currentOptionsContainers; | |||
this.setTab("customize"); | |||
}, | |||
on_snippet_dropped: this.updateInvisibleEls.bind(this), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You use the editor config onChange
to take the history in consideration.
@@ -22,3 +22,48 @@ | |||
background-color: #3e3e46; | |||
} | |||
|
|||
.o_we_invisible_el_panel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of the refactoring is to remove css that should be converted to bootstrap classes so you should add the bootsrap classes directly in the component xml template whenever possible.
For precise position & size, we haven't concluded anything yet, I'm not sure of the current team vision on that. cc @FrancoisGe
import { Component, onWillStart, onWillUpdateProps, useState } from "@odoo/owl"; | ||
import { WithSubEnv } from "../builder_helpers"; | ||
import { getSnippetName } from "../../utils"; | ||
export class InvisibleElementsTab extends Component { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not mention the concept of "Tab" in the name as it is not a Tab.
InvisibleElements
?
@@ -235,6 +248,12 @@ export class SnippetsMenu extends Component { | |||
} | |||
return true; | |||
} | |||
|
|||
updateInvisibleEls() { | |||
this.state.invisibleEls = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invisibleElements
to avoid abbreviation
}; | ||
|
||
setup() { | ||
this.state = useState({ invisibleEls: null }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invisibleEntries
?
this.state.invisibleEls = createInvisibleElements(rootInvisibleSnippetEls, false); | ||
} | ||
|
||
onInvisibleEntryClick(invisibleEntry) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toggleElementVisibility(element)
?
Invisible Elements | ||
</div> | ||
<t t-foreach="state.invisibleEls" t-as="invisibleEntry" t-key="invisibleEntry_index"> | ||
<t t-call="html_builder.invisibleSnippetEntry" t-call-context="{'entry': invisibleEntry, 'invisibleElTab': this}"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of 'invisibleElTab': this
, what about 'toggleElementVisibility': toggleElementVisibility
} | ||
|
||
function getBasicSection(content) { | ||
function getBasicSection(content, name, processed = false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Another reason why not to have some processing changing the template, so we don't have "convoluted" checks.
- If it is really necessary, you could always return the "processed" to avoid to having to write
getBasicSection(..., false)
andgetBasicSection(..., true)
. - Just a side note and detail, I would always avoid boolean arguments and have it wrapped in an object instead. Some arguments can be found here: https://alexkondov.com/should-you-pass-boolean-to-functions/
No description provided.