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
Labels
Merge Requests
140
Merge Requests
140
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
f2318991
Commit
f2318991
authored
Apr 16, 2024
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Plain Diff
More fixes for json editor
See merge request
!1919
parents
ef20fc9b
e17a41e5
Pipeline
#34085
failed with stage
in 0 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
72 deletions
+89
-72
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
+2
-2
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
+85
-68
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
+2
-2
No files found.
bt5/erp5_json_editor/SkinTemplateItem/portal_skins/erp5_json_editor/json-editor.gadget.css.css
View file @
f2318991
...
...
@@ -61,13 +61,13 @@ div.json-editor-container .je-switcher {
div
.json-editor-container
.btn
{
vertical-align
:
middle
;
border
:
1px
solid
transparent
;
padding
:
0.25rem
0.5rem
;
padding
:
2pt
5pt
3pt
5pt
;
flex
:
1
1
auto
;
color
:
#fff
;
background-color
:
#6c757d
;
border-color
:
#6c757d
;
font-size
:
0.875rem
;
border-radius
:
0.
2
rem
;
border-radius
:
0.
325
rem
;
}
div
.json-editor-container
.btn
:hover
{
color
:
#fff
;
...
...
bt5/erp5_json_editor/SkinTemplateItem/portal_skins/erp5_json_editor/json-editor.gadget.js.js
View file @
f2318991
...
...
@@ -12,6 +12,13 @@
return
undefined
;
};
JSONEditor
.
AbstractEditor
.
prototype
.
preBuild
=
function
()
{
if
(
this
.
jsoneditor
.
options
.
readonly
)
{
this
.
schema
.
readOnly
=
this
.
jsoneditor
.
options
.
readonly
;
}
};
function
isEmpty
(
obj
)
{
return
obj
===
undefined
||
obj
===
''
||
(
...
...
@@ -37,10 +44,77 @@
return
result
;
};
JSONEditor
.
AbstractEditor
.
prototype
.
preBuild
=
function
()
{
if
(
this
.
jsoneditor
.
options
.
readonly
)
{
this
.
schema
.
readOnly
=
this
.
jsoneditor
.
options
.
readonly
;
if
(
JSONEditor
.
defaults
.
editors
.
object
.
prototype
.
original_getPropertySchema
===
undefined
)
{
JSONEditor
.
defaults
.
editors
.
object
.
prototype
.
original_getPropertySchema
=
JSONEditor
.
defaults
.
editors
.
object
.
prototype
.
getPropertySchema
;
}
JSONEditor
.
defaults
.
editors
.
object
.
prototype
.
getPropertySchema
=
function
(
key
)
{
var
schema
=
this
.
original_getPropertySchema
(
key
);
/* Strip forbidden properties, that aren't part of json schema spec.
They are removed because the UI must be complaint with other usages of
json schemas.
*/
delete
schema
.
template
;
delete
schema
.
options
;
if
(
schema
.
const
!==
undefined
)
{
schema
.
enum
=
[
schema
.
const
];
}
/* Display default value as part of description */
if
(
schema
.
default
!==
undefined
&&
typeof
schema
.
default
!==
"
object
"
)
{
if
(
schema
.
description
!==
undefined
)
{
schema
.
description
=
schema
.
description
+
"
(default:
"
+
schema
.
default
+
"
)
"
;
}
else
{
schema
.
description
=
"
(default:
"
+
schema
.
default
+
"
)
"
;
}
}
return
schema
;
};
/* The original code would remove the field if value is undefined */
JSONEditor
.
defaults
.
editors
.
object
.
prototype
.
setValue
=
function
(
value
,
initial
)
{
var
object_editor
=
this
;
value
=
value
||
{};
if
(
typeof
value
!==
'
object
'
||
Array
.
isArray
(
value
))
{
value
=
{};
}
/* First, set the values for all of the defined properties */
// @ts-ignore
Object
.
entries
(
this
.
cached_editors
).
forEach
(
function
(
entry
)
{
var
i
=
entry
[
0
],
editor
=
entry
[
1
];
/* Value explicitly set */
if
(
value
[
i
]
!==
undefined
)
{
object_editor
.
addObjectProperty
(
i
);
editor
.
setValue
(
value
[
i
],
initial
);
editor
.
activate
();
/* Otherwise if it is read only remove the field */
}
else
if
(
editor
.
schema
.
readOnly
)
{
object_editor
.
removeObjectProperty
(
i
);
/* Otherwise, set the value to the default */
}
else
{
editor
.
setValue
(
editor
.
getDefault
(),
initial
);
}
});
// @ts-ignore
Object
.
entries
(
value
).
forEach
(
function
(
entry
)
{
var
i
=
entry
[
0
],
val
=
entry
[
1
];
if
(
!
object_editor
.
cached_editors
[
i
])
{
object_editor
.
addObjectProperty
(
i
);
if
(
object_editor
.
editors
[
i
])
{
object_editor
.
editors
[
i
].
setValue
(
val
,
initial
,
!!
object_editor
.
editors
[
i
].
template
);
}
}
});
object_editor
.
refreshValue
();
object_editor
.
layoutEditors
();
object_editor
.
onChange
();
};
JSONEditor
.
defaults
.
editors
.
select
.
prototype
.
setValue
=
function
(
value
,
initial
)
{
...
...
@@ -237,73 +311,16 @@
field
.
onChange
(
typeChanged
);
};
if
(
JSONEditor
.
defaults
.
editors
.
object
.
prototype
.
original_getPropertySchema
===
undefined
)
{
JSONEditor
.
defaults
.
editors
.
object
.
prototype
.
original_getPropertySchema
=
JSONEditor
.
defaults
.
editors
.
object
.
prototype
.
getPropertySchema
;
}
JSONEditor
.
defaults
.
editors
.
object
.
prototype
.
getPropertySchema
=
function
(
key
)
{
var
schema
=
this
.
original_getPropertySchema
(
key
);
/* Strip forbidden properties, that aren't part of json schema spec.
They are removed because the UI must be complaint with other usages of
json schemas.
*/
delete
schema
.
template
;
delete
schema
.
options
;
/* Display default value as part of description */
if
(
schema
.
default
!==
undefined
&&
typeof
schema
.
default
!==
"
object
"
)
{
if
(
schema
.
description
!==
undefined
)
{
schema
.
description
=
schema
.
description
+
"
(default:
"
+
schema
.
default
+
"
)
"
;
}
else
{
schema
.
description
=
"
(default:
"
+
schema
.
default
+
"
)
"
;
}
}
return
schema
;
JSONEditor
.
defaults
.
editors
.
array
.
prototype
.
ensureArraySize
=
function
(
value
)
{
// Don't extend or slice data based on the input
// Let the user handle it.
return
value
;
};
/* The original code would remove the field if value is undefined */
JSONEditor
.
defaults
.
editors
.
object
.
prototype
.
setValue
=
function
(
value
,
initial
)
{
var
object_editor
=
this
;
value
=
value
||
{};
if
(
typeof
value
!==
'
object
'
||
Array
.
isArray
(
value
))
{
value
=
{};
}
/* First, set the values for all of the defined properties */
// @ts-ignore
Object
.
entries
(
this
.
cached_editors
).
forEach
(
function
(
entry
)
{
var
i
=
entry
[
0
],
editor
=
entry
[
1
];
/* Value explicitly set */
if
(
value
[
i
]
!==
undefined
)
{
object_editor
.
addObjectProperty
(
i
);
editor
.
setValue
(
value
[
i
],
initial
);
editor
.
activate
();
/* Otherwise if it is read only remove the field */
}
else
if
(
editor
.
schema
.
readOnly
)
{
object_editor
.
removeObjectProperty
(
i
);
/* Otherwise, set the value to the default */
}
else
{
editor
.
setValue
(
editor
.
getDefault
(),
initial
);
}
});
// @ts-ignore
Object
.
entries
(
value
).
forEach
(
function
(
entry
)
{
var
i
=
entry
[
0
],
val
=
entry
[
1
];
if
(
!
object_editor
.
cached_editors
[
i
])
{
object_editor
.
addObjectProperty
(
i
);
if
(
object_editor
.
editors
[
i
])
{
object_editor
.
editors
[
i
].
setValue
(
val
,
initial
,
!!
object_editor
.
editors
[
i
].
template
);
}
}
});
object_editor
.
refreshValue
();
object_editor
.
layoutEditors
();
object_editor
.
onChange
();
JSONEditor
.
defaults
.
editors
.
table
.
prototype
.
ensureArraySize
=
function
(
value
)
{
// Don't extend or slice data based on the input
// Let the user handle it.
return
value
;
};
JSONEditor
.
defaults
.
editors
.
string
.
prototype
.
setValueToInputField
=
function
(
value
)
{
...
...
bt5/erp5_json_editor/SkinTemplateItem/portal_skins/erp5_json_editor/json-editor.gadget.less.txt
View file @
f2318991
...
...
@@ -70,13 +70,13 @@ div.json-editor-container {
& .btn {
vertical-align: middle;
border: 1px solid transparent;
padding:
0.25rem 0.5rem
;
padding:
2pt 5pt 3pt 5pt
;
flex: 1 1 auto;
color: #fff;
background-color: #6c757d;
border-color: #6c757d;
font-size: .875rem;
border-radius: 0.
2
rem;
border-radius: 0.
325
rem;
}
& .btn:hover {
...
...
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