comable-backend 0.6.0 → 0.7.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/comable/admin/dispatcher.coffee +12 -2
  3. data/app/assets/javascripts/comable/admin/navigations.coffee +37 -0
  4. data/app/assets/javascripts/comable/admin/pages.coffee +0 -3
  5. data/app/assets/javascripts/comable/admin/products.coffee +35 -0
  6. data/app/assets/javascripts/comable/admin/search.coffee +6 -6
  7. data/app/assets/javascripts/comable/admin/themes.coffee +53 -64
  8. data/app/assets/javascripts/comable/admin/variants.coffee +106 -0
  9. data/app/assets/stylesheets/comable/admin/_common.scss +9 -0
  10. data/app/assets/stylesheets/comable/admin/_navigations.scss +13 -0
  11. data/app/assets/stylesheets/comable/admin/_variants.scss +40 -0
  12. data/app/assets/stylesheets/comable/admin/application.scss +2 -0
  13. data/app/controllers/comable/admin/navigations_controller.rb +84 -0
  14. data/app/controllers/comable/admin/orders_controller.rb +7 -14
  15. data/app/controllers/comable/admin/products_controller.rb +14 -6
  16. data/app/controllers/comable/admin/stocks_controller.rb +5 -2
  17. data/app/controllers/comable/admin/themes_controller.rb +5 -9
  18. data/app/controllers/comable/admin/variants_controller.rb +59 -0
  19. data/app/helpers/comable/admin/application_helper.rb +19 -12
  20. data/app/helpers/comable/admin/navigations_helper.rb +23 -0
  21. data/app/helpers/comable/admin/themes_helper.rb +1 -1
  22. data/{config/initializers/awesome_admin_layout.rb → app/navigations/comable/admin/application.rb} +8 -4
  23. data/app/views/comable/admin/navigations/_form.slim +40 -0
  24. data/app/views/comable/admin/navigations/_navigation_item_fields.slim +24 -0
  25. data/app/views/comable/admin/navigations/edit.slim +27 -0
  26. data/app/views/comable/admin/navigations/index.slim +25 -0
  27. data/app/views/comable/admin/navigations/new.slim +16 -0
  28. data/app/views/comable/admin/navigations/search_linkable_ids.coffee +15 -0
  29. data/app/views/comable/admin/orders/show.slim +1 -1
  30. data/app/views/comable/admin/products/_form.slim +91 -68
  31. data/app/views/comable/admin/products/edit.slim +4 -0
  32. data/app/views/comable/admin/products/index.slim +13 -11
  33. data/app/views/comable/admin/shared/{_image_fields.slim → _images_fields.slim} +5 -5
  34. data/app/views/comable/admin/shared/_option_type_fields.slim +13 -0
  35. data/app/views/comable/admin/shared/_option_types_fields.slim +13 -0
  36. data/app/views/comable/admin/shared/_variant_form.slim +26 -0
  37. data/app/views/comable/admin/shared/_variants_fields.slim +14 -0
  38. data/app/views/comable/admin/stocks/index.slim +16 -11
  39. data/app/views/comable/admin/variants/_form.slim +34 -0
  40. data/app/views/comable/admin/variants/edit.slim +31 -0
  41. data/app/views/comable/admin/variants/index.slim +97 -0
  42. data/app/views/comable/admin/variants/new.slim +16 -0
  43. data/app/views/layouts/comable/admin/application.slim +1 -1
  44. data/config/routes.rb +8 -1
  45. metadata +166 -49
