mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] web_widget_dropdown_dynamic: black, isort, prettier
This commit is contained in:
committed by
Thanakrit Pintana
parent
503487e589
commit
9ed3444fb3
@@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Brainbean Apps (https://brainbeanapps.com)
|
||||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
*/
|
||||
odoo.define("web_widget_dropdown_dynamic.basic_model", function(require) {
|
||||
odoo.define("web_widget_dropdown_dynamic.basic_model", function (require) {
|
||||
"use strict";
|
||||
|
||||
var BasicModel = require("web.BasicModel");
|
||||
@@ -20,7 +20,7 @@ odoo.define("web_widget_dropdown_dynamic.basic_model", function(require) {
|
||||
* (for the given parameters), no RPC is done and the promise
|
||||
* is resolved with the undefined value.
|
||||
*/
|
||||
_fetchDynamicDropdownValues: function(record, fieldName, fieldInfo) {
|
||||
_fetchDynamicDropdownValues: function (record, fieldName, fieldInfo) {
|
||||
var model = fieldInfo.options.model || record.model;
|
||||
var method = fieldInfo.values || fieldInfo.options.values;
|
||||
if (!method) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
|
||||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
*/
|
||||
odoo.define("web_widget_dropdown_dynamic.field_dynamic_dropdown", function(require) {
|
||||
odoo.define("web_widget_dropdown_dynamic.field_dynamic_dropdown", function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require("web.core");
|
||||
@@ -22,7 +22,7 @@ odoo.define("web_widget_dropdown_dynamic.field_dynamic_dropdown", function(requi
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
init: function() {
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this._setValues();
|
||||
},
|
||||
@@ -35,13 +35,13 @@ odoo.define("web_widget_dropdown_dynamic.field_dynamic_dropdown", function(requi
|
||||
* @override
|
||||
* @returns {jQuery}
|
||||
*/
|
||||
getFocusableElement: function() {
|
||||
getFocusableElement: function () {
|
||||
return this.$el.is("select") ? this.$el : $();
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
isSet: function() {
|
||||
isSet: function () {
|
||||
return this.value !== false;
|
||||
},
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ odoo.define("web_widget_dropdown_dynamic.field_dynamic_dropdown", function(requi
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
updateModifiersValue: function() {
|
||||
updateModifiersValue: function () {
|
||||
this._super.apply(this, arguments);
|
||||
if (!this.attrs.modifiersValue.invisible && this.mode !== "readonly") {
|
||||
this._setValues();
|
||||
@@ -66,14 +66,14 @@ odoo.define("web_widget_dropdown_dynamic.field_dynamic_dropdown", function(requi
|
||||
* @override
|
||||
* @private
|
||||
*/
|
||||
_formatValue: function(value) {
|
||||
_formatValue: function (value) {
|
||||
var options = _.extend(
|
||||
{},
|
||||
this.nodeOptions,
|
||||
{data: this.recordData},
|
||||
this.formatOptions
|
||||
);
|
||||
var formattedValue = _.find(this.values, function(option) {
|
||||
var formattedValue = _.find(this.values, function (option) {
|
||||
return option[0] === value;
|
||||
});
|
||||
if (!formattedValue) {
|
||||
@@ -89,7 +89,7 @@ odoo.define("web_widget_dropdown_dynamic.field_dynamic_dropdown", function(requi
|
||||
* @override
|
||||
* @private
|
||||
*/
|
||||
_renderEdit: function() {
|
||||
_renderEdit: function () {
|
||||
this.$el.empty();
|
||||
for (var i = 0; i < this.values.length; i++) {
|
||||
this.$el.append(
|
||||
@@ -105,13 +105,13 @@ odoo.define("web_widget_dropdown_dynamic.field_dynamic_dropdown", function(requi
|
||||
* @override
|
||||
* @private
|
||||
*/
|
||||
_renderReadonly: function() {
|
||||
_renderReadonly: function () {
|
||||
this.$el.empty().text(this._formatValue(this.value));
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_reset: function() {
|
||||
_reset: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this._setValues();
|
||||
},
|
||||
@@ -120,8 +120,8 @@ odoo.define("web_widget_dropdown_dynamic.field_dynamic_dropdown", function(requi
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_setValues: function() {
|
||||
this.values = _.reject(this.record.specialData[this.name], function(v) {
|
||||
_setValues: function () {
|
||||
this.values = _.reject(this.record.specialData[this.name], function (v) {
|
||||
return v[0] === false && v[1] === "";
|
||||
});
|
||||
if (!this.attrs.modifiersValue || !this.attrs.modifiersValue.required) {
|
||||
@@ -138,7 +138,7 @@ odoo.define("web_widget_dropdown_dynamic.field_dynamic_dropdown", function(requi
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_onChange: function() {
|
||||
_onChange: function () {
|
||||
var value = JSON.parse(this.$el.val());
|
||||
this._setValue(value.toString());
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user