-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#20 blank list and filter partial added to scaffold generator
- Loading branch information
Showing
10 changed files
with
115 additions
and
52 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
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
# | ||
# It's strongly recommended that you check this file into your version control system. | ||
|
||
ActiveRecord::Schema.define(version: 20130905072700) do | ||
ActiveRecord::Schema.define(version: 20130911070035) do | ||
|
||
create_table "admins", force: true do |t| | ||
t.string "email", default: "", null: false | ||
|
@@ -31,6 +31,13 @@ | |
add_index "admins", ["email"], name: "index_admins_on_email", unique: true | ||
add_index "admins", ["reset_password_token"], name: "index_admins_on_reset_password_token", unique: true | ||
|
||
create_table "products", force: true do |t| | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
adamdilek
Author
Contributor
|
||
t.string "name" | ||
t.string "barcode" | ||
t.datetime "created_at" | ||
t.datetime "updated_at" | ||
end | ||
|
||
create_table "users", force: true do |t| | ||
t.string "email", default: "", null: false | ||
t.string "encrypted_password", default: "", null: false | ||
|
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,48 @@ | ||
require 'rails/generators/erb/scaffold/scaffold_generator' | ||
|
||
module Haml | ||
module Generators | ||
class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator | ||
source_root File.expand_path("../templates", __FILE__) | ||
|
||
def copy_view_files | ||
available_views.each do |view| | ||
filename = filename_with_extensions(view) | ||
if filename == "_#{singular_table_name}.html.haml" | ||
#create_file File.join("app/views", controller_file_path, "_#{singular_table_name}.html.haml") do | ||
# hostname = ask("What is the virtual hostname I should use?") | ||
# "vhost.name = #{hostname}" | ||
#end | ||
|
||
template 'single_entry.html.haml', File.join("app/views", controller_file_path, filename) | ||
else | ||
template "#{view}.html.haml", File.join("app/views", controller_file_path, filename) | ||
end | ||
end | ||
end | ||
|
||
hook_for :form_builder, :as => :scaffold | ||
|
||
def copy_form_file | ||
if options[:form_builder].nil? | ||
filename = filename_with_extensions("_form") | ||
template "_form.html.haml", File.join("app/views", controller_file_path, filename) | ||
end | ||
end | ||
|
||
protected | ||
|
||
def available_views | ||
file = "_#{singular_table_name}" | ||
list = %w(index edit show new _list _blank _filters) | ||
list << file | ||
list | ||
end | ||
|
||
def handler | ||
:haml | ||
end | ||
|
||
end | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
%h1 Your blank message here |
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 @@ | ||
%h1 Your filters here |
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 @@ | ||
%h1 Your list here |
12 changes: 12 additions & 0 deletions
12
lib/generators/haml/scaffold/templates/single_entry.html.haml
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,12 @@ | ||
%tr | ||
%td= <%= singular_table_name %>.id | ||
<% for attribute in attributes -%> | ||
%td= <%= singular_table_name %>.<%= attribute.name %> | ||
<% end -%> | ||
%td.action | ||
= link_to(<%= singular_table_name %>, class: 'btn btn-success', toogle: 'tooltip', title: t('tooltips.zoom')) do | ||
%i.icon-zoom-in | ||
= link_to(edit_<%= singular_table_name %>_path(<%= singular_table_name %>) , class: 'btn btn-info') do | ||
%i.icon-edit | ||
= link_to(<%= singular_table_name %>, class: 'btn btn-danger', method: :delete) do | ||
%i.icon-trash |
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,12 @@ | ||
<% @search = "" -%> | ||
<% attributes.each { |attribute| @search += "_#{attribute.name}_or" } -%> | ||
.table-header.row | ||
.col-lg-9 | ||
TODO: Add filters here | ||
.col-lg-3 | ||
= search_form_for @search, builder: SimpleForm::FormBuilder do |f| | ||
.input-group | ||
= f.input_field :<%= @search[[email protected]] %>_cont, label: false, input_html: {class: 'form-control'}, placeholder: 'Quick search...' | ||
%span.input-group-btn | ||
= button_tag( class: 'btn') do | ||
%i.icon-search |
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,27 @@ | ||
.panel-heading | ||
%i.icon-table.icon-large | ||
= t('tt.index', resource_name: <%= singular_table_name.capitalize %>.model_name.human) | ||
.panel-tools | ||
.btn-group | ||
%a.btn{href: '#'} | ||
%i.icon-wrench | ||
Settings | ||
%a.btn{href: '#'} | ||
%i.icon-filter | ||
Filters | ||
%a.btn{href: <%= index_helper %>_path, data: {toggle: 'toolbar-tooltip'}, title: 'Reload'} | ||
%i.icon-refresh | ||
.badge= @<%= plural_table_name %>.total_entries | ||
.panel-body.no-padding | ||
= render 'filters' | ||
%table.table | ||
%thead | ||
%tr | ||
%th # | ||
<% for attribute in attributes -%> | ||
%th= sort_link(@search, :<%= attribute.name %>, t('activerecord.attributes.<%= singular_table_name %>.<%= attribute.name %>')) | ||
<% end -%> | ||
%th.actions | ||
Actions | ||
%tbody | ||
= render @<%= plural_table_name %> |
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,9 @@ | ||
<% @search = "" -%> | ||
<% attributes.each { |attribute| @search += "_#{attribute.name}_or" } -%> | ||
|
||
- content_for :toolbar do | ||
= link_to new_<%= singular_table_name %>_path, class: 'btn btn-default' do | ||
%i.icon-plus | ||
= t('action_button.new', resource_name: <%= singular_table_name.capitalize %>.model_name.human) | ||
|
||
.panel.tables | ||
.panel-heading | ||
%i.icon-table.icon-large | ||
= t('tt.index', resource_name: <%= singular_table_name.capitalize %>.model_name.human) | ||
.panel-tools | ||
.btn-group | ||
%a.btn{href: '#'} | ||
%i.icon-wrench | ||
Settings | ||
%a.btn{href: '#'} | ||
%i.icon-filter | ||
Filters | ||
%a.btn{href: <%= index_helper %>_path, data: {toggle: 'toolbar-tooltip'}, title: 'Reload'} | ||
%i.icon-refresh | ||
.badge= @<%= plural_table_name %>.total_entries | ||
.panel-body.no-padding | ||
.table-header.row | ||
.col-lg-9 | ||
TODO: Add filters here | ||
.col-lg-3 | ||
= search_form_for @search, builder: SimpleForm::FormBuilder do |f| | ||
.input-group | ||
= f.input_field :<%= @search[[email protected]] %>_cont, label: false, input_html: {class: 'form-control'}, placeholder: 'Quick search...' | ||
%span.input-group-btn | ||
= button_tag( class: 'btn') do | ||
%i.icon-search | ||
%table.table | ||
%thead | ||
%tr | ||
%th # | ||
<% for attribute in attributes -%> | ||
%th= sort_link(@search, :<%= attribute.name %>, t('activerecord.attributes.<%= singular_table_name %>.<%= attribute.name %>')) | ||
<% end -%> | ||
%th.actions | ||
Actions | ||
%tbody | ||
- @<%= plural_table_name %>.each do |<%= singular_table_name %>| | ||
%tr | ||
%td= <%= singular_table_name %>.id | ||
<% for attribute in attributes -%> | ||
%td= <%= singular_table_name %>.<%= attribute.name %> | ||
<% end -%> | ||
%td.action | ||
= link_to(<%= singular_table_name %>, class: 'btn btn-success', toogle: 'tooltip', title: t('tooltips.zoom')) do | ||
%i.icon-zoom-in | ||
= link_to(edit_<%= singular_table_name %>_path(<%= singular_table_name %>) , class: 'btn btn-info') do | ||
%i.icon-edit | ||
= link_to(<%= singular_table_name %>, class: 'btn btn-danger', method: :delete) do | ||
%i.icon-trash | ||
= render 'list' | ||
|
||
= will_paginate @<%= plural_table_name %>, renderer: BootstrapPagination::Rails, bootstrap: 3 |
@muhammetdilek products ? 😧