comable_backend 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/comable/admin/application.coffee +21 -14
  3. data/app/assets/stylesheets/comable/admin/_common.scss +264 -0
  4. data/app/assets/stylesheets/comable/admin/_dashboard.scss +81 -0
  5. data/app/assets/stylesheets/comable/admin/_errors.scss +18 -0
  6. data/app/assets/stylesheets/comable/admin/_mixins.scss +16 -0
  7. data/app/assets/stylesheets/comable/admin/_orders.scss +54 -0
  8. data/app/assets/stylesheets/comable/admin/_overrides.scss +4 -0
  9. data/app/assets/stylesheets/comable/admin/_products.scss +18 -0
  10. data/app/assets/stylesheets/comable/admin/_user_sessions.scss +57 -0
  11. data/app/assets/stylesheets/comable/admin/_variables.scss +44 -0
  12. data/app/assets/stylesheets/comable/admin/application.scss +15 -597
  13. data/app/assets/stylesheets/comable/admin/overrides/bootstrap.scss +83 -0
  14. data/app/assets/stylesheets/comable/admin/overrides/jstree.scss +71 -0
  15. data/app/assets/stylesheets/comable/admin/overrides/pace.scss +4 -0
  16. data/app/assets/stylesheets/comable/admin/overrides/tagit.scss +22 -0
  17. data/app/controllers/comable/admin/application_controller.rb +3 -0
  18. data/app/controllers/comable/admin/categories_controller.rb +3 -0
  19. data/app/controllers/comable/admin/customers_controller.rb +6 -0
  20. data/app/controllers/comable/admin/orders_controller.rb +3 -0
  21. data/app/controllers/comable/admin/payment_methods_controller.rb +7 -1
  22. data/app/controllers/comable/admin/products_controller.rb +10 -4
  23. data/app/controllers/comable/admin/shipment_methods_controller.rb +7 -1
  24. data/app/controllers/comable/admin/stocks_controller.rb +16 -20
  25. data/app/controllers/comable/admin/store_controller.rb +3 -0
  26. data/app/controllers/comable/admin/user_sessions_controller.rb +7 -0
  27. data/app/helpers/comable/admin/application_helper.rb +16 -0
  28. data/app/views/comable/admin/categories/index.slim +83 -86
  29. data/app/views/comable/admin/customers/edit.slim +64 -79
  30. data/app/views/comable/admin/customers/index.slim +60 -59
  31. data/app/views/comable/admin/customers/show.slim +83 -88
  32. data/app/views/comable/admin/dashboard/show.slim +59 -57
  33. data/app/views/comable/admin/orders/_google_map.slim +22 -0
  34. data/app/views/comable/admin/orders/index.slim +67 -70
  35. data/app/views/comable/admin/orders/show.slim +98 -68
  36. data/app/views/comable/admin/payment_methods/_form.slim +26 -41
  37. data/app/views/comable/admin/payment_methods/edit.slim +25 -26
  38. data/app/views/comable/admin/payment_methods/index.slim +38 -50
  39. data/app/views/comable/admin/payment_methods/new.slim +14 -15
  40. data/app/views/comable/admin/products/_form.slim +124 -101
  41. data/app/views/comable/admin/products/_image_fields.slim +15 -0
  42. data/app/views/comable/admin/products/edit.slim +39 -38
  43. data/app/views/comable/admin/products/index.slim +64 -70
  44. data/app/views/comable/admin/products/new.slim +14 -15
  45. data/app/views/comable/admin/shared/_footer.slim +8 -0
  46. data/app/views/comable/admin/shared/_header.slim +31 -0
  47. data/app/views/comable/admin/shared/_notifier.slim +5 -0
  48. data/app/views/comable/admin/shared/_sidebar.slim +52 -0
  49. data/app/views/comable/admin/shipment_methods/_form.slim +23 -43
  50. data/app/views/comable/admin/shipment_methods/edit.slim +25 -26
  51. data/app/views/comable/admin/shipment_methods/index.slim +35 -47
  52. data/app/views/comable/admin/shipment_methods/new.slim +14 -15
  53. data/app/views/comable/admin/stocks/_form.slim +27 -33
  54. data/app/views/comable/admin/stocks/edit.slim +35 -44
  55. data/app/views/comable/admin/stocks/index.slim +57 -76
  56. data/app/views/comable/admin/stocks/new.slim +16 -15
  57. data/app/views/comable/admin/store/_form.slim +26 -42
  58. data/app/views/comable/admin/store/edit.slim +10 -11
  59. data/app/views/comable/admin/user_sessions/new.slim +25 -0
  60. data/app/views/layouts/comable/admin/application.slim +14 -96
  61. data/config/routes.rb +4 -1
  62. data/lib/comable/backend/engine.rb +2 -1
  63. metadata +93 -53
  64. data/app/assets/stylesheets/comable/admin/products.css +0 -4
