mirror of
https://github.com/apache/superset.git
synced 2024-09-12 16:49:40 -04:00
Checkboxes everywhere
This commit is contained in:
parent
06c12e7cd9
commit
0d6720ad37
81
panoramix/templates/appbuilder/general/widgets/list.html
Normal file
81
panoramix/templates/appbuilder/general/widgets/list.html
Normal file
@ -0,0 +1,81 @@
|
||||
{% import 'appbuilder/general/lib.html' as lib %}
|
||||
{% extends 'appbuilder/general/widgets/base_list.html' %}
|
||||
|
||||
|
||||
{% block begin_content scoped %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover">
|
||||
{% endblock %}
|
||||
|
||||
{% block begin_loop_header scoped %}
|
||||
<thead>
|
||||
<tr>
|
||||
{% if actions %}
|
||||
<th class="action_checkboxes">
|
||||
<input id="check_all" class="action_check_all" name="check_all" type="checkbox">
|
||||
</th>
|
||||
{% endif %}
|
||||
|
||||
{% if can_show or can_edit or can_delete %}
|
||||
<th class="col-md-1 col-lg-1 col-sm-1" ></th>
|
||||
{% endif %}
|
||||
|
||||
{% for item in include_columns %}
|
||||
{% if item in order_columns %}
|
||||
{% set res = item | get_link_order(modelview_name) %}
|
||||
{% if res == 2 %}
|
||||
<th><a href={{ item | link_order(modelview_name) }}>{{label_columns.get(item)}}
|
||||
<i class="fa fa-chevron-up pull-right"></i></a></th>
|
||||
{% elif res == 1 %}
|
||||
<th><a href={{ item | link_order(modelview_name) }}>{{label_columns.get(item)}}
|
||||
<i class="fa fa-chevron-down pull-right"></i></a></th>
|
||||
{% else %}
|
||||
<th><a href={{ item | link_order(modelview_name) }}>{{label_columns.get(item)}}
|
||||
<i class="fa fa-arrows-v pull-right"></i></a></th>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<th>{{label_columns.get(item)}}</th>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
{% endblock %}
|
||||
|
||||
{% block begin_loop_values %}
|
||||
{% for item in value_columns %}
|
||||
{% set pk = pks[loop.index-1] %}
|
||||
<tr>
|
||||
{% if actions %}
|
||||
<td>
|
||||
<input id="{{pk}}" class="action_check" name="rowid" value="{{pk}}" type="checkbox">
|
||||
</td>
|
||||
{% endif %}
|
||||
{% if can_show or can_edit or can_delete %}
|
||||
<td><center>
|
||||
{{ lib.btn_crud(can_show, can_edit, can_delete, pk, modelview_name, filters) }}
|
||||
</center></td>
|
||||
{% endif %}
|
||||
{% for value in include_columns %}
|
||||
<td class="text-center">
|
||||
{% if item[value].__class__.__name__ == 'bool' %}
|
||||
<input
|
||||
class="form-control"
|
||||
type="checkbox"
|
||||
{{'checked' if item[value] }}
|
||||
name="{{ '{}__{}'.format(pk, value) }}"
|
||||
id="{{ '{}__{}'.format(pk, value) }}"
|
||||
onchange="$.get('/panoramix/checkbox/{{ modelview_name }}/{{ pk }}/{{ value }}/' + $('#{{ '{}__{}'.format(pk, value) }}')[0].checked ) + '/';">
|
||||
{% else %}
|
||||
{{ item[value]|safe }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block end_content scoped %}
|
||||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -418,6 +418,22 @@ class Panoramix(BaseView):
|
||||
mimetype="application/json")
|
||||
return resp
|
||||
|
||||
@has_access
|
||||
@expose("/checkbox/<model_view>/<id_>/<attr>/<value>", methods=['GET'])
|
||||
def checkbox(self, model_view, id_, attr, value):
|
||||
model = None
|
||||
if model_view == 'TableColumnInlineView':
|
||||
model = models.TableColumn
|
||||
elif model_view == 'ColumnInlineView':
|
||||
model = models.Column
|
||||
|
||||
obj = db.session.query(model).filter_by(id=id_).first()
|
||||
if obj:
|
||||
setattr(obj, attr, value=='true')
|
||||
db.session.commit()
|
||||
return Response("OK", mimetype="application/json")
|
||||
|
||||
|
||||
@has_access
|
||||
@expose("/save_dash/<dashboard_id>/", methods=['GET', 'POST'])
|
||||
def save_dash(self, dashboard_id):
|
||||
|
Loading…
Reference in New Issue
Block a user