space module mods

This commit is contained in:
Harry Bomrah 2015-10-13 18:55:18 +08:00
parent 876c7df7c7
commit 7c0295d9d8
7 changed files with 45 additions and 4 deletions

View File

@ -8,12 +8,27 @@ class Admin::SpacesController < OrbitAdminController
@building = Building.new
end
def edit
uid = params[:id].split("-").last
@building = Building.find_by(:uid => uid) rescue nil
end
def create
building = Building.new(building_params)
building.save
redirect_to admin_spaces_path
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
uid = params[:space_id].split("-").last
@building = Building.find_by(:uid => uid) rescue nil

View File

@ -1,13 +1,15 @@
class SpacesController < ApplicationController
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|
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-image" => image,
"alt-title" => floor.title,
"link_to_show" => OrbitHelper.url_to_show(floor.to_param)
"link_to_show" => link
}
end
{

View File

@ -1,6 +1,7 @@
class Building
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCategory::Categorizable
include Slug
field :title, as: :slug_title, localize: true

View File

@ -5,6 +5,6 @@
<p><%= building.title %></p>
</a>
<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>
</li>

View File

@ -20,11 +20,20 @@
<div class="control-group">
<%= f.label :title.to_s + " (" + locale.to_s + ")", :class => "control-label muted" %>
<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>
<% 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 -->
<div class="control-group">
<label class="control-label muted"><%= t(:image) %></label>

View File

@ -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 %>

View File

@ -5,6 +5,7 @@ module Space
module_label "space.space"
base_url File.expand_path File.dirname(__FILE__)
frontend_enabled
categorizable
side_bar do
head_label_i18n 'space.space', icon_class: "icons-leaf"
available_for "users"
@ -16,6 +17,14 @@ module Space
:priority=>1,
:active_for_action=>{'admin/spaces'=>'index'},
: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