@@ -0,0 +1,71 @@
1
+ .jstree {
2
+ @include border-radius($input-border-radius);
3
+ @include box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075));
4
+ padding: 5px 0;
5
+ border: 1px solid $input-border;
6
+
7
+ .jstree-wholerow {
8
+ @include transition(none);
9
+ }
10
+
11
+ .jstree-wholerow-hovered {
12
+ color: $dropdown-link-color;
13
+ background-color: $dropdown-link-hover-bg;
14
+ }
15
+
16
+ .jstree-wholerow-clicked {
17
+ color: $dropdown-link-active-color;
18
+ background-color: $dropdown-link-active-bg;
19
+ }
20
+
21
+ .jstree-anchor.jstree-clicked {
22
+ color: $dropdown-link-active-color;
23
+
24
+ &:link, &:visited, &:hover, &:active {
25
+ color: $dropdown-link-active-color;
26
+ }
27
+
28
+ & > input {
29
+ @include border-radius($input-border-radius);
30
+ @include box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075));
31
+ color: $dropdown-link-color;
32
+ padding-left: 5px !important;
33
+ padding-right: 5px !important;
34
+ }
35
+ }
36
+ }
37
+
38
+ ul.vakata-context.jstree-contextmenu {
39
+ @include border-radius($border-radius-base);
40
+ @include box-shadow(0 6px 12px rgba(0, 0, 0, 0.175));
41
+
42
+ padding: 5px 0;
43
+ background-color: $dropdown-bg;
44
+ border-color: $dropdown-border;
45
+
46
+ & > li {
47
+ @include border-radius(0);
48
+
49
+ & > a {
50
+ padding-top: 0;
51
+ padding-bottom: 0;
52
+ line-height: $line-height-computed;
53
+ color: $dropdown-link-color;
54
+ background-color: $dropdown-bg;
55
+
56
+ & > i,
57
+ & > .vakata-contextmenu-sep {
58
+ display: none;
59
+ }
60
+ }
61
+
62
+ &.vakata-context-hover > a {
63
+ @include box-shadow(none);
64
+ background-color: $dropdown-bg;
65
+
66
+ &:hover {
67
+ background-color: $dropdown-link-hover-bg;
68
+ }
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,4 @@
1
+ .pace .pace-progress {
2
+ @include transition-property(none);
3
+ background-color: $comable-pace !important;
4
+ }
@@ -0,0 +1,22 @@
1
+ ul.tagit > li > input[type="text"] {
2
+ height: auto;
3
+ }
4
+
5
+ ul.tagit-autocomplete.ui-menu {
6
+ @include border-radius($border-radius-base);
7
+ @include box-shadow(0 6px 12px rgba(0, 0, 0, 0.175));
8
+ padding: 5px 0;
9
+ border-color: $dropdown-border;
10
+
11
+ li.ui-menu-item {
12
+ padding: $padding-base-vertical $padding-base-horizontal;
13
+ color: $dropdown-link-color;
14
+ background-color: $dropdown-bg;
15
+ border: none;
16
+
17
+ &.ui-state-focus {
18
+ color: $dropdown-link-active-color;
19
+ background-color: $dropdown-link-active-bg;
20
+ }
21
+ }
22
+ }
@@ -3,6 +3,9 @@ module Comable
3
3
  class ApplicationController < ActionController::Base
4
4
  include Comable::ApplicationHelper
5
5
 
6
+ # Include `asset_path` method for gritter
7
+ helper Sprockets::Helpers::RailsHelper if Rails::VERSION::MAJOR == 3
8
+
6
9
  layout 'comable/admin/application'
7
10
 
8
11
  def current_ability
@@ -5,6 +5,9 @@ module Comable
5
5
  class CategoriesController < Comable::Admin::ApplicationController
6
6
  load_and_authorize_resource class: Comable::Category.name
7
7
 
8
+ def index
9
+ end
10
+
8
11
  def create
9
12
  Comable::Category.from_jstree!(params[:jstree_json])
10
13
  redirect_to comable.admin_categories_path
@@ -12,6 +12,12 @@ module Comable
12
12
  @customers = @q.result.page(params[:page]).accessible_by(current_ability)
13
13
  end
14
14
 
15
+ def show
16
+ end
17
+
18
+ def edit
19
+ end
20
+
15
21
  def update
16
22
  if @customer.update_attributes(customer_params)
17
23
  redirect_to comable.admin_customer_path(@customer), notice: Comable.t('successful')
@@ -9,6 +9,9 @@ module Comable
9
9
  @q = Comable::Order.complete.ransack(params[:q])
10
10
  @orders = @q.result.page(params[:page]).per(15).order('completed_at DESC').accessible_by(current_ability)
11
11
  end
12
+
13
+ def show
14
+ end
12
15
  end
13
16
  end
14
17
  end
@@ -13,8 +13,11 @@ module Comable
13
13
  render :edit
14
14
  end
15
15
 
16
+ def new
17
+ end
18
+
16
19
  def create
17
- if @payment_method.update_attributes(payment_method_params)
20
+ if @payment_method.save
18
21
  redirect_to comable.admin_payment_method_path(@payment_method), notice: Comable.t('successful')
19
22
  else
20
23
  flash.now[:alert] = Comable.t('failure')
@@ -22,6 +25,9 @@ module Comable
22
25
  end
23
26
  end
24
27
 
28
+ def edit
29
+ end
30
+
25
31
  def update
26
32
  if @payment_method.update_attributes(payment_method_params)
27
33
  redirect_to comable.admin_payment_method_path(@payment_method), notice: Comable.t('successful')
@@ -5,17 +5,20 @@ module Comable
5
5
  class ProductsController < Comable::Admin::ApplicationController
6
6
  load_and_authorize_resource class: Comable::Product.name, except: :index
7
7
 
8
+ def index
9
+ @q = Comable::Product.ransack(params[:q])
10
+ @products = @q.result.includes(:stocks, :images).page(params[:page]).accessible_by(current_ability)
11
+ end
12
+
8
13
  def show
9
14
  render :edit
10
15
  end
11
16
 
12
- def index
13
- @q = Comable::Product.ransack(params[:q])
14
- @products = @q.result.includes(:stocks).page(params[:page]).accessible_by(current_ability)
17
+ def new
15
18
  end
16
19
 
17
20
  def create
18
- if @product.update_attributes(product_params)
21
+ if @product.save
19
22
  redirect_to comable.admin_product_path(@product), notice: Comable.t('successful')
20
23
  else
21
24
  flash.now[:alert] = Comable.t('failure')
@@ -23,6 +26,9 @@ module Comable
23
26
  end
24
27
  end
25
28
 
29
+ def edit
30
+ end
31
+
26
32
  def update
27
33
  if @product.update_attributes(product_params)
28
34
  redirect_to comable.admin_product_path(@product), notice: Comable.t('successful')
@@ -13,8 +13,11 @@ module Comable
13
13
  render :edit
14
14
  end
15
15
 
16
+ def new
17
+ end
18
+
16
19
  def create
17
- if @shipment_method.update_attributes(shipment_method_params)
20
+ if @shipment_method.save
18
21
  redirect_to comable.admin_shipment_method_path(@shipment_method), notice: Comable.t('successful')
19
22
  else
20
23
  flash.now[:alert] = Comable.t('failure')
@@ -22,6 +25,9 @@ module Comable
22
25
  end
23
26
  end
24
27
 
28
+ def edit
29
+ end
30
+
25
31
  def update
26
32
  if @shipment_method.update_attributes(shipment_method_params)
27
33
  redirect_to comable.admin_shipment_method_path(@shipment_method), notice: Comable.t('successful')
@@ -3,32 +3,38 @@ require_dependency 'comable/admin/application_controller'
3
3
  module Comable
4
4
  module Admin
5
5
  class StocksController < Comable::Admin::ApplicationController
6
- load_and_authorize_resource :product, class: Comable::Product.name
7
- load_and_authorize_resource :stock, class: Comable::Stock.name, through: :product
6
+ load_and_authorize_resource :stock, class: Comable::Stock.name, except: [:new, :create]
8
7
 
9
- before_filter :redirect_to_show_when_nonsku_product, only: :index
8
+ load_and_authorize_resource :product, class: Comable::Product.name, only: [:new, :create]
9
+ load_and_authorize_resource :stock, class: Comable::Stock.name, through: :product, only: [:new, :create]
10
+
11
+ def index
12
+ @q = @stocks.ransack(params[:q])
13
+ @stocks = @q.result.includes(:product).page(params[:page]).accessible_by(current_ability)
14
+ end
10
15
 
11
16
  def show
12
17
  render :edit
13
18
  end
14
19
 
15
- def index
16
- @q = @product.stocks.ransack(params[:q])
17
- @stocks = @q.result.includes(:product).page(params[:page]).accessible_by(current_ability)
20
+ def new
18
21
  end
19
22
 
20
23
  def create
21
- if @stock.update_attributes(stock_params)
22
- redirect_to comable.admin_product_stock_path(@product, @stock), notice: Comable.t('successful')
24
+ if @stock.save
25
+ redirect_to comable.admin_stock_path(@stock), notice: Comable.t('successful')
23
26
  else
24
27
  flash.now[:alert] = Comable.t('failure')
25
28
  render :new
26
29
  end
27
30
  end
28
31
 
32
+ def edit
33
+ end
34
+
29
35
  def update
30
36
  if @stock.update_attributes(stock_params)
31
- redirect_to comable.admin_product_stock_path(@product, @stock), notice: Comable.t('successful')
37
+ redirect_to comable.admin_stock_path(@stock), notice: Comable.t('successful')
32
38
  else
33
39
  flash.now[:alert] = Comable.t('failure')
34
40
  render :edit
@@ -37,7 +43,7 @@ module Comable
37
43
 
38
44
  def destroy
39
45
  if @stock.destroy
40
- redirect_to comable.admin_product_stocks_path(@product), notice: Comable.t('successful')
46
+ redirect_to comable.admin_stocks_path, notice: Comable.t('successful')
41
47
  else
42
48
  flash.now[:alert] = Comable.t('failure')
43
49
  render :edit
@@ -54,16 +60,6 @@ module Comable
54
60
  :sku_v_choice_name
55
61
  )
56
62
  end
57
-
58
- def redirect_to_show_when_nonsku_product
59
- return if @product.sku?
60
-
61
- if @product.stocks.first
62
- redirect_to comable.admin_product_stock_path(@product, @product.stocks.first)
63
- else
64
- redirect_to comable.new_admin_product_stock_path(@product)
65
- end
66
- end
67
63
  end
68
64
  end
69
65
  end
@@ -11,6 +11,9 @@ module Comable
11
11
  render :edit
12
12
  end
13
13
 
14
+ def edit
15
+ end
16
+
14
17
  def update
15
18
  if @store.update_attributes(store_params)
16
19
  redirect_to comable.admin_store_url, notice: Comable.t('successful')
@@ -0,0 +1,7 @@
1
+ module Comable
2
+ module Admin
3
+ class UserSessionsController < Devise::SessionsController
4
+ layout 'comable/admin/application'
5
+ end
6
+ end
7
+ end
@@ -1,6 +1,22 @@
1
1
  module Comable
2
2
  module Admin
3
3
  module ApplicationHelper
4
+ def link_to_save
5
+ link_to Comable.t('admin.actions.save'), 'javascript:$("form").submit()', class: 'btn btn-primary'
6
+ end
7
+
8
+ def gravatar_tag(email, options = {})
9
+ hash = Digest::MD5.hexdigest(email)
10
+ image_tag "//www.gravatar.com/avatar/#{hash}?default=mm", options
11
+ end
12
+
13
+ def link_to_add_fields(name, f, association, options = {})
14
+ new_object = f.object.class.reflect_on_association(association).klass.new
15
+ fields = f.fields_for(association, new_object, child_index: "new_#{association}") do |builder|
16
+ render("#{association.to_s.singularize}_fields", ff: builder)
17
+ end
18
+ link_to(name, 'javascript:void(0)', options.merge(onclick: "add_fields(this, '#{association}', '#{escape_javascript(fields)}')"))
19
+ end
4
20
  end
5
21
  end
6
22
  end
@@ -1,94 +1,91 @@
1
- #comable-category
2
- ol.breadcrumb
3
- li
4
- = link_to Comable.t('admin.nav.dashboard'), comable.admin_root_path
5
- li.active
6
- = Comable.t('admin.nav.category')
1
+ / TODO: Use downloaded files
2
+ = javascript_include_tag 'http://rawgit.com/vakata/jstree/3.0.9/dist/jstree.min.js'
3
+ = content_for :head do
4
+ = stylesheet_link_tag 'http://rawgit.com/vakata/jstree/3.0.9/dist/themes/default/style.min.css', media: 'all'
7
5
 
8
- h1.page-header
9
- = Comable.t('admin.nav.category')
6
+ / TODO: Move to a file.
7
+ javascript:
8
+ comable_jstree_json = #{raw @categories.to_jstree(state: { opened: true }, icon: 'fa fa-bars')};
9
+ comable_new_node_label = '#{Comable.t('admin.categories.new_node')}';
10
+ comable_action_new = '#{Comable.t('admin.actions.new')}';
11
+ comable_action_edit = '#{Comable.t('admin.actions.edit')}';
12
+ comable_action_destroy = '#{Comable.t('admin.actions.destroy')}';
13
+ comable_destroied_nodes = [];
10
14
 
11
- javascript:
12
- comable_jstree_json = #{raw @categories.to_jstree(state: { opened: true }, icon: 'fa fa-bars')};
13
- comable_new_node_label = '#{Comable.t('admin.categories.new_node')}';
14
- comable_action_new = '#{Comable.t('admin.actions.new')}';
15
- comable_action_edit = '#{Comable.t('admin.actions.edit')}';
16
- comable_action_destroy = '#{Comable.t('admin.actions.destroy')}';
17
- comable_destroied_nodes = [];
18
-
19
- coffee:
20
- jQuery(->
21
- $comable_jstree = $('#comable-jstree')
22
- $comable_jstree.jstree({
23
- core: {
24
- check_callback: true,
25
- data: comable_jstree_json,
26
- strings : { new_node: comable_new_node_label, icon: 'fa fa-bars' }
27
- },
28
- contextmenu: {
29
- items: ($node) ->
30
- _this = $comable_jstree.jstree(true)
31
- {
32
- create: {
33
- label: comable_action_new,
34
- action: -> create_new_node($node)
35
- }
36
- edit: {
37
- label: comable_action_edit,
38
- action: -> _this.edit($node)
39
- }
40
- destory: {
41
- label: comable_action_destroy,
42
- action: ->
43
- comable_destroied_nodes.push { _destroy: $node.id }
44
- _this.delete_node($node)
45
- }
15
+ coffee:
16
+ jQuery(->
17
+ $comable_jstree = $('#comable-jstree')
18
+ $comable_jstree.jstree({
19
+ core: {
20
+ check_callback: true,
21
+ data: comable_jstree_json,
22
+ strings : { new_node: comable_new_node_label, icon: 'fa fa-bars' }
23
+ },
24
+ contextmenu: {
25
+ items: ($node) ->
26
+ _this = $comable_jstree.jstree(true)
27
+ {
28
+ create: {
29
+ label: comable_action_new,
30
+ action: -> create_new_node($node)
31
+ }
32
+ edit: {
33
+ label: comable_action_edit,
34
+ action: -> _this.edit($node)
35
+ }
36
+ destory: {
37
+ label: comable_action_destroy,
38
+ action: ->
39
+ comable_destroied_nodes.push { _destroy: $node.id }
40
+ _this.delete_node($node)
46
41
  }
47
- },
48
- plugins: ['dnd', 'wholerow', 'contextmenu']
49
- })
42
+ }
43
+ },
44
+ plugins: ['dnd', 'wholerow', 'contextmenu']
45
+ })
50
46
 
51
- window.create_new_node = ($node = '#') ->
52
- jstree = $comable_jstree.jstree(true)
53
- new_node = jstree.create_node($node)
54
- jstree.open_node($node) unless jstree.is_open($node)
55
- jstree.rename_node(new_node, comable_new_node_label)
56
- jstree.set_icon(new_node, 'fa fa-bars')
47
+ window.create_new_node = ($node = '#') ->
48
+ jstree = $comable_jstree.jstree(true)
49
+ new_node = jstree.create_node($node)
50
+ jstree.open_node($node) unless jstree.is_open($node)
51
+ jstree.rename_node(new_node, comable_new_node_label)
52
+ jstree.set_icon(new_node, 'fa fa-bars')
57
53
 
58
- $('form').submit(->
59
- json = $comable_jstree.jstree(true).get_json().concat(comable_destroied_nodes)
60
- json_string = JSON.stringify(json)
61
- $(this).find('#jstree_json').val(json_string)
62
- )
54
+ $('form').submit(->
55
+ json = $comable_jstree.jstree(true).get_json().concat(comable_destroied_nodes)
56
+ json_string = JSON.stringify(json)
57
+ $(this).find('#jstree_json').val(json_string)
63
58
  )
59
+ )
60
+
61
+ .comable-page
62
+ .comable-main-fixed-top
63
+ .comable-page-heading
64
+ ul.pull-right.list-inline
65
+ li
66
+ = link_to_save
67
+
68
+ h1.page-header
69
+ = Comable.t('admin.nav.category')
64
70
 
65
- .row
66
- section.col-sm-8
67
- .panel.panel-inverse
68
- .panel-heading
69
- .panel-title
70
- = Comable.t('admin.actions.edit')
71
- - if @categories.empty?
72
- .panel-body
73
- = Comable.t('admin.not_found')
74
- - else
75
- .panel-body
76
- .well.well-sm
77
- p
78
- strong
79
- = Comable.t('admin.note')
80
- ul
81
- li
82
- = Comable.t('admin.you_can_drag_and_drop')
83
- li
84
- = Comable.t('admin.you_can_right_click')
85
- li
86
- = Comable.t('admin.link_to_add_new_node')
87
- = link_to Comable.t('admin.actions.new'), '#', onclick: 'create_new_node()'
88
- #comable-jstree
89
- .panel-footer
90
- = form_tag comable.admin_categories_path do
91
- = hidden_field_tag :jstree_json
92
- = submit_tag Comable.t('admin.actions.update')
71
+ .comable-page-body
72
+ fieldset
73
+ .col-sm-3
74
+ legend
75
+ = Comable.t('admin.note')
76
+ .help-block
77
+ ul
78
+ li
79
+ = Comable.t('admin.you_can_drag_and_drop')
80
+ li
81
+ = Comable.t('admin.you_can_right_click')
82
+ li
83
+ = Comable.t('admin.link_to_add_new_node')
84
+ = link_to Comable.t('admin.actions.new'), 'javascript:create_new_node()'
93
85
 
94
- nav.col-sm-4
86
+ .col-sm-9
87
+ #comable-jstree
88
+ = form_tag comable.admin_categories_path do
89
+ .hidden
90
+ = submit_tag
91
+ = hidden_field_tag :jstree_json