Module: GameShelvesHelper

Defined in:
app/helpers/game_shelves_helper.rb

Instance Method Summary collapse

Instance Method Details

#add_shelf_dropdown(user, user_shelves, game, no_margin: true) ⇒ Object


2
3
4
5
6
7
# File 'app/helpers/game_shelves_helper.rb', line 2

def add_shelf_dropdown(user, user_shelves, game, no_margin: true)
	main_shelf_item, other_shelf_items = ShelfItem.shelf_items_per_user_and_game(user.id, game.class.name, game.id)
	wishlist_shelf = user_shelves.first

	render :partial => "shared/add_shelf_dropdown", :locals => {:shelves => user_shelves, :main_shelf_item => main_shelf_item, :other_shelf_items => other_shelf_items, :game => game, :wishlist_shelf => wishlist_shelf, :user => user, :no_margin => no_margin}
end

#add_user_game_shelf_path(user, shelf, game) ⇒ Object


25
26
27
28
29
30
31
# File 'app/helpers/game_shelves_helper.rb', line 25

def add_user_game_shelf_path(user, shelf, game)
	if game.class.name == Edition.name
		add_edition_user_game_shelf_path(user, shelf, :edition_id => game.id)
	elsif game.class.name == Expansion.name
		add_expansion_user_game_shelf_path(user, shelf, :expansion_id => game.id)
	end
end

#href_user_game_shelf_path(user, shelf, game, shelf_item) ⇒ Object


9
10
11
12
13
14
15
# File 'app/helpers/game_shelves_helper.rb', line 9

def href_user_game_shelf_path(user, shelf, game, shelf_item)
	if is_item_on_shelf?(shelf_item, shelf) == 0 or not shelf_item.present?
		add_user_game_shelf_path(user, shelf, game)
	else
		remove_item_user_game_shelves_path(user, :item_id => shelf_item.id)
	end
end

#is_item_on_shelf?(shelf_item, game_shelf) ⇒ Boolean

Returns:

  • (Boolean)

33
34
35
36
37
38
39
# File 'app/helpers/game_shelves_helper.rb', line 33

def is_item_on_shelf?(shelf_item, game_shelf)
	if(shelf_item && shelf_item.game_shelf == game_shelf)
		1
	else
		0
	end
end

#toggle_href_user_game_shelf_path(user, shelf, game, shelf_item) ⇒ Object


17
18
19
20
21
22
23
# File 'app/helpers/game_shelves_helper.rb', line 17

def toggle_href_user_game_shelf_path(user, shelf, game, shelf_item)
	if is_item_on_shelf?(shelf_item, shelf) == 1
		add_user_game_shelf_path(user, shelf, game)
	else
		remove_item_user_game_shelves_path(user)
	end
end