@@ -0,0 +1,40 @@
1
+ = error_messages_for @navigation
2
+
3
+ - url = @navigation.new_record? ? comable.admin_navigations_path : comable.admin_navigation_path(@navigation)
4
+
5
+ = form_for @navigation, url: url do |f|
6
+ .hidden
7
+ = f.submit
8
+
9
+ fieldset
10
+ .col-md-3
11
+ legend
12
+ = Comable.t('admin.nav.navigations.general')
13
+
14
+ .col-md-9
15
+ .form-group
16
+ = f.label :name
17
+ = f.text_field :name
18
+
19
+ hr
20
+
21
+ fieldset
22
+ .col-md-3
23
+ legend
24
+ = Comable.t('admin.nav.navigations.navigation_items')
25
+
26
+ .col-md-9
27
+ #navigation-items
28
+ = f.fields_for :navigation_items do |navigation_items_form|
29
+ = render 'navigation_item_fields', f: navigation_items_form
30
+
31
+ hr
32
+
33
+ .row
34
+ = add_fields_button_tag Comable.t('admin.nav.navigation_items.add_link'), f, :navigation_items
35
+
36
+ .hidden
37
+ = form_tag(comable.search_linkable_ids_admin_navigations_path, remote: true) do
38
+ = text_field_tag :linkable_type
39
+ = text_field_tag :position
40
+ = submit_tag
@@ -0,0 +1,24 @@
1
+ - linkable_class = f.object.linkable_class
2
+ - link_selectable = linkable_class.try(:linkable_exists?)
3
+
4
+ fieldset.navigation-item class="#{'hidden' if f.object._destroy}"
5
+ .row
6
+ .col-sm-3
7
+ = f.label :name
8
+ = f.text_field :name
9
+
10
+ .col-sm-3
11
+ = f.label :linkable_type
12
+ = f.select :linkable_type, linkable_type_options, {}, class: :linkable_type
13
+
14
+ .col-sm-3.url class="#{'hidden' if link_selectable}"
15
+ = f.label :url
16
+ = f.text_field :url
17
+
18
+ .col-sm-3.linkable_id class="#{'hidden' unless link_selectable}"
19
+ = f.select :linkable_id, linkable_id_options(f.object)
20
+
21
+ .col-sm-3
22
+ = f.hidden_field :_destroy, class: :destroy
23
+ button.btn.btn-default.pull-right.remove_fields type="button"
24
+ = Comable.t('actions.destroy')
@@ -0,0 +1,27 @@
1
+ .comable-page
2
+ .comable-main-fixed-top
3
+ .comable-page-heading
4
+ ul.pull-right.list-inline
5
+ li
6
+ = link_to_save
7
+
8
+ h1.page-header
9
+ ol.breadcrumb
10
+ li>
11
+ = link_to Comable.t('admin.nav.navigation'), comable.admin_navigations_path
12
+ li.active
13
+ = @navigation.name
14
+
15
+ .comable-page-body
16
+ = render 'form'
17
+ hr
18
+ .panel.panel-danger
19
+ .panel-heading type="button" data-toggle="collapse" data-target="#comable-danger"
20
+ strong
21
+ span.fa.fa-angle-down>
22
+ = Comable.t('admin.actions.destroy')
23
+ #comable-danger.collapse
24
+ .panel-body
25
+ p
26
+ = Comable.t('admin.confirmation_to_remove_navigation')
27
+ = link_to Comable.t('admin.actions.destroy'), comable.admin_navigation_path(@navigation), method: :delete, class: 'btn btn-danger'
@@ -0,0 +1,25 @@
1
+ .comable-page
2
+ .comable-page-heading
3
+ ul.pull-right.list-inline
4
+ li
5
+ = link_to Comable.t('admin.actions.new'), comable.new_admin_navigation_path, class: 'btn btn-default'
6
+ h1.page-header
7
+ = Comable.t('admin.nav.navigation')
8
+ small<
9
+ | #{@navigations.size} #{Comable.t('admin.results')}
10
+
11
+ .comable-page-body
12
+ section
13
+ - if @navigations.empty?
14
+ = Comable.t('admin.not_found')
15
+ - else
16
+ table.table.table-striped
17
+ thead
18
+ th
19
+ = sort_link [:comable, @q], :name
20
+
21
+ tbody
22
+ - @navigations.each do |navigation|
23
+ tr
24
+ td
25
+ = link_to navigation.name, comable.admin_navigation_path(navigation)
@@ -0,0 +1,16 @@
1
+ .comable-page
2
+ .comable-main-fixed-top
3
+ .comable-page-heading
4
+ ul.pull-right.list-inline
5
+ li
6
+ = link_to_save
7
+
8
+ h1.page-header
9
+ ol.breadcrumb
10
+ li>
11
+ = link_to Comable.t('admin.nav.navigation'), comable.admin_navigations_path
12
+ li.active
13
+ = Comable.t('admin.actions.new')
14
+
15
+ .comable-page-body
16
+ = render 'form'
@@ -0,0 +1,15 @@
1
+ $url = $('#navigation_navigation_items_attributes_<%= params[:position] %>_url')
2
+ $linkable_id = $('#navigation_navigation_items_attributes_<%= params[:position] %>_linkable_id')
3
+
4
+ $linkable_id.html('<%= options_for_select(@linkable_id_options) %>')
5
+
6
+ if <%= params[:linkable_type].blank? %>
7
+ # アドレスを入力する場合
8
+ $linkable_id.closest('.linkable_id').addClass('hidden')
9
+ $linkable_id.val('')
10
+ $url.closest('.url').removeClass('hidden')
11
+
12
+ else
13
+ $url.closest('.url').addClass('hidden')
14
+ $url.val('')
15
+ $linkable_id.closest('.linkable_id').removeClass('hidden')
@@ -64,7 +64,7 @@
64
64
  td
