storefront 0.3.2 → 0.5.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.
- data/Rakefile +4 -4
- data/lib/storefront.rb +22 -35
- data/lib/storefront/components/base.rb +99 -0
- data/lib/storefront/components/breadcrumb.rb +7 -0
- data/lib/storefront/components/button.rb +37 -0
- data/lib/storefront/components/definition_list.rb +34 -0
- data/lib/storefront/components/definition_list_item.rb +63 -0
- data/lib/storefront/components/flash.rb +12 -0
- data/lib/storefront/components/footer.rb +19 -0
- data/lib/storefront/components/form.rb +82 -0
- data/lib/storefront/{form → components/form}/base.rb +3 -3
- data/lib/storefront/{form → components/form}/builder.rb +3 -3
- data/lib/storefront/{form → components/form}/errors.rb +1 -3
- data/lib/storefront/{form → components/form}/field.rb +1 -1
- data/lib/storefront/{form → components/form}/fieldset.rb +0 -0
- data/lib/storefront/{form → components/form}/hint.rb +0 -0
- data/lib/storefront/{form → components/form}/input.rb +7 -5
- data/lib/storefront/components/form/inputs.rb +7 -0
- data/lib/storefront/{form → components/form}/inputs/checkbox.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/date.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/file.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/hidden.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/radio.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/range.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/select.rb +6 -6
- data/lib/storefront/{form → components/form}/inputs/string.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/submit.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/textarea.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/value.rb +0 -0
- data/lib/storefront/{form → components/form}/label.rb +1 -1
- data/lib/storefront/components/header.rb +73 -0
- data/lib/storefront/components/image.rb +12 -0
- data/lib/storefront/components/javascript_template.rb +21 -0
- data/lib/storefront/components/list.rb +27 -0
- data/lib/storefront/components/menu.rb +41 -0
- data/lib/storefront/components/nav.rb +78 -0
- data/lib/storefront/components/sidebar.rb +23 -0
- data/lib/storefront/components/table.rb +232 -0
- data/lib/storefront/components/text.rb +29 -0
- data/lib/storefront/configuration.rb +53 -5
- data/lib/storefront/helpers/cache_helper.rb +37 -19
- data/lib/storefront/helpers/component_helper.rb +80 -41
- data/lib/storefront/helpers/content_helper.rb +211 -0
- data/lib/storefront/helpers/dom_helper.rb +136 -0
- data/lib/storefront/helpers/head_helper.rb +277 -205
- data/lib/storefront/helpers/model_helper.rb +21 -0
- data/lib/storefront/helpers/request_helper.rb +301 -53
- data/lib/storefront/helpers/tag_helper.rb +29 -0
- data/lib/storefront/{proxies/attribute_proxy.rb → models/attribute.rb} +1 -1
- data/lib/storefront/{proxies/model_proxy.rb → models/model.rb} +4 -6
- data/lib/storefront/railtie.rb +3 -16
- metadata +48 -64
- data/lib/storefront/dashboard.rb +0 -185
- data/lib/storefront/form.rb +0 -82
- data/lib/storefront/helpers/attribute_helper.rb +0 -81
- data/lib/storefront/helpers/body_helper.rb +0 -18
- data/lib/storefront/helpers/browser_helper.rb +0 -54
- data/lib/storefront/helpers/collection_helper.rb +0 -14
- data/lib/storefront/helpers/dashboard_helper.rb +0 -29
- data/lib/storefront/helpers/debug_helper.rb +0 -11
- data/lib/storefront/helpers/definition_list_helper.rb +0 -110
- data/lib/storefront/helpers/error_helper.rb +0 -11
- data/lib/storefront/helpers/flash_helper.rb +0 -14
- data/lib/storefront/helpers/form_helper.rb +0 -13
- data/lib/storefront/helpers/format_helper.rb +0 -59
- data/lib/storefront/helpers/image_helper.rb +0 -30
- data/lib/storefront/helpers/list_helper.rb +0 -135
- data/lib/storefront/helpers/locale_helper.rb +0 -245
- data/lib/storefront/helpers/open_graph_helper.rb +0 -5
- data/lib/storefront/helpers/page_helper.rb +0 -91
- data/lib/storefront/helpers/presenter_helper.rb +0 -5
- data/lib/storefront/helpers/semantic/location_helper.rb +0 -18
- data/lib/storefront/helpers/semantic/time_helper.rb +0 -14
- data/lib/storefront/helpers/sidebar_helper.rb +0 -27
- data/lib/storefront/helpers/system_helper.rb +0 -18
- data/lib/storefront/helpers/table_helper.rb +0 -38
- data/lib/storefront/helpers/template_helper.rb +0 -11
- data/lib/storefront/helpers/time_helper.rb +0 -21
- data/lib/storefront/helpers/url_helper.rb +0 -32
- data/lib/storefront/helpers/user_helper.rb +0 -15
- data/lib/storefront/helpers/widget_helper.rb +0 -142
- data/lib/storefront/helpers/workflow_helper.rb +0 -50
- data/lib/storefront/model_helper.rb +0 -17
- data/lib/storefront/table.rb +0 -198
- data/rails/init.rb +0 -1
- data/test/form_helper_test.rb +0 -5
- data/test/support/mock_controller.rb +0 -15
- data/test/support/mock_response.rb +0 -14
- data/test/support/models.rb +0 -0
- data/test/test_helper.rb +0 -34
data/lib/storefront/railtie.rb
CHANGED
|
@@ -2,12 +2,7 @@ module Storefront
|
|
|
2
2
|
class Railtie < Rails::Railtie
|
|
3
3
|
initializer "storefront.insert_into_action_view" do
|
|
4
4
|
ActiveSupport.on_load :action_view do
|
|
5
|
-
|
|
6
|
-
Dir["#{base}/*"].each do |path|
|
|
7
|
-
next if File.directory?(path)
|
|
8
|
-
constant_name = File.basename(path, File.extname(path)).gsub("/", "::").camelize
|
|
9
|
-
ActionView::Base.send :include, "Storefront::#{constant_name}".constantize
|
|
10
|
-
end
|
|
5
|
+
Storefront.configuration.configure_action_view
|
|
11
6
|
end
|
|
12
7
|
|
|
13
8
|
ActiveSupport.on_load :active_record do
|
|
@@ -15,16 +10,8 @@ module Storefront
|
|
|
15
10
|
end
|
|
16
11
|
|
|
17
12
|
ActiveSupport.on_load :action_controller do
|
|
18
|
-
|
|
19
|
-
Dir["#{base}/*"].each do |path|
|
|
20
|
-
next if File.directory?(path) || File.basename(path) =~ /(form|table|dashboard)/
|
|
21
|
-
# need to do these as traditional helper declarations somehow
|
|
22
|
-
constant_name = File.basename(path, File.extname(path)).gsub("/", "::").camelize
|
|
23
|
-
ActionController::Base.send :include, "Storefront::#{constant_name}".constantize
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
ActionController::Base.send :before_filter, :configure_storefront
|
|
13
|
+
Storefront.configuration.configure_action_controller
|
|
27
14
|
end
|
|
28
15
|
end
|
|
29
|
-
end
|
|
16
|
+
end if defined?(::Rails)
|
|
30
17
|
end
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: storefront
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.
|
|
5
|
+
version: 0.5.0
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Lance Pollard
|
|
@@ -10,10 +10,10 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2011-
|
|
13
|
+
date: 2011-09-14 00:00:00 Z
|
|
14
14
|
dependencies: []
|
|
15
15
|
|
|
16
|
-
description:
|
|
16
|
+
description: Opinionated Forms, Tables, and Widgets for Rails and Sinatra
|
|
17
17
|
email: lancejpollard@gmail.com
|
|
18
18
|
executables: []
|
|
19
19
|
|
|
@@ -23,72 +23,56 @@ extra_rdoc_files: []
|
|
|
23
23
|
|
|
24
24
|
files:
|
|
25
25
|
- Rakefile
|
|
26
|
+
- lib/storefront/components/base.rb
|
|
27
|
+
- lib/storefront/components/breadcrumb.rb
|
|
28
|
+
- lib/storefront/components/button.rb
|
|
29
|
+
- lib/storefront/components/definition_list.rb
|
|
30
|
+
- lib/storefront/components/definition_list_item.rb
|
|
31
|
+
- lib/storefront/components/flash.rb
|
|
32
|
+
- lib/storefront/components/footer.rb
|
|
33
|
+
- lib/storefront/components/form/base.rb
|
|
34
|
+
- lib/storefront/components/form/builder.rb
|
|
35
|
+
- lib/storefront/components/form/errors.rb
|
|
36
|
+
- lib/storefront/components/form/field.rb
|
|
37
|
+
- lib/storefront/components/form/fieldset.rb
|
|
38
|
+
- lib/storefront/components/form/hint.rb
|
|
39
|
+
- lib/storefront/components/form/input.rb
|
|
40
|
+
- lib/storefront/components/form/inputs/checkbox.rb
|
|
41
|
+
- lib/storefront/components/form/inputs/date.rb
|
|
42
|
+
- lib/storefront/components/form/inputs/file.rb
|
|
43
|
+
- lib/storefront/components/form/inputs/hidden.rb
|
|
44
|
+
- lib/storefront/components/form/inputs/radio.rb
|
|
45
|
+
- lib/storefront/components/form/inputs/range.rb
|
|
46
|
+
- lib/storefront/components/form/inputs/select.rb
|
|
47
|
+
- lib/storefront/components/form/inputs/string.rb
|
|
48
|
+
- lib/storefront/components/form/inputs/submit.rb
|
|
49
|
+
- lib/storefront/components/form/inputs/textarea.rb
|
|
50
|
+
- lib/storefront/components/form/inputs/value.rb
|
|
51
|
+
- lib/storefront/components/form/inputs.rb
|
|
52
|
+
- lib/storefront/components/form/label.rb
|
|
53
|
+
- lib/storefront/components/form.rb
|
|
54
|
+
- lib/storefront/components/header.rb
|
|
55
|
+
- lib/storefront/components/image.rb
|
|
56
|
+
- lib/storefront/components/javascript_template.rb
|
|
57
|
+
- lib/storefront/components/list.rb
|
|
58
|
+
- lib/storefront/components/menu.rb
|
|
59
|
+
- lib/storefront/components/nav.rb
|
|
60
|
+
- lib/storefront/components/sidebar.rb
|
|
61
|
+
- lib/storefront/components/table.rb
|
|
62
|
+
- lib/storefront/components/text.rb
|
|
26
63
|
- lib/storefront/configuration.rb
|
|
27
|
-
- lib/storefront/dashboard.rb
|
|
28
|
-
- lib/storefront/form/base.rb
|
|
29
|
-
- lib/storefront/form/builder.rb
|
|
30
|
-
- lib/storefront/form/errors.rb
|
|
31
|
-
- lib/storefront/form/field.rb
|
|
32
|
-
- lib/storefront/form/fieldset.rb
|
|
33
|
-
- lib/storefront/form/hint.rb
|
|
34
|
-
- lib/storefront/form/input.rb
|
|
35
|
-
- lib/storefront/form/inputs/checkbox.rb
|
|
36
|
-
- lib/storefront/form/inputs/date.rb
|
|
37
|
-
- lib/storefront/form/inputs/file.rb
|
|
38
|
-
- lib/storefront/form/inputs/hidden.rb
|
|
39
|
-
- lib/storefront/form/inputs/radio.rb
|
|
40
|
-
- lib/storefront/form/inputs/range.rb
|
|
41
|
-
- lib/storefront/form/inputs/select.rb
|
|
42
|
-
- lib/storefront/form/inputs/string.rb
|
|
43
|
-
- lib/storefront/form/inputs/submit.rb
|
|
44
|
-
- lib/storefront/form/inputs/textarea.rb
|
|
45
|
-
- lib/storefront/form/inputs/value.rb
|
|
46
|
-
- lib/storefront/form/label.rb
|
|
47
|
-
- lib/storefront/form.rb
|
|
48
|
-
- lib/storefront/helpers/attribute_helper.rb
|
|
49
|
-
- lib/storefront/helpers/body_helper.rb
|
|
50
|
-
- lib/storefront/helpers/browser_helper.rb
|
|
51
64
|
- lib/storefront/helpers/cache_helper.rb
|
|
52
|
-
- lib/storefront/helpers/collection_helper.rb
|
|
53
65
|
- lib/storefront/helpers/component_helper.rb
|
|
54
|
-
- lib/storefront/helpers/
|
|
55
|
-
- lib/storefront/helpers/
|
|
56
|
-
- lib/storefront/helpers/definition_list_helper.rb
|
|
57
|
-
- lib/storefront/helpers/error_helper.rb
|
|
58
|
-
- lib/storefront/helpers/flash_helper.rb
|
|
59
|
-
- lib/storefront/helpers/form_helper.rb
|
|
60
|
-
- lib/storefront/helpers/format_helper.rb
|
|
66
|
+
- lib/storefront/helpers/content_helper.rb
|
|
67
|
+
- lib/storefront/helpers/dom_helper.rb
|
|
61
68
|
- lib/storefront/helpers/head_helper.rb
|
|
62
|
-
- lib/storefront/helpers/
|
|
63
|
-
- lib/storefront/helpers/list_helper.rb
|
|
64
|
-
- lib/storefront/helpers/locale_helper.rb
|
|
65
|
-
- lib/storefront/helpers/open_graph_helper.rb
|
|
66
|
-
- lib/storefront/helpers/page_helper.rb
|
|
67
|
-
- lib/storefront/helpers/presenter_helper.rb
|
|
69
|
+
- lib/storefront/helpers/model_helper.rb
|
|
68
70
|
- lib/storefront/helpers/request_helper.rb
|
|
69
|
-
- lib/storefront/helpers/
|
|
70
|
-
- lib/storefront/
|
|
71
|
-
- lib/storefront/
|
|
72
|
-
- lib/storefront/helpers/system_helper.rb
|
|
73
|
-
- lib/storefront/helpers/table_helper.rb
|
|
74
|
-
- lib/storefront/helpers/template_helper.rb
|
|
75
|
-
- lib/storefront/helpers/time_helper.rb
|
|
76
|
-
- lib/storefront/helpers/url_helper.rb
|
|
77
|
-
- lib/storefront/helpers/user_helper.rb
|
|
78
|
-
- lib/storefront/helpers/widget_helper.rb
|
|
79
|
-
- lib/storefront/helpers/workflow_helper.rb
|
|
80
|
-
- lib/storefront/model_helper.rb
|
|
81
|
-
- lib/storefront/proxies/attribute_proxy.rb
|
|
82
|
-
- lib/storefront/proxies/model_proxy.rb
|
|
71
|
+
- lib/storefront/helpers/tag_helper.rb
|
|
72
|
+
- lib/storefront/models/attribute.rb
|
|
73
|
+
- lib/storefront/models/model.rb
|
|
83
74
|
- lib/storefront/railtie.rb
|
|
84
|
-
- lib/storefront/table.rb
|
|
85
75
|
- lib/storefront.rb
|
|
86
|
-
- rails/init.rb
|
|
87
|
-
- test/form_helper_test.rb
|
|
88
|
-
- test/support/mock_controller.rb
|
|
89
|
-
- test/support/mock_response.rb
|
|
90
|
-
- test/support/models.rb
|
|
91
|
-
- test/test_helper.rb
|
|
92
76
|
homepage: http://github.com/viatropos/storefront
|
|
93
77
|
licenses: []
|
|
94
78
|
|
|
@@ -112,9 +96,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
112
96
|
requirements: []
|
|
113
97
|
|
|
114
98
|
rubyforge_project: storefront
|
|
115
|
-
rubygems_version: 1.
|
|
99
|
+
rubygems_version: 1.8.10
|
|
116
100
|
signing_key:
|
|
117
101
|
specification_version: 3
|
|
118
|
-
summary: A simple and semantic FormBuilder, TableBuilder, Locale Interpolator, and Widget API for Rails 3
|
|
102
|
+
summary: A simple and semantic FormBuilder, TableBuilder, Locale Interpolator, and Widget API for Rails 3 and Sinatra
|
|
119
103
|
test_files: []
|
|
120
104
|
|
data/lib/storefront/dashboard.rb
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
module Storefront
|
|
2
|
-
class Dashboard
|
|
3
|
-
include Storefront::AttributeHelper
|
|
4
|
-
include Storefront::LocaleHelper
|
|
5
|
-
attr_reader :content, :template, :key, :report, :keys
|
|
6
|
-
|
|
7
|
-
def initialize(template, record_or_key, hash, options = {}, &block)
|
|
8
|
-
@template = template
|
|
9
|
-
@key = record_key(record_or_key)
|
|
10
|
-
@section_index = -1
|
|
11
|
-
@column_index = -1
|
|
12
|
-
@row_index = -1
|
|
13
|
-
@cols = 0
|
|
14
|
-
@section_scope = nil
|
|
15
|
-
@column_scope = nil
|
|
16
|
-
@filter_scope = nil
|
|
17
|
-
@model_names = @key.to_s.camelize.constantize.ancestor_classes.map {|i| i.name.underscore}
|
|
18
|
-
@filter = Array(options.delete(:filter)).compact
|
|
19
|
-
@report = hash
|
|
20
|
-
options[:id] ||= "#{record_or_key.to_s}-section"
|
|
21
|
-
@keys = options.delete(:keys) || {}
|
|
22
|
-
|
|
23
|
-
@content = template.capture_haml do
|
|
24
|
-
template.haml_tag :article, options do
|
|
25
|
-
yield(self)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# section :when, :cols => 3
|
|
31
|
-
def section(*args, &block)
|
|
32
|
-
attributes = args.extract_options!
|
|
33
|
-
@section_scope = args.shift
|
|
34
|
-
@section_index += 1
|
|
35
|
-
@row_index = -1
|
|
36
|
-
@column_index = -1
|
|
37
|
-
@cols = attributes.delete(:cols)
|
|
38
|
-
@header = attributes.delete(:title) != false
|
|
39
|
-
attributes[:"data-filters"] = @filter.join(",")
|
|
40
|
-
attributes[:"data-section"] = @section_scope.to_s
|
|
41
|
-
@subtitle = attributes.delete(:subtitle) || report_subtitle
|
|
42
|
-
|
|
43
|
-
merge_class! attributes, index_class(@section_index, @cols), "dashboard-widget", "#{@section_scope}-dashboard-widget"
|
|
44
|
-
|
|
45
|
-
template.capture_haml do
|
|
46
|
-
template.haml_tag :section, attributes do
|
|
47
|
-
if @header
|
|
48
|
-
template.haml_tag :header, :class => "header" do
|
|
49
|
-
template.haml_tag :h3, t?(:"#{@section_scope}.title", locale_keys.merge(:scope => :"reports.titles")), :class => "title"
|
|
50
|
-
if @subtitle.present?
|
|
51
|
-
template.haml_tag :h4, @subtitle, :class => "subtitle"
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
yield
|
|
56
|
-
end
|
|
57
|
-
@row_index = 0
|
|
58
|
-
@cols = 0
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def figure(*args, &block)
|
|
63
|
-
attributes = args.extract_options!
|
|
64
|
-
@figure_scope = args.shift
|
|
65
|
-
|
|
66
|
-
merge_class! attributes, "figure"
|
|
67
|
-
attributes[:id] ||= "#{@figure_scope.to_s}-figure"
|
|
68
|
-
|
|
69
|
-
template.capture_haml do
|
|
70
|
-
template.haml_tag :figure, "", attributes
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def locale_keys
|
|
75
|
-
hash = {}
|
|
76
|
-
keys.each do |key, value|
|
|
77
|
-
hash[key] = value.is_a?(::Symbol) ? t?(:"#{value}", :scope => :"reports.keys", :model_names => @model_names) : value
|
|
78
|
-
end
|
|
79
|
-
hash.merge(:model_names => @model_names)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def column(*args, &block)
|
|
83
|
-
attributes = args.extract_options!
|
|
84
|
-
@column_scope = args.shift
|
|
85
|
-
@column_index += 1
|
|
86
|
-
@row_data = []
|
|
87
|
-
@row_index = -1
|
|
88
|
-
@rows = attributes.delete(:rows)
|
|
89
|
-
|
|
90
|
-
keys = attributes.delete(:keys) || @locale_keys
|
|
91
|
-
|
|
92
|
-
merge_class! attributes, index_class(@column_index, @cols), "#{@column_scope}-column", "col#{@cols}", "column"
|
|
93
|
-
attributes[:"data-column"] = @column_scope.to_s
|
|
94
|
-
|
|
95
|
-
title = attributes.delete(:title) || t?(:"#{@section_scope}.#{@column_scope}.title", locale_keys.merge(:scope => :"reports.titles"))
|
|
96
|
-
|
|
97
|
-
template.capture_haml do
|
|
98
|
-
template.capture_haml(&block)
|
|
99
|
-
@rows = @row_data.length
|
|
100
|
-
template.haml_tag :section, attributes.merge("data-rows" => @rows) do
|
|
101
|
-
template.haml_tag :header, :class => "header" do
|
|
102
|
-
template.haml_tag @header ? :h4 : :h3, title, :class => "title"
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
template.haml_tag :dl, :class => "statistics" do
|
|
106
|
-
@row_data.map { |row_data| _row(*row_data) }
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
@row_index = -1
|
|
110
|
-
@rows = 0
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def row(*args)
|
|
115
|
-
@row_data << args
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
# data-type='distance' (microdata for each statistic)
|
|
119
|
-
def _row(*args, &block)
|
|
120
|
-
attributes = args.extract_options!
|
|
121
|
-
@row_scope = args.shift
|
|
122
|
-
@row_index += 1
|
|
123
|
-
@row_tags = []
|
|
124
|
-
|
|
125
|
-
merge_class! attributes, index_class(@row_index, @rows)
|
|
126
|
-
|
|
127
|
-
template.haml_tag :dt, t?(:"#{@section_scope}.#{@column_scope}.#{@row_scope}", locale_keys.merge(attributes.slice(:past, :present, :future).merge(:scope => :"reports.titles"))), merge_class(attributes, "key")
|
|
128
|
-
template.haml_tag :dd, report_value, merge_class(attributes.merge(:"data-stat" => @row_scope.to_s), "value")
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
private
|
|
132
|
-
def report_value
|
|
133
|
-
keys = @filter + [@section_scope, @column_scope, @row_scope]
|
|
134
|
-
result = report
|
|
135
|
-
begin
|
|
136
|
-
|
|
137
|
-
keys.each { |key| result = result[key] }
|
|
138
|
-
rescue Exception => e
|
|
139
|
-
raise keys.inspect
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
if result.is_a?(::Array)
|
|
143
|
-
result.compact.blank? ? I18n.t("reports.values.missing") : result
|
|
144
|
-
else
|
|
145
|
-
result.blank? ? I18n.t("reports.values.missing") : result
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def report_subtitle
|
|
150
|
-
keys = @filter + [@section_scope, :subtitle]
|
|
151
|
-
result = report
|
|
152
|
-
keys.each { |key| result = result[key] }
|
|
153
|
-
result
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def record_key(record_or_key)
|
|
157
|
-
if record_or_key.is_a?(String) || record_or_key.is_a?(Symbol)
|
|
158
|
-
record_or_key.to_s
|
|
159
|
-
else
|
|
160
|
-
record_or_key.class.name
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
def id_for(type, key, value, row_index = @row_index, column_index = @column_index)
|
|
165
|
-
[key, type, row_index, column_index].compact.map do |node|
|
|
166
|
-
node.to_s.gsub(/[\s_]/, "-")
|
|
167
|
-
end.join("-")
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
# reports:
|
|
171
|
-
# titles:
|
|
172
|
-
# what:
|
|
173
|
-
# summary: Quick Summary
|
|
174
|
-
# total: Total Activity
|
|
175
|
-
# deal:
|
|
176
|
-
# what:
|
|
177
|
-
# summary: Quick Summary
|
|
178
|
-
# total: Total Activity
|
|
179
|
-
# rewards_deal:
|
|
180
|
-
# what:
|
|
181
|
-
# summary: Quick Summary
|
|
182
|
-
# total: Total Activity
|
|
183
|
-
|
|
184
|
-
end
|
|
185
|
-
end
|
data/lib/storefront/form.rb
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
module Storefront
|
|
2
|
-
class Form
|
|
3
|
-
include Storefront::LocaleHelper
|
|
4
|
-
include Storefront::AttributeHelper
|
|
5
|
-
|
|
6
|
-
attr_reader :model, :template, :tabindex, :access_keys, :attributes
|
|
7
|
-
delegate :object, :parent, :to => :model
|
|
8
|
-
|
|
9
|
-
def initialize(template, *args)
|
|
10
|
-
options = args.extract_options!
|
|
11
|
-
@template = template
|
|
12
|
-
@model = Storefront::ModelProxy.new(:object => extract_object!(args.shift))
|
|
13
|
-
@attributes = extract_attributes!(options)
|
|
14
|
-
@builder = Storefront::Form::Builder.new(
|
|
15
|
-
:template => template,
|
|
16
|
-
:tabindex => 1,
|
|
17
|
-
:access_keys => {},
|
|
18
|
-
:model => model
|
|
19
|
-
)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def render(&block)
|
|
23
|
-
template.capture_haml do
|
|
24
|
-
template.haml_tag :form, attributes do
|
|
25
|
-
@builder.render(&block) if block_given?
|
|
26
|
-
|
|
27
|
-
unless attributes[:"data-method"] == attributes[:method]
|
|
28
|
-
template.haml_tag :input, :type => :hidden, :name => :_method, :value => attributes[:"data-method"]
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
protected
|
|
35
|
-
def extract_object!(object)
|
|
36
|
-
if (object.is_a?(::Symbol) || object.is_a?(::String))
|
|
37
|
-
begin
|
|
38
|
-
"::#{object.to_s.camelize}".constantize.new
|
|
39
|
-
rescue Exception => e
|
|
40
|
-
require 'ostruct'
|
|
41
|
-
result = ::OpenStruct.new
|
|
42
|
-
result.klass = object.to_s.camelize
|
|
43
|
-
result
|
|
44
|
-
end
|
|
45
|
-
else
|
|
46
|
-
object
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def config
|
|
51
|
-
Storefront.configuration
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def extract_attributes!(options = {})
|
|
55
|
-
attributes = options[:html] || {}
|
|
56
|
-
attributes[:action] = options[:url]
|
|
57
|
-
attributes[:class] = options[:class] if options.has_key?(:class)
|
|
58
|
-
merge_class! attributes, config.form_class
|
|
59
|
-
attributes[:id] = options[:id] if options.has_key?(:id)
|
|
60
|
-
#attributes[:id] ||=
|
|
61
|
-
attributes[:multipart] = "true" if options[:multipart] == "true"
|
|
62
|
-
attributes[:role] = :form
|
|
63
|
-
attributes[:novalidate] = "true" if options[:validate] == false
|
|
64
|
-
attributes[:"data-validate"] = options[:validate].to_s if options.has_key?(:validate)
|
|
65
|
-
|
|
66
|
-
method = attributes[:method] || options[:method]
|
|
67
|
-
|
|
68
|
-
if method.blank?
|
|
69
|
-
if @model.new_record?
|
|
70
|
-
method = :put
|
|
71
|
-
else
|
|
72
|
-
method = :post
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
attributes[:"data-method"] = method
|
|
77
|
-
attributes[:method] = method == :get ? :get : :post
|
|
78
|
-
|
|
79
|
-
attributes
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|