Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a disable_type_switcher option. #647

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ Here are all the available options:
<td>If <code>true</code>, remove all Edit Properties buttons from objects.</td>
<td><code>false</code></td>
</tr>
<tr>
<td>disable_type_switcher</td>
<td>If <code>true</code>, remove all type switcher from objects. It's recommended to use it with <code>disable_properties</code> option.</td>
<td><code>false</code></td>
</tr>
<tr>
<td>form_name_root</td>
<td>The first part of the `name` attribute of form inputs in the editor. An full example name is `root[person][name]` where "root" is the form_name_root.</td>
Expand Down
1 change: 1 addition & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ <h2>Options</h2>
<option value='disable_edit_json'>Disable "Edit JSON" buttons</option>
<option value='disable_collapse'>Disable collapse buttons</option>
<option value='disable_properties'>Disable properties buttons</option>
<option value='disable_type_switcher'>Disable type switcher</option>
<option value='disable_array_add'>Disable array add buttons</option>
<option value='disable_array_reorder'>Disable array move buttons</option>
<option value='disable_array_delete'>Disable array delete buttons</option>
Expand Down
6 changes: 6 additions & 0 deletions src/editors/multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ JSONEditor.defaults.editors.multiple = JSONEditor.AbstractEditor.extend({
this.container.appendChild(this.header);

this.switcher = this.theme.getSwitcher(this.display_text);

// Disable the type switcher if specified
if(this.jsoneditor.options.disable_type_switcher){
this.switcher.style.display = "none";
}

container.appendChild(this.switcher);
this.switcher.addEventListener('change',function(e) {
e.preventDefault();
Expand Down