wallaby 4.1.6
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 +29 -0
- data/app/assets/javascripts/wallaby/application.js +15 -0
- data/app/assets/javascripts/wallaby/form.js +8 -0
- data/app/assets/stylesheets/wallaby/application.scss +51 -0
- data/app/assets/stylesheets/wallaby/base/_functions.scss +0 -0
- data/app/assets/stylesheets/wallaby/base/_layout.scss +14 -0
- data/app/assets/stylesheets/wallaby/base/_mixins.scss +0 -0
- data/app/assets/stylesheets/wallaby/base/_normalize.scss +0 -0
- data/app/assets/stylesheets/wallaby/base/_reset.scss +0 -0
- data/app/assets/stylesheets/wallaby/base/_vars.scss +5 -0
- data/app/assets/stylesheets/wallaby/components/_forms.scss +53 -0
- data/app/assets/stylesheets/wallaby/components/_nav.scss +19 -0
- data/app/assets/stylesheets/wallaby/components/_pagination.scss +105 -0
- data/app/assets/stylesheets/wallaby/components/_tables.scss +78 -0
- data/app/assets/stylesheets/wallaby/components/_text.scss +11 -0
- data/app/assets/stylesheets/wallaby/form.scss +11 -0
- data/app/assets/stylesheets/wallaby/summernote.scss.erb +7 -0
- data/app/controllers/wallaby/application_controller.rb +21 -0
- data/app/controllers/wallaby/core_controller.rb +28 -0
- data/app/controllers/wallaby/resources_controller.rb +134 -0
- data/app/controllers/wallaby/secure_controller.rb +42 -0
- data/app/routes/wallaby/resources_router.rb +52 -0
- data/app/security/ability.rb +33 -0
- data/app/views/layouts/wallaby/_footer.html.erb +2 -0
- data/app/views/layouts/wallaby/_header.html.erb +57 -0
- data/app/views/layouts/wallaby/_navs.html.erb +1 -0
- data/app/views/layouts/wallaby/application.html.erb +22 -0
- data/app/views/layouts/wallaby/error.html.erb +20 -0
- data/app/views/wallaby/core/home.html.erb +5 -0
- data/app/views/wallaby/errors/access_denied.html.erb +1 -0
- data/app/views/wallaby/errors/not_authenticated.html.erb +1 -0
- data/app/views/wallaby/errors/not_found.html.erb +6 -0
- data/app/views/wallaby/errors/unprocessable_entity.erb +1 -0
- data/app/views/wallaby/resources/_form.html.erb +12 -0
- data/app/views/wallaby/resources/_index_actions.html.erb +1 -0
- data/app/views/wallaby/resources/_resource_actions.html.erb +3 -0
- data/app/views/wallaby/resources/edit.html.erb +14 -0
- data/app/views/wallaby/resources/form/_belongs_to.html.erb +21 -0
- data/app/views/wallaby/resources/form/_bigint.html.erb +9 -0
- data/app/views/wallaby/resources/form/_binary.html.erb +12 -0
- data/app/views/wallaby/resources/form/_bit.html.erb +9 -0
- data/app/views/wallaby/resources/form/_bit_varying.html.erb +9 -0
- data/app/views/wallaby/resources/form/_boolean.html.erb +14 -0
- data/app/views/wallaby/resources/form/_cidr.html.erb +9 -0
- data/app/views/wallaby/resources/form/_citext.html.erb +21 -0
- data/app/views/wallaby/resources/form/_color.html.erb +20 -0
- data/app/views/wallaby/resources/form/_date.html.erb +29 -0
- data/app/views/wallaby/resources/form/_daterange.html.erb +37 -0
- data/app/views/wallaby/resources/form/_datetime.html.erb +30 -0
- data/app/views/wallaby/resources/form/_decimal.html.erb +9 -0
- data/app/views/wallaby/resources/form/_email.html.erb +5 -0
- data/app/views/wallaby/resources/form/_float.html.erb +9 -0
- data/app/views/wallaby/resources/form/_has_and_belongs_to_many.html.erb +13 -0
- data/app/views/wallaby/resources/form/_has_many.html.erb +13 -0
- data/app/views/wallaby/resources/form/_has_one.html.erb +7 -0
- data/app/views/wallaby/resources/form/_hstore.html.erb +25 -0
- data/app/views/wallaby/resources/form/_inet.html.erb +9 -0
- data/app/views/wallaby/resources/form/_int4range.html.erb +18 -0
- data/app/views/wallaby/resources/form/_int8range.html.erb +18 -0
- data/app/views/wallaby/resources/form/_integer.html.erb +9 -0
- data/app/views/wallaby/resources/form/_json.html.erb +23 -0
- data/app/views/wallaby/resources/form/_jsonb.html.erb +23 -0
- data/app/views/wallaby/resources/form/_ltree.html.erb +5 -0
- data/app/views/wallaby/resources/form/_macaddr.html.erb +9 -0
- data/app/views/wallaby/resources/form/_money.html.erb +12 -0
- data/app/views/wallaby/resources/form/_numrange.html.erb +18 -0
- data/app/views/wallaby/resources/form/_password.html.erb +5 -0
- data/app/views/wallaby/resources/form/_point.html.erb +18 -0
- data/app/views/wallaby/resources/form/_string.html.erb +5 -0
- data/app/views/wallaby/resources/form/_text.html.erb +21 -0
- data/app/views/wallaby/resources/form/_time.html.erb +29 -0
- data/app/views/wallaby/resources/form/_tsrange.html.erb +38 -0
- data/app/views/wallaby/resources/form/_tstzrange.html.erb +38 -0
- data/app/views/wallaby/resources/form/_tsvector.html.erb +5 -0
- data/app/views/wallaby/resources/form/_uuid.html.erb +9 -0
- data/app/views/wallaby/resources/form/_xml.html.erb +23 -0
- data/app/views/wallaby/resources/index/_belongs_to.html.erb +1 -0
- data/app/views/wallaby/resources/index/_bigint.html.erb +1 -0
- data/app/views/wallaby/resources/index/_binary.html.erb +1 -0
- data/app/views/wallaby/resources/index/_bit.html.erb +5 -0
- data/app/views/wallaby/resources/index/_bit_varying.html.erb +5 -0
- data/app/views/wallaby/resources/index/_boolean.html.erb +5 -0
- data/app/views/wallaby/resources/index/_cidr.html.erb +6 -0
- data/app/views/wallaby/resources/index/_citext.html.erb +12 -0
- data/app/views/wallaby/resources/index/_color.html.erb +5 -0
- data/app/views/wallaby/resources/index/_date.html.erb +7 -0
- data/app/views/wallaby/resources/index/_daterange.html.erb +8 -0
- data/app/views/wallaby/resources/index/_datetime.html.erb +7 -0
- data/app/views/wallaby/resources/index/_decimal.html.erb +1 -0
- data/app/views/wallaby/resources/index/_email.html.erb +1 -0
- data/app/views/wallaby/resources/index/_float.html.erb +1 -0
- data/app/views/wallaby/resources/index/_has_and_belongs_to_many.html.erb +11 -0
- data/app/views/wallaby/resources/index/_has_many.html.erb +11 -0
- data/app/views/wallaby/resources/index/_has_one.html.erb +1 -0
- data/app/views/wallaby/resources/index/_hstore.html.erb +12 -0
- data/app/views/wallaby/resources/index/_inet.html.erb +6 -0
- data/app/views/wallaby/resources/index/_int4range.html.erb +7 -0
- data/app/views/wallaby/resources/index/_int8range.html.erb +7 -0
- data/app/views/wallaby/resources/index/_integer.html.erb +1 -0
- data/app/views/wallaby/resources/index/_json.html.erb +12 -0
- data/app/views/wallaby/resources/index/_jsonb.html.erb +12 -0
- data/app/views/wallaby/resources/index/_ltree.html.erb +12 -0
- data/app/views/wallaby/resources/index/_macaddr.html.erb +5 -0
- data/app/views/wallaby/resources/index/_money.html.erb +1 -0
- data/app/views/wallaby/resources/index/_numrange.html.erb +7 -0
- data/app/views/wallaby/resources/index/_point.html.erb +6 -0
- data/app/views/wallaby/resources/index/_string.html.erb +12 -0
- data/app/views/wallaby/resources/index/_text.html.erb +12 -0
- data/app/views/wallaby/resources/index/_time.html.erb +6 -0
- data/app/views/wallaby/resources/index/_tsrange.html.erb +8 -0
- data/app/views/wallaby/resources/index/_tstzrange.html.erb +8 -0
- data/app/views/wallaby/resources/index/_tsvector.html.erb +12 -0
- data/app/views/wallaby/resources/index/_uuid.html.erb +12 -0
- data/app/views/wallaby/resources/index/_xml.html.erb +12 -0
- data/app/views/wallaby/resources/index.html.erb +66 -0
- data/app/views/wallaby/resources/new.html.erb +14 -0
- data/app/views/wallaby/resources/shared/_resource_nav.html.erb +29 -0
- data/app/views/wallaby/resources/show/_belongs_to.html.erb +7 -0
- data/app/views/wallaby/resources/show/_bigint.html.erb +1 -0
- data/app/views/wallaby/resources/show/_binary.html.erb +1 -0
- data/app/views/wallaby/resources/show/_bit.html.erb +5 -0
- data/app/views/wallaby/resources/show/_bit_varying.html.erb +5 -0
- data/app/views/wallaby/resources/show/_boolean.html.erb +5 -0
- data/app/views/wallaby/resources/show/_cidr.html.erb +6 -0
- data/app/views/wallaby/resources/show/_citext.html.erb +1 -0
- data/app/views/wallaby/resources/show/_color.html.erb +5 -0
- data/app/views/wallaby/resources/show/_date.html.erb +7 -0
- data/app/views/wallaby/resources/show/_daterange.html.erb +7 -0
- data/app/views/wallaby/resources/show/_datetime.html.erb +6 -0
- data/app/views/wallaby/resources/show/_decimal.html.erb +1 -0
- data/app/views/wallaby/resources/show/_email.html.erb +1 -0
- data/app/views/wallaby/resources/show/_float.html.erb +1 -0
- data/app/views/wallaby/resources/show/_has_and_belongs_to_many.html.erb +5 -0
- data/app/views/wallaby/resources/show/_has_many.html.erb +5 -0
- data/app/views/wallaby/resources/show/_has_one.html.erb +1 -0
- data/app/views/wallaby/resources/show/_hstore.html.erb +5 -0
- data/app/views/wallaby/resources/show/_inet.html.erb +6 -0
- data/app/views/wallaby/resources/show/_int4range.html.erb +7 -0
- data/app/views/wallaby/resources/show/_int8range.html.erb +7 -0
- data/app/views/wallaby/resources/show/_integer.html.erb +1 -0
- data/app/views/wallaby/resources/show/_json.html.erb +5 -0
- data/app/views/wallaby/resources/show/_jsonb.html.erb +5 -0
- data/app/views/wallaby/resources/show/_ltree.html.erb +1 -0
- data/app/views/wallaby/resources/show/_macaddr.html.erb +5 -0
- data/app/views/wallaby/resources/show/_money.html.erb +1 -0
- data/app/views/wallaby/resources/show/_numrange.html.erb +7 -0
- data/app/views/wallaby/resources/show/_point.html.erb +6 -0
- data/app/views/wallaby/resources/show/_string.html.erb +1 -0
- data/app/views/wallaby/resources/show/_text.html.erb +1 -0
- data/app/views/wallaby/resources/show/_time.html.erb +6 -0
- data/app/views/wallaby/resources/show/_tsrange.html.erb +7 -0
- data/app/views/wallaby/resources/show/_tstzrange.html.erb +7 -0
- data/app/views/wallaby/resources/show/_tsvector.html.erb +1 -0
- data/app/views/wallaby/resources/show/_uuid.html.erb +5 -0
- data/app/views/wallaby/resources/show/_xml.html.erb +5 -0
- data/app/views/wallaby/resources/show.html.erb +31 -0
- data/app/views/wallaby/shared/_flash_messages.html.erb +13 -0
- data/config/locales/en.yml +29 -0
- data/config/routes.rb +34 -0
- data/lib/adaptors/wallaby/active_record/model_decorator/fields_builder.rb +105 -0
- data/lib/adaptors/wallaby/active_record/model_decorator/title_field_finder.rb +18 -0
- data/lib/adaptors/wallaby/active_record/model_decorator.rb +81 -0
- data/lib/adaptors/wallaby/active_record/model_finder.rb +12 -0
- data/lib/adaptors/wallaby/active_record/model_operator/normalizer.rb +44 -0
- data/lib/adaptors/wallaby/active_record/model_operator/permitter.rb +50 -0
- data/lib/adaptors/wallaby/active_record/model_operator/querier.rb +47 -0
- data/lib/adaptors/wallaby/active_record/model_operator/validator.rb +16 -0
- data/lib/adaptors/wallaby/active_record/model_operator.rb +82 -0
- data/lib/adaptors/wallaby/active_record.rb +2 -0
- data/lib/decorators/wallaby/resource_decorator.rb +78 -0
- data/lib/errors/wallaby/deprecated.rb +4 -0
- data/lib/errors/wallaby/general_error.rb +4 -0
- data/lib/errors/wallaby/invalid_error.rb +4 -0
- data/lib/errors/wallaby/model_not_found.rb +4 -0
- data/lib/errors/wallaby/not_authenticated.rb +4 -0
- data/lib/errors/wallaby/not_implemented.rb +4 -0
- data/lib/errors/wallaby/operation_not_found.rb +4 -0
- data/lib/errors/wallaby/resource_not_found.rb +4 -0
- data/lib/forms/wallaby/form_builder.rb +30 -0
- data/lib/handlers/wallaby/cached_compiled_erb.rb +14 -0
- data/lib/helpers/wallaby/application_helper.rb +30 -0
- data/lib/helpers/wallaby/core_helper.rb +50 -0
- data/lib/helpers/wallaby/form_helper.rb +21 -0
- data/lib/helpers/wallaby/links_helper.rb +83 -0
- data/lib/helpers/wallaby/paginatable_helper.rb +9 -0
- data/lib/helpers/wallaby/resources_helper.rb +55 -0
- data/lib/helpers/wallaby/secure_helper.rb +25 -0
- data/lib/helpers/wallaby/sorting_helper.rb +43 -0
- data/lib/helpers/wallaby/styling_helper.rb +57 -0
- data/lib/interfaces/wallaby/mode.rb +18 -0
- data/lib/interfaces/wallaby/model_decorator.rb +58 -0
- data/lib/interfaces/wallaby/model_finder.rb +5 -0
- data/lib/interfaces/wallaby/model_operator.rb +31 -0
- data/lib/services/wallaby/decorator_finder.rb +16 -0
- data/lib/services/wallaby/lookup_context_wrapper.rb +40 -0
- data/lib/services/wallaby/map.rb +53 -0
- data/lib/services/wallaby/model_servicer.rb +38 -0
- data/lib/services/wallaby/servicer_finder.rb +5 -0
- data/lib/tasks/wallaby_tasks.rake +4 -0
- data/lib/utils/wallaby/utils.rb +31 -0
- data/lib/wallaby/configuration/models.rb +17 -0
- data/lib/wallaby/configuration/security.rb +30 -0
- data/lib/wallaby/configuration.rb +49 -0
- data/lib/wallaby/engine.rb +89 -0
- data/lib/wallaby/version.rb +3 -0
- data/lib/wallaby.rb +5 -0
- metadata +459 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
<% if value.nil? %>
|
2
|
+
<%= null %>
|
3
|
+
<% else %>
|
4
|
+
<% max = metadata[:max] || 20 %>
|
5
|
+
<% value = value.to_s %>
|
6
|
+
<% if value.length > max %>
|
7
|
+
<code><%= value.truncate max %></code>
|
8
|
+
<%= imodal metadata[:label], "<pre>#{ h value }</pre>".html_safe %>
|
9
|
+
<% else %>
|
10
|
+
<code><%= value %></code>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<%
|
2
|
+
# decorate first on every page or partial
|
3
|
+
decorated_collection = decorate collection
|
4
|
+
%>
|
5
|
+
<section>
|
6
|
+
<% # Search form %>
|
7
|
+
<div class="search-form <%= params[:sort].present? && 'sort' || '' %>">
|
8
|
+
<div class="right">
|
9
|
+
<%= index_link(current_model_class, class: 'btn btn-default') { ct 'link.clear_sort' } if params[:sort].present? %>
|
10
|
+
<%= render 'index_actions' %>
|
11
|
+
</div>
|
12
|
+
<%= form_tag wallaby_engine.resources_path, method: :get do %>
|
13
|
+
<%= text_field_tag :q, request.query_parameters[:q], placeholder: "Press enter to search. Example: 'text_keyword1 text_keyword2 field_name:value'" %>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
<% # /Search form %>
|
17
|
+
<%= render 'wallaby/shared/flash_messages' %>
|
18
|
+
<% # Data table %>
|
19
|
+
<table class="data-table">
|
20
|
+
<thead>
|
21
|
+
<tr>
|
22
|
+
<% current_model_decorator.index_field_names.each do |field_name| %>
|
23
|
+
<th class="<%= sort_class field_name %>">
|
24
|
+
<%= sort_link field_name %>
|
25
|
+
</th>
|
26
|
+
<% end %>
|
27
|
+
<th>Actions</th>
|
28
|
+
</tr>
|
29
|
+
</thead>
|
30
|
+
<tbody>
|
31
|
+
<% if decorated_collection.present? %>
|
32
|
+
<% decorated_collection.each do |decorated| %>
|
33
|
+
<tr>
|
34
|
+
<% current_model_decorator.index_field_names.each do |field_name| %>
|
35
|
+
<td>
|
36
|
+
<%= index_type_partial_render decorated.index_type_of(field_name), object: decorated, field_name: field_name %>
|
37
|
+
</td>
|
38
|
+
<% end %>
|
39
|
+
<td>
|
40
|
+
<%= render 'resource_actions', decorated: decorated %>
|
41
|
+
</td>
|
42
|
+
</tr>
|
43
|
+
<% end %>
|
44
|
+
<% else %>
|
45
|
+
<tr>
|
46
|
+
<td colspan="<%= current_model_decorator.index_field_names.length + 1 %>">
|
47
|
+
<%= t 'collection.not_found' %>
|
48
|
+
</td>
|
49
|
+
</tr>
|
50
|
+
<% end %>
|
51
|
+
</tbody>
|
52
|
+
</table>
|
53
|
+
<% # /Data table %>
|
54
|
+
<% # Kaminari pagination %>
|
55
|
+
<% if paginatable? collection %>
|
56
|
+
<div class="kaminari clearfix">
|
57
|
+
<div class="pull-left pagination-info">
|
58
|
+
<%= page_entries_info collection rescue custom_pagination_stats collection %>
|
59
|
+
</div>
|
60
|
+
<% _with_routes wallaby_engine do %>
|
61
|
+
<%= paginate collection rescue nil %>
|
62
|
+
<% end %>
|
63
|
+
</div>
|
64
|
+
<% end %>
|
65
|
+
<% # /Kaminari pagination %>
|
66
|
+
</section>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% decorated = decorate resource %>
|
2
|
+
<section>
|
3
|
+
<%= render 'wallaby/resources/shared/resource_nav' %>
|
4
|
+
<div class="page-header">
|
5
|
+
<h1>Create a <%= to_model_label current_resources_name %></h1>
|
6
|
+
</div>
|
7
|
+
<%= render 'wallaby/shared/flash_messages' %>
|
8
|
+
<%= form_for decorated, url: wallaby_engine.resources_path, method: :post, html: { :multipart => true }, builder: Wallaby::FormBuilder do |form| %>
|
9
|
+
<%= render 'form', form: form, decorated: decorated %>
|
10
|
+
<% end %>
|
11
|
+
</section>
|
12
|
+
|
13
|
+
<% content_for :custom_stylesheet, stylesheet_link_tag('wallaby/form', media: 'all', 'data-turbolinks-track' => true) %>
|
14
|
+
<% content_for :custom_javascript, javascript_include_tag('wallaby/form', 'data-turbolinks-track' => true) %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<nav class="pull-right">
|
2
|
+
<ul class="nav nav-pills">
|
3
|
+
<%# list %>
|
4
|
+
<li role="presentation">
|
5
|
+
<%= index_link { ct 'link.list' } %>
|
6
|
+
</li>
|
7
|
+
|
8
|
+
<%# show %>
|
9
|
+
<% if action_name == 'edit' %>
|
10
|
+
<li role="presentation">
|
11
|
+
<%= show_link(resource) { ct 'link.show' } %>
|
12
|
+
</li>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<%# edit %>
|
16
|
+
<% if action_name == 'show' %>
|
17
|
+
<li role="presentation">
|
18
|
+
<%= edit_link(resource) { ct 'link.edit' } %>
|
19
|
+
</li>
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
<%# delete %>
|
23
|
+
<% if action_name == 'show' %>
|
24
|
+
<li role="presentation">
|
25
|
+
<%= delete_link resource %>
|
26
|
+
</li>
|
27
|
+
<% end %>
|
28
|
+
</ul>
|
29
|
+
</nav>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value || null %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value ? na : null %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value || null %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value || null %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value.nil? ? null : mail_to(value) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value.try(:to_f) || null %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value.present? ? show_link(value) : new_link(metadata[:class]) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value || null %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value || null %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value || null %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value || null %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value || null %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= value || null %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<%
|
2
|
+
# decorate first on every page or partial
|
3
|
+
decorated = decorate resource
|
4
|
+
%>
|
5
|
+
<article>
|
6
|
+
<%= render 'wallaby/resources/shared/resource_nav' %>
|
7
|
+
<div class="page-header">
|
8
|
+
<h1>
|
9
|
+
<%= show_title decorated %>
|
10
|
+
</h1>
|
11
|
+
</div>
|
12
|
+
<%= render 'wallaby/shared/flash_messages' %>
|
13
|
+
<section class="fields">
|
14
|
+
<table class="detail-table">
|
15
|
+
<thead>
|
16
|
+
<tr>
|
17
|
+
<th>Field</th>
|
18
|
+
<th>Value</th>
|
19
|
+
</tr>
|
20
|
+
</thead>
|
21
|
+
<tbody>
|
22
|
+
<% decorated.show_field_names.each do |field_name| %>
|
23
|
+
<tr>
|
24
|
+
<th><%= decorated.show_label_of field_name %></th>
|
25
|
+
<td><%= type_partial_render decorated.show_type_of(field_name).to_s, object: decorated, field_name: field_name %></td>
|
26
|
+
</tr>
|
27
|
+
<% end %>
|
28
|
+
</tbody>
|
29
|
+
</table>
|
30
|
+
</section>
|
31
|
+
</article>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% flash_classes = {
|
2
|
+
'alert' => 'danger',
|
3
|
+
'error' => 'danger',
|
4
|
+
'notice' => 'success',
|
5
|
+
'success' => 'success',
|
6
|
+
'warning' => 'warning'
|
7
|
+
} %>
|
8
|
+
<% flash.each do |type, message| %>
|
9
|
+
<div class="alert alert-<%= flash_classes[type.to_s] || type %> alert-dismissible" role="alert">
|
10
|
+
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
11
|
+
<%= raw message %>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
+
|
22
|
+
en:
|
23
|
+
link:
|
24
|
+
new: Create
|
25
|
+
show: Show
|
26
|
+
edit: Edit
|
27
|
+
delete: Delete
|
28
|
+
confirm:
|
29
|
+
delete: Please confirm to delete
|
data/config/routes.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
Wallaby::Engine.routes.draw do
|
2
|
+
root to: 'wallaby/core#home'
|
3
|
+
|
4
|
+
get 'status', to: 'wallaby/core#status'
|
5
|
+
|
6
|
+
scope path: ':resources' do
|
7
|
+
with_options to: Wallaby::ResourcesRouter.new do |route|
|
8
|
+
begin # resourceful routes
|
9
|
+
route.get '',
|
10
|
+
defaults: { action: 'index' },
|
11
|
+
as: :resources
|
12
|
+
route.get 'new',
|
13
|
+
defaults: { action: 'new' },
|
14
|
+
as: :new_resource
|
15
|
+
route.get ':id/edit',
|
16
|
+
defaults: { action: 'edit' },
|
17
|
+
as: :edit_resource
|
18
|
+
route.get ':id',
|
19
|
+
defaults: { action: 'show' },
|
20
|
+
as: :resource
|
21
|
+
|
22
|
+
route.post '',
|
23
|
+
defaults: { action: 'create' }
|
24
|
+
route.match ':id',
|
25
|
+
via: %i( patch put ),
|
26
|
+
defaults: { action: 'update' }
|
27
|
+
route.delete ':id',
|
28
|
+
defaults: { action: 'destroy' }
|
29
|
+
end
|
30
|
+
route.match ':id/:action', via: :all, as: :member
|
31
|
+
route.match ':action', via: :all, as: :collection
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
class Wallaby::ActiveRecord::ModelDecorator::FieldsBuilder
|
2
|
+
def initialize(model_class)
|
3
|
+
@model_class = model_class
|
4
|
+
end
|
5
|
+
|
6
|
+
def general_fields
|
7
|
+
@model_class.columns.inject({}) do |fields, column|
|
8
|
+
fields[column.name] = {
|
9
|
+
name: column.name,
|
10
|
+
type: column.type.to_s,
|
11
|
+
label: @model_class.human_attribute_name(column.name),
|
12
|
+
is_origin: true
|
13
|
+
}
|
14
|
+
fields
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def association_fields
|
19
|
+
@model_class.reflections.inject({}) do |fields, (field_name, reflection)|
|
20
|
+
type = extract_type_from reflection
|
21
|
+
|
22
|
+
fields[field_name] = {
|
23
|
+
name: field_name,
|
24
|
+
type: type,
|
25
|
+
label: field_name.titleize,
|
26
|
+
is_origin: true,
|
27
|
+
is_association: true,
|
28
|
+
is_polymorphic: is_polymorphic?(reflection),
|
29
|
+
is_through: is_through?(reflection),
|
30
|
+
has_scope: has_scope?(reflection),
|
31
|
+
foreign_key: foreign_key_for(reflection, type),
|
32
|
+
polymorphic_type: polymorphic_type_for(reflection, type),
|
33
|
+
polymorphic_list: polymorphic_list_for(reflection),
|
34
|
+
class: class_for(reflection)
|
35
|
+
}
|
36
|
+
fields
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
def has_scope?(reflection)
|
42
|
+
reflection.scope.present?
|
43
|
+
end
|
44
|
+
|
45
|
+
def is_through?(reflection)
|
46
|
+
reflection.respond_to? :delegate_reflection
|
47
|
+
end
|
48
|
+
|
49
|
+
def is_polymorphic?(reflection)
|
50
|
+
reflection.options[:polymorphic].present?
|
51
|
+
end
|
52
|
+
|
53
|
+
def extract_type_from(reflection)
|
54
|
+
target = if is_through?(reflection)
|
55
|
+
reflection.delegate_reflection
|
56
|
+
else
|
57
|
+
reflection
|
58
|
+
end
|
59
|
+
target.class.name.match(/([^:]+)Reflection/)[1].underscore
|
60
|
+
end
|
61
|
+
|
62
|
+
def foreign_key_for(reflection, type)
|
63
|
+
if 'belongs_to' == type
|
64
|
+
reflection.foreign_key
|
65
|
+
else
|
66
|
+
reflection.association_foreign_key.try do |foreign_key|
|
67
|
+
/many/ =~ type ? "#{ foreign_key }s" : foreign_key
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def polymorphic_type_for(reflection, type)
|
73
|
+
if is_polymorphic? reflection
|
74
|
+
foreign_key = foreign_key_for reflection, type
|
75
|
+
foreign_key.gsub %r(_ids?$), '_type'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def polymorphic_list_for(reflection)
|
80
|
+
if is_polymorphic? reflection
|
81
|
+
available_model_class.inject([]) do |list, model_class|
|
82
|
+
if model_defined_polymorphic_name? model_class, reflection.name
|
83
|
+
list << model_class
|
84
|
+
end
|
85
|
+
list
|
86
|
+
end
|
87
|
+
end || []
|
88
|
+
end
|
89
|
+
|
90
|
+
def model_defined_polymorphic_name?(model_class, polymorphic_name)
|
91
|
+
model_class.reflections.any? do |field_name, reflection|
|
92
|
+
reflection.options[:as].to_s == polymorphic_name.to_s
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def available_model_class
|
97
|
+
Wallaby::Map.mode_map.select do |_, mode|
|
98
|
+
mode == Wallaby::ActiveRecord
|
99
|
+
end.keys
|
100
|
+
end
|
101
|
+
|
102
|
+
def class_for(reflection)
|
103
|
+
reflection.class_name.constantize if !is_polymorphic? reflection
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Wallaby::ActiveRecord::ModelDecorator::TitleFieldFinder
|
2
|
+
def initialize(model_class, fields)
|
3
|
+
@model_class = model_class
|
4
|
+
@fields = fields
|
5
|
+
end
|
6
|
+
|
7
|
+
def find
|
8
|
+
possible_title_fields = @fields.select do |field_name, metadata|
|
9
|
+
%w( string ).include? metadata[:type]
|
10
|
+
end
|
11
|
+
target_field = possible_title_fields.values.find do |metadata|
|
12
|
+
%w( name title string text ).any?{ |v| metadata[:name].index v }
|
13
|
+
end
|
14
|
+
target_field ||= possible_title_fields.values.first
|
15
|
+
target_field ||= { name: @model_class.primary_key }
|
16
|
+
target_field[:name]
|
17
|
+
end
|
18
|
+
end
|