Fix multiple json field input. (#98)

This commit is contained in:
long2ice
2022-01-14 21:28:00 +08:00
parent 6f50cede91
commit 1601be1aa1
3 changed files with 13 additions and 12 deletions

View File

@@ -8,13 +8,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install and configure Poetry
uses: snok/install-poetry@v1.1.1
with:
virtualenvs-create: false
run: |
pip install -U pip poetry
poetry config virtualenvs.create false
- name: Build dists
run: make build
- name: Pypi Publish

View File

@@ -5,6 +5,7 @@
### 1.0.4
- Add `widgets.filters.Boolean` class
- Fix multiple json field input. (#98)
### 1.0.3

View File

@@ -22,19 +22,19 @@
</style>
<script>
const container = document.getElementById("{{name}}")
let options = {{options|safe}};
if (Object.keys(options).length === 0) {
options = {
const container_{{ name }} = document.getElementById("{{name}}")
let options_{{ name }} = {{options|safe}};
if (Object.keys(options_{{ name }}).length === 0) {
options_{{ name }} = {
modes: ['tree', 'view', 'form', 'code', 'text', 'preview'],
}
}
options.onChangeText = function (json) {
options_{{ name }}.onChangeText = function (json) {
$('input[name={{ name }}]').val(json);
}
const editor = new JSONEditor(container, options)
const editor_{{ name }} = new JSONEditor(container_{{ name }}, options_{{ name }})
{% if value %}
editor.set({{ value|safe }})
editor_{{ name }}.set({{ value|safe }})
{% endif %}
editor.expandAll();
editor_{{ name }}.expandAll();
</script>