65
65
  = order_item.name_with_sku
66
66
  .text-muted
67
- small = order_item.code
67
+ small = order_item.sku
68
68
  td
69
69
  = number_to_currency order_item.price
70
70
  td
@@ -14,21 +14,13 @@
14
14
  .help-block
15
15
 
16
16
  .col-md-9
17
- .form-group
18
- = f.label :code
19
- = f.text_field :code
20
-
21
17
  .form-group
22
18
  = f.label :name
23
19
  = f.text_field :name
24
20
 
25
21
  .form-group
26
22
  = f.label :caption
27
- = f.text_field :caption
28
-
29
- .form-group
30
- = f.label :price
31
- = f.text_field :price
23
+ = f.text_area :caption
32
24
 
33
25
  / TODO: Refactoring
34
26
  javascript:
@@ -43,64 +35,6 @@
43
35
 
44
36
  hr
45
37
 
46
- fieldset
47
- .col-md-3
48
- legend
49
- = Comable.t('admin.stocks')
50
- .help-block
51
- - if @product.sku? || (@product.persisted? && @product.stocks.empty?)
52
- = Comable.t('admin.link_to_add_new_stock')
53
- = link_to Comable.t('admin.actions.new'), comable.new_admin_product_stock_path(@product)
54
-
55
- .col-md-9
56
- - if @product.stocks.any?
57
- table.table.table-striped
58
- thead
59
- th
60
- = @product.stocks.human_attribute_name(:code)
61
- th
62
- = @product.stocks.human_attribute_name(:quantity)
63
- - if @product.sku?
64
- - if @product.sku_h?
65
- th
66
- = @product.sku_h_item_name
67
- - if @product.sku_v?
68
- th
69
- = @product.sku_v_item_name
70
- th
71
- = Comable.t('admin.operation')
72
- tbody
73
- - @product.stocks.each do |stock|
74
- tr
75
- td
76
- = stock.code
77
- td
78
- strong class="#{(stock.quantity <= 0) ? 'text-danger' : (stock.quantity <= 10) ? 'text-warning' : 'text-success'}"
79
- = number_with_delimiter stock.quantity
80
- - if @product.sku?
81
- - if @product.sku_h?
82
- td
83
- = stock.sku_h_choice_name
84
- - if @product.sku_v?
85
- td
86
- = stock.sku_v_choice_name
87
- td
88
- = link_to comable.admin_stock_path(stock), class: 'btn btn-default'
89
- i.fa.fa-edit>
90
- = Comable.t('admin.actions.edit')
91
-
92
- .form-group
93
- = f.label :sku_h_item_name
94
- = f.text_field :sku_h_item_name
95
- .help-block
96
- = Comable.t('admin.please_fill_when_using_sku')
97
-
98
- .form-group
99
- = f.label :sku_v_item_name
100
- = f.text_field :sku_v_item_name
101
-
102
- hr
103
-
104
38
  fieldset
