express_admin 1.4.4 → 1.4.5
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 +4 -4
- data/README.md +2 -0
- data/app/assets/stylesheets/express_admin/shared/_forms.sass +15 -2
- data/app/components/express_admin/definition_list.rb +8 -5
- data/app/components/express_admin/smart_form.rb +2 -1
- data/app/components/express_admin/smart_table.rb +3 -6
- data/app/views/layouts/express_admin/external.html.et +1 -1
- data/app/views/shared/express_admin/_messages.html.et +1 -1
- data/config/initializers/tinymce-rails.rb +1 -0
- data/config/tinymce.yml +4 -2
- data/lib/express_admin/version.rb +1 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/test/components/definition_list_test.rb +71 -0
- data/test/dummy/test/components/definition_table_test.rb +72 -0
- data/test/dummy/test/components/flash_messages_test.rb +35 -0
- data/test/dummy/test/components/icon_link_test.rb +77 -0
- data/test/dummy/test/components/icon_test.rb +31 -0
- data/test/dummy/test/components/mega_menu_test.rb +45 -0
- data/test/dummy/test/components/module_sidebar_test.rb +56 -0
- data/test/dummy/test/components/widget_box_test.rb +30 -0
- data/vendor/gems/express_templates/Gemfile.lock +1 -1
- data/vendor/gems/express_templates/README.md +1 -1
- data/vendor/gems/express_templates/express_templates-0.9.3.gem +0 -0
- data/vendor/gems/express_templates/express_templates-0.9.4.gem +0 -0
- data/vendor/gems/express_templates/lib/core_extensions/proc.rb +13 -1
- data/vendor/gems/express_templates/lib/express_templates/components/capabilities/resourceful.rb +1 -0
- data/vendor/gems/express_templates/lib/express_templates/components/configurable.rb +10 -1
- data/vendor/gems/express_templates/lib/express_templates/components/forms/form_component.rb +2 -0
- data/vendor/gems/express_templates/lib/express_templates/components/tree_for.rb +1 -1
- data/vendor/gems/express_templates/lib/express_templates/template/handler.rb +17 -1
- data/vendor/gems/express_templates/lib/express_templates/version.rb +1 -1
- data/vendor/gems/express_templates/test/components/forms/basic_fields_test.rb +58 -0
- data/vendor/gems/express_templates/test/components/forms/submit_test.rb +4 -0
- data/vendor/gems/express_templates/test/components/tree_for_test.rb +1 -6
- data/vendor/gems/express_templates/test/core_extensions/proc_test.rb +10 -1
- data/vendor/gems/express_templates/test/dummy/log/test.log +4761 -0
- data/vendor/gems/express_templates/test/handler_test.rb +24 -0
- data/vendor/gems/express_templates/test/test_helper.rb +5 -5
- metadata +21 -3
- data/app/assets/stylesheets/express_admin/components/_modals.sass +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4e4c3c080c9d417ad96cec7a4f482d681998e89
|
4
|
+
data.tar.gz: 39e8700c94d154d98d25930090d3794c81d16aa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64e004b1571753b064868e753d29035a198b079316b12745ac77d1ce2856a0030562a70fe8a34805bfdcb6eec65c1e3fbc650a13333d3dd57646c2569dbc9265
|
7
|
+
data.tar.gz: 886a1812ab705290b6cf3a97a242495371b46e56e8b3b6fdd1e7a8469d84e957137b33f0d2963bd6c39e127ee13571131c554d8e48bb46c05c19b167ea6a2021
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
express_admin
|
2
2
|
=============
|
3
3
|
|
4
|
+
[](https://circleci.com/gh/aelogica/express_admin/tree/master)
|
5
|
+
|
4
6
|
ExpressAdmin is a common admin layout based on [Foundation](http://foundation.zurb.com). It also provides tools for creating modules for [AppExpress](http://www.appexpress.io).
|
5
7
|
|
6
8
|

|
@@ -1,4 +1,4 @@
|
|
1
|
-
form
|
1
|
+
.smart-form, .express-form
|
2
2
|
margin:
|
3
3
|
bottom: 1rem
|
4
4
|
|
@@ -8,6 +8,19 @@ form
|
|
8
8
|
select[multiple]
|
9
9
|
height: 6rem
|
10
10
|
|
11
|
+
.error
|
12
|
+
border: none
|
13
|
+
input, select, textarea, .select2-container
|
14
|
+
border: 1px solid $red
|
15
|
+
|
16
|
+
.help
|
17
|
+
font:
|
18
|
+
size: 0.9em
|
19
|
+
padding: 1em 0
|
20
|
+
margin:
|
21
|
+
bottom: 0
|
22
|
+
top: 0.5em
|
23
|
+
|
11
24
|
.help
|
12
25
|
color: $gray
|
13
26
|
font:
|
@@ -17,4 +30,4 @@ form
|
|
17
30
|
background: #fff
|
18
31
|
border: 1px solid #ddd
|
19
32
|
margin: 100px 0
|
20
|
-
padding: 40px 20px 0 20px
|
33
|
+
padding: 40px 20px 0 20px
|
@@ -21,19 +21,22 @@ module ExpressAdmin
|
|
21
21
|
|
22
22
|
def definitions
|
23
23
|
if config[:list].kind_of?(Array)
|
24
|
-
definitions_from_array(
|
24
|
+
definitions_from_array(config[:list])
|
25
25
|
elsif config[:list].kind_of?(Hash)
|
26
|
-
definitions_from_hash(
|
26
|
+
definitions_from_hash(config[:list])
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def definitions_from_hash(hash)
|
31
31
|
processed = hash.map do |k,v|
|
32
|
-
if v.kind_of? Symbol
|
33
|
-
|
32
|
+
value = if v.kind_of? Symbol
|
33
|
+
resource.send(v)
|
34
|
+
elsif v.respond_to?(:call)
|
35
|
+
v.call(resource).html_safe
|
34
36
|
else
|
35
|
-
|
37
|
+
v
|
36
38
|
end
|
39
|
+
[promptify(k), value]
|
37
40
|
end
|
38
41
|
Hash[processed]
|
39
42
|
end
|
@@ -4,7 +4,7 @@ module ExpressAdmin
|
|
4
4
|
class SmartForm < ExpressTemplates::Components::Forms::ExpressForm
|
5
5
|
TIMESTAMPS = %w(updated_at created_at)
|
6
6
|
|
7
|
-
has_option :
|
7
|
+
has_option :virtual, 'Override the list of virtual attributes of the resource to be displayed'
|
8
8
|
has_option :exclude, 'Attributes not to be included in the form'
|
9
9
|
has_option :only, 'Respects the order the attributes are listed in'
|
10
10
|
has_option :show_timestamps, 'Set to true to show timestamps as labels'
|
@@ -41,6 +41,7 @@ module ExpressAdmin
|
|
41
41
|
'datetime_select' => 'datetime',
|
42
42
|
'check_box' => 'checkbox'}
|
43
43
|
field_type = attrib.field_type.to_s.sub(/_field$/,'')
|
44
|
+
field_type = "password" if attrib.name.match(/password/)
|
44
45
|
if relation = attrib.name.match(/(\w+)_id$/).try(:[], 1)
|
45
46
|
# TODO: should allow select2 override
|
46
47
|
select(attrib.name.to_sym, options: config["#{relation}_collection".to_sym], select2: true)
|
@@ -8,7 +8,7 @@ module ExpressAdmin
|
|
8
8
|
|
9
9
|
attr :columns
|
10
10
|
|
11
|
-
has_option :scrollable, 'Set to true if the table should be scrollable'
|
11
|
+
has_option :scrollable, 'Set to true if the table should be scrollable', type: :boolean, default: false
|
12
12
|
has_option :show_actions, 'Set to true if table has actions for each row'
|
13
13
|
has_option :row_class, 'Add a class to each table row'
|
14
14
|
|
@@ -51,6 +51,7 @@ module ExpressAdmin
|
|
51
51
|
}
|
52
52
|
|
53
53
|
before_build -> {
|
54
|
+
_initialize_columns
|
54
55
|
add_class 'table striped'
|
55
56
|
}
|
56
57
|
|
@@ -130,7 +131,7 @@ module ExpressAdmin
|
|
130
131
|
end
|
131
132
|
|
132
133
|
def display_columns
|
133
|
-
specified_columns? ? columns : columns.slice(1..MAX_COLS_TO_SHOW_IDX)
|
134
|
+
specified_columns? ? @columns : @columns.slice(1..MAX_COLS_TO_SHOW_IDX)
|
134
135
|
end
|
135
136
|
|
136
137
|
def columns_hidden?
|
@@ -146,10 +147,6 @@ module ExpressAdmin
|
|
146
147
|
end
|
147
148
|
end
|
148
149
|
|
149
|
-
def columns
|
150
|
-
@columns ||= _initialize_columns
|
151
|
-
end
|
152
|
-
|
153
150
|
def specified_columns?
|
154
151
|
!!specified_columns
|
155
152
|
end
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
flash_messages
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails.application.config.tinymce.config_path = '../tinymce.yml'
|
data/config/tinymce.yml
CHANGED
@@ -3,14 +3,16 @@ default:
|
|
3
3
|
theme: 'modern'
|
4
4
|
height: 400
|
5
5
|
toolbar:
|
6
|
-
- bold italic underline strikethrough | link unlink | bullist numlist
|
6
|
+
- bold italic underline strikethrough | link unlink | bullist numlist
|
7
|
+
- table | nonbreaking hr | formatselect | blockquote | alignleft aligncenter alignright alignjustify
|
8
|
+
- outdent indent | image media | forecolor charmap | spellchecker removeformat | pastetext searchreplace | undo redo | code | fullscreen
|
7
9
|
relative_urls: false
|
8
10
|
remove_script_host: false
|
9
11
|
convert_urls: true
|
12
|
+
resize: false
|
10
13
|
plugins:
|
11
14
|
- advlist
|
12
15
|
- anchor
|
13
|
-
- anchor
|
14
16
|
- autolink
|
15
17
|
- charmap
|
16
18
|
- code
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ExpressAdmin
|
4
|
+
|
5
|
+
class DefinitionListTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
def assigns
|
8
|
+
{list_types: list_types}
|
9
|
+
end
|
10
|
+
|
11
|
+
def helpers
|
12
|
+
mock_action_view(assigns)
|
13
|
+
end
|
14
|
+
|
15
|
+
def list_types
|
16
|
+
@list_types ||= OpenStruct.new(
|
17
|
+
array: ["field1", "field2"],
|
18
|
+
hash: {term1: "def1",
|
19
|
+
term2: "def2",
|
20
|
+
term3: "def3"})
|
21
|
+
end
|
22
|
+
|
23
|
+
def deflist(*args)
|
24
|
+
arbre {
|
25
|
+
definition_list(:deflist, *args)
|
26
|
+
}.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
test "accepts array as input" do
|
30
|
+
assert deflist(list_types[:array])
|
31
|
+
end
|
32
|
+
|
33
|
+
test "accepts hash as input" do
|
34
|
+
assert deflist(list_types[:hash])
|
35
|
+
end
|
36
|
+
|
37
|
+
test "uses keys as labels and values as definitions" do
|
38
|
+
assert_match /<dt>Term1/, deflist(list_types[:hash])
|
39
|
+
end
|
40
|
+
|
41
|
+
DEFLIST_MARKUP_ARR = <<-HTML
|
42
|
+
<dl class="definition-list" id="deflist">
|
43
|
+
<dt>Field1:</dt>
|
44
|
+
<dd>{{resource.field1}}</dd>
|
45
|
+
<dt>Field2:</dt>
|
46
|
+
<dd>{{resource.field2}}</dd>
|
47
|
+
</dl>
|
48
|
+
HTML
|
49
|
+
|
50
|
+
DEFLIST_MARKUP_HASH = <<-HTML
|
51
|
+
<dl class="definition-list" id="deflist">
|
52
|
+
<dt>Term1:</dt>
|
53
|
+
<dd>def1</dd>
|
54
|
+
<dt>Term2:</dt>
|
55
|
+
<dd>def2</dd>
|
56
|
+
<dt>Term3:</dt>
|
57
|
+
<dd>def3</dd>
|
58
|
+
</dl>
|
59
|
+
HTML
|
60
|
+
|
61
|
+
test "definition_list renders correct markup with hash input" do
|
62
|
+
assert_equal DEFLIST_MARKUP_HASH, deflist(list_types[:hash])
|
63
|
+
end
|
64
|
+
|
65
|
+
test "definition_list renders correct markup with array input" do
|
66
|
+
assert_equal DEFLIST_MARKUP_ARR, deflist(list_types[:array])
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ExpressAdmin
|
4
|
+
|
5
|
+
class DefinitionTableTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
def assigns
|
8
|
+
{list_types: list_types}
|
9
|
+
end
|
10
|
+
|
11
|
+
def helpers
|
12
|
+
mock_action_view(assigns)
|
13
|
+
end
|
14
|
+
|
15
|
+
def list_types
|
16
|
+
@list_types ||= OpenStruct.new(
|
17
|
+
array: ["field1", "field2"],
|
18
|
+
hash: {term1: "def1",
|
19
|
+
term2: "def2",
|
20
|
+
term3: "def3"})
|
21
|
+
end
|
22
|
+
|
23
|
+
def deftable(*args)
|
24
|
+
arbre {
|
25
|
+
definition_table(:deftable, *args)
|
26
|
+
}.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
DEFTABLE_MARKUP = <<-HTML
|
30
|
+
<table class="definition-table" id="deftable">
|
31
|
+
<tbody>
|
32
|
+
<tr>
|
33
|
+
<th align="right">Term1:</th>
|
34
|
+
<td>def1</td>
|
35
|
+
</tr>
|
36
|
+
<tr>
|
37
|
+
<th align="right">Term2:</th>
|
38
|
+
<td>def2</td>
|
39
|
+
</tr>
|
40
|
+
<tr>
|
41
|
+
<th align="right">Term3:</th>
|
42
|
+
<td>def3</td>
|
43
|
+
</tr>
|
44
|
+
</tbody>
|
45
|
+
</table>
|
46
|
+
HTML
|
47
|
+
|
48
|
+
DEFTABLE_MARKUP_ARR = <<-HTML
|
49
|
+
<table class="definition-table" id="deftable">
|
50
|
+
<tbody>
|
51
|
+
<tr>
|
52
|
+
<th align="right">Field1:</th>
|
53
|
+
<td>{{resource.field1}}</td>
|
54
|
+
</tr>
|
55
|
+
<tr>
|
56
|
+
<th align="right">Field2:</th>
|
57
|
+
<td>{{resource.field2}}</td>
|
58
|
+
</tr>
|
59
|
+
</tbody>
|
60
|
+
</table>
|
61
|
+
HTML
|
62
|
+
|
63
|
+
test "definition_table renders correct markup with hash input" do
|
64
|
+
assert_equal DEFTABLE_MARKUP, deftable(list_types[:hash])
|
65
|
+
end
|
66
|
+
|
67
|
+
test "definition_table renders correct markup with array input" do
|
68
|
+
assert_equal DEFTABLE_MARKUP_ARR, deftable(list_types[:array])
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Components
|
4
|
+
|
5
|
+
class FlashMessagesTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
def assigns
|
8
|
+
{ flash: flash }
|
9
|
+
end
|
10
|
+
|
11
|
+
def flash
|
12
|
+
{notice: "Message"}
|
13
|
+
end
|
14
|
+
|
15
|
+
def helpers
|
16
|
+
view = mock_action_view(assigns)
|
17
|
+
end
|
18
|
+
|
19
|
+
def flashmsg
|
20
|
+
arbre {
|
21
|
+
flash_messages
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
test "renders" do
|
26
|
+
assert flashmsg
|
27
|
+
end
|
28
|
+
|
29
|
+
test "shows correct flash message" do
|
30
|
+
assert_match /<span>Message<\/span>/, flashmsg
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ExpressAdmin
|
4
|
+
|
5
|
+
class IconLinkTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
def assigns
|
8
|
+
{resource: resource}
|
9
|
+
end
|
10
|
+
|
11
|
+
def resource
|
12
|
+
@resource ||= OpenStruct.new(
|
13
|
+
text: 'Beer',
|
14
|
+
title: 'beer icon',
|
15
|
+
target: '_blank',
|
16
|
+
right: true,
|
17
|
+
delete: true,
|
18
|
+
confirm: true,
|
19
|
+
href: 'http://something.com'
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def helpers
|
24
|
+
mock_action_view(assigns)
|
25
|
+
end
|
26
|
+
|
27
|
+
def rendered_icon_link(*args)
|
28
|
+
arbre {
|
29
|
+
icon_link(:beer, *args)
|
30
|
+
}.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
test "renders" do
|
34
|
+
assert rendered_icon_link
|
35
|
+
end
|
36
|
+
|
37
|
+
test "icon link href default is set to #" do
|
38
|
+
assert_match /href="#"/, rendered_icon_link
|
39
|
+
end
|
40
|
+
|
41
|
+
test "icon-link target set to blank" do
|
42
|
+
# binding.pry
|
43
|
+
assert_match /target="_blank"/, rendered_icon_link(target: "#{resource[:target]}")
|
44
|
+
end
|
45
|
+
|
46
|
+
test "delete attribute is true" do
|
47
|
+
assert_match /data-delete="true"/, rendered_icon_link(delete: resource[:delete])
|
48
|
+
end
|
49
|
+
|
50
|
+
test "confirm attribute is true" do
|
51
|
+
assert_match /data-confirm="true"/, rendered_icon_link(confirm: resource[:confirm])
|
52
|
+
end
|
53
|
+
|
54
|
+
test "icon link has title set" do
|
55
|
+
assert_match /title="beer icon"/, rendered_icon_link(title: "#{resource[:title]}")
|
56
|
+
end
|
57
|
+
|
58
|
+
test "icon link has accompanying text" do
|
59
|
+
assert_match /i>\nBeer<\/a>/, rendered_icon_link(text: "#{resource[:text]}")
|
60
|
+
end
|
61
|
+
|
62
|
+
test "icon link has link set" do
|
63
|
+
assert_match /href="#{resource[:href]}"/, rendered_icon_link(href: "#{resource[:href]}")
|
64
|
+
end
|
65
|
+
|
66
|
+
MARKUP_RIGHT = <<-HTML
|
67
|
+
<a class="icon-link" href="#">
|
68
|
+
Beer <i class="icon ion-beer"></i>
|
69
|
+
</a>
|
70
|
+
HTML
|
71
|
+
|
72
|
+
test "if icon-link is set to right" do
|
73
|
+
assert_equal MARKUP_RIGHT, rendered_icon_link(text: "#{resource[:text]}", right: "#{resource[:right]}")
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Components
|
4
|
+
|
5
|
+
class IconTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
def assigns
|
8
|
+
{}
|
9
|
+
end
|
10
|
+
|
11
|
+
def helpers
|
12
|
+
mock_action_view(assigns)
|
13
|
+
end
|
14
|
+
|
15
|
+
def rendered_icon(*args)
|
16
|
+
arbre {
|
17
|
+
icon(*args)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
test "accepts string as input for icon name as id" do
|
22
|
+
assert_match /i class="icon ion-beer"/, rendered_icon("beer")
|
23
|
+
end
|
24
|
+
|
25
|
+
test "accepts symbol as input for icon name as id" do
|
26
|
+
assert_match /i class="icon ion-beer"/, rendered_icon(:beer)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ExpressAdmin
|
4
|
+
|
5
|
+
class MegaMenuTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
class MenuItem
|
8
|
+
attr_accessor :title, :path
|
9
|
+
|
10
|
+
def initialize(title, path)
|
11
|
+
@title = title
|
12
|
+
@path = path
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def rendered_mega_menu
|
17
|
+
arbre {
|
18
|
+
mega_menu
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def helpers
|
23
|
+
OpenStruct.new(
|
24
|
+
admin_menus: [MenuItem.new('Big Menu', 'my_path'), MenuItem.new('Foo', 'another_path')],
|
25
|
+
my_path: 'evaled_path',
|
26
|
+
another_path: 'some_path'
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
test "renders" do
|
31
|
+
assert rendered_mega_menu
|
32
|
+
end
|
33
|
+
|
34
|
+
test "links menu to eval'd path" do
|
35
|
+
assert_match /href="evaled_path"/, rendered_mega_menu
|
36
|
+
assert_match /href="some_path"/, rendered_mega_menu
|
37
|
+
end
|
38
|
+
|
39
|
+
test "replaces whitespace in menu title to underscore for icon class" do
|
40
|
+
assert_match /icon-express_big_menu/, rendered_mega_menu
|
41
|
+
assert_match /icon-express_foo/, rendered_mega_menu
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Components
|
4
|
+
|
5
|
+
class ModuleSidebarTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
class MenuItem
|
8
|
+
attr_accessor :title, :path, :items
|
9
|
+
|
10
|
+
def initialize(title, path, items)
|
11
|
+
@title = title
|
12
|
+
@path = path
|
13
|
+
@items = items
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def rendered_module_sidebar
|
18
|
+
arbre {
|
19
|
+
module_sidebar
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def assigns
|
24
|
+
{ current_menu: current_menu,
|
25
|
+
current_menu_name: current_menu_name,
|
26
|
+
foo_path: 'foo',
|
27
|
+
bar_path: 'bar',
|
28
|
+
baz_path: 'baz'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def current_menu
|
33
|
+
MenuItem.new('Big Menu', 'menu_path', [
|
34
|
+
MenuItem.new('Foo', 'foo_path',[]),
|
35
|
+
MenuItem.new('Bar', 'bar_path', []),
|
36
|
+
MenuItem.new('Baz', 'baz_path', [])])
|
37
|
+
end
|
38
|
+
|
39
|
+
def current_menu_name
|
40
|
+
current_menu.title
|
41
|
+
end
|
42
|
+
|
43
|
+
def helpers
|
44
|
+
mock_action_view(assigns)
|
45
|
+
end
|
46
|
+
|
47
|
+
test "renders the correct current menu name as sidebar title" do
|
48
|
+
assert_match /class="title">Big Menu/, rendered_module_sidebar
|
49
|
+
end
|
50
|
+
|
51
|
+
test "evals the correct path" do
|
52
|
+
assert_equal "foo", helpers.instance_eval(current_menu.items.first.path)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ExpressAdmin
|
4
|
+
|
5
|
+
class WidgetBoxTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
def helpers
|
8
|
+
mock_action_view(assigns)
|
9
|
+
end
|
10
|
+
|
11
|
+
def assigns
|
12
|
+
{resource: Widget.first}
|
13
|
+
end
|
14
|
+
|
15
|
+
def rendered_widget_box(*args)
|
16
|
+
arbre {
|
17
|
+
widget_box(:test, *args)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
test "renders correct widget box title" do
|
22
|
+
assert_match /<header class="title">Edit Test/, rendered_widget_box
|
23
|
+
end
|
24
|
+
|
25
|
+
test "renders correct widget box title with param" do
|
26
|
+
assert_match /<header class="title">Widget Box/, rendered_widget_box(title: "Widget Box")
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -40,7 +40,7 @@ Everything should work as you would expect.
|
|
40
40
|
|
41
41
|
Set your editor syntax for .et files to Ruby.
|
42
42
|
|
43
|
-
You can now utilize components which are found with documentation and examples in <tt>ExpressTemplates::Components
|
43
|
+
You can now utilize components which are found with documentation and examples in <tt>ExpressTemplates::Components</tt>.
|
44
44
|
|
45
45
|
Components are the real strength of both arbre and express_templates.
|
46
46
|
|
Binary file
|
Binary file
|
@@ -29,7 +29,8 @@ class Proc
|
|
29
29
|
tokens = Ripper.lex File.read(file)
|
30
30
|
tokens_on_line = tokens.select {|pos, lbl, str| pos[0].eql?(line_no) }
|
31
31
|
starting_token = tokens_on_line.detect do |pos, lbl, str|
|
32
|
-
TOKEN_PAIRS.keys.include?
|
32
|
+
TOKEN_PAIRS.keys.include?([lbl, str]) &&
|
33
|
+
_actually_starting_a_proc?(tokens, [pos, lbl, str])
|
33
34
|
end
|
34
35
|
starting_token_type = [starting_token[1], starting_token[2]]
|
35
36
|
ending_token_type = TOKEN_PAIRS[starting_token_type]
|
@@ -54,6 +55,17 @@ class Proc
|
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
58
|
+
def _actually_starting_a_proc?(tokens, tok)
|
59
|
+
return true if tokens.index(tok).eql?(0)
|
60
|
+
look_back = tokens.slice(0..tokens.index(tok)-1)
|
61
|
+
look_back.pop if look_back.last.try(:[], 1).eql? :on_sp
|
62
|
+
if [:on_tlambeg, :on_tlambda].include?(tok[1])
|
63
|
+
true
|
64
|
+
else
|
65
|
+
![:on_comma, :on_lparen, :on_label].include?(look_back.last.try(:[], 1))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
57
69
|
# Examines the source of a proc to extract the body by
|
58
70
|
# removing the outermost block delimiters and any surrounding.
|
59
71
|
# whitespace.
|
data/vendor/gems/express_templates/lib/express_templates/components/capabilities/resourceful.rb
CHANGED
@@ -6,6 +6,7 @@ module ExpressTemplates
|
|
6
6
|
|
7
7
|
def self.included(base)
|
8
8
|
base.class_eval do
|
9
|
+
has_argument :id, "The name of the collection", type: :symbol, optional: false
|
9
10
|
has_option :collection, 'Provide an explicit collection as a resource.'
|
10
11
|
has_option :collection_path, 'Provide an explicit path for the collection resource.'
|
11
12
|
has_option :resource_class, 'Overrides namespaced resource_class for using resources from a different module or namespace.'
|