[FIX] agreement_legal: lint warnings

This commit is contained in:
Alexandre Fayolle
2019-10-14 13:07:03 +02:00
parent 15a7245a1f
commit 6a20d54993
2 changed files with 180 additions and 177 deletions

View File

@@ -17,10 +17,10 @@ odoo.define('agreement_legal.domain_widget_ext', function (require) {
// Add Additional options // Add Additional options
this.partialUse = this.nodeOptions.partial_use || false; this.partialUse = this.nodeOptions.partial_use || false;
}, },
//-------------------------------------------------------------------------- //----------------------------------------------------------------------
// Private // Private
//-------------------------------------------------------------------------- //----------------------------------------------------------------------
/** /**
* @private * @private
@@ -37,15 +37,17 @@ odoo.define('agreement_legal.domain_widget_ext', function (require) {
// Convert char value to array value // Convert char value to array value
var value = this.value || "[]"; var value = this.value || "[]";
// Create the domain selector or change the value of the current one... // Create the domain selector or change the value of the current
// one...
var def; var def;
if (!this.domainSelector) { if (!this.domainSelector) {
this.domainSelector = new DomainSelector(this, this._domainModel, value, { this.domainSelector = new DomainSelector(
readonly: this.mode === "readonly" || this.inDialog, this, this._domainModel, value, {
filters: this.fsFilters, readonly: this.mode === "readonly" || this.inDialog,
debugMode: session.debug, filters: this.fsFilters,
partialUse: this.partialUse || false, debugMode: session.debug,
}); partialUse: this.partialUse || false,
});
def = this.domainSelector.prependTo(this.$el); def = this.domainSelector.prependTo(this.$el);
} else { } else {
def = this.domainSelector.setDomain(value); def = this.domainSelector.setDomain(value);
@@ -54,9 +56,10 @@ odoo.define('agreement_legal.domain_widget_ext', function (require) {
return def.then(this._replaceContent.bind(this)); return def.then(this._replaceContent.bind(this));
}, },
/** /**
* Render the field DOM except for the domain selector part. The full field * Render the field DOM except for the domain selector part. The full
* DOM is composed of a DIV which contains the domain selector widget, * field DOM is composed of a DIV which contains the domain selector
* followed by other content. This other content is handled by this method. * widget, followed by other content. This other content is handled by
* this method.
* *
* @private * @private
*/ */

View File