105
39
  .col-md-3
106
40
  legend
@@ -131,7 +65,96 @@
131
65
  .row
132
66
  - sub_images.each.with_index(1) do |image, index|
133
67
  = f.fields_for :images, image do |ff|
134
- = render 'comable/admin/shared/image_fields', ff: ff, index: index
68
+ = render 'comable/admin/shared/images_fields', f: ff, index: index
135
69
 
136
70
  .col-md-6
137
71
  = link_to_add_fields Comable.t('admin.add_sub_image'), f, :images
72
+
73
+ hr
74
+
75
+ - if @product.new_record? || @product.master?
76
+ = f.fields_for :variants, f.object.variants.first do |ff|
77
+ = render 'comable/admin/shared/variant_form', f: ff
78
+ = ff.hidden_field :_destroy, value: !f.object.master?
79
+ hr
80
+
81
+ - if @product.new_record? || @product.persisted? && !@product.master?
82
+ fieldset
83
+ .col-md-3
84
+ legend
85
+ = Comable.t('admin.variants')
86
+
87
+ .col-md-9
88
+ = f.fields_for :option_types, f.object.option_types do |ff|
89
+ = render 'comable/admin/shared/option_types_fields', f: ff, readonly: @product.persisted?
90
+
91
+ - if @product.new_record?
92
+ = link_to_add_fields Comable.t('admin.add_variants'), f, :option_types, class: 'btn btn-link js-add-option'
93
+
94
+ table.table.table-striped.js-variants-table class="#{'hidden' if @product.master?}"
95
+ thead
96
+ th
97
+ th
98
+ = Comable.t('admin.variants')
99
+ th
100
+ = @product.variants.human_attribute_name(:sku)
101
+ th
102
+ = @product.variants.human_attribute_name(:price)
103
+ th
104
+ = @product.variants.human_attribute_name(:quantity)
105
+ tbody
106
+ = f.fields_for :variants do |ff|
107
+ = render 'comable/admin/shared/variants_fields', f: ff
108
+ = link_to_add_fields nil, f, :variants, class: 'hidden js-add-variant'
109
+
110
+ - if @product.persisted?
111
+ table.table.table-striped
112
+ thead
113
+ th
114
+ = @product.variants.human_attribute_name(:sku)
115
+ th
116
+ = @product.variants.human_attribute_name(:price)
117
+ th
118
+ = @product.variants.human_attribute_name(:quantity)
119
+ th
120
+ = Comable.t('admin.variants')
121
+ th
122
+ = Comable.t('admin.operation')
123
+ tbody
124
+ - @product.variants.each do |variant|
125
+ tr
126
+ td
127
+ = variant.sku
128
+ td
129
+ = number_to_currency variant.price
130
+ td
131
+ - quantity = variant.quantity
132
+ strong class="#{(quantity <= 0) ? 'text-danger' : (quantity <= 10) ? 'text-warning' : 'text-success'}"
133
+ = number_with_delimiter quantity
134
+ td
135
+ - variant.options.each do |option|
136
+ span.comable-variant-name
137
+ = option.value
138
+ td
139
+ = link_to comable.admin_product_variant_path(@product, variant), class: 'btn btn-default'
140
+ i.fa.fa-edit>
141
+ = Comable.t('admin.actions.edit')
142
+
143
+ hr
144
+
145
+ fieldset
146
+ .col-md-3
147
+ legend
148
+ = Comable.t('admin.nav.products.visibility')
149
+
150
+ .col-md-9
151
+ .form-group
152
+ .radio-inline
153
+ label
154
+ = f.radio_button :published_at, :published, checked: @product.published_at.present?
155
+ = Comable.t('admin.nav.products.published')
156
+ .radio-inline
157
+ label
158
+ = f.radio_button :published_at, :unpublished, checked: @product.published_at.blank?
159
+ = Comable.t('admin.nav.products.unpublished')
160
+ = f.text_field :published_at, value: @product.published_at.try(:strftime, '%Y-%m-%d %H:%M'), class: 'datetimepicker'
@@ -2,6 +2,10 @@
2
2
  .comable-main-fixed-top
