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

@ -1,12 +1,11 @@
class Location class Location
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
mount_uploader :file, GprsUploader mount_uploader :file, GprsUploader
field :name
field :description
field :longitude, type: Float
field :latitude, type: Float
field :name
field :description
field :longitude, 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">
<thead>
<tr>
<th class="span1"><%= t('location.picture') %></th>
<th class="span1"><%= t('location.name') %></th>
<th class="span1"><%= t('location.longitude') %></th>
<th class="span1"><%= t('location.latitude') %></th>
<th class="span3"><%= t('location.description') %></th>
<th class="span1"><%= t('location.edit') %></th>
<th class="span1"><%= t('location.delete') %></th>
</tr>
</thead>
<tbody id="tbody_locations" class="sort-holder">
<% @locations.each do |location| %>
<tr class="with_action">
<td><%= image_tag(location.file, alt: location.file, size: "50x50" )%></td>
<td><%= location.name%></td>
<td><%= location.longitude%></td>
<td><%= location.latitude%></td>
<td><%= location.description%></td>
<td><%= link_to 'Edit', edit_panel_gprs_back_end_locations_path(location) %></td>
<td><%= link_to 'Destroy', location, method: :delete %>
</tr>
<% end %>
</tbody>
</table>
<!-- <form class="form-horizontal"> --> <td><%= link_to 'New', new_panel_gprs_back_end_locations_path %></td>
<%= form_for @newlocation, :url=>{:action => "create"}, :remote => true, :class=>"form-horizontal" do |f| %>
<div class="control-group">
<label class="control-label" for="">Name</label>
<div class="controls">
<!-- <input type="text" id="" class="span4" placeholder="Taipei 101"> -->
<%= f.text_field :name, :class=>"span4", :placeholder => "Area" %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Picture</label>
<div class="controls">
<!-- <input type="file" id=""> -->
<%= f.file_field :file %>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">Coordinates</label>
<div class="controls">
<!-- <input type="text" id="" class="span2" placeholder="long"> -->
<%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %>
<%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %>
<!-- <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 %>
<!-- </form> -->

View File

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

View File

@ -1,14 +1,12 @@
Rails.application.routes.draw do Rails.application.routes.draw do
namespace :panel do namespace :panel do
namespace :gprs do namespace :gprs do
namespace :back_end do namespace :back_end do
match "locations/get_locations" => "locations#get_locations" match "locations/get_locations" => "locations#get_locations"
resources :locations
end
end
end
resources :locations
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