comable-backend 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cc13f09174988052b4dac133bb4b2fad27edb360
|
4
|
+
data.tar.gz: 6da4749c448aa3de6cd592ccfb6b5aac8b24d602
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fd165e1f0602941a9b79291a90816fd57aa8341358cdc4d576ddf9f8aea39666963487bbf375fa72ca7507a3509f89eeb7e928d15c5451fb472331407d6bde9e
|
7
|
+
data.tar.gz: 7de02b45f9941793ac7a6b6e8caa4d9d19e121509fe161ad3a07a15c15293ff53e05ac867cfa015fa8a7e0231337d72453086e1cb23cb96b113d35b095e4e1a2
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 YOSHIDA Hiroki
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Comable'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
14
|
+
end
|
15
|
+
|
16
|
+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
17
|
+
load 'rails/tasks/engine.rake'
|
18
|
+
|
19
|
+
def command(string)
|
20
|
+
puts string
|
21
|
+
system string
|
22
|
+
end
|
23
|
+
|
24
|
+
if File.exist?('comable.gemspec')
|
25
|
+
$LOAD_PATH.unshift File.expand_path('..', __FILE__)
|
26
|
+
require 'tasks/release'
|
27
|
+
|
28
|
+
namespace :app do
|
29
|
+
namespace :spec do
|
30
|
+
desc 'Run the code examples'
|
31
|
+
RSpec::Core::RakeTask.new(:all) do |t|
|
32
|
+
FRAMEWORKS.each do |framework|
|
33
|
+
t.pattern << ",#{framework}/spec/**{,/*/**}/*_spec.rb"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
FRAMEWORKS.each do |framework|
|
38
|
+
desc "Run the code examples in #{framework}/spec"
|
39
|
+
RSpec::Core::RakeTask.new(framework) do |t|
|
40
|
+
t.pattern = "../#{framework}/spec/**{,/*/**}/*_spec.rb"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
namespace :db do
|
47
|
+
task 'migrate' => 'app:db:migrate'
|
48
|
+
task 'app:db:migrate' => 'migrate:all'
|
49
|
+
|
50
|
+
namespace :migrate do
|
51
|
+
task :all do
|
52
|
+
FRAMEWORKS.each do |framework|
|
53
|
+
command "cd #{framework} && test -d db/migrate && bundle exec rake db:migrate RAILS_ENV=#{Rails.env}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
namespace :migrate do
|
59
|
+
task 'reset' => 'app:db:migrate:reset'
|
60
|
+
task 'app:db:migrate:reset' => 'app:db:migrate'
|
61
|
+
task 'app:db:migrate' => 'reset:all'
|
62
|
+
|
63
|
+
namespace :reset do
|
64
|
+
task :all do
|
65
|
+
command "bundle exec rake db:drop db:create RAILS_ENV=#{Rails.env}"
|
66
|
+
Rake::Task['db:migrate'].invoke
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
task default: ['app:spec:all', 'rubocop', 'brakeman:all']
|
73
|
+
else
|
74
|
+
task default: ['app:spec', 'rubocop', 'brakeman']
|
75
|
+
end
|
76
|
+
|
77
|
+
Bundler::GemHelper.install_tasks
|
78
|
+
|
79
|
+
# from https://github.com/rspec/rspec-rails/issues/936
|
80
|
+
task 'test:prepare'
|
81
|
+
|
82
|
+
task :rubocop do
|
83
|
+
sh 'rubocop'
|
84
|
+
end
|
85
|
+
|
86
|
+
task :brakeman do
|
87
|
+
sh 'brakeman --exit-on-warn --ignore-config .brakeman.ignore'
|
88
|
+
end
|
89
|
+
|
90
|
+
namespace :brakeman do
|
91
|
+
task :all do
|
92
|
+
FRAMEWORKS.each do |framework|
|
93
|
+
next unless File.directory?("#{framework}/app")
|
94
|
+
sh "brakeman --exit-on-warn --ignore-config .brakeman.ignore #{framework}"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#= require jquery
|
2
|
+
#= require jquery.turbolinks
|
3
|
+
#= require jquery_ujs
|
4
|
+
#= require jquery-ui
|
5
|
+
#= require bootstrap-sprockets
|
6
|
+
#= require raphael
|
7
|
+
#= require morris
|
8
|
+
#= require nprogress
|
9
|
+
#= require nprogress-turbolinks
|
10
|
+
#= require gritter
|
11
|
+
#= require awesome_admin_layout
|
12
|
+
#= require ace/ace
|
13
|
+
#= require ace/worker-html
|
14
|
+
#= require ace/mode-liquid
|
15
|
+
#= require moment
|
16
|
+
#= require bootstrap-datetimepicker
|
17
|
+
#= require comable/admin/dispatcher
|
18
|
+
#= require_tree .
|
19
|
+
#= require_self
|
20
|
+
#= require turbolinks
|
21
|
+
|
22
|
+
# ---
|
23
|
+
# variables
|
24
|
+
# ---
|
25
|
+
|
26
|
+
# TODO: Install 'i18n-js' gem
|
27
|
+
window.beforeunload_message = 'The changes not saved. Are you sure you want to move from this page?'
|
28
|
+
|
29
|
+
# ---
|
30
|
+
# functions
|
31
|
+
# ---
|
32
|
+
|
33
|
+
add_beforeunload_event = ->
|
34
|
+
$form = $('form[method!="get"]')
|
35
|
+
$form.change(->
|
36
|
+
$(window).bind('beforeunload', ->
|
37
|
+
window.beforeunload_message
|
38
|
+
)
|
39
|
+
$(document).on('page:before-change', ->
|
40
|
+
confirm(window.beforeunload_message)
|
41
|
+
)
|
42
|
+
)
|
43
|
+
remove_beforeunload_function = ->
|
44
|
+
$(window).unbind('beforeunload')
|
45
|
+
$(document).off('page:before-change')
|
46
|
+
$form.submit(remove_beforeunload_function)
|
47
|
+
$(document).on('page:change', remove_beforeunload_function)
|
48
|
+
|
49
|
+
window.add_fields = (_this, association, content) ->
|
50
|
+
new_id = new Date().getTime()
|
51
|
+
regexp = new RegExp('new_' + association, 'g')
|
52
|
+
$(_this).parent().before(content.replace(regexp, new_id))
|
53
|
+
|
54
|
+
# ---
|
55
|
+
# main
|
56
|
+
# ---
|
57
|
+
|
58
|
+
$(document).ready(->
|
59
|
+
add_beforeunload_event()
|
60
|
+
|
61
|
+
$('.btn-file :file').change(->
|
62
|
+
$(this).closest('form').submit()
|
63
|
+
)
|
64
|
+
|
65
|
+
# datetimepicker setting
|
66
|
+
$('.datetimepicker').datetimepicker(format: 'YYYY-MM-DD HH:mm')
|
67
|
+
|
68
|
+
$('[data-toggle="tooltip"]').tooltip()
|
69
|
+
)
|
70
|
+
|
71
|
+
NProgress.configure(
|
72
|
+
showSpinner: false,
|
73
|
+
ease: 'ease',
|
74
|
+
speed: 500,
|
75
|
+
parent: '#wrapper'
|
76
|
+
)
|
@@ -0,0 +1,59 @@
|
|
1
|
+
window.add_comable_jstree_node = ($node = '#') ->
|
2
|
+
jstree = $('#comable-jstree').jstree(true)
|
3
|
+
new_node = jstree.create_node($node)
|
4
|
+
jstree.open_node($node) unless jstree.is_open($node)
|
5
|
+
jstree.rename_node(new_node, comable_new_node_label)
|
6
|
+
jstree.set_icon(new_node, 'fa fa-bars')
|
7
|
+
|
8
|
+
can_comable_jstree = ->
|
9
|
+
return false unless comable_jstree_json?
|
10
|
+
return false unless comable_new_node_label?
|
11
|
+
return false unless comable_action_new?
|
12
|
+
return false unless comable_action_edit?
|
13
|
+
return false unless comable_action_destroy?
|
14
|
+
return false unless comable_destroied_nodes?
|
15
|
+
return false unless $('#comable-jstree').length
|
16
|
+
true
|
17
|
+
|
18
|
+
initializa_comable_jstree = ->
|
19
|
+
return unless can_comable_jstree()
|
20
|
+
|
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
|
+
}
|
46
|
+
}
|
47
|
+
},
|
48
|
+
plugins: ['dnd', 'wholerow', 'contextmenu']
|
49
|
+
})
|
50
|
+
|
51
|
+
$('form').submit(->
|
52
|
+
json = $comable_jstree.jstree(true).get_json().concat(comable_destroied_nodes)
|
53
|
+
json_string = JSON.stringify(json)
|
54
|
+
$(this).find('#jstree_json').val(json_string)
|
55
|
+
)
|
56
|
+
|
57
|
+
$(document).ready(->
|
58
|
+
initializa_comable_jstree()
|
59
|
+
)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
can_comable_tagit = ->
|
2
|
+
return false unless comable_morris_data?
|
3
|
+
return false unless comable_morris_keys?
|
4
|
+
return false unless comable_morris_labels?
|
5
|
+
return false unless $('#comable-morris').length
|
6
|
+
true
|
7
|
+
|
8
|
+
initializa_comable_morris = ->
|
9
|
+
return unless can_comable_tagit()
|
10
|
+
|
11
|
+
new Morris.Line({
|
12
|
+
# ID of the element in which to draw the chart.
|
13
|
+
element: 'comable-morris',
|
14
|
+
# Chart data records -- each entry in this array corresponds to a point on
|
15
|
+
# the chart.
|
16
|
+
data: comable_morris_data,
|
17
|
+
# The name of the data record attribute that contains x-values.
|
18
|
+
xkey: 'date',
|
19
|
+
# A list of names of data record attributes that contain y-values.
|
20
|
+
ykeys: comable_morris_keys,
|
21
|
+
# Labels for the ykeys -- will be displayed when you hover over the
|
22
|
+
# chart.
|
23
|
+
labels: comable_morris_labels,
|
24
|
+
xLabelAngle: 45,
|
25
|
+
xLabels: ['day'],
|
26
|
+
lineColors: ['#00acac', '#348fe2'],
|
27
|
+
hideHover: 'auto'
|
28
|
+
})
|
29
|
+
|
30
|
+
$(document).ready(->
|
31
|
+
initializa_comable_morris()
|
32
|
+
)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$(->
|
2
|
+
new Dispatcher
|
3
|
+
)
|
4
|
+
|
5
|
+
class Dispatcher
|
6
|
+
constructor: ->
|
7
|
+
@initialize_page_scripts()
|
8
|
+
|
9
|
+
initialize_page_scripts: ->
|
10
|
+
page = $('body').attr('data-page')
|
11
|
+
return false unless page
|
12
|
+
|
13
|
+
path = page.split(':')
|
14
|
+
contoller_name = path[0]
|
15
|
+
action_name = path[1]
|
16
|
+
|
17
|
+
switch page
|
18
|
+
when 'orders:edit'
|
19
|
+
new DynamicOrder
|
20
|
+
when 'pages:new', 'pages:show', 'pages:edit'
|
21
|
+
new Page
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class @DynamicOrder
|
2
|
+
@refresh_trigger_attributes = ['price', 'quantity', 'payment_fee', 'shipment_fee']
|
3
|
+
|
4
|
+
constructor: (@options = {}) ->
|
5
|
+
@options['order_item_selector'] = '.comable-order-items' unless @options['order_item_selector']
|
6
|
+
@listen_events()
|
7
|
+
|
8
|
+
listen_events: ->
|
9
|
+
self = this
|
10
|
+
$('input').on('change', ->
|
11
|
+
attribute_name = $(this).attr('data-name')
|
12
|
+
return unless jQuery.inArray(attribute_name, self.refresh_trigger_attributes)
|
13
|
+
self.refresh_order_item_prices_for(this)
|
14
|
+
)
|
15
|
+
|
16
|
+
refresh_order_item_prices_for: (element) ->
|
17
|
+
$group = $(element).closest(@options['order_item_selector'])
|
18
|
+
|
19
|
+
$price = $group.find('[data-name="price"]')
|
20
|
+
$quantity = $group.find('[data-name="quantity"]')
|
21
|
+
$subtotal_price = $group.find('[data-name="subtotal_price"]')
|
22
|
+
|
23
|
+
price = Number($price.val())
|
24
|
+
quantity = Number($quantity.val())
|
25
|
+
$subtotal_price.val(price * quantity)
|
26
|
+
|
27
|
+
@refresh_order_prices()
|
28
|
+
|
29
|
+
refresh_order_prices: ->
|
30
|
+
item_total_price = 0
|
31
|
+
$('[data-name="subtotal_price"]').each( ->
|
32
|
+
item_total_price += Number($(this).val())
|
33
|
+
)
|
34
|
+
|
35
|
+
$item_total_price = $('[data-name="item_total_price"]')
|
36
|
+
$payment_fee = $('[data-name="payment_fee"]')
|
37
|
+
$shipment_fee = $('[data-name="shipment_fee"]')
|
38
|
+
$total_price = $('[data-name="total_price"]')
|
39
|
+
|
40
|
+
payment_fee = Number($payment_fee.val())
|
41
|
+
shipment_fee = Number($shipment_fee.val())
|
42
|
+
|
43
|
+
$item_total_price.val(item_total_price)
|
44
|
+
$total_price.val(item_total_price + payment_fee + shipment_fee)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
class @Page
|
2
|
+
constructor: ->
|
3
|
+
$(document).ready(@ready)
|
4
|
+
|
5
|
+
ready: =>
|
6
|
+
@radio_published = $('#page_published_at_published')
|
7
|
+
@radio_unpublished = $('#page_published_at_unpublished')
|
8
|
+
@published_at = $('#page_published_at')
|
9
|
+
|
10
|
+
@initialize_visibility()
|
11
|
+
@add_event_to_set_visibility()
|
12
|
+
@add_event_to_set_page_title()
|
13
|
+
@add_event_to_set_meta_description()
|
14
|
+
|
15
|
+
# 公開/非公開の制御
|
16
|
+
initialize_visibility: ->
|
17
|
+
if @radio_published.is(':checked')
|
18
|
+
@published()
|
19
|
+
if @radio_unpublished.is(':checked')
|
20
|
+
@unpublished()
|
21
|
+
|
22
|
+
# 公開の際の制御
|
23
|
+
published: =>
|
24
|
+
@published_at.show()
|
25
|
+
@published_at.val(moment().format('YYYY-MM-DD HH:mm')) unless @published_at.val()
|
26
|
+
|
27
|
+
# 非公開の際の制御
|
28
|
+
unpublished: =>
|
29
|
+
@published_at.hide()
|
30
|
+
@published_at.val('')
|
31
|
+
|
32
|
+
add_event_to_set_visibility: ->
|
33
|
+
@radio_published.click(@published)
|
34
|
+
@radio_unpublished.click(@unpublished)
|
35
|
+
|
36
|
+
# 日付を空にされたら非公開にする
|
37
|
+
@published_at.blur( =>
|
38
|
+
@radio_unpublished.click() unless @published_at.val()
|
39
|
+
)
|
40
|
+
|
41
|
+
# ページタイトルの制御
|
42
|
+
add_event_to_set_page_title: ->
|
43
|
+
$title = $('#page_title')
|
44
|
+
$page_title = $('#page_page_title')
|
45
|
+
|
46
|
+
# タイトルを入力した時にページタイトルが空だったらタイトルの値を入れる
|
47
|
+
$title.blur( ->
|
48
|
+
$page_title.val($(this).val()) unless $page_title.val()
|
49
|
+
)
|
50
|
+
|
51
|
+
# ページタイトルが空にされたらタイトルの値を入れる
|
52
|
+
$page_title.blur( ->
|
53
|
+
$(this).val($title.val()) unless $(this).val()
|
54
|
+
)
|
55
|
+
|
56
|
+
# メタディスクリプションの制御
|
57
|
+
add_event_to_set_meta_description: ->
|
58
|
+
$content = $('#page_content')
|
59
|
+
$meta_description = $('#page_meta_description')
|
60
|
+
|
61
|
+
# 内容を入力した時にメタディスクリプションが空だったら内容の値を入れる
|
62
|
+
$content.blur( ->
|
63
|
+
$meta_description.val($($(this).val()).text()) unless $meta_description.val()
|
64
|
+
)
|
65
|
+
|
66
|
+
# メタディスクリプションが空にされたら内容の値を入れる
|
67
|
+
$meta_description.blur( ->
|
68
|
+
$(this).val($($content.val()).text()) unless $(this).val()
|
69
|
+
)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
can_comable_tagit = ->
|
2
|
+
return false unless comable_tagit_available_tags?
|
3
|
+
return false unless $("#comable-tagit").length
|
4
|
+
true
|
5
|
+
|
6
|
+
initializa_comable_tagit = ->
|
7
|
+
return unless can_comable_tagit()
|
8
|
+
|
9
|
+
$("#comable-tagit").tagit({
|
10
|
+
fieldName: 'product[category_path_names][]',
|
11
|
+
availableTags: comable_tagit_available_tags,
|
12
|
+
autocomplete: { delay: 0, minLength: 0 },
|
13
|
+
showAutocompleteOnFocus: true,
|
14
|
+
removeConfirmation: true,
|
15
|
+
# Only allow available tags
|
16
|
+
beforeTagAdded: (event, ui) -> (comable_tagit_available_tags.indexOf(ui.tagLabel) != -1)
|
17
|
+
})
|
18
|
+
|
19
|
+
$(document).ready(->
|
20
|
+
initializa_comable_tagit()
|
21
|
+
)
|