3
3
  .comable-page-heading
4
4
  ul.pull-right.list-inline
5
+ li
6
+ = link_to comable.product_path(@product), class: 'btn btn-default', target: '_blank' do
7
+ i.fa.fa-external-link>
8
+ = Comable.t('admin.preview')
5
9
  li.dropdown
6
10
  = link_to '#', class: 'btn btn-default', 'data-toggle' => 'dropdown' do
7
11
  i.fa.fa-bars
@@ -47,7 +47,7 @@
47
47
  = link_to Comable.t('admin.advanced_search'), 'javascript:void(0)', 'data-toggle' => 'collapse', 'data-target' => '#comable-advanced-search'
48
48
  li
49
49
  = link_to Comable.t('admin.clear_search_conditions'), comable.admin_products_path
50
- = f.text_field :code_or_name_cont_any_splitted, class: 'form-control'
50
+ = f.text_field :name_or_variants_sku_cont_any_splitted, class: 'form-control'
51
51
  span.input-group-btn
52
52
  = f.submit Comable.t('admin.search'), class: 'btn btn-default'
53
53
 
@@ -60,8 +60,6 @@
60
60
  table.table.table-striped
61
61
  thead
62
62
  th
63
- th
64
- = sort_link [:comable, @q], :code
65
63
  th
66
64
  = sort_link [:comable, @q], :name
67
65
  th
@@ -70,26 +68,30 @@
70
68
  = Comable.t('admin.stocks')
71
69
  tbody
72
70
  - @products.each do |product|
73
- - quantity = product.stocks.to_a.sum(&:quantity)
74
71
  tr
75
72
  td.comable-image
76
73
  = link_to comable.admin_product_path(product), class: 'thumbnail' do
77
74
  = image_tag product.image_url, width: '100%'
78
75
  td
79
- = link_to product.code, comable.admin_product_path(product)
80
- td
81
- = product.name
76
+ = link_to product.name, comable.admin_product_path(product)
77
+ - unless product.published?
78
+ span.fa.fa-eye-slash.text-muted<
82
79
  td
83
80
  = number_to_currency product.price
84
81
  td
85
82
  ul.list-unstyled
86
- - product.stocks.each do |stock|
83
+ - product.variants.each do |variant|
87
84
  li
85
+ - quantity = variant.quantity
88
86
  strong class="#{(quantity <= 0) ? 'text-danger' : (quantity <= 10) ? 'text-warning' : 'text-success'}"
89
- = number_with_delimiter stock.quantity
90
- - if stock.sku?
87
+ = number_with_delimiter quantity
88
+ - if !product.master?
91
89
  span<
92
- | (#{stock.sku_name})
90
+ | (
91
+ - variant.options.each do |option|
92
+ span.comable-variant-name
93
+ = option.value
94
+ | )
93
95
 
94
96
  .text-center
95
97
  = paginate @products, theme: :comable_backend
@@ -5,11 +5,11 @@
5
5
  span<
6
6
  | ##{index}
7
7
  p
8
- = ff.file_field :file
9
- - if ff.object.url
8
+ = f.file_field :file
9
+ - if f.object.url
10
10
  .thumbnail
11
- = image_tag ff.object.url
12
- - if ff.object.persisted?
11
+ = image_tag f.object.url
12
+ - if f.object.persisted?
13
13
  label.remove
14
- span> = ff.check_box :_destroy
14
+ span> = f.check_box :_destroy
15
15
  span> = Comable.t('admin.actions.destroy')
@@ -0,0 +1,13 @@
1
+ - readonly ||= false
2
+
3
+ .comable-option
4
+ .form-group
5
+ .row
6
+ .col-xs-4
7
+ = text_field_tag :option_type, nil, placeholder: Comable.t('admin.size'), class: 'comable-option-name', disabled: readonly
8
+
9
+ .col-xs-8
10
+ ul.js-tagit-option-values.comable-option-values data-index="#{f.index}" class="#{'tagit-readonly' if readonly}"
11
+ - f.object.values.each do |value|
12
+ li
13
+ = value