comable-backend 0.6.0
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +97 -0
- data/app/assets/javascripts/comable/admin/application.coffee +76 -0
- data/app/assets/javascripts/comable/admin/categories.coffee +59 -0
- data/app/assets/javascripts/comable/admin/dashboard.coffee +32 -0
- data/app/assets/javascripts/comable/admin/dispatcher.coffee +21 -0
- data/app/assets/javascripts/comable/admin/orders.coffee +44 -0
- data/app/assets/javascripts/comable/admin/pages.coffee +69 -0
- data/app/assets/javascripts/comable/admin/products.coffee +21 -0
- data/app/assets/javascripts/comable/admin/search.coffee +35 -0
- data/app/assets/javascripts/comable/admin/themes.coffee +64 -0
- data/app/assets/stylesheets/comable/admin/_common.scss +153 -0
- data/app/assets/stylesheets/comable/admin/_dashboard.scss +81 -0
- data/app/assets/stylesheets/comable/admin/_errors.scss +18 -0
- data/app/assets/stylesheets/comable/admin/_flow.scss +149 -0
- data/app/assets/stylesheets/comable/admin/_mixins.scss +16 -0
- data/app/assets/stylesheets/comable/admin/_orders.scss +54 -0
- data/app/assets/stylesheets/comable/admin/_overrides.scss +4 -0
- data/app/assets/stylesheets/comable/admin/_pages.scss +30 -0
- data/app/assets/stylesheets/comable/admin/_products.scss +18 -0
- data/app/assets/stylesheets/comable/admin/_themes.scss +71 -0
- data/app/assets/stylesheets/comable/admin/_user_sessions.scss +57 -0
- data/app/assets/stylesheets/comable/admin/_variables.scss +38 -0
- data/app/assets/stylesheets/comable/admin/application.scss +26 -0
- data/app/assets/stylesheets/comable/admin/overrides/awesome_admin_layout.scss +25 -0
- data/app/assets/stylesheets/comable/admin/overrides/bootstrap.scss +81 -0
- data/app/assets/stylesheets/comable/admin/overrides/jstree.scss +71 -0
- data/app/assets/stylesheets/comable/admin/overrides/tagit.scss +22 -0
- data/app/controllers/comable/admin/application_controller.rb +58 -0
- data/app/controllers/comable/admin/categories_controller.rb +17 -0
- data/app/controllers/comable/admin/dashboard_controller.rb +19 -0
- data/app/controllers/comable/admin/orders_controller.rb +102 -0
- data/app/controllers/comable/admin/pages_controller.rb +72 -0
- data/app/controllers/comable/admin/payment_methods_controller.rb +59 -0
- data/app/controllers/comable/admin/products_controller.rb +82 -0
- data/app/controllers/comable/admin/shipment_methods_controller.rb +57 -0
- data/app/controllers/comable/admin/stocks_controller.rb +81 -0
- data/app/controllers/comable/admin/store_controller.rb +42 -0
- data/app/controllers/comable/admin/themes_controller.rb +101 -0
- data/app/controllers/comable/admin/trackers_controller.rb +58 -0
- data/app/controllers/comable/admin/user_sessions_controller.rb +8 -0
- data/app/controllers/comable/admin/users_controller.rb +47 -0
- data/app/helpers/comable/admin/application_helper.rb +53 -0
- data/app/helpers/comable/admin/orders_helper.rb +30 -0
- data/app/helpers/comable/admin/pages_helper.rb +6 -0
- data/app/helpers/comable/admin/products_helper.rb +6 -0
- data/app/helpers/comable/admin/shipment_methods_helper.rb +6 -0
- data/app/helpers/comable/admin/stores_helper.rb +6 -0
- data/app/helpers/comable/admin/themes_helper.rb +69 -0
- data/app/views/comable/admin/categories/index.slim +40 -0
- data/app/views/comable/admin/dashboard/_widget.slim +13 -0
- data/app/views/comable/admin/dashboard/show.slim +43 -0
- data/app/views/comable/admin/orders/_google_map.slim +39 -0
- data/app/views/comable/admin/orders/_payment_state.slim +40 -0
- data/app/views/comable/admin/orders/_shipment_state.slim +44 -0
- data/app/views/comable/admin/orders/edit.slim +170 -0
- data/app/views/comable/admin/orders/index.slim +95 -0
- data/app/views/comable/admin/orders/show.slim +177 -0
- data/app/views/comable/admin/pages/_form.slim +69 -0
- data/app/views/comable/admin/pages/edit.slim +31 -0
- data/app/views/comable/admin/pages/index.slim +55 -0
- data/app/views/comable/admin/pages/new.slim +16 -0
- data/app/views/comable/admin/payment_methods/_form.slim +35 -0
- data/app/views/comable/admin/payment_methods/edit.slim +27 -0
- data/app/views/comable/admin/payment_methods/index.slim +40 -0
- data/app/views/comable/admin/payment_methods/new.slim +16 -0
- data/app/views/comable/admin/products/_form.slim +137 -0
- data/app/views/comable/admin/products/edit.slim +41 -0
- data/app/views/comable/admin/products/index.slim +95 -0
- data/app/views/comable/admin/products/new.slim +16 -0
- data/app/views/comable/admin/shared/_advanced_search.slim +7 -0
- data/app/views/comable/admin/shared/_condition_fields.slim +15 -0
- data/app/views/comable/admin/shared/_footer.slim +8 -0
- data/app/views/comable/admin/shared/_grouping_fields.slim +8 -0
- data/app/views/comable/admin/shared/_image_fields.slim +15 -0
- data/app/views/comable/admin/shared/_notifier.slim +5 -0
- data/app/views/comable/admin/shared/_value_fields.slim +1 -0
- data/app/views/comable/admin/shared/export.xlsx.axlsx +17 -0
- data/app/views/comable/admin/shipment_methods/_form.slim +29 -0
- data/app/views/comable/admin/shipment_methods/edit.slim +27 -0
- data/app/views/comable/admin/shipment_methods/index.slim +37 -0
- data/app/views/comable/admin/shipment_methods/new.slim +16 -0
- data/app/views/comable/admin/stocks/_form.slim +34 -0
- data/app/views/comable/admin/stocks/edit.slim +37 -0
- data/app/views/comable/admin/stocks/index.slim +81 -0
- data/app/views/comable/admin/stocks/new.slim +18 -0
- data/app/views/comable/admin/store/_form.slim +32 -0
- data/app/views/comable/admin/store/edit.slim +12 -0
- data/app/views/comable/admin/themes/_editor.slim +8 -0
- data/app/views/comable/admin/themes/_form.slim +31 -0
- data/app/views/comable/admin/themes/edit.slim +35 -0
- data/app/views/comable/admin/themes/index.slim +37 -0
- data/app/views/comable/admin/themes/new.slim +16 -0
- data/app/views/comable/admin/themes/show_file.slim +93 -0
- data/app/views/comable/admin/trackers/_form.slim +109 -0
- data/app/views/comable/admin/trackers/edit.slim +27 -0
- data/app/views/comable/admin/trackers/index.slim +37 -0
- data/app/views/comable/admin/trackers/new.slim +16 -0
- data/app/views/comable/admin/user_sessions/new.slim +25 -0
- data/app/views/comable/admin/users/edit.slim +79 -0
- data/app/views/comable/admin/users/index.slim +71 -0
- data/app/views/comable/admin/users/show.slim +88 -0
- data/app/views/kaminari/comable_backend/_first_page.html.slim +2 -0
- data/app/views/kaminari/comable_backend/_gap.html.slim +2 -0
- data/app/views/kaminari/comable_backend/_last_page.html.slim +2 -0
- data/app/views/kaminari/comable_backend/_next_page.html.slim +2 -0
- data/app/views/kaminari/comable_backend/_page.html.slim +3 -0
- data/app/views/kaminari/comable_backend/_paginator.html.slim +15 -0
- data/app/views/kaminari/comable_backend/_prev_page.html.slim +2 -0
- data/app/views/layouts/comable/admin/application.slim +36 -0
- data/config/initializers/awesome_admin_layout.rb +110 -0
- data/config/routes.rb +63 -0
- data/lib/comable/backend.rb +1 -0
- data/lib/comable/backend/engine.rb +67 -0
- data/lib/tasks/comable_backend_tasks.rake +4 -0
- metadata +514 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require_dependency 'comable/admin/application_controller'
|
|
2
|
+
|
|
3
|
+
module Comable
|
|
4
|
+
module Admin
|
|
5
|
+
class StocksController < Comable::Admin::ApplicationController
|
|
6
|
+
load_and_authorize_resource :stock, class: Comable::Stock.name, except: [:new, :create]
|
|
7
|
+
|
|
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
|
|
15
|
+
|
|
16
|
+
def show
|
|
17
|
+
render :edit
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def new
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create
|
|
24
|
+
if @stock.save
|
|
25
|
+
redirect_to comable.admin_stock_path(@stock), notice: Comable.t('successful')
|
|
26
|
+
else
|
|
27
|
+
flash.now[:alert] = Comable.t('failure')
|
|
28
|
+
render :new
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def edit
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def update
|
|
36
|
+
if @stock.update_attributes(stock_params)
|
|
37
|
+
redirect_to comable.admin_stock_path(@stock), notice: Comable.t('successful')
|
|
38
|
+
else
|
|
39
|
+
flash.now[:alert] = Comable.t('failure')
|
|
40
|
+
render :edit
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def destroy
|
|
45
|
+
if @stock.destroy
|
|
46
|
+
redirect_to comable.admin_stocks_path, notice: Comable.t('successful')
|
|
47
|
+
else
|
|
48
|
+
flash.now[:alert] = Comable.t('failure')
|
|
49
|
+
render :edit
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def export
|
|
54
|
+
q = @stocks.ransack(params[:q])
|
|
55
|
+
stocks = q.result.includes(:product).accessible_by(current_ability)
|
|
56
|
+
|
|
57
|
+
respond_to_export_with stocks
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def import
|
|
61
|
+
ActiveRecord::Base.transaction do
|
|
62
|
+
Comable::Stock.import_from(params[:file])
|
|
63
|
+
end
|
|
64
|
+
redirect_to comable.admin_stocks_path, notice: Comable.t('successful')
|
|
65
|
+
rescue Comable::Importable::Exception => e
|
|
66
|
+
redirect_to comable.admin_stocks_path, alert: e.message
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
private
|
|
70
|
+
|
|
71
|
+
def stock_params
|
|
72
|
+
params.require(:stock).permit(
|
|
73
|
+
:code,
|
|
74
|
+
:quantity,
|
|
75
|
+
:sku_h_choice_name,
|
|
76
|
+
:sku_v_choice_name
|
|
77
|
+
)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require_dependency 'comable/admin/application_controller'
|
|
2
|
+
|
|
3
|
+
module Comable
|
|
4
|
+
module Admin
|
|
5
|
+
class StoreController < Comable::Admin::ApplicationController
|
|
6
|
+
authorize_resource class: Comable::Store.name
|
|
7
|
+
|
|
8
|
+
before_filter :find_store, only: [:show, :edit, :update]
|
|
9
|
+
|
|
10
|
+
def show
|
|
11
|
+
render :edit
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def edit
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def update
|
|
18
|
+
if @store.update_attributes(store_params)
|
|
19
|
+
redirect_to comable.admin_store_url, notice: Comable.t('successful')
|
|
20
|
+
else
|
|
21
|
+
flash.now[:alert] = Comable.t('failure')
|
|
22
|
+
render :edit
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def find_store
|
|
29
|
+
@store = Comable::Store.instance
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def store_params
|
|
33
|
+
params.require(:store).permit(
|
|
34
|
+
:name,
|
|
35
|
+
:meta_keywords,
|
|
36
|
+
:meta_description,
|
|
37
|
+
:email
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
require_dependency 'comable/admin/application_controller'
|
|
2
|
+
|
|
3
|
+
module Comable
|
|
4
|
+
module Admin
|
|
5
|
+
class ThemesController < Comable::Admin::ApplicationController
|
|
6
|
+
load_and_authorize_resource class: Comable::Theme.name, find_by: :name
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def show
|
|
12
|
+
render :edit
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def new
|
|
16
|
+
@theme.attributes = {
|
|
17
|
+
version: @theme.default_version,
|
|
18
|
+
author: current_comable_user.bill_full_name || current_comable_user.email
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create
|
|
23
|
+
if @theme.save
|
|
24
|
+
redirect_to comable.admin_theme_path(@theme), notice: Comable.t('successful')
|
|
25
|
+
else
|
|
26
|
+
flash.now[:alert] = Comable.t('failure')
|
|
27
|
+
render :new
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def edit
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def update
|
|
35
|
+
if @theme.update_attributes(theme_params)
|
|
36
|
+
redirect_to comable.admin_theme_path(@theme), notice: Comable.t('successful')
|
|
37
|
+
else
|
|
38
|
+
flash.now[:alert] = Comable.t('failure')
|
|
39
|
+
render :edit
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def destroy
|
|
44
|
+
@theme.destroy
|
|
45
|
+
FileUtils.rm_rf(theme_dir)
|
|
46
|
+
redirect_to comable.admin_themes_path, notice: Comable.t('successful')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def tree
|
|
50
|
+
render :show_file
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def show_file
|
|
54
|
+
@code = File.read(filepath) if filepath && File.exist?(filepath)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def update_file
|
|
58
|
+
save_file
|
|
59
|
+
redirect_to comable.file_admin_theme_path(@theme, path: params[:path]), notice: Comable.t('successful')
|
|
60
|
+
rescue => e
|
|
61
|
+
@code = params[:code]
|
|
62
|
+
flash.now[:alert] = e.message
|
|
63
|
+
render :show_file
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def use
|
|
67
|
+
current_store.update_attributes!(theme: @theme)
|
|
68
|
+
redirect_to :back, notice: Comable.t('successful')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
def save_file
|
|
74
|
+
# Validate the Liquid syntax
|
|
75
|
+
Liquid::Template.parse(params[:code])
|
|
76
|
+
|
|
77
|
+
FileUtils.mkdir_p(File.dirname(filepath)) unless File.exist?(filepath)
|
|
78
|
+
File.write(filepath, params[:code])
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def theme_dir
|
|
82
|
+
File.join('themes', @theme.name)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def filepath
|
|
86
|
+
return unless params[:path]
|
|
87
|
+
File.join(theme_dir, params[:path])
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def theme_params
|
|
91
|
+
params.require(:theme).permit(
|
|
92
|
+
:name,
|
|
93
|
+
:version,
|
|
94
|
+
:display,
|
|
95
|
+
:homepage,
|
|
96
|
+
:author
|
|
97
|
+
)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require_dependency 'comable/admin/application_controller'
|
|
2
|
+
|
|
3
|
+
module Comable
|
|
4
|
+
module Admin
|
|
5
|
+
class TrackersController < Comable::Admin::ApplicationController
|
|
6
|
+
load_and_authorize_resource class: Comable::Tracker.name
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
@trackers = @trackers.page(params[:page])
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def show
|
|
13
|
+
render :edit
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def create
|
|
20
|
+
if @tracker.save
|
|
21
|
+
redirect_to comable.admin_tracker_path(@tracker), notice: Comable.t('successful')
|
|
22
|
+
else
|
|
23
|
+
flash.now[:alert] = Comable.t('failure')
|
|
24
|
+
render :new
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def edit
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def update
|
|
32
|
+
if @tracker.update_attributes(tracker_params)
|
|
33
|
+
redirect_to comable.admin_tracker_path(@tracker), notice: Comable.t('successful')
|
|
34
|
+
else
|
|
35
|
+
flash.now[:alert] = Comable.t('failure')
|
|
36
|
+
render :edit
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def destroy
|
|
41
|
+
@tracker.destroy
|
|
42
|
+
redirect_to comable.admin_trackers_path, notice: Comable.t('successful')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def tracker_params
|
|
48
|
+
params.require(:tracker).permit(
|
|
49
|
+
:activated_flag,
|
|
50
|
+
:name,
|
|
51
|
+
:tracker_id,
|
|
52
|
+
:code,
|
|
53
|
+
:place
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require_dependency 'comable/admin/application_controller'
|
|
2
|
+
|
|
3
|
+
module Comable
|
|
4
|
+
module Admin
|
|
5
|
+
class UsersController < Comable::Admin::ApplicationController
|
|
6
|
+
include Comable::PermittedAttributes
|
|
7
|
+
|
|
8
|
+
load_and_authorize_resource class: Comable::User.name, except: :index
|
|
9
|
+
|
|
10
|
+
def index
|
|
11
|
+
@q = Comable::User.ransack(params[:q])
|
|
12
|
+
@users = @q.result.page(params[:page]).accessible_by(current_ability)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def show
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def edit
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def update
|
|
22
|
+
if @user.update_attributes(user_params)
|
|
23
|
+
redirect_to comable.admin_user_path(@user), notice: Comable.t('successful')
|
|
24
|
+
else
|
|
25
|
+
flash.now[:alert] = Comable.t('failure')
|
|
26
|
+
render :edit
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def profile
|
|
31
|
+
@user = current_comable_user
|
|
32
|
+
render :edit
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def user_params
|
|
38
|
+
params.require(:user).permit(
|
|
39
|
+
:email,
|
|
40
|
+
:password,
|
|
41
|
+
:role,
|
|
42
|
+
bill_address_attributes: permitted_address_attributes
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module Comable
|
|
2
|
+
module Admin
|
|
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("comable/admin/shared/#{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
|
|
20
|
+
|
|
21
|
+
def button_to_remove_fields(name, options = {})
|
|
22
|
+
content_tag(:button, name, options.merge(class: "ransack remove_fields #{options[:class]}"))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def button_to_add_fields(name, f, type, options = {})
|
|
26
|
+
new_fields = build_fields(f, type)
|
|
27
|
+
content_tag(:button, name, options.merge(class: "ransack add_fields #{options[:class]}", 'data-field-type' => type, 'data-content' => "#{new_fields}"))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def build_fields(f, type)
|
|
31
|
+
new_object = f.object.send("build_#{type}")
|
|
32
|
+
|
|
33
|
+
f.send("#{type}_fields", new_object, child_index: "new_#{type}") do |builder|
|
|
34
|
+
render("comable/admin/shared/#{type}_fields", f: builder)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def enable_advanced_search?
|
|
39
|
+
grouping_params = params[:q][:g]
|
|
40
|
+
conditions_params = grouping_params.values.first[:c]
|
|
41
|
+
value_params = conditions_params.values.first[:v]
|
|
42
|
+
|
|
43
|
+
value_params.values.first[:value].present?
|
|
44
|
+
rescue NoMethodError
|
|
45
|
+
false
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def page_name
|
|
49
|
+
[controller_name, action_name].join(':')
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Comable
|
|
2
|
+
module Admin
|
|
3
|
+
module OrdersHelper
|
|
4
|
+
def options_of_shipment_badge_for(shipment, state:)
|
|
5
|
+
human_name = shipment.class.state_machine.states[state].human_name
|
|
6
|
+
{ class: shipment_badge_class_for(shipment, state: state), title: human_name, data: { toggle: 'tooltip', placement: 'top' } }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def shipment_badge_class_for(shipment, state:)
|
|
10
|
+
return badge_class_for_state(state) if shipment.state.to_sym == state.to_sym
|
|
11
|
+
can_cancel = shipment.resumed? && state.to_sym == :canceled
|
|
12
|
+
(!can_cancel && shipment.stated?(state)) ? 'comable-badge comable-badge-disable' : 'comable-badge comable-badge-default'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
alias_method :options_of_payment_badge_for, :options_of_shipment_badge_for
|
|
16
|
+
alias_method :payment_badge_class_for, :shipment_badge_class_for
|
|
17
|
+
|
|
18
|
+
def badge_class_for_state(state)
|
|
19
|
+
case state.to_sym
|
|
20
|
+
when :pending, :ready
|
|
21
|
+
'comable-badge comable-badge-warning'
|
|
22
|
+
when :completed, :resumed
|
|
23
|
+
'comable-badge comable-badge-success'
|
|
24
|
+
when :canceled
|
|
25
|
+
'comable-badge comable-badge-danger'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|