-
Notifications
You must be signed in to change notification settings - Fork 1
feat(spp_change_request_v2): improve Update ID Document CR type #104
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,77 @@ | ||
| /** @odoo-module **/ | ||
|
|
||
| import {RadioField, radioField} from "@web/views/fields/radio/radio_field"; | ||
| import {registry} from "@web/core/registry"; | ||
| import {_t} from "@web/core/l10n/translation"; | ||
|
|
||
| /** | ||
| * A radio widget that supports hiding individual options based on | ||
| * boolean fields on the record. | ||
| * | ||
| * Usage in XML views: | ||
| * <field | ||
| * name="operation" | ||
| * widget="filterable_radio" | ||
| * options="{ | ||
| * 'disabled_map': { | ||
| * 'update': 'allow_id_edit', | ||
| * 'remove': 'allow_id_remove' | ||
| * } | ||
| * }" | ||
| * /> | ||
| * | ||
| * The `disabled_map` option maps selection values to boolean field names. | ||
| * When the boolean field is falsy, the corresponding radio option is | ||
| * hidden from the user. | ||
| */ | ||
| export class FilterableRadioField extends RadioField { | ||
| static template = "spp_base_common.FilterableRadioField"; | ||
| static props = { | ||
| ...RadioField.props, | ||
| disabledMap: {type: Object, optional: true}, | ||
| }; | ||
| static defaultProps = { | ||
| ...RadioField.defaultProps, | ||
| disabledMap: {}, | ||
| }; | ||
|
|
||
| /** | ||
| * Check whether a given selection value should be disabled. | ||
| * @param {any} value - The selection key to check | ||
| * @returns {Boolean} | ||
| */ | ||
| isItemDisabled(value) { | ||
| if (this.props.readonly) { | ||
| return true; | ||
| } | ||
| const map = this.props.disabledMap; | ||
| if (!map || !(value in map)) { | ||
| return false; | ||
| } | ||
| const boolField = map[value]; | ||
| return !this.props.record.data[boolField]; | ||
| } | ||
| } | ||
|
|
||
| export const filterableRadioField = { | ||
| ...radioField, | ||
| component: FilterableRadioField, | ||
| displayName: _t("Filterable Radio"), | ||
| supportedOptions: [ | ||
| ...radioField.supportedOptions, | ||
| { | ||
| label: _t("Disabled map (value → boolean field)"), | ||
| name: "disabled_map", | ||
| type: "object", | ||
| }, | ||
| ], | ||
| extractProps: (fieldInfo, dynamicInfo) => { | ||
| const baseProps = radioField.extractProps(fieldInfo, dynamicInfo); | ||
| return { | ||
| ...baseProps, | ||
| disabledMap: fieldInfo.options.disabled_map || {}, | ||
| }; | ||
| }, | ||
| }; | ||
|
|
||
| registry.category("fields").add("filterable_radio", filterableRadioField); |
This file contains hidden or 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,36 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-name="spp_base_common.FilterableRadioField"> | ||
| <div | ||
| role="radiogroup" | ||
| t-attf-class="o_{{ props.orientation }}" | ||
| t-att-aria-label="props.label" | ||
| > | ||
| <t t-foreach="items" t-as="item" t-key="item[0]"> | ||
| <div | ||
| t-attf-class="form-check o_radio_item #{isItemDisabled(item[0]) ? 'd-none' : ''}" | ||
| aria-atomic="true" | ||
| > | ||
| <input | ||
| type="radio" | ||
| class="form-check-input o_radio_input" | ||
| t-att-checked="item[0] === value" | ||
| t-att-disabled="isItemDisabled(item[0])" | ||
| t-att-name="id" | ||
| t-att-data-value="item[0]" | ||
| t-att-data-index="item_index" | ||
| t-att-id="`${id}_${item[0]}`" | ||
| t-on-change="() => this.onChange(item)" | ||
| /> | ||
| <label | ||
| t-att-for="`${id}_${item[0]}`" | ||
| t-attf-class="form-check-label o_form_label #{isItemDisabled(item[0]) ? 'text-muted' : ''}" | ||
| t-esc="item[1]" | ||
| /> | ||
| </div> | ||
| </t> | ||
| </div> | ||
| </t> | ||
|
|
||
| </templates> |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The functions
_render_comparison_tableand_render_action_summaryrender HTML for the review page. They use the internal helper_format_review_valueto format values. This helper does not escape string values, which could lead to a Cross-Site Scripting (XSS) vulnerability if a user-controlled value (like an ID value) contains malicious HTML or JavaScript. Sincereview_comparison_htmlis rendered withsanitize=False, it's crucial to escape all user-provided data.I recommend updating
_format_review_valueto useodoo.tools.html_escape. For example: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.
Fixed in 9d94eef — added
html_escapeviamarkupsafe.escapeto_format_review_value.