From dbfc70e5201f899c286589cacaddcdefcb1bde07 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Thu, 8 Nov 2012 01:26:33 +0800 Subject: [PATCH] Refine the location module, but it have some bugs about path ... --- .../panel/gprs/back_end/locations.js | 2 + .../panel/gprs/back_end/locations.css | 4 ++ .../panel/gprs/back_end/locations_helper.rb | 2 + .../gprs/app/models/location.rb | 17 +++-- .../gprs/back_end/locations/_form.html.erb | 34 ++++++++++ .../gprs/back_end/locations/edit.html.erb | 2 + .../gprs/back_end/locations/index.html.erb | 68 ++++++++----------- .../gprs/back_end/locations/new.html.erb | 1 + .../gprs/back_end/locations/show.html.erb | 0 vendor/built_in_modules/gprs/config/routes.rb | 18 +++-- .../back_end/locations_controller_test.rb | 14 ++++ .../gprs/back_end/locations_helper_test.rb | 4 ++ 12 files changed, 106 insertions(+), 60 deletions(-) create mode 100644 vendor/built_in_modules/gprs/app/assets/javascripts/panel/gprs/back_end/locations.js create mode 100644 vendor/built_in_modules/gprs/app/assets/stylesheets/panel/gprs/back_end/locations.css create mode 100644 vendor/built_in_modules/gprs/app/helpers/panel/gprs/back_end/locations_helper.rb create mode 100644 vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/_form.html.erb create mode 100644 vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/edit.html.erb create mode 100644 vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/new.html.erb create mode 100644 vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/show.html.erb create mode 100644 vendor/built_in_modules/gprs/test/functional/panel/gprs/back_end/locations_controller_test.rb create mode 100644 vendor/built_in_modules/gprs/test/unit/helpers/panel/gprs/back_end/locations_helper_test.rb diff --git a/vendor/built_in_modules/gprs/app/assets/javascripts/panel/gprs/back_end/locations.js b/vendor/built_in_modules/gprs/app/assets/javascripts/panel/gprs/back_end/locations.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/vendor/built_in_modules/gprs/app/assets/javascripts/panel/gprs/back_end/locations.js @@ -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. diff --git a/vendor/built_in_modules/gprs/app/assets/stylesheets/panel/gprs/back_end/locations.css b/vendor/built_in_modules/gprs/app/assets/stylesheets/panel/gprs/back_end/locations.css new file mode 100644 index 000000000..afad32db0 --- /dev/null +++ b/vendor/built_in_modules/gprs/app/assets/stylesheets/panel/gprs/back_end/locations.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/vendor/built_in_modules/gprs/app/helpers/panel/gprs/back_end/locations_helper.rb b/vendor/built_in_modules/gprs/app/helpers/panel/gprs/back_end/locations_helper.rb new file mode 100644 index 000000000..50985d545 --- /dev/null +++ b/vendor/built_in_modules/gprs/app/helpers/panel/gprs/back_end/locations_helper.rb @@ -0,0 +1,2 @@ +module Panel::Gprs::BackEnd::LocationsHelper +end diff --git a/vendor/built_in_modules/gprs/app/models/location.rb b/vendor/built_in_modules/gprs/app/models/location.rb index 2f955205e..f6455920b 100644 --- a/vendor/built_in_modules/gprs/app/models/location.rb +++ b/vendor/built_in_modules/gprs/app/models/location.rb @@ -1,12 +1,11 @@ class Location - include Mongoid::Document - include Mongoid::Timestamps + include Mongoid::Document + include Mongoid::Timestamps - mount_uploader :file, GprsUploader + mount_uploader :file, GprsUploader - field :name - field :description - field :longitude, type: Float - field :latitude, type: Float - -end \ No newline at end of file + field :name + field :description + field :longitude, type: Float + field :latitude, type: Float +end diff --git a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/_form.html.erb b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/_form.html.erb new file mode 100644 index 000000000..efda0d9e5 --- /dev/null +++ b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/_form.html.erb @@ -0,0 +1,34 @@ +<%= form_for @location, :url => 'panel_gprs_back_end_locations_path' ,:class=>"form-horizontal" do |f| %> +
+ +
+ <%= f.text_field :name, :class=>"span4", :placeholder => "Area" %> +
+
+
+ +
+ <%= f.file_field :file %> +
+
+
+ +
+ <%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %> + <%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %> +
+
+
+ +
+ <%= f.text_area :description, :class=>"span4", :cols=>"30", :row=>"5" %> +
+
+
+
+ <%= f.submit "Save", :class=>"btn" %> +
+
+ <% end %> + + diff --git a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/edit.html.erb b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/edit.html.erb new file mode 100644 index 000000000..37afa8054 --- /dev/null +++ b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/edit.html.erb @@ -0,0 +1,2 @@ +<%= render 'form' %> + diff --git a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb index 912c0184f..78dd48a82 100644 --- a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb +++ b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb @@ -1,42 +1,28 @@ + + + + + + + + + + + + + + <% @locations.each do |location| %> + + + + + + + + + <% end %> + +
<%= t('location.picture') %><%= t('location.name') %><%= t('location.longitude') %><%= t('location.latitude') %><%= t('location.description') %><%= t('location.edit') %><%= t('location.delete') %>
<%= image_tag(location.file, alt: location.file, size: "50x50" )%><%= location.name%><%= location.longitude%><%= location.latitude%><%= location.description%><%= link_to 'Edit', edit_panel_gprs_back_end_locations_path(location) %><%= link_to 'Destroy', location, method: :delete %> +
- -<%= form_for @newlocation, :url=>{:action => "create"}, :remote => true, :class=>"form-horizontal" do |f| %> -
- -
- - <%= f.text_field :name, :class=>"span4", :placeholder => "Area" %> -
-
-
- -
- - <%= f.file_field :file %> -
-
-
- -
- - <%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %> - <%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %> - - -
-
-
- -
- - <%= f.text_area :description, :class=>"span4", :cols=>"30", :row=>"5" %> -
-
-
-
- - <%= f.submit "Save", :class=>"btn" %> -
-
- <% end %> - \ No newline at end of file +<%= link_to 'New', new_panel_gprs_back_end_locations_path %> diff --git a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/new.html.erb b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/new.html.erb new file mode 100644 index 000000000..2d3436368 --- /dev/null +++ b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/new.html.erb @@ -0,0 +1 @@ +<%= render 'form' %> diff --git a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/show.html.erb b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/show.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/gprs/config/routes.rb b/vendor/built_in_modules/gprs/config/routes.rb index 050b2cbda..0ba8a27cb 100644 --- a/vendor/built_in_modules/gprs/config/routes.rb +++ b/vendor/built_in_modules/gprs/config/routes.rb @@ -1,14 +1,12 @@ Rails.application.routes.draw do - namespace :panel do - namespace :gprs do - namespace :back_end do + namespace :panel do + namespace :gprs do + namespace :back_end do - match "locations/get_locations" => "locations#get_locations" - - resources :locations - - end - end - end + match "locations/get_locations" => "locations#get_locations" + resources :locations + end + end + end end diff --git a/vendor/built_in_modules/gprs/test/functional/panel/gprs/back_end/locations_controller_test.rb b/vendor/built_in_modules/gprs/test/functional/panel/gprs/back_end/locations_controller_test.rb new file mode 100644 index 000000000..bb6d0908b --- /dev/null +++ b/vendor/built_in_modules/gprs/test/functional/panel/gprs/back_end/locations_controller_test.rb @@ -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 diff --git a/vendor/built_in_modules/gprs/test/unit/helpers/panel/gprs/back_end/locations_helper_test.rb b/vendor/built_in_modules/gprs/test/unit/helpers/panel/gprs/back_end/locations_helper_test.rb new file mode 100644 index 000000000..e1302ea29 --- /dev/null +++ b/vendor/built_in_modules/gprs/test/unit/helpers/panel/gprs/back_end/locations_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class Panel::Gprs::BackEnd::LocationsHelperTest < ActionView::TestCase +end