@@ -1,179 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve"> <templates id="template" xml:space="preserve">
<t t-name="FieldDomain.content"> <t t-name="FieldDomain.content">
<t t-if="partialUse"> <t t-if="partialUse">
<div t-if="hasModel" class="o_field_domain_panel"> <div t-if="hasModel" class="o_field_domain_panel">
<!--<div t-if="hasModel" class="o_field_domain_panel"> <!--<div t-if="hasModel" class="o_field_domain_panel">
<i class="fa fa-arrow-right" role="img" aria-label="Domain" title="Domain"/> <i class="fa fa-arrow-right" role="img" aria-label="Domain" title="Domain"/>
<button t-if="isValid" class="btn btn-sm btn-secondary o_domain_show_selection_button" type="button">
<t t-esc="nbRecords"/> record(s)
</button>
<span t-else="" class="text-warning" role="alert"><i class="fa fa-exclamation-triangle" role="img" aria-label="Warning" title="Warning"/> Invalid domain</span>
<button t-if="inDialogEdit" class="btn btn-sm btn-primary o_field_domain_dialog_button">Edit Domain</button>
</div>
<div t-else="">Select a model to add a filter.</div>-->
</div>
</t>
<t t-if="!partialUse">
<div t-if="hasModel" class="o_field_domain_panel">
<i class="fa fa-arrow-right" role="img" aria-label="Domain" title="Domain"/>
<button t-if="isValid" class="btn btn-sm btn-secondary o_domain_show_selection_button" type="button">
<t t-esc="nbRecords"/> record(s)
</button>
<span t-else="" class="text-warning" role="alert"><i class="fa fa-exclamation-triangle" role="img" aria-label="Warning" title="Warning"/> Invalid domain</span>
<button t-if="inDialogEdit" class="btn btn-sm btn-primary o_field_domain_dialog_button">Edit Domain</button>
</div>
<div t-else="">Select a model to add a filter.</div>
</t>
</t>
<div aria-atomic="true" t-name="DomainSelector" t-attf-class="o_domain_node o_domain_tree o_domain_selector #{widget.readonly ? 'o_read_mode' : 'o_edit_mode'}"> <button t-if="isValid" class="btn btn-sm btn-secondary o_domain_show_selection_button" type="button">
<t t-if="widget.options.partialUse"> <t t-esc="nbRecords"/> record(s)
<t t-if="widget.children.length === 0"> </button>
<span>SMatch <strong>all records</strong></span> <span t-else="" class="text-warning" role="alert"><i class="fa fa-exclamation-triangle" role="img" aria-label="Warning" title="Warning"/> Invalid domain</span>
<button t-if="!widget.readonly" class="btn btn-sm btn-primary o_domain_add_first_node_button"><i class="fa fa-plus"/> Add filter</button>
<button t-if="inDialogEdit" class="btn btn-sm btn-primary o_field_domain_dialog_button">Edit Domain</button>
</div>
<div t-else="">Select a model to add a filter.</div>-->
</div>
</t> </t>
<t t-else=""> <t t-if="!partialUse">
<div class="o_domain_tree_header"> <div t-if="hasModel" class="o_field_domain_panel">
<t t-if="widget.children.length === 1">Please navigate below and select field:</t> <i class="fa fa-arrow-right" role="img" aria-label="Domain" title="Domain"/>
<t t-else="">
<span>SSMatch records with</span>
<t t-call="DomainTree.OperatorSelector"/>
<span>of the following rules:</span>
</t>
</div>
<div class="o_domain_node_children_container"/>
</t>
</t>
<t t-if="!widget.options.partialUse">
<t t-if="widget.children.length === 0">
<span>Match <strong>all records</strong></span>
<button t-if="!widget.readonly" class="btn btn-sm btn-primary o_domain_add_first_node_button"><i class="fa fa-plus"/> Add filter</button>
</t>
<t t-else="">
<div class="o_domain_tree_header">
<t t-if="widget.children.length === 1">Match records with the following rule:</t>
<t t-else="">
<span>Match records with</span>
<t t-call="DomainTree.OperatorSelector"/>
<span>of the following rules:</span>
</t>
</div>
<div class="o_domain_node_children_container"/>
</t>
<label t-if="widget.debug &amp;&amp; !widget.readonly" class="o_domain_debug_container">
<span class="small"># Code editor</span>
<input type="text" class="o_domain_debug_input"/>
</label>
</t>
</div>
<t t-name="DomainNode.ControlPanel">
<t t-if="widget.options.partialUse">
<div t-if="!widget.readonly &amp;&amp; !widget.noControlPanel" class="o_domain_node_control_panel" role="toolbar" aria-label="Domain node">
</div>
</t>
<t t-if="!widget.options.partialUse">
<div t-if="!widget.readonly &amp;&amp; !widget.noControlPanel" class="o_domain_node_control_panel" role="toolbar" aria-label="Domain node">
<button class="btn o_domain_delete_node_button" title="Delete node" aria-label="Delete node"><i class="fa fa-times"/></button>
<button class="btn o_domain_add_node_button" title="Add node" aria-label="Add node"><i class="fa fa-plus-circle"/></button>
<button class="btn o_domain_add_node_button" title="Add branch" aria-label="Add branch" data-branch="1"><i class="fa fa-ellipsis-h"/></button>
</div>
</t>
</t>
<div t-name="DomainLeaf" t-attf-class="o_domain_node o_domain_leaf o_domain_selector_row #{widget.readonly ? 'o_read_mode' : 'o_edit_mode'}">
<t t-call="DomainNode.ControlPanel"/>
<div t-if="!widget.readonly" class="o_domain_leaf_edition"> <button t-if="isValid" class="btn btn-sm btn-secondary o_domain_show_selection_button" type="button">
<!-- field selector will be instantiated here --> <t t-esc="nbRecords"/> record(s)
<t t-if="!widget.options.partialUse"> </button>
<div> <!-- used for flex stretching --> <span t-else="" class="text-warning" role="alert"><i class="fa fa-exclamation-triangle" role="img" aria-label="Warning" title="Warning"/> Invalid domain</span>
<select class="o_domain_leaf_operator_select o_input">
<option t-foreach="widget.operators" t-as="key" <button t-if="inDialogEdit" class="btn btn-sm btn-primary o_field_domain_dialog_button">Edit Domain</button>
t-att-value="key" </div>
t-att-selected="widget.displayOperator === key ? 'selected' : None"> <div t-else="">Select a model to add a filter.</div>
<t t-esc="key_value"/> </t>
</option> </t>
</select>
</div> <div aria-atomic="true" t-name="DomainSelector" t-attf-class="o_domain_node o_domain_tree o_domain_selector #{widget.readonly ? 'o_read_mode' : 'o_edit_mode'}">
<div t-attf-class="o_ds_value_cell#{_.contains(['set', 'not set'], widget.displayOperator) ? ' d-none' : ''}"> <t t-if="widget.options.partialUse">
<t t-if="widget.selectionChoices !== null"> <t t-if="widget.children.length === 0">
<select class="o_domain_leaf_value_input o_input"> <span>SMatch <strong>all records</strong></span>
<option t-foreach="widget.selectionChoices" t-as="val" <button t-if="!widget.readonly" class="btn btn-sm btn-primary o_domain_add_first_node_button"><i class="fa fa-plus"/> Add filter</button>
t-att-value="val[0]"
t-att-selected="_.contains(val, widget.displayValue) ? 'selected' : None">
<t t-esc="val[1]"/>
</option>
</select>
</t> </t>
<t t-else=""> <t t-else="">
<t t-if="_.contains(['in', 'not in'], widget.operator)"> <div class="o_domain_tree_header">
<div class="o_domain_leaf_value_input"> <t t-if="widget.children.length === 1">Please navigate below and select field:</t>
<span class="badge badge-pill" t-foreach="widget.displayValue" t-as="val"> <t t-else="">
<t t-esc="val"/> <i class="o_domain_leaf_value_remove_tag_button fa fa-times" t-att-data-value="val" role="img" aria-label="Remove tag" title="Remove tag"/> <span>SSMatch records with</span>
</span> <t t-call="DomainTree.OperatorSelector"/>
</div> <span>of the following rules:</span>
<div class="o_domain_leaf_value_tags"> </t>
<input placeholder="Add new value" type="text" class="o_input"/> </div>
<button class="btn btn-sm btn-primary fa fa-plus o_domain_leaf_value_add_tag_button" aria-label="Add tag" title="Add tag"/>
</div> <div class="o_domain_node_children_container"/>
</t>
<t t-else="">
<input class="o_domain_leaf_value_input o_input" type="text" t-att-value="widget.displayValue"/>
</t>
</t>
</div>
</t>
</div>
<div t-else="" class="o_domain_leaf_info">
<!-- field selector will be instantiated here -->
<t t-if="_.isString(widget.value)">
<span class="o_domain_leaf_operator"><t t-esc="widget.operator_mapping[widget.operator]"/></span>
<span class="o_domain_leaf_value text-primary">"<t t-esc="widget.value"/>"</span>
</t>
<t t-if="_.isArray(widget.value)">
<span class="o_domain_leaf_operator"><t t-esc="widget.operator_mapping[widget.operator]"/></span>
<t t-foreach="widget.value" t-as="v">
<span class="o_domain_leaf_value text-primary">"<t t-esc="v"/>"</span>
<t t-if="!v_last"> or </t>
</t> </t>
</t> </t>
<t t-if="_.isNumber(widget.value)"> <t t-if="!widget.options.partialUse">
<span class="o_domain_leaf_operator"><t t-esc="widget.operator_mapping[widget.operator]"/></span> <t t-if="widget.children.length === 0">
<span class="o_domain_leaf_value text-primary"><t t-esc="widget.value"></t></span> <span>Match <strong>all records</strong></span>
</t> <button t-if="!widget.readonly" class="btn btn-sm btn-primary o_domain_add_first_node_button"><i class="fa fa-plus"/> Add filter</button>
<t t-if="_.isBoolean(widget.value)"> </t>
is <t t-else="">
<t t-if="widget.operator === '=' &amp;&amp; widget.value === false || widget.operator === '!=' &amp;&amp; widget.value === true">not</t> <div class="o_domain_tree_header">
set <t t-if="widget.children.length === 1">Match records with the following rule:</t>
<t t-else="">
<span>Match records with</span>
<t t-call="DomainTree.OperatorSelector"/>
<span>of the following rules:</span>
</t>
</div>
<div class="o_domain_node_children_container"/>
</t>
<label t-if="widget.debug &amp;&amp; !widget.readonly" class="o_domain_debug_container">
<span class="small"># Code editor</span>
<input type="text" class="o_domain_debug_input"/>
</label>
</t> </t>
</div> </div>
</div> <t t-name="DomainNode.ControlPanel">
<div aria-atomic="true" t-name="ModelFieldSelector" t-attf-class="o_field_selector#{!widget.options.readonly ? ' o_edit_mode o_input' : ''}"> <t t-if="widget.options.partialUse">
<div class="o_field_selector_value" tabindex="0"/> <div t-if="!widget.readonly &amp;&amp; !widget.noControlPanel" class="o_domain_node_control_panel" role="toolbar" aria-label="Domain node">
<t t-if="!widget.options.partialUse"> </div>
<div class="o_field_selector_controls" tabindex="0"> </t>
<i role="alert" class="fa fa-exclamation-triangle o_field_selector_warning d-none" title="Invalid field chain" aria-label="Invalid field chain"/> <t t-if="!widget.options.partialUse">
</div> <div t-if="!widget.readonly &amp;&amp; !widget.noControlPanel" class="o_domain_node_control_panel" role="toolbar" aria-label="Domain node">
<button class="btn o_domain_delete_node_button" title="Delete node" aria-label="Delete node"><i class="fa fa-times"/></button>
<button class="btn o_domain_add_node_button" title="Add node" aria-label="Add node"><i class="fa fa-plus-circle"/></button>
<button class="btn o_domain_add_node_button" title="Add branch" aria-label="Add branch" data-branch="1"><i class="fa fa-ellipsis-h"/></button>
</div>
</t>
</t> </t>
<div t-if="!widget.options.readonly" class="o_field_selector_popover d-none" tabindex="0"> <div t-name="DomainLeaf" t-attf-class="o_domain_node o_domain_leaf o_domain_selector_row #{widget.readonly ? 'o_read_mode' : 'o_edit_mode'}">
<div class="o_field_selector_popover_header text-center"> <t t-call="DomainNode.ControlPanel"/>
<i class="fa fa-arrow-left o_field_selector_popover_option o_field_selector_prev_page" title="Previous" role="img" aria-label="Previous"/>
<div class="o_field_selector_title"/> <div t-if="!widget.readonly" class="o_domain_leaf_edition">
<i class="fa fa-times o_field_selector_popover_option o_field_selector_close" title="Close" role="img" aria-label="Close"/> <!-- field selector will be instantiated here -->
<t t-if="!widget.options.partialUse">
<div> <!-- used for flex stretching -->
<select class="o_domain_leaf_operator_select o_input">
<option t-foreach="widget.operators" t-as="key"
t-att-value="key"
t-att-selected="widget.displayOperator === key ? 'selected' : None">
<t t-esc="key_value"/>
</option>
</select>
</div>
<div t-attf-class="o_ds_value_cell#{_.contains(['set', 'not set'], widget.displayOperator) ? ' d-none' : ''}">
<t t-if="widget.selectionChoices !== null">
<select class="o_domain_leaf_value_input o_input">
<option t-foreach="widget.selectionChoices" t-as="val"
t-att-value="val[0]"
t-att-selected="_.contains(val, widget.displayValue) ? 'selected' : None">
<t t-esc="val[1]"/>
</option>
</select>
</t>
<t t-else="">
<t t-if="_.contains(['in', 'not in'], widget.operator)">
<div class="o_domain_leaf_value_input">
<span class="badge badge-pill" t-foreach="widget.displayValue" t-as="val">
<t t-esc="val"/> <i class="o_domain_leaf_value_remove_tag_button fa fa-times" t-att-data-value="val" role="img" aria-label="Remove tag" title="Remove tag"/>
</span>
</div>
<div class="o_domain_leaf_value_tags">
<input placeholder="Add new value" type="text" class="o_input"/>
<button class="btn btn-sm btn-primary fa fa-plus o_domain_leaf_value_add_tag_button" aria-label="Add tag" title="Add tag"/>
</div>
</t>
<t t-else="">
<input class="o_domain_leaf_value_input o_input" type="text" t-att-value="widget.displayValue"/>
</t>
</t>
</div>
</t>
</div> </div>
<div class="o_field_selector_popover_body"> <div t-else="" class="o_domain_leaf_info">
<ul class="o_field_selector_page"/> <!-- field selector will be instantiated here -->
</div> <t t-if="_.isString(widget.value)">
<div t-if="widget.options.debugMode" class="o_field_selector_popover_footer"> <span class="o_domain_leaf_operator"><t t-esc="widget.operator_mapping[widget.operator]"/></span>
<input type="text" class="o_input"/> <span class="o_domain_leaf_value text-primary">"<t t-esc="widget.value"/>"</span>
</t>
<t t-if="_.isArray(widget.value)">
<span class="o_domain_leaf_operator"><t t-esc="widget.operator_mapping[widget.operator]"/></span>
<t t-foreach="widget.value" t-as="v">
<span class="o_domain_leaf_value text-primary">"<t t-esc="v"/>"</span>
<t t-if="!v_last"> or </t>
</t>
</t>
<t t-if="_.isNumber(widget.value)">
<span class="o_domain_leaf_operator"><t t-esc="widget.operator_mapping[widget.operator]"/></span>
<span class="o_domain_leaf_value text-primary"><t t-esc="widget.value"></t></span>
</t>
<t t-if="_.isBoolean(widget.value)">
is
<t t-if="widget.operator === '=' &amp;&amp; widget.value === false || widget.operator === '!=' &amp;&amp; widget.value === true">not</t>
set
</t>
</div> </div>
</div> </div>
</div> <div aria-atomic="true" t-name="ModelFieldSelector" t-attf-class="o_field_selector#{!widget.options.readonly ? ' o_edit_mode o_input' : ''}">
</templates> <div class="o_field_selector_value" tabindex="0"/>
<t t-if="!widget.options.partialUse">
<div class="o_field_selector_controls" tabindex="0">
<i role="alert" class="fa fa-exclamation-triangle o_field_selector_warning d-none" title="Invalid field chain" aria-label="Invalid field chain"/>
</div>
</t>
<div t-if="!widget.options.readonly" class="o_field_selector_popover d-none" tabindex="0">
<div class="o_field_selector_popover_header text-center">
<i class="fa fa-arrow-left o_field_selector_popover_option o_field_selector_prev_page" title="Previous" role="img" aria-label="Previous"/>
<div class="o_field_selector_title"/>
<i class="fa fa-times o_field_selector_popover_option o_field_selector_close" title="Close" role="img" aria-label="Close"/>
</div>
<div class="o_field_selector_popover_body">
<ul class="o_field_selector_page"/>
</div>
<div t-if="widget.options.debugMode" class="o_field_selector_popover_footer">
<input type="text" class="o_input"/>
</div>
</div>
</div>
</templates>