Skip to content

Commit

Permalink
Modularizando os relatorios via javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
ktalmeida committed Dec 3, 2014
1 parent 3a2243b commit 1cf7a41
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 30 deletions.
83 changes: 53 additions & 30 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,46 @@
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">RioBus - Relatórios</a>
</div>
</div><!-- /.container-fluid -->
</nav>
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">RioBus - Relatórios</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Selecione um relatório<span class="caret"/></a>
<ul class="dropdown-menu" role="menu">
<li><a data-input-id="empty-lines">Ônibus sem linha</a></li>
<li class="divider"></li>
<li><a data-input-id="stopped">Ônibus parados</a></li>
<li class="divider"></li>
<li><a data-input-id="outdated-gps">GPS desatualizado</a></li>
<li class="divider"></li>
<li><a data-input-id="line-counter-by-bus">Linhas por quantidade de ônibus</a></li>
<li class="divider"></li>
<li><a data-input-id="buses-by-speed">Ônibus por faixa de velocidade</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>

<div class="container">
<h1> Preencha as informações abaixo</h1>

<form class="form-horizontal" role="form">

<div class="form-group">
<div class="form-group" data-form-name="empty-lines">
<div class="col-sm-offset-1 col-sm-10">
<div class="checkbox">
<label>
Expand All @@ -39,8 +62,8 @@ <h1> Preencha as informações abaixo</h1>
</div>
</div>
</div>
<hr>
<div class="form-group">

<div class="form-group" data-form-name="stopped">
<div class="col-sm-offset-1 col-sm-10">
<div class="checkbox">
<label>
Expand All @@ -49,35 +72,35 @@ <h1> Preencha as informações abaixo</h1>
</div>
</div>
</div>
<div class="form-group">
<div class="form-group" data-form-name="stopped">
<label for="lat" class="col-sm-2 control-label">Latitude</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="lat" placeholder="Latitude">
</div>
</div>

<div class="form-group">
<div class="form-group" data-form-name="stopped">
<label for="lng" class="col-sm-2 control-label">Longitude</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="lng" placeholder="Longitude">
</div>
</div>

<div class="form-group">
<div class="form-group" data-form-name="stopped">
<label for="r" class="col-sm-2 control-label">Raio</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="r" placeholder="Raio">
</div>
</div>

<div class="form-group">
<div class="form-group" data-form-name="stopped">
<label for="minv" class="col-sm-2 control-label">Velocidade Mínima</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="minv" placeholder="Velocidade Mínima">
</div>
</div>
<hr>
<div class="form-group">

<div class="form-group" data-form-name="outdated-gps">
<div class="col-sm-offset-1 col-sm-10">
<div class="checkbox">
<label>
Expand All @@ -87,14 +110,14 @@ <h1> Preencha as informações abaixo</h1>
</div>
</div>

<div class="form-group">
<div class="form-group" data-form-name="outdated-gps">
<label for="hour" class="col-sm-2 control-label">Atraso (em horas)</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="hour" placeholder="Atraso (em horas)">
</div>
</div>
<hr>
<div class="form-group">

<div class="form-group" data-form-name="line-counter-by-bus">
<div class="col-sm-offset-1 col-sm-10">
<div class="checkbox">
<label>
Expand All @@ -104,7 +127,7 @@ <h1> Preencha as informações abaixo</h1>
</div>
</div>

<div class="form-group">
<div class="form-group" data-form-name="line-counter-by-bus">
<label for="minq" class="col-sm-2 control-label">Qnt mínima de ônibus</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="minq" placeholder="Quantidade mínima de ônibus">
Expand All @@ -114,9 +137,9 @@ <h1> Preencha as informações abaixo</h1>
<input type="text" class="form-control" id="maxq" placeholder="Quantidade máxima de ônibus">
</div>
</div>
<hr>


<div class="form-group">
<div class="form-group" data-form-name="buses-by-speed">
<div class="col-sm-offset-1 col-sm-10">
<div class="checkbox">
<label>
Expand All @@ -126,7 +149,7 @@ <h1> Preencha as informações abaixo</h1>
</div>
</div>

<div class="form-group">
<div class="form-group" data-form-name="buses-by-speed">
<label for="mins" class="col-sm-2 control-label">Velocidade Mínima</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="mins" placeholder="Velocidade Mínima">
Expand All @@ -137,15 +160,15 @@ <h1> Preencha as informações abaixo</h1>
</div>
</div>

<div class="form-group">
<div class="form-group" data-form-name="buses-by-speed">
<label for="lines" class="col-sm-2 control-label">Linhas</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="lines" placeholder="(Opcional, separe por vírgulas)">
</div>
</div>
<hr>

<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="col-sm-offset-5 col-sm-6">
<button type="submit" id="button" class="btn btn-success"> Enviar </button>
</div>
</div>
Expand Down
20 changes: 20 additions & 0 deletions public/relatorioCodigo.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,24 @@ window.onload = function() {
document.getElementById("resposta").innerHTML = JSON.stringify(result);
});
});
}
$(function(){
$('.checkbox').hide();
$('ul[role=menu] a').click(function(event) {
var inputName = $(this).data('input-id');
showForm(inputName);

});
$('ul[role=menu] a').first().trigger('click')

})
function showForm(form){
var formTitle = $('a[data-input-id='+form+']').html();
$('.dropdown-toggle').html( formTitle + '<span class="caret"/>');
$('h1').html(formTitle);
$('[data-form-name]:visible').fadeOut('fast', function() {
$('[data-form-name='+form+']').fadeIn('fast',function() {
$('input[value='+form+']').trigger('click')
});
});
}

0 comments on commit 1cf7a41

Please sign in to comment.