Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
feba703c
Commit
feba703c
authored
Mar 14, 2024
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_json_editor: make jslint happy
parent
5c252784
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
23 deletions
+27
-23
bt5/erp5_json_editor/SkinTemplateItem/portal_skins/erp5_json_editor/json-editor.gadget.js.js
...em/portal_skins/erp5_json_editor/json-editor.gadget.js.js
+27
-23
No files found.
bt5/erp5_json_editor/SkinTemplateItem/portal_skins/erp5_json_editor/json-editor.gadget.js.js
View file @
feba703c
...
...
@@ -45,38 +45,42 @@
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
setValue
=
function
(
value
,
initial
)
{
/* Sanitize value before setting it */
let
sanitized
=
this
.
typecast
(
value
)
const
inEnum
=
(
this
.
enum_options
.
length
>
0
&&
this
.
enum_values
.
includes
(
sanitized
))
const
haveToUseDefaultValue
=
!!
this
.
jsoneditor
.
options
.
use_default_values
||
typeof
this
.
schema
.
default
!==
'
undefined
'
var
sanitized
=
this
.
typecast
(
value
),
inEnum
=
(
this
.
enum_options
.
length
>
0
&&
this
.
enum_values
.
includes
(
sanitized
)),
haveToUseDefaultValue
=
(
!!
this
.
jsoneditor
.
options
.
use_default_values
||
this
.
schema
.
default
===
undefined
);
if
(
!
this
.
hasPlaceholderOption
&&
(
!
inEnum
||
(
initial
&&
!
this
.
isRequired
()
&&
!
haveToUseDefaultValue
)))
{
/* NXD: We forcefuly include the value even */
this
.
theme
.
setSelectOptions
(
this
.
input
,
this
.
enum_options
.
concat
([
value
]),
this
.
enum_display
.
concat
([
value
]),
this
.
hasPlaceholderOption
,
this
.
placeholderOptionText
)
this
.
theme
.
setSelectOptions
(
this
.
input
,
this
.
enum_options
.
concat
([
value
]),
this
.
enum_display
.
concat
([
value
]),
this
.
hasPlaceholderOption
,
this
.
placeholderOptionText
);
}
if
(
this
.
value
===
sanitized
)
return
if
(
this
.
value
===
sanitized
)
{
return
;
}
/* NXD: !this.hasPlaceholderOption seems to be a bug on upstream introduces by:
https://github.com/json-editor/json-editor/pull/1499/commits/2f9b1b3a30e64383b92dc4cd7494f55ba089ae66 */
if
(
inEnum
&&
!
this
.
hasPlaceholderOption
)
{
this
.
input
.
value
=
this
.
enum_options
[
this
.
enum_values
.
indexOf
(
sanitized
)]
this
.
input
.
value
=
this
.
enum_options
[
this
.
enum_values
.
indexOf
(
sanitized
)]
;
}
else
if
(
!
inEnum
&&
!
this
.
hasPlaceholderOption
)
{
this
.
input
.
value
=
sanitized
this
.
input
.
value
=
sanitized
;
}
else
{
this
.
input
.
value
=
'
_placeholder_
'
this
.
input
.
value
=
'
_placeholder_
'
;
}
this
.
value
=
sanitized
this
.
value
=
sanitized
;
if
(
!
initial
)
{
this
.
is_dirty
=
true
this
.
is_dirty
=
true
;
}
this
.
onChange
()
this
.
change
()
}
this
.
onChange
();
this
.
change
();
};
if
(
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
original_preBuild
===
undefined
)
{
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
original_preBuild
=
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
preBuild
;
...
...
@@ -118,16 +122,16 @@
/* The value should be modified but it must be preserve its integrity,
it must not be modified even if the type is not the good one */
if
(
this
.
schema
.
type
===
'
boolean
'
&&
(
value
===
'
undefined
'
||
value
===
undefined
))
{
return
undefined
;
return
undefined
;
}
if
(
this
.
schema
.
type
===
'
boolean
'
&&
(
typeof
value
==
"
boolean
"
))
{
return
value
;
if
(
this
.
schema
.
type
===
'
boolean
'
&&
(
typeof
value
==
=
"
boolean
"
))
{
return
value
;
}
if
(
this
.
schema
.
type
===
'
boolean
'
&&
(
value
===
"
true
"
||
value
===
"
1
"
))
{
return
true
;
return
true
;
}
if
(
this
.
schema
.
type
===
'
boolean
'
&&
(
value
===
"
false
"
||
value
===
""
))
{
return
false
;
return
false
;
}
if
(
this
.
schema
.
type
===
'
number
'
&&
value
===
""
)
{
return
undefined
;
...
...
@@ -140,7 +144,7 @@
}
if
(
this
.
schema
.
type
===
'
integer
'
)
{
if
(
parseFloat
(
value
))
{
return
Math
.
floor
(
parseFloat
(
value
))
return
Math
.
floor
(
parseFloat
(
value
))
;
}
}
if
(
this
.
schema
.
enum
&&
value
===
undefined
)
{
...
...
@@ -295,8 +299,8 @@
// editor relies on async load function, so we must return the promise
// to finish before continue, otherwise rendering errors wont throw Errors
// in the same stack as expected.
return
editor
.
promise
})
return
editor
.
promise
;
})
;
})
.
declareMethod
(
'
getContent
'
,
function
()
{
var
form_data
=
{};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment