Sections dropdown is updated when changing network
This commit is contained in:
@@ -196,12 +196,27 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="networksection_id">Bauabschnitt</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="select2 form-control " name="networksection_id" id="networksection_id">
|
||||
<option></option>
|
||||
<?php foreach($networksections as $section): ?>
|
||||
<option value="<?=$section->id?>" <?=($building->networksection_id == $section->id) ? "selected='selected'" : ""?>><?=($section->network->name)?> - <?=($section->name)?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="description">Bauabschnitt</label>
|
||||
<div class="col-lg-10">
|
||||
<textarea id="description" class="form-control" name="description" rows="5"><?=$building->description?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="status_id">Status</label>
|
||||
@@ -309,6 +324,7 @@
|
||||
},
|
||||
function(success) {
|
||||
if(success.status == "OK") {
|
||||
//console.log(success);
|
||||
pops = success.result.pops;
|
||||
if(typeof pops !== 'object' || pops === null) {
|
||||
return true;
|
||||
@@ -323,6 +339,33 @@
|
||||
);
|
||||
}
|
||||
|
||||
function updateSections() {
|
||||
var network_id = $("#network_id").val();
|
||||
if(!network_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$.get("<?=self::getUrl("Networksection","Api")?>",
|
||||
{
|
||||
"do": "getSections",
|
||||
network_id: network_id
|
||||
},
|
||||
function(success) {
|
||||
if(success.status == "OK") {
|
||||
sections = success.result.sections;
|
||||
if(typeof sections !== 'object' || sections === null) {
|
||||
return true;
|
||||
}
|
||||
$("#networksection_id option:gt(0)").remove();
|
||||
for(var section_id in sections) {
|
||||
$("#networksection_id").append($("<option></option>").attr("value", pop_id).text(sections[section_id]));
|
||||
}
|
||||
}
|
||||
},
|
||||
'json'
|
||||
);
|
||||
}
|
||||
|
||||
function updatePermissions() {
|
||||
var network_id = $("#network_id").val();
|
||||
if(!network_id) {
|
||||
@@ -331,7 +374,6 @@
|
||||
|
||||
var types = ["lineworker", "pipeworker"];
|
||||
|
||||
// get new pops
|
||||
$.get("<?=self::getUrl("Network","Api")?>",
|
||||
{
|
||||
"do": "getPermissions",
|
||||
@@ -341,6 +383,9 @@
|
||||
function(success) {
|
||||
if(success.status == "OK") {
|
||||
var perms = success.result.permissions;
|
||||
if(typeof perms !== 'object' || perms === null) {
|
||||
return true;
|
||||
}
|
||||
types.forEach(function(type) {
|
||||
$("#" + type + "_id").empty();
|
||||
$("#" + type + "_id").append($("<option></option>"));
|
||||
@@ -404,11 +449,13 @@
|
||||
$("#network_id").change(function() {
|
||||
updatePops();
|
||||
updatePermissions();
|
||||
updateSections();
|
||||
});
|
||||
|
||||
$( document ).ready(function() {
|
||||
updatePops();
|
||||
updatePermissions();
|
||||
updateSections();
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user