Dynamic form working for sensors, only visuals no save logic
Former-commit-id: 7bfd7a5bd685b7527e75e692531a2f9a544733e1
This commit is contained in:
parent
35ac4ba678
commit
26810e9b2c
2 changed files with 39 additions and 9 deletions
|
|
@ -182,7 +182,18 @@
|
|||
|
||||
<!------------- MODALS --------------->
|
||||
<script>
|
||||
var sensorDataConf = {};
|
||||
|
||||
$(function(){
|
||||
// initialize sensor modal things
|
||||
$("#sensor-data-conf-template div").each(function(){
|
||||
sensorDataConf[$(this).attr("id")] = $(this).html();
|
||||
});
|
||||
$("#sensorModal select[name=type]").change(function(){
|
||||
// Update dynamic inputs
|
||||
$("#sensorModal #sensor-data-conf").html(sensorDataConf[$(this).val()]);
|
||||
});
|
||||
// event
|
||||
$("#sensorModal").on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var modal = $(this);
|
||||
|
|
@ -191,7 +202,7 @@
|
|||
modal.find("input[name=action]").val("modify_local_sensor");
|
||||
modal.find("input[name=id]").val(button.data("id"));
|
||||
modal.find("input[name=name]").val(button.data("name"));
|
||||
modal.find("input[name=type]").val(button.data("type"));
|
||||
modal.find("select[name=type]").val(button.data("type"));
|
||||
modal.find("input[name=sync]").prop("checked", button.data("sync"));
|
||||
modal.find("input[name=config]").val(button.data("config"));
|
||||
}
|
||||
|
|
@ -200,6 +211,8 @@
|
|||
modal.find("input[name=id]").val(-1);
|
||||
modal.find("input[name=sync]").prop("checked", "false");
|
||||
}
|
||||
// Update dynamic inputs
|
||||
modal.find("select[name=type]").change();
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -253,9 +266,8 @@
|
|||
</div>
|
||||
|
||||
<hr>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Config:</label> <!-- Should be improved, dynamic forms? -->
|
||||
<input type="text" class="form-control" name="config">
|
||||
<div id="sensor-data-conf">
|
||||
<!-- Dynamic form -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
|
@ -266,6 +278,18 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="sensor-data-conf-template" class="hidden">
|
||||
{{#localSensorConf}}
|
||||
<div id="{{.clazz.getName()}}">
|
||||
{{#.params}}
|
||||
<div class="form-group">
|
||||
<label class="control-label">{{.getNiceName()}}:</label>
|
||||
<input type="text" class="form-control" name="{{.getName()}}">
|
||||
</div>
|
||||
{{/.params}}
|
||||
</div>
|
||||
{{/localSensorConf}}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="userModal" tabindex="-1">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue