diff --git a/app/assets/stylesheets/maps.css.scss b/app/assets/stylesheets/maps.css.scss index 4716c561..0fe6cfa1 100644 --- a/app/assets/stylesheets/maps.css.scss +++ b/app/assets/stylesheets/maps.css.scss @@ -1,35 +1,41 @@ -// Place all the styles related to the maps controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -.map { display:block; float:left; position:relative; width:170px; height:300px; padding:10px 10px 10px 35px; background: url('bg.png'); border-radius:15px; margin:30px 0 30px 50px; color:#000; } - -.map .delete {position: absolute; -top: -14px; -left: 0px; -background: none; -border: 0; -color: white; -border: none; -font-size: 14px; -margin: 0; -padding: 0; -cursor:pointer; -} - -.map .type {position: absolute; -color: white; -top: -22px; -right: 0; -font-weight: bold; -font-size: 20px; -line-height: 24px;} - -.map .icon { position:absolute; top:135px; left:-25px; } - -.map .title { font-size:22px; line-height:25px; display:block; border-bottom:2px solid #000; padding-bottom:5px; } - -.map .desc { font-style:italic; font-size:15px; } -.map .desc h3 { font-style:normal; margin-top:5px; } - -.map .link { position:absolute; width:170px; top:295px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } \ No newline at end of file +// Place all the styles related to the maps controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + +.map { display:block; float:left; position:relative; width:170px; height:300px; padding:10px 10px 10px 35px; background: url('bg.png'); border-radius:15px; margin:30px 0 30px 50px; color:#000; } + +.map .delete {position: absolute; +top: -14px; +left: 0px; +background: none; +border: 0; +color: white; +border: none; +font-size: 14px; +margin: 0; +padding: 0; +cursor:pointer; +} + +.map .type {position: absolute; +color: white; +top: -22px; +right: 0; +font-weight: bold; +font-size: 20px; +line-height: 24px;} + +.map .icon { position:absolute; top:135px; left:-25px; } + +.map .title { font-size:22px; line-height:25px; display:block; border-bottom:2px solid #000; padding-bottom:5px; } + +.map .desc { font-style:italic; font-size:15px; } +.map .desc h3 { font-style:normal; margin-top:5px; } + +.map .link { position:absolute; width:170px; top:295px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + + + +// add topic on maps pages +.selecttype { border:1px solid #000; margin-top: 20px; border-radius:15px; } +.mapspages .new_item h3 { padding: 10px 26px; display: block; cursor: pointer; color: #2d6a5d; float:left; } \ No newline at end of file diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 369cea85..5bb1b89d 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -45,15 +45,20 @@ class ItemsController < ApplicationController def create @user = current_user - @item = Item.new() - @item.name = params[:item][:name] - @item.desc = params[:item][:desc] - @item.link = params[:item][:link] - @item.permission = params[:item][:permission] - @item.item_category = ItemCategory.find(params[:category]) - @item.user = @user - @item.save + if params[:initem] + @item = Item.find(params[:initem]) + else + @item = Item.new() + @item.name = params[:item][:name] + @item.desc = params[:item][:desc] + @item.link = params[:item][:link] + @item.permission = params[:item][:permission] + @item.item_category = ItemCategory.find(params[:category]) + @item.user = @user + + @item.save + end if params[:item][:map] @mapping = Mapping.new() diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index fce39278..507dc47d 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -66,8 +66,10 @@ class MapsController < ApplicationController if not @map redirect_to root_url and return end + + @outitems = @map.items.order("name ASC").delete_if{|item| not item.authorize_to_view(@current)} - respond_with(@user, @map) + respond_with(@user, @map, @outitems) end # PUT /users/:user_id/maps/:id @@ -79,6 +81,14 @@ class MapsController < ApplicationController @map.attributes = params[:map] @map.save + if params[:outitems] + @outitems = params[:outitems] + @outitems.each do |item| + @mapping = Mapping.where("map_id = ? AND item_id = ?", @map.id, item).first + @mapping.delete + end + end + respond_with(@user, location: user_map_path(@user, @map)) do |format| end diff --git a/app/views/maps/_newtopic.html.erb b/app/views/maps/_newtopic.html.erb index 75fe05e3..86cd0b33 100644 --- a/app/views/maps/_newtopic.html.erb +++ b/app/views/maps/_newtopic.html.erb @@ -1,18 +1,29 @@ -