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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul Graydon
erp5
Commits
38483df3
Commit
38483df3
authored
Mar 18, 2024
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Plain Diff
General fixes for json_editor
See merge request
nexedi/erp5!1904
parents
ef735f9b
feba703c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
14 deletions
+77
-14
bt5/erp5_json_editor/SkinTemplateItem/portal_skins/erp5_json_editor/json-editor.gadget.css.css
.../portal_skins/erp5_json_editor/json-editor.gadget.css.css
+10
-4
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
+58
-7
bt5/erp5_json_editor/SkinTemplateItem/portal_skins/erp5_json_editor/json-editor.gadget.less.txt
...portal_skins/erp5_json_editor/json-editor.gadget.less.txt
+9
-3
No files found.
bt5/erp5_json_editor/SkinTemplateItem/portal_skins/erp5_json_editor/json-editor.gadget.css.css
View file @
38483df3
...
@@ -17,16 +17,22 @@ div.json-editor-container label {
...
@@ -17,16 +17,22 @@ div.json-editor-container label {
div
.json-editor-container
label
.visually-hidden
{
div
.json-editor-container
label
.visually-hidden
{
display
:
none
;
display
:
none
;
}
}
div
.json-editor-container
.alert-danger
{
div
.json-editor-container
.invalid-feedback
{
padding
:
1px
10px
2px
10px
;
border-radius
:
0.25rem
;
border-color
:
#f5c2c7
;
border
:
1px
solid
#f5c2c7
;
}
div
.json-editor-container
.alert-danger
,
div
.json-editor-container
.invalid-feedback
{
color
:
#842029
;
color
:
#842029
;
background-color
:
#f8d7da
;
background-color
:
#f8d7da
;
border-color
:
#f5c2c7
;
}
}
div
.json-editor-container
.alert
{
div
.json-editor-container
.alert
{
position
:
relative
;
position
:
relative
;
padding
:
1rem
1rem
;
padding
:
1rem
1rem
;
margin-bottom
:
1rem
;
margin-bottom
:
1rem
;
border
:
1px
solid
transparent
;
border
:
1px
solid
#f5c2c7
;
border-radius
:
0.25rem
;
border-radius
:
0.25rem
;
}
}
div
.json-editor-container
.form-label
{
div
.json-editor-container
.form-label
{
...
@@ -101,4 +107,4 @@ div.json-editor-container .form-control:disabled,
...
@@ -101,4 +107,4 @@ div.json-editor-container .form-control:disabled,
div
.json-editor-container
.form-control
[
readonly
]
{
div
.json-editor-container
.form-control
[
readonly
]
{
background-color
:
#e9ecef
!important
;
background-color
:
#e9ecef
!important
;
opacity
:
1
;
opacity
:
1
;
}
}
\ No newline at end of file
bt5/erp5_json_editor/SkinTemplateItem/portal_skins/erp5_json_editor/json-editor.gadget.js.js
View file @
38483df3
...
@@ -43,6 +43,45 @@
...
@@ -43,6 +43,45 @@
}
}
};
};
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
setValue
=
function
(
value
,
initial
)
{
/* Sanitize value before setting it */
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
);
}
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
)];
}
else
if
(
!
inEnum
&&
!
this
.
hasPlaceholderOption
)
{
this
.
input
.
value
=
sanitized
;
}
else
{
this
.
input
.
value
=
'
_placeholder_
'
;
}
this
.
value
=
sanitized
;
if
(
!
initial
)
{
this
.
is_dirty
=
true
;
}
this
.
onChange
();
this
.
change
();
};
if
(
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
original_preBuild
===
undefined
)
{
if
(
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
original_preBuild
===
undefined
)
{
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
original_preBuild
=
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
preBuild
;
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
original_preBuild
=
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
preBuild
;
}
}
...
@@ -80,8 +119,19 @@
...
@@ -80,8 +119,19 @@
};
};
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
typecast
=
function
(
value
)
{
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
typecast
=
function
(
value
)
{
if
(
this
.
schema
.
type
===
'
boolean
'
)
{
/* The value should be modified but it must be preserve its integrity,
return
value
===
'
undefined
'
||
value
===
undefined
?
undefined
:
!!
value
;
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
;
}
if
(
this
.
schema
.
type
===
'
boolean
'
&&
(
typeof
value
===
"
boolean
"
))
{
return
value
;
}
if
(
this
.
schema
.
type
===
'
boolean
'
&&
(
value
===
"
true
"
||
value
===
"
1
"
))
{
return
true
;
}
if
(
this
.
schema
.
type
===
'
boolean
'
&&
(
value
===
"
false
"
||
value
===
""
))
{
return
false
;
}
}
if
(
this
.
schema
.
type
===
'
number
'
&&
value
===
""
)
{
if
(
this
.
schema
.
type
===
'
number
'
&&
value
===
""
)
{
return
undefined
;
return
undefined
;
...
@@ -90,10 +140,12 @@
...
@@ -90,10 +140,12 @@
return
undefined
;
return
undefined
;
}
}
if
(
this
.
schema
.
type
===
'
number
'
)
{
if
(
this
.
schema
.
type
===
'
number
'
)
{
return
parseFloat
(
value
)
||
0
;
return
parseFloat
(
value
)
||
value
;
}
}
if
(
this
.
schema
.
type
===
'
integer
'
)
{
if
(
this
.
schema
.
type
===
'
integer
'
)
{
return
Math
.
floor
(
parseFloat
(
value
)
||
0
);
if
(
parseFloat
(
value
))
{
return
Math
.
floor
(
parseFloat
(
value
));
}
}
}
if
(
this
.
schema
.
enum
&&
value
===
undefined
)
{
if
(
this
.
schema
.
enum
&&
value
===
undefined
)
{
return
undefined
;
return
undefined
;
...
@@ -101,7 +153,6 @@
...
@@ -101,7 +153,6 @@
if
(
value
===
undefined
)
{
if
(
value
===
undefined
)
{
return
undefined
;
return
undefined
;
}
}
return
value
.
toString
();
return
value
.
toString
();
};
};
...
@@ -248,8 +299,8 @@
...
@@ -248,8 +299,8 @@
// editor relies on async load function, so we must return the promise
// editor relies on async load function, so we must return the promise
// to finish before continue, otherwise rendering errors wont throw Errors
// to finish before continue, otherwise rendering errors wont throw Errors
// in the same stack as expected.
// in the same stack as expected.
return
editor
.
promise
return
editor
.
promise
;
})
})
;
})
})
.
declareMethod
(
'
getContent
'
,
function
()
{
.
declareMethod
(
'
getContent
'
,
function
()
{
var
form_data
=
{};
var
form_data
=
{};
...
...
bt5/erp5_json_editor/SkinTemplateItem/portal_skins/erp5_json_editor/json-editor.gadget.less.txt
View file @
38483df3
...
@@ -22,17 +22,23 @@ div.json-editor-container {
...
@@ -22,17 +22,23 @@ div.json-editor-container {
display: none;
display: none;
}
}
& .alert-danger {
& .invalid-feedback{
padding: 1px 10px 2px 10px;
border-radius: 0.25rem;
border-color: #f5c2c7;
border: 1px solid #f5c2c7;
}
& .alert-danger, .invalid-feedback{
color: #842029;
color: #842029;
background-color: #f8d7da;
background-color: #f8d7da;
border-color: #f5c2c7;
}
}
& .alert {
& .alert {
position: relative;
position: relative;
padding: 1rem 1rem;
padding: 1rem 1rem;
margin-bottom: 1rem;
margin-bottom: 1rem;
border: 1px solid
transparent
;
border: 1px solid
#f5c2c7
;
border-radius: 0.25rem;
border-radius: 0.25rem;
}
}
& .form-label {
& .form-label {
...
...
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