chili_pepper 0.0.8 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2cc9fbae80c7d653e65073069858aae7fc85a56
4
- data.tar.gz: 1b135bb9920088588544dfa0814c031ce1b6f428
3
+ metadata.gz: c44ce6899a1d3aa6decb4ac457c5f4e71bbb2a59
4
+ data.tar.gz: aebab7b8b07893dba5e110bde6a1ad1892245a57
5
5
  SHA512:
6
- metadata.gz: 4571c0de0c25107aa800b93373fd75486e83f2110b58fe1bd085a3b2df94798c280a4e974bab5f09cbacb378d51a256210075712b0327e06ed9f94690ac6ba59
7
- data.tar.gz: c8849f2f6a703977c9bbcc48bb2c48b3dd2b4dc794c03fa9c6df0750a2f2f3097f01ff5924b939dbaa59ce63fd4b476e5c8c7e8d800885947ede37cbf99431f4
6
+ metadata.gz: 87c4cefbcea26b5591a03091765c27a9c492efd1835ef5defdf381435a1040934ad5d42cba58312bc0ebeb04ace0e5937eb1e187bcf1e7174c80a944fc38dab5
7
+ data.tar.gz: 6179b307a2e5beeade63812adca606d2f2b519d293f7ba57cd90bc3e9e85511b5432c452818c682b8c4744a9fb5fd73c344a0d5b95fc25bf543779406acf1d13
@@ -2,11 +2,17 @@ jQuery ->
2
2
  if $('#menu_container').length && $('#menu_container').hasClass('chili_pepper_admin')
3
3
  SectionsAdminControls.init_sort()
4
4
  ItemsAdminControls.init_sort()
5
+
5
6
 
6
7
  if $('#new_dish').length
7
8
  DishForm.act_on_select()
8
9
 
9
10
  MenuForm.init()
11
+ MenusAdminControls.init_sort()
12
+
13
+ $('#dish_name').on 'autocompleteresponse', (event, ui) ->
14
+ if ui.content?[0].id.length == 0 || $('.edit_dish').length
15
+ $(this).autocomplete('close')
10
16
 
11
17
 
12
18
 
@@ -10,11 +10,12 @@
10
10
  $(this).parent('li').before($(this).data('fields').replace(regexp, time))
11
11
  event.preventDefault()
12
12
 
13
- # @MenusAdminControls =
14
- # init_sort: ->
15
- # $('#menu_nav ul').removeClass('regular').addClass('sortable').sortable(
16
- # axis: 'x'
17
- # update: ->
18
- # $.post($(this).data('update-url'), $(this).sortable('serialize'))
19
- # )
13
+ @MenusAdminControls =
14
+ init_sort: ->
15
+ if $('.chili_pepper_admin').length
16
+ $('#menu_nav ul').sortable(
17
+ axis: 'x'
18
+ update: ->
19
+ $.post($(this).data('update-url'), $(this).sortable('serialize'))
20
+ )
20
21
 
@@ -11,5 +11,4 @@
11
11
  // about supported directives.
12
12
  //
13
13
 
14
- //= require autocomplete-rails
15
14
  //= require_tree ./chili_pepper
@@ -6,7 +6,7 @@ module ChiliPepper
6
6
  before_action :section, :menu, except: [:autocomplete_dish_name]
7
7
  before_action :find_dish, except: [:new, :create, :autocomplete_dish_name]
8
8
  before_action :find_item, except: [:new, :create, :autocomplete_dish_name]
9
- autocomplete :dish, :name, class_name: 'chili_pepper/dish' #, display_value: :name_for_autocomplete
9
+ autocomplete :dish, :name, class_name: 'chili_pepper/dish' , display_value: :name_for_autocomplete
10
10
 
11
11
  def new
12
12
  @dish = Dish.new
@@ -3,7 +3,7 @@ require_dependency 'chili_pepper/application_controller'
3
3
  module ChiliPepper
4
4
  class MenusController < ApplicationController
5
5
  before_action :authenticate_admin!, except: [:show, :index]
6
- before_action :menu, except: [:index, :new, :create]
6
+ before_action :menu, except: [:index, :new, :create, :sort]
7
7
 
