Refine the location module, but it have some bugs about path ...

This commit is contained in:
Rueshyna 2012-11-08 01:26:33 +08:00
parent 11fefa100f
commit dbfc70e520
12 changed files with 106 additions and 60 deletions

View File

@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

View File

@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

View File

@ -0,0 +1,2 @@
module Panel::Gprs::BackEnd::LocationsHelper
end

View File

@ -8,5 +8,4 @@ class Location
field :description field :description
field :longitude, type: Float field :longitude, type: Float
field :latitude, type: Float field :latitude, type: Float
end end

View File

@ -0,0 +1,34 @@
<%= form_for @location, :url => 'panel_gprs_back_end_locations_path' ,:class=>"form-horizontal" do |f| %>
<div class="control-group">
<label class="control-label" for="">Name</label>
<div class="controls">
<%= f.text_field :name, :class=>"span4", :placeholder => "Area" %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Picture</label>
<div class="controls">
<%= f.file_field :file %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Coordinates</label>
<div class="controls">
<%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %>
<%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Description</label>
<div class="controls">
<%= f.text_area :description, :class=>"span4", :cols=>"30", :row=>"5" %>
</div>
</div>
<div class="control-group">
<div class="controls">
<%= f.submit "Save", :class=>"btn" %>
</div>
</div>
<% end %>
<!-- </form> -->

View File

@ -0,0 +1,2 @@
<%= render 'form' %>

View File

@ -1,42 +1,28 @@
<table class="table main-list">
<!-- <form class="form-horizontal"> --> <thead>
<%= form_for @newlocation, :url=>{:action => "create"}, :remote => true, :class=>"form-horizontal" do |f| %> <tr>
<div class="control-group"> <th class="span1"><%= t('location.picture') %></th>
<label class="control-label" for="">Name</label> <th class="span1"><%= t('location.name') %></th>
<div class="controls"> <th class="span1"><%= t('location.longitude') %></th>
<!-- <input type="text" id="" class="span4" placeholder="Taipei 101"> --> <th class="span1"><%= t('location.latitude') %></th>
<%= f.text_field :name, :class=>"span4", :placeholder => "Area" %> <th class="span3"><%= t('location.description') %></th>
</div> <th class="span1"><%= t('location.edit') %></th>
</div> <th class="span1"><%= t('location.delete') %></th>
<div class="control-group"> </tr>
<label class="control-label" for="">Picture</label> </thead>
<div class="controls"> <tbody id="tbody_locations" class="sort-holder">
<!-- <input type="file" id=""> --> <% @locations.each do |location| %>
<%= f.file_field :file %> <tr class="with_action">
</div> <td><%= image_tag(location.file, alt: location.file, size: "50x50" )%></td>
</div> <td><%= location.name%></td>
<div class="control-group"> <td><%= location.longitude%></td>
<label class="control-label" for="">Coordinates</label> <td><%= location.latitude%></td>
<div class="controls"> <td><%= location.description%></td>
<!-- <input type="text" id="" class="span2" placeholder="long"> --> <td><%= link_to 'Edit', edit_panel_gprs_back_end_locations_path(location) %></td>
<%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %> <td><%= link_to 'Destroy', location, method: :delete %>
<%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %> </tr>
<!-- <input type="text" id="" class="span2" placeholder="lat"> -->
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Description</label>
<div class="controls">
<!-- <textarea name="" id="" class="span4" cols="30" rows="5"></textarea> -->
<%= f.text_area :description, :class=>"span4", :cols=>"30", :row=>"5" %>
</div>
</div>
<div class="control-group">
<div class="controls">
<!-- <textarea name="" id="" class="span4" cols="30" rows="5"></textarea> -->
<%= f.submit "Save", :class=>"btn" %>
</div>
</div>
<% end %> <% end %>
<!-- </form> --> </tbody>
</table>
<td><%= link_to 'New', new_panel_gprs_back_end_locations_path %></td>

View File

@ -0,0 +1 @@
<%= render 'form' %>

View File

@ -6,9 +6,7 @@ Rails.application.routes.draw do
match "locations/get_locations" => "locations#get_locations" match "locations/get_locations" => "locations#get_locations"
resources :locations resources :locations
end end
end end
end end
end end

View File

@ -0,0 +1,14 @@
require 'test_helper'
class Panel::Gprs::BackEnd::LocationsControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
test "should get edit" do
get :edit
assert_response :success
end
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class Panel::Gprs::BackEnd::LocationsHelperTest < ActionView::TestCase
end