Skip to content

Commit

Permalink
GUI bonita
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfsaldana committed Apr 12, 2012
1 parent cb9791b commit 752ca15
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 81 deletions.
21 changes: 4 additions & 17 deletions app/views/cursos/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
<%= form_for(@curso) do |f| %>
<% if @curso.errors.any?
cantidadErrores = @curso.errors.count
mensajeError=""
if cantidadErrores ==1
mensajeError = "Se presentó " + cantidadErrores.to_s+ " error al grabar el curso."
else
mensajeError = "Se presentaron " + cantidadErrores.to_s+ " errrores al grabar el curso."
end
%>

<% if @curso.errors.any? %>
<div id="error_explanation">
<h2><%= mensajeError %> </h2>
<h2><%= pluralize(@curso.errors.count, "error") %> prohibited this curso from being saved:</h2>

<ul>
<% @curso.errors.full_messages.each do |msg| %>
Expand All @@ -21,13 +12,9 @@
<% end %>

<div class="field">
<!--<div data-role="fieldcontain" class="ui-hide-label">-->
<%= f.label :nombre %><br />
<%= f.text_field :nombre %>
<!--<label for="nombreCurso"><%= f.label :nombre %></label>
<input type="text" name="nombreCurso" id="nombreCurso" placeholder="Nombre del Curso"/>
</div>-->
</div>
</div>
<div class="field">
<%= f.label :formula %><br />
<%= f.text_field :formula %>
Expand All @@ -36,4 +23,4 @@
<div class="actions">
<%= f.submit %>
</div>
<% end %>
<% end %>
31 changes: 26 additions & 5 deletions app/views/cursos/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
<script type"text/javascript">
$(document).ready(function(){
$("a.save").click(function(){
var id=$(this).attr("rel");
$("form.edit_curso").submit();
});
$("a.cancel").click(function(){
window.location = "/cursos";
});
});
</script>
<% content_for :header do%>
<h1>Modificar curso</h1>
<div data-role="header" data-position="inline">
<a href="#" class="cancel" data-icon="delete" data-theme="b">Cancelar</a>
<h1>Modificar curso</h1>
<a href="#" class="save" rel="<%=@curso.id%>" data-icon="check" data-theme="b">Save</a>
</div>
<%end%>
<%= render 'form' %>
<%= link_to 'Mostrar', @curso %> |
<%= link_to 'Volver', cursos_path %>
<%= form_for(@curso) do |f| %>
<div class="field">
<%= f.label :nombre %><br />
<%= f.text_field :nombre %>
</div>
<div class="field">
<%= f.label :formula %><br />
<%= f.text_field :formula %>
</div>
<% end %>
50 changes: 24 additions & 26 deletions app/views/cursos/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
<script type"text/javascript">
$(document).ready(function(){
$("a.linked").click(function(){
var id=$(this).attr("rel");
window.location = "/cursos/"+id+"/edit";
});
$("a.ui-btn-right").click(function(){
window.location = "/cursos/new";
});
});
</script>
<% content_for :header do%>
<h1>Listado de cursos</h1>
<div data-role="header" data-position="inline">
<h1>Listado de cursos</h1>
<a href="#" class="ui-btn-right" data-icon="check" data-theme="b">Nuevo</a>
</div>
<%end%>
<table>
<tr>
<th>Nombre</th>
<th>Formula</th>

<th></th>
<th></th>
<th></th>
</tr>

<% @cursos.each do |curso| %>
<tr>
<td><%= curso.nombre %></td>
<td><%= curso.formula %></td>

<td><%= link_to 'Mostrar', curso %></td>
<td><%= link_to 'Modificar', edit_curso_path(curso) %></td>
<td><%= link_to 'Eliminar', curso, confirm: '¿Esta seguro de eliminar este curso?', method: :delete %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'Nuevo curso', new_curso_path %>
<div data-role="content">
<div class="content-primary">
<ul data-role="listview" data-filter="true">
<% @cursos.each do |curso| %>
<li><a href="#" id="link1" class="linked" rel="<%=curso.id%>"><%= curso.nombre %></a></li>
<% end %>
</ul>
</div>
</div>
29 changes: 25 additions & 4 deletions app/views/cursos/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
<script type"text/javascript">
$(document).ready(function(){
$("a.new").click(function(){
$("form.new_curso").submit();
});
$("a.cancel").click(function(){
window.location = "/cursos";
});
});
</script>
<% content_for :header do%>
<h1>Registrar Curso</h1>
<div data-role="header" data-position="inline">
<a href="#" class="cancel" data-icon="delete" data-theme="b">Cancelar</a>
<h1>Registrar Curso</h1>
<a href="#" class="new" data-icon="check" data-theme="b">Save</a>
</div>
<%end%>
<%= render 'form' %>
<%= link_to 'Volver', cursos_path %>
<%= form_for(@curso) do |f| %>
<div class="field">
<%= f.label :nombre %><br />
<%= f.text_field :nombre %>
</div>
<div class="field">
<%= f.label :formula %><br />
<%= f.text_field :formula %>
</div>
<% end %>
21 changes: 19 additions & 2 deletions app/views/cursos/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
<p id="notice"><%= notice %></p>
<script type"text/javascript">
$(document).ready(function(){
$("a.back").click(function(){
window.location = "/cursos";
});
$("a.edit").click(function(){
var id=$(this).attr("rel");
window.location = "/cursos/"+id+"/edit";
});
});
</script>
<% content_for :header do%>
<div data-role="header" data-position="inline">
<a href="#" class="back" data-icon="home" data-theme="b">Inicio</a>
<h1><%= notice %></h1>
<a href="#" class="edit" rel="<%=@curso.id%>" data-icon="edit" data-theme="b">Editar</a>
</div>
<%end%>

<p>
<b>Nombre:</b>
Expand All @@ -11,4 +28,4 @@
</p>

<%= link_to 'Edit', edit_curso_path(@curso) %> |
<%= link_to 'Back', cursos_path %>
<%= link_to 'Back', cursos_path %>
5 changes: 4 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<title>TDEW2012</title>
<!-- ====== LINEAS PARA JQUERY MOBILE =========-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.2/jquery.mobile-1.1.0-rc.2.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.2/jquery.mobile-1.1.0-rc.2.min.js"></script>-->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
Expand All @@ -25,4 +28,4 @@
</div><!-- /page -->

</body>
</html>
</html>
52 changes: 26 additions & 26 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120317220952) do

create_table "cursos", :force => true do |t|
t.string "nombre"
t.string "formula"
t.integer "cantpcs"
t.boolean "exafinal"
t.boolean "proyecto"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end

end
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120317220952) do

create_table "cursos", :force => true do |t|
t.string "nombre"
t.string "formula"
t.integer "cantpcs"
t.boolean "exafinal"
t.boolean "proyecto"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end

end

0 comments on commit 752ca15

Please sign in to comment.