space module mods
This commit is contained in:
parent
876c7df7c7
commit
7c0295d9d8
|
@ -8,12 +8,27 @@ class Admin::SpacesController < OrbitAdminController
|
||||||
@building = Building.new
|
@building = Building.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
uid = params[:id].split("-").last
|
||||||
|
@building = Building.find_by(:uid => uid) rescue nil
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
building = Building.new(building_params)
|
building = Building.new(building_params)
|
||||||
building.save
|
building.save
|
||||||
redirect_to admin_spaces_path
|
redirect_to admin_spaces_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
uid = params[:id].split("-").last
|
||||||
|
building = Building.find_by(:uid => uid) rescue nil
|
||||||
|
if !building.nil?
|
||||||
|
building.update_attributes(building_params)
|
||||||
|
building.save
|
||||||
|
end
|
||||||
|
redirect_to admin_spaces_path
|
||||||
|
end
|
||||||
|
|
||||||
def floors
|
def floors
|
||||||
uid = params[:space_id].split("-").last
|
uid = params[:space_id].split("-").last
|
||||||
@building = Building.find_by(:uid => uid) rescue nil
|
@building = Building.find_by(:uid => uid) rescue nil
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
class SpacesController < ApplicationController
|
class SpacesController < ApplicationController
|
||||||
def index
|
def index
|
||||||
buildings = Building.all.collect do |building|
|
page = Page.where(:module => OrbitHelper.this_module_app.key).first
|
||||||
|
buildings = Building.filter_by_categories.collect do |building|
|
||||||
floors = building.floors.desc(:title).collect do |floor|
|
floors = building.floors.desc(:title).collect do |floor|
|
||||||
image = (!floor.frontend_image.thumb.url.nil? ? floor.frontend_image.thumb.url : "/assets/default-floor.jpg")
|
image = (!floor.frontend_image.thumb.url.nil? ? floor.frontend_image.thumb.url : "/assets/default-floor.jpg")
|
||||||
|
link = floor.layout.nil? ? (floor.floor_units.empty? ? "#" : "/#{I18n.locale.to_s}#{page.url}/#{floor.floor_units.first.to_param}?method=unit") : OrbitHelper.url_to_show(floor.to_param)
|
||||||
{
|
{
|
||||||
"floor-title" => floor.title,
|
"floor-title" => floor.title,
|
||||||
"floor-image" => image,
|
"floor-image" => image,
|
||||||
"alt-title" => floor.title,
|
"alt-title" => floor.title,
|
||||||
"link_to_show" => OrbitHelper.url_to_show(floor.to_param)
|
"link_to_show" => link
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
class Building
|
class Building
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
|
include OrbitCategory::Categorizable
|
||||||
include Slug
|
include Slug
|
||||||
|
|
||||||
field :title, as: :slug_title, localize: true
|
field :title, as: :slug_title, localize: true
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
<p><%= building.title %></p>
|
<p><%= building.title %></p>
|
||||||
</a>
|
</a>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<a href="#">Edit</a> | <a href="#">Delete</a>
|
<a href="<%= edit_admin_space_path(building) %>">Edit</a> | <a href="#">Delete</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
|
@ -20,11 +20,20 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<%= f.label :title.to_s + " (" + locale.to_s + ")", :class => "control-label muted" %>
|
<%= f.label :title.to_s + " (" + locale.to_s + ")", :class => "control-label muted" %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field locale, placeholder: t("space.building_name") %>
|
<%= f.text_field locale, placeholder: t("space.building_name"), :value => @building.title_translations[locale.to_s] %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<!-- Category -->
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t(:category) %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= select_category(f, ModuleApp.find_by_key("space")) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Images Upload -->
|
<!-- Images Upload -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted"><%= t(:image) %></label>
|
<label class="control-label muted"><%= t(:image) %></label>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<%= form_for @building, url: admin_space_path(@building), html: {class: "form-horizontal main-forms"} do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<%= render :partial => "form", locals: {f: f} %>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
|
@ -5,6 +5,7 @@ module Space
|
||||||
module_label "space.space"
|
module_label "space.space"
|
||||||
base_url File.expand_path File.dirname(__FILE__)
|
base_url File.expand_path File.dirname(__FILE__)
|
||||||
frontend_enabled
|
frontend_enabled
|
||||||
|
categorizable
|
||||||
side_bar do
|
side_bar do
|
||||||
head_label_i18n 'space.space', icon_class: "icons-leaf"
|
head_label_i18n 'space.space', icon_class: "icons-leaf"
|
||||||
available_for "users"
|
available_for "users"
|
||||||
|
@ -16,6 +17,14 @@ module Space
|
||||||
:priority=>1,
|
:priority=>1,
|
||||||
:active_for_action=>{'admin/spaces'=>'index'},
|
:active_for_action=>{'admin/spaces'=>'index'},
|
||||||
:available_for => 'users'
|
:available_for => 'users'
|
||||||
|
|
||||||
|
context_link 'categories',
|
||||||
|
:link_path=>"admin_module_app_categories_path" ,
|
||||||
|
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'space').id}",
|
||||||
|
:priority=>3,
|
||||||
|
:active_for_action=>{'admin/spaces'=>'categories'},
|
||||||
|
:active_for_category => 'Announcement',
|
||||||
|
:available_for => 'managers'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue