-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract pages into templates for better overwriting (#209)
- Loading branch information
Showing
21 changed files
with
210 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<% | ||
# decorate first on every page or partial | ||
decorated = decorate resource | ||
%> | ||
<article class="resource"> | ||
<div class="resource__header"> | ||
<h1><%= wt 'labels.edit', id: decorated.id %></h1> | ||
<%= render 'resource_navs' %> | ||
</div> | ||
<%= render 'flash_messages' %> | ||
<section> | ||
<div class="resource__container"> | ||
<%= form_for decorated, | ||
url: url_for(action: :show), method: :put, | ||
html: { :multipart => true } do |form| %> | ||
<%= render 'form', form: form, decorated: decorated %> | ||
<% end %> | ||
</div> | ||
</section> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1> | ||
Welcome | ||
</h1> | ||
<%# TODO: turn this page into intro maybe? %> | ||
<%= render 'flash_messages' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<% | ||
# decorate first on every page or partial | ||
decorated_collection = decorate collection | ||
%> | ||
<article class="resources"> | ||
<div class="resources__header"> | ||
<h1><%= to_model_label(current_model_class) %></h1> | ||
<%= render 'index_query' %> | ||
<%= render 'index_filters' %> | ||
<%= render 'index_pagination' %> | ||
</div> | ||
<%= render 'flash_messages' %> | ||
|
||
<section> | ||
<% # Data table %> | ||
<% if decorated_collection.present? %> | ||
<% field_names = current_model_decorator.index_field_names %> | ||
<div class="resources__container"> | ||
<table class="resources__data"> | ||
<thead> | ||
<tr> | ||
<% field_names.each do |field_name| %> | ||
<%= content_tag :th, class: sort_link_builder.current_sort[field_name] do %> | ||
<%= sort_link_builder.build field_name %> | ||
<% end %> | ||
<% end %> | ||
<th> </th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% decorated_collection.each do |decorated| %> | ||
<tr> | ||
<% field_names.each do |field_name| %> | ||
<td> | ||
<%= render decorated.index_type_of(field_name), | ||
object: decorated, | ||
field_name: field_name, | ||
value: decorated.try(field_name), | ||
metadata: decorated.index_metadata_of(field_name) | ||
%> | ||
</td> | ||
<% end %> | ||
<td class="resource__actions"> | ||
<%= render 'resource_actions', decorated: decorated %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
<% else %> | ||
<div class="resources__not-found"> | ||
<%= image_tag 'wallaby/not_found.png' %> | ||
<%= wt 'errors.not_found.collection' %> | ||
</div> | ||
<% end %> | ||
<% # /Data table %> | ||
</section> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<% decorated = decorate resource %> | ||
<article class="resource"> | ||
<div class="resource__header"> | ||
<h1><%= wt 'labels.create', model: to_model_label(current_model_class) %></h1> | ||
<%= render 'resource_navs' %> | ||
</div> | ||
<%= render 'flash_messages' %> | ||
<section> | ||
<div class="resource__container"> | ||
<%= form_for( | ||
decorated, | ||
url: url_for(action: :index), method: :post, | ||
html: { :multipart => true } | ||
) do |form| %> | ||
<%= render 'form', form: form, decorated: decorated %> | ||
<% end %> | ||
</div> | ||
</section> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<article class="resource"> | ||
<% | ||
if resource | ||
# decorate first on every page or partial | ||
decorated = decorate resource | ||
%> | ||
<div class="resource__header"> | ||
<h1><%= show_title decorated %></h1> | ||
<%= render 'resource_navs' %> | ||
</div> | ||
<%= render 'flash_messages' %> | ||
<section> | ||
<div class="resource__container"> | ||
<% decorated.show_field_names.each do |field_name| %> | ||
<dl> | ||
<dt><%= decorated.show_label_of field_name %></dt> | ||
<dd> | ||
<%= render decorated.show_type_of(field_name), | ||
object: decorated, | ||
field_name: field_name, | ||
value: decorated.try(field_name), | ||
metadata: decorated.show_metadata_of(field_name) | ||
%> | ||
</dd> | ||
</dl> | ||
<% end %> | ||
</div> | ||
</section> | ||
<% else %> | ||
<div class="resource__header"> | ||
<h1><%= to_model_label(current_model_class) %></h1> | ||
<%= render 'resource_navs' %> | ||
</div> | ||
<%= render 'flash_messages' %> | ||
<section> | ||
<div class="resource__not-found"> | ||
<%= image_tag 'wallaby/not_found.png' %> | ||
<%= wt 'errors.not_found.resource', resource: to_model_label(current_model_class) %> | ||
</div> | ||
</section> | ||
<% end %> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1 @@ | ||
<% | ||
# decorate first on every page or partial | ||
decorated = decorate resource | ||
%> | ||
<article class="resource"> | ||
<div class="resource__header"> | ||
<h1><%= wt 'labels.edit', id: decorated.id %></h1> | ||
<%= render 'resource_navs' %> | ||
</div> | ||
<%= render 'flash_messages' %> | ||
<section> | ||
<div class="resource__container"> | ||
<%= form_for decorated, | ||
url: url_for(action: :show), method: :put, | ||
html: { :multipart => true } do |form| %> | ||
<%= render 'form', form: form, decorated: decorated %> | ||
<% end %> | ||
</div> | ||
</section> | ||
</article> | ||
<%= render 'edit_page' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
<h1> | ||
Welcome | ||
</h1> | ||
<%# TODO: turn this page into intro maybe? %> | ||
<%= render 'flash_messages' %> | ||
<%= render 'home_page' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1 @@ | ||
<% | ||
# decorate first on every page or partial | ||
decorated_collection = decorate collection | ||
%> | ||
<article class="resources"> | ||
<div class="resources__header"> | ||
<h1><%= to_model_label(current_model_class) %></h1> | ||
<%= render 'index_query' %> | ||
<%= render 'index_filters' %> | ||
<%= render 'index_pagination' %> | ||
</div> | ||
<%= render 'flash_messages' %> | ||
|
||
<section> | ||
<% # Data table %> | ||
<% if decorated_collection.present? %> | ||
<% field_names = current_model_decorator.index_field_names %> | ||
<div class="resources__container"> | ||
<table class="resources__data"> | ||
<thead> | ||
<tr> | ||
<% field_names.each do |field_name| %> | ||
<%= content_tag :th, class: sort_link_builder.current_sort[field_name] do %> | ||
<%= sort_link_builder.build field_name %> | ||
<% end %> | ||
<% end %> | ||
<th> </th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% decorated_collection.each do |decorated| %> | ||
<tr> | ||
<% field_names.each do |field_name| %> | ||
<td> | ||
<%= render decorated.index_type_of(field_name), | ||
object: decorated, | ||
field_name: field_name, | ||
value: decorated.try(field_name), | ||
metadata: decorated.index_metadata_of(field_name) | ||
%> | ||
</td> | ||
<% end %> | ||
<td class="resource__actions"> | ||
<%= render 'resource_actions', decorated: decorated %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
<% else %> | ||
<div class="resources__not-found"> | ||
<%= image_tag 'wallaby/not_found.png' %> | ||
<%= wt 'errors.not_found.collection' %> | ||
</div> | ||
<% end %> | ||
<% # /Data table %> | ||
</section> | ||
</article> | ||
<%= render 'index_page' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%# @param object [model] model instance %> | ||
<%# @param field_name [String] name of the field %> | ||
<%# @param value [Object] value of the field %> | ||
<%# @param metadata [Hash] metadata of the field %> | ||
<%= value.try { |v| number_to_currency(v, metadata[:dollar] || {}) } || null %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<%# @param object [model] model instance %> | ||
<%# @param field_name [String] name of the field %> | ||
<%# @param value [Object] value of the field %> | ||
<%# @param metadata [Hash] metadata of the field %> | ||
<%= if value.nil? | ||
null | ||
else | ||
"%.#{ metadata[:precision] || 2 }f%%" % | ||
(value.to_f * (metadata[:is_percent] ? 1 : 100)) | ||
end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1 @@ | ||
<% decorated = decorate resource %> | ||
<article class="resource"> | ||
<div class="resource__header"> | ||
<h1><%= wt 'labels.create', model: to_model_label(current_model_class) %></h1> | ||
<%= render 'resource_navs' %> | ||
</div> | ||
<%= render 'flash_messages' %> | ||
<section> | ||
<div class="resource__container"> | ||
<%= form_for( | ||
decorated, | ||
url: url_for(action: :index), method: :post, | ||
html: { :multipart => true } | ||
) do |form| %> | ||
<%= render 'form', form: form, decorated: decorated %> | ||
<% end %> | ||
</div> | ||
</section> | ||
</article> | ||
<%= render 'new_page' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1 @@ | ||
<article class="resource"> | ||
<% | ||
if resource | ||
# decorate first on every page or partial | ||
decorated = decorate resource | ||
%> | ||
<div class="resource__header"> | ||
<h1><%= show_title decorated %></h1> | ||
<%= render 'resource_navs' %> | ||
</div> | ||
<%= render 'flash_messages' %> | ||
<section> | ||
<div class="resource__container"> | ||
<% decorated.show_field_names.each do |field_name| %> | ||
<dl> | ||
<dt><%= decorated.show_label_of field_name %></dt> | ||
<dd> | ||
<%= render decorated.show_type_of(field_name), | ||
object: decorated, | ||
field_name: field_name, | ||
value: decorated.try(field_name), | ||
metadata: decorated.show_metadata_of(field_name) | ||
%> | ||
</dd> | ||
</dl> | ||
<% end %> | ||
</div> | ||
</section> | ||
<% else %> | ||
<div class="resource__header"> | ||
<h1><%= to_model_label(current_model_class) %></h1> | ||
<%= render 'resource_navs' %> | ||
</div> | ||
<%= render 'flash_messages' %> | ||
<section> | ||
<div class="resource__not-found"> | ||
<%= image_tag 'wallaby/not_found.png' %> | ||
<%= wt 'errors.not_found.resource', resource: to_model_label(current_model_class) %> | ||
</div> | ||
</section> | ||
<% end %> | ||
</article> | ||
<%= render 'show_page' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Admin::ProductDecorator < Wallaby::ResourceDecorator | ||
filters[:featured] = { | ||
scope: -> { where(featured: true) } | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
class Person < ActiveRecord::Base | ||
has_one :picture, as: :imageable | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,20 @@ | ||
<%= render 'edit', form_url: url_for(action: :member_update) %> | ||
<% | ||
# decorate first on every page or partial | ||
decorated = decorate resource | ||
%> | ||
<article class="resource"> | ||
<div class="resource__header"> | ||
<h1><%= wt 'labels.edit', id: decorated.id %></h1> | ||
<%= render 'resource_navs' %> | ||
</div> | ||
<%= render 'flash_messages' %> | ||
<section> | ||
<div class="resource__container"> | ||
<%= form_for decorated, | ||
url: url_for(action: :member_update), method: :put, | ||
html: { :multipart => true } do |form| %> | ||
<%= render 'form', form: form, decorated: decorated %> | ||
<% end %> | ||
</div> | ||
</section> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.