8
8
  def index
9
9
  menu_type = params[:menu_type] || :food
@@ -65,6 +65,18 @@ module ChiliPepper
65
65
  redirect_to action: :index
66
66
  end
67
67
 
68
+ def sort
69
+ params[:menu].each_with_index do |id, index|
70
+ Menu.find(id).update_attributes(position: index + 1)
71
+ end
72
+ render nothing: true
73
+ end
74
+
75
+ def duplicate
76
+ @menu.duplicate
77
+ redirect_to menu_path(Menu.same_type_menus(@menu.menu_type).last)
78
+ end
79
+
68
80
  private
69
81
 
70
82
  def menu
@@ -19,10 +19,20 @@ module ChiliPepper
19
19
  class Dish < ActiveRecord::Base
20
20
  enum coeliac: [:coeliac_friendly, :not_coeliac_friendly, :coeliac_option_available]
21
21
  has_many :items, class_name: 'ChiliPepper::Item', dependent: :destroy
22
- accepts_nested_attributes_for :items, :allow_destroy => true
23
- has_many :sections, :through => :items
22
+ accepts_nested_attributes_for :items, allow_destroy: true
23
+ has_many :sections, through: :items
24
24
  validates_presence_of :name
25
- has_attached_file :picture, :styles => { :medium => "1200x720>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
25
+ has_attached_file :picture, styles: { medium: "1200x720>", thumb: "100x100>" }, default_url: "/images/:style/missing.png"
26
+
27
+ def name_for_autocomplete
28
+ name_display = name
29
+ if sections.count > 0
30
+ sections.each do |s|
31
+ name_display += (' | ' + s.menu.name + ' -> ' + s.name + '')
32
+ end
33
+ end
34
+ name_display
35
+ end
26
36
 
27
37
  end
28
38
  end
@@ -69,5 +69,22 @@ module ChiliPepper
69
69
  def food_menu?
70
70
  menu_type == 'food'
71
71
  end
72
+
73
+ def duplicate
74
+ new_menu = Menu.create!(name: "#{name} copy", menu_type: menu_type)
75
+ sections.each do |original_section|
76
+ new_section = original_section.dup
77
+ new_section.menu_id = new_menu.id
78
+ new_section.save
79
+ original_section.items.each do |item|
80
+ Item.create!(
81
+ section_id: new_section.id,
82
+ dish_id: item.dish_id,
83
+ column: item.column,
84
+ position: item.position
85
+ )
86
+ end
87
+ end
88
+ end
72
89
  end
73
90
  end
@@ -15,6 +15,7 @@
15
15
  %span
16
16
  menu
17
17
  - if admin_signed_in?
18
+ = link_to "Duplicate Menu", duplicate_menu_path(@menu), :method => :post, :class => "duplicate admin"
18
19
  = link_to "Edit Menu", edit_menu_path(@menu, section: @section), :class => "edit admin"
19
20
  = link_to "Delete Menu", menu_path(@menu), :method => :delete, :class => "delete admin"
20
21
 
data/config/routes.rb CHANGED
@@ -2,7 +2,10 @@ ChiliPepper::Engine.routes.draw do
2
2
 
3
3
  devise_for :admins, class_name: 'ChiliPepper::Admin', module: :devise
4
4
 
5
- resources :menus
5
+ resources :menus do
6
+ member { post :duplicate }
7
+ end
8
+
6
9
  resources :menus do
7
10
  collection { post :sort }
8
11
  resources :sections, path: '', except: [:index] do
@@ -1,3 +1,3 @@
1
1
  module ChiliPepper
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chili_pepper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loic Seigland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-10 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,44 +28,44 @@ dependencies:
28
28
  name: jquery-rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 3.1.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 3.1.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jquery-ui-rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 5.0.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 5.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: coffee-rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 4.0.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 4.0.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: acts_as_list
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -182,16 +182,16 @@ dependencies:
182
182
  name: rails3-jquery-autocomplete
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ">="
185
+ - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '0'
187
+ version: 1.0.14
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ">="
192
+ - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '0'
194
+ version: 1.0.14
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: codeclimate-test-reporter
197
197
  requirement: !ruby/object:Gem::Requirement