diff --git a/vendor/built_in_modules/location/app/controllers/panel/location/back_end/location_categories_controller.rb b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/location_categories_controller.rb new file mode 100644 index 000000000..07911caa2 --- /dev/null +++ b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/location_categories_controller.rb @@ -0,0 +1,36 @@ +class Panel::Location::BackEnd::LocationCategoriesController < OrbitBackendController + + def index + @categorylist = LocationCategory.all + @new_category = LocationCategory.new + end + + def create + @category = LocationCategory.new(params[:location_category]) + @category.save! + respond_to do |h| + h.js + end + end + + def edit + @category = LocationCategory.find(params[:id]) + render :layout => false + end + + def update + @category = LocationCategory.find(params[:id]) + @category.update_attributes(params[:location_category]) + respond_to do |h| + h.js + end + end + + + def destroy + @category = LocationCategory.find(params['id']) + @category.delete + render :json=>{"success"=>"true"}.to_json + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb index 5594bb7fd..7754835a6 100644 --- a/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb +++ b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb @@ -14,7 +14,6 @@ class Panel::Location::BackEnd::LocationsController < OrbitBackendController def new @location_info = LocationInfo.new - respond_to do |format| format.html # new.html.erb format.json { render json: @location } diff --git a/vendor/built_in_modules/location/app/models/location.rb b/vendor/built_in_modules/location/app/models/location.rb index 58d032bdd..2f6be8296 100644 --- a/vendor/built_in_modules/location/app/models/location.rb +++ b/vendor/built_in_modules/location/app/models/location.rb @@ -8,4 +8,6 @@ class Location field :description field :longitude, type: Float field :latitude, type: Float + + belongs_to :location_category end diff --git a/vendor/built_in_modules/location/app/models/location_category.rb b/vendor/built_in_modules/location/app/models/location_category.rb new file mode 100644 index 000000000..32a3fcdd0 --- /dev/null +++ b/vendor/built_in_modules/location/app/models/location_category.rb @@ -0,0 +1,14 @@ +class LocationCategory + include Mongoid::Document + include Mongoid::Timestamps + + # include OrbitCoreLib::ObjectAuthable + + # ObjectAuthTitlesOptions = %W{new_album} + # APP_NAME = "album" + + field :name, localize: true + + has_many :location_infos, :autosave => true, :dependent => :destroy + +end \ No newline at end of file diff --git a/vendor/built_in_modules/location/app/models/location_info.rb b/vendor/built_in_modules/location/app/models/location_info.rb index 23e878419..8e25449bb 100644 --- a/vendor/built_in_modules/location/app/models/location_info.rb +++ b/vendor/built_in_modules/location/app/models/location_info.rb @@ -9,6 +9,8 @@ class LocationInfo field :longitude, type: Float field :latitude, type: Float + belongs_to :location_category + validates :file, presence: true validates :longitude, numericality: { less_than_or_equal_to: 180.0, greater_than_or_equal_to: -180.0 }, diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/_category.html.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/_category.html.erb new file mode 100644 index 000000000..84d18bdeb --- /dev/null +++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/_category.html.erb @@ -0,0 +1,13 @@ +
+
+ + <% @site_valid_locales.each do |locale| %> + <%= category.name_translations[locale] rescue nil %> + <% end %> +
+
+ <%= link_to(t(:delete_), panel_location_back_end_location_category_path(category), :method => :delete, :confirm => t("sure?"), :remote => true, :class => "delete") %> + <%= link_to(t(:edit), edit_panel_location_back_end_location_category_path(category), :remote => true, :class => "edit") %> + <%#= show_gallery_category_permission_link(category) %> +
+
\ No newline at end of file diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/create.js.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/create.js.erb new file mode 100644 index 000000000..2f3a82e12 --- /dev/null +++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/create.js.erb @@ -0,0 +1,2 @@ +var dom = $("<%= j render :partial => 'category', :object => @category %>"); +$("div#tags").append(dom); \ No newline at end of file diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/edit.html.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/edit.html.erb new file mode 100644 index 000000000..ea7eecced --- /dev/null +++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/edit.html.erb @@ -0,0 +1,10 @@ +<%= form_for @category, :url => panel_location_back_end_location_category_path(@category), :remote => true do |f| %> + <%= f.fields_for :name_translations do |name| %> + <% @site_valid_locales.each do |locale| %> + <%= label_tag(locale,t("location.new_category")+"["+I18nVariable.from_locale(locale)+"]") %> + <%= name.text_field locale, :value =>(@category.name_translations[locale]) %> + <% end %> + <% end %> +<%= f.submit "Save", :class=> "btn btn-primary temp_save_btn" %> +<%= I18n.t(:cancel) %> +<% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/index.html.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/index.html.erb new file mode 100644 index 000000000..ea00a7702 --- /dev/null +++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/index.html.erb @@ -0,0 +1,41 @@ +
+ <%= render :partial => 'category', :collection => @categorylist %> +
+
+ <%= form_for @new_category, :url => {:action => "create"}, :remote => true do |f| %> + <%= f.fields_for :name_translations do |name| %> + <% @site_valid_locales.each do |locale| %> + <%= label_tag(locale,t("location.new_category")+"["+I18nVariable.from_locale(locale)+"]") %> + <%= name.text_field locale %> + <% end %> + <% end %> + <%= f.submit "Save", :class=> "btn btn-primary" %> + <% end %> +
+ + \ No newline at end of file diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/update.js.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/update.js.erb new file mode 100644 index 000000000..1113b88c8 --- /dev/null +++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/update.js.erb @@ -0,0 +1,2 @@ +var dom = $("<%= j render :partial => 'category', :object => @category %>"); +parent.html(dom.html()); \ No newline at end of file diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb index d38b744c0..3187e04a2 100644 --- a/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb +++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb @@ -9,6 +9,12 @@ <% end %> +
+ +
+ <%= f.select(:location_category_id, LocationCategory.all.collect {|p| [ p.name, p.id ] },{:prompt => t("location.select_category")},:class => "validate input-xlarge") %> +
+
@@ -20,7 +26,7 @@
<%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %> - <%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %> + <%= f.text_field :latitude, :class=>"span2", :placeholder => "Lantitude" %>
diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/new.html.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/new.html.erb index 36545064b..d923d9f69 100644 --- a/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/new.html.erb +++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/new.html.erb @@ -1,3 +1,3 @@ -<%= form_for @location_info, :url=> panel_location_back_end_locations_path, :html => { :class=>"form-horizontal"} do |f| %> +<%= form_for @location_info, :url=> panel_location_back_end_locations_path, :html => { :class=>"form-horizontal",:multipart => true} do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <% end %> diff --git a/vendor/built_in_modules/location/config/locales/en.yml b/vendor/built_in_modules/location/config/locales/en.yml index 5f7ec8ea0..68fcb3605 100644 --- a/vendor/built_in_modules/location/config/locales/en.yml +++ b/vendor/built_in_modules/location/config/locales/en.yml @@ -1,3 +1,5 @@ en: - location: - location: Location \ No newline at end of file + location: Location + new_category: "New Category" + save: Save + select_category: "Select Category" \ No newline at end of file diff --git a/vendor/built_in_modules/location/config/routes.rb b/vendor/built_in_modules/location/config/routes.rb index f7332d21b..d65c5b2ef 100644 --- a/vendor/built_in_modules/location/config/routes.rb +++ b/vendor/built_in_modules/location/config/routes.rb @@ -6,6 +6,7 @@ Rails.application.routes.draw do match "locations/get_locations" => "locations#get_locations" resources :locations + resources :location_categories end end end