blueberry_form 0.1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/CODE_OF_CONDUCT.md +13 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +41 -0
  7. data/Rakefile +1 -0
  8. data/bin/console +14 -0
  9. data/bin/heroku-setup +106 -0
  10. data/bin/setup +7 -0
  11. data/blueberry_form.gemspec +25 -0
  12. data/lib/blueberry_form.rb +4 -0
  13. data/lib/blueberry_form/version.rb +3 -0
  14. data/lib/generators/blueberry/form/form_generator.rb +116 -0
  15. data/lib/generators/blueberry/form/templates/controllers/railties/controller.rb.erb +21 -0
  16. data/lib/generators/blueberry/form/templates/views/slim/_form.html.slim +7 -0
  17. data/lib/generators/blueberry/form/templates/views/slim/_state.html.slim +2 -0
  18. data/lib/generators/blueberry/form/templates/views/slim/_thanks.html.slim +3 -0
  19. data/lib/generators/blueberry/form/templates/views/slim/create.js.erb +10 -0
  20. data/lib/generators/inherited_resources_views/generators/generator.rb +67 -0
  21. data/lib/generators/inherited_resources_views/inherited_resources_views_generator.rb +1 -0
  22. data/lib/generators/inherited_resources_views/templates/config/translation.yml.erb +30 -0
  23. data/lib/generators/inherited_resources_views/templates/controllers/controller.rb.erb +26 -0
  24. data/lib/generators/inherited_resources_views/templates/controllers/inherited_resources_controller.rb +17 -0
  25. data/lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_collection_table.html.erb +23 -0
  26. data/lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_edit_navigation.html.erb +2 -0
  27. data/lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_form.html.erb +29 -0
  28. data/lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_index_navigation.html.erb +1 -0
  29. data/lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_new_navigation.html.erb +1 -0
  30. data/lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_resource_detail.html.erb +9 -0
  31. data/lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_show_navigation.html.erb +2 -0
  32. data/lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/edit.html.erb +5 -0
  33. data/lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/index.html.erb +7 -0
  34. data/lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/new.html.erb +5 -0
  35. data/lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/show.html.erb +5 -0
  36. data/lib/generators/inherited_resources_views/templates/views/partials/_form_errors.html.slim +5 -0
  37. data/lib/generators/inherited_resources_views/templates/views/partials/_standard_actions.html.slim +6 -0
  38. data/lib/generators/inherited_resources_views/templates/views/slim/_empty.html.slim +3 -0
  39. data/lib/generators/inherited_resources_views/templates/views/slim/_form.html.slim +13 -0
  40. data/lib/generators/inherited_resources_views/templates/views/slim/_model.html.slim +14 -0
  41. data/lib/generators/inherited_resources_views/templates/views/slim/edit.html.slim +17 -0
  42. data/lib/generators/inherited_resources_views/templates/views/slim/index.html.slim +29 -0
  43. data/lib/generators/inherited_resources_views/templates/views/slim/new.html.slim +17 -0
  44. metadata +115 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f2f79c783e50f61239d22bb329788e5d30fbee7e
4
+ data.tar.gz: 2f422c9ec1487467f6af15e71699586b6a5b48bc
5
+ SHA512:
6
+ metadata.gz: 9fe2e5370c3d43e298520cfc262bf1a6e5f9197ebf2c37c869f1be826594b5f888c625eb9f552b2cdde2a880d3877f028986b267c147ba601699593d1eebaeef
7
+ data.tar.gz: fec515f8ff34e5e86238851d02523b61f41b069e84e33bb10011679b2cc732baa40b9bd518ac4c83ad4f46e7466244d385b0cdb52d1c015835ce9de6179a26cc
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in blueberry_form.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Tonda Pleskac
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # BlueberryForm
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/blueberry_form`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'blueberry_form'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install blueberry_form
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/blueberry_form. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "blueberry_form"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+
4
+ OptionParser.new do |o|
5
+ o.banner = "Usage: create-pipeline.rb [options]"
6
+ o.on('-dt', 'Add ruby-rake-deploy-tasks buildpack and set DEPLOY_TASKS=db:migrate') { |b| $deploy_tasks = b }
7
+ o.on('-ms', 'Run migration and seed for all apps') { |b| $migration = b }
8
+ o.on('-c collaborators', 'Set collaborators emails') { |b| $users = b }
9
+ o.on('-o OWNER', 'Set owner email - it will be transfer to this user') { |owner| $owner = owner }
10
+ o.on('-h') { puts o; exit }
11
+ end.parse!
12
+
13
+ class String
14
+ def colorize(color_code)
15
+ "\e[#{color_code}m#{self}\e[0m"
16
+ end
17
+ def red
18
+ colorize(31)
19
+ end
20
+ end
21
+
22
+ def print_message(string)
23
+ STDOUT.print "\n"
24
+ STDOUT.print "".center(70, '-').upcase.red
25
+ STDOUT.print "\n"
26
+ STDOUT.print string.center(70, ' ').upcase
27
+ STDOUT.print "\n"
28
+ STDOUT.print "".center(70, '-').upcase.red
29
+ STDOUT.print "\n"
30
+ end
31
+
32
+ class Hash
33
+ def without(*keys)
34
+ cpy = self.dup
35
+ keys.each { |key| cpy.delete(key) }
36
+ cpy
37
+ end
38
+ end
39
+
40
+ unless ARGV[0]
41
+ puts 'Use create-pipeline.rb APP_NAME -ms -c "email@mail.com email2@email.com" -o owner@email.com -dt'
42
+ puts 'Or create-pipeline.rb -h for help'
43
+ exit
44
+ end
45
+
46
+ app_name = ARGV[0].gsub('.', '-')
47
+
48
+ domains = {
49
+ production: "#{app_name}-production",
50
+ staging: "#{app_name}-staging",
51
+ integration: "#{app_name}-integration",
52
+ }
53
+
54
+ owner = $owner || 'jbrhel@blueberryapps.com'
55
+ users = $users ? $users.split(' ') : %w(pleskac@gmail.com jbrhel@blueberryapps.com mmagnusek@blueberryapps.com jchrtek@blueberryapps.com ahencze@blueberryapps.com)
56
+
57
+ if $migration
58
+ puts print_message 'Migrate and seed apps'
59
+
60
+ domains.each do |_, domain|
61
+ puts `heroku run rake db:migrate db:seed --app "#{domain}"`
62
+ end
63
+
64
+ else
65
+
66
+ puts print_message 'Creating apps'
67
+
68
+ domains.each do |_, domain|
69
+ puts `heroku create "#{domain}"`
70
+ end
71
+
72
+ puts print_message'Creating pipeline'
73
+
74
+ puts `heroku pipelines:create -a #{domains[:production]} #{app_name} -s production`
75
+
76
+ puts print_message 'Adding apps to pipeline'
77
+
78
+ domains.without(:production).map do |env, domain|
79
+ env = :production if env == :integration
80
+ puts `heroku pipelines:add -a "#{domain}" "#{app_name}" -s "#{env}"`
81
+ end
82
+
83
+ puts print_message 'Setting up access for apps'
84
+
85
+ users.map do |user|
86
+ domains.map do |_, domain|
87
+ puts `heroku access:add "#{user}" --app "#{domain}"`
88
+ end
89
+ end
90
+
91
+ if $deploy_tasks
92
+ puts print_message 'Add deploy tasks buildpacks'
93
+
94
+ domains.map do |_, domain|
95
+ puts `heroku buildpacks:add heroku/ruby --app "#{domain}"`
96
+ puts `heroku buildpacks:add https://github.com/gunpowderlabs/buildpack-ruby-rake-deploy-tasks --app "#{domain}"`
97
+ puts `heroku config:set DEPLOY_TASKS='db:migrate' --app "#{domain}"`
98
+ end
99
+ end
100
+
101
+ puts print_message 'Transfer ownership to jbrhel@blueberryapps.com'
102
+
103
+ domains.map do |_, domain|
104
+ puts `heroku apps:transfer "#{owner}" --app "#{domain}"`
105
+ end
106
+ end
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'blueberry_form/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "blueberry_form"
8
+ spec.version = BlueberryForm::VERSION
9
+ spec.authors = ["Tonda Pleskac"]
10
+ spec.email = ["pleskac@gmail.com"]
11
+
12
+ spec.summary = %q{Write a short summary, because Rubygems requires one.}
13
+ spec.description = %q{Write a longer description or delete this line.}
14
+ spec.homepage = "http://github.com"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "bin"
19
+ spec.executables = ["heroku-setup"]
20
+
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
@@ -0,0 +1,4 @@
1
+ require "blueberry_form/version"
2
+
3
+ module BlueberryForm
4
+ end
@@ -0,0 +1,3 @@
1
+ module BlueberryForm
2
+ VERSION = "0.1.2.1"
3
+ end
@@ -0,0 +1,116 @@
1
+ require 'rubygems/specification'
2
+ require 'rails/generators/named_base'
3
+ require 'rails/generators/resource_helpers'
4
+ require 'rails/generators/migration'
5
+ require 'rails/generators/active_record'
6
+
7
+ module Blueberry
8
+ module Generators
9
+ class FormGenerator < Rails::Generators::NamedBase
10
+ include Rails::Generators::ResourceHelpers
11
+ include Rails::Generators::Migration
12
+
13
+ source_root File.expand_path('../templates', __FILE__)
14
+
15
+ check_class_collision suffix: "Controller"
16
+
17
+ check_class_collision suffix: "Helper"
18
+
19
+ class_option :orm, banner: "NAME", type: :string, required: true,
20
+ desc: "ORM to generate the controller for"
21
+
22
+ class_option :parent_controller, banner: "admin", type: :string, default: "application",
23
+ desc: "Define the parent controller"
24
+
25
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
26
+
27
+ def initialize(args, *options)
28
+ super
29
+ end
30
+
31
+ def generate_model
32
+ invoke "active_record:model", [name, *attributes.map { |c| "#{c.name}:#{c.type}" }], migration: true
33
+ end
34
+
35
+ def create_controller_files
36
+ template "controllers/railties/controller.rb.erb", File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
37
+ end
38
+
39
+ def create_root_folder
40
+ empty_directory File.join("app/views", controller_file_path)
41
+ end
42
+
43
+ def copy_view_files
44
+ available_views.each do |view|
45
+ filename = filename_with_extensions(view)
46
+ template_path = "views/#{handler}/#{filename}"
47
+ template template_path, File.join("app/views", controller_file_path, filename)
48
+ end
49
+
50
+ template "views/#{handler}/create.js.erb", File.join("app/views", controller_file_path, "create.js.erb")
51
+
52
+ render_info_banner
53
+ end
54
+
55
+ hook_for :helper, in: :rails do |helper|
56
+ invoke helper, [controller_class_name]
57
+ end
58
+
59
+ hook_for :resource_route, in: :rails do |resource_route|
60
+ invoke resource_route, [class_name]
61
+ end
62
+
63
+ protected
64
+
65
+ def render_info_banner
66
+ puts ' ' * 80
67
+ puts '-' * 80
68
+ puts "| Render form in your view | ".center(80)
69
+ puts '-' * 80
70
+ puts ' ' * 80
71
+ puts ".#{singular_table_name}-box = render '#{controller_file_path}/form'"
72
+ puts ".#{singular_table_name}-state"
73
+ puts ' ' * 80
74
+ puts '-' * 80
75
+ end
76
+
77
+ def parent_controller_class_name
78
+ options[:parent_controller].capitalize
79
+ end
80
+
81
+ def available_views
82
+ %w(_thanks _state _form)
83
+ end
84
+
85
+ def format
86
+ :html
87
+ end
88
+
89
+ def handler
90
+ :slim
91
+ end
92
+
93
+ def migration_attributes
94
+ attributes.collect { |c| "'#{c.name}:#{c.type}'" }.join(',')
95
+ end
96
+
97
+ def filename_with_extensions(name)
98
+ [name, format, handler].compact.join(".")
99
+ end
100
+
101
+ def self.check_class_collision(options={})
102
+ define_method :check_class_collision do
103
+ name = if self.respond_to?(:controller_class_name)
104
+ controller_class_name
105
+ elsif self.respond_to?(:controller_class_name)
106
+ controller_class_name
107
+ else
108
+ class_name
109
+ end
110
+
111
+ class_collisions "#{name}#{options[:suffix]}"
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,21 @@
1
+ <% module_namespacing do -%>
2
+ class <%= controller_class_name %>Controller < <%= parent_controller_class_name %>Controller
3
+ def create
4
+ @<%= singular_table_name %> = <%= orm_class.build class_name %> <%="#{singular_table_name}_params"%>
5
+
6
+ if @<%= orm_instance.save %>
7
+ @<%= singular_table_name %> = <%= orm_class.build class_name %>
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def <%= "#{singular_table_name}_params" %>
14
+ <%- if attributes_names.empty? -%>
15
+ params[<%= ":#{singular_table_name}" %>]
16
+ <%- else -%>
17
+ params.require(<%= ":#{singular_table_name}" %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
18
+ <%- end -%>
19
+ end
20
+ end
21
+ <% end -%>
@@ -0,0 +1,7 @@
1
+ = simple_form_for <%= "@#{singular_table_name}" %> || <%= "#{singular_table_name.camelize}.new" %>, remote: true do |f|
2
+ .<%= "#{singular_table_name}" %>-form-wrapper
3
+ <% for attribute in attributes -%>
4
+ = f.input :<%= attribute.name %>
5
+ <% end -%>
6
+ .actions
7
+ = f.submit t('submit')
@@ -0,0 +1,2 @@
1
+ - if <%= "@#{singular_table_name}.errors.any?" %>
2
+ .error = t('.error_html')
@@ -0,0 +1,3 @@
1
+ .thanks
2
+ i.icon-envelope
3
+ p = t('.message_html')
@@ -0,0 +1,10 @@
1
+ <%% if @<%= singular_table_name %>.errors.any? %>
2
+ $('.<%= singular_table_name %>-box').html("<%%= escape_javascript render 'form' %>").fadeIn(300);
3
+ $('.<%= singular_table_name %>-state').html("<%%= escape_javascript render 'state' %>").fadeIn(300);
4
+ <%% else %>
5
+ $('.<%= singular_table_name %>-box .<%= singular_table_name %>-form-wrapper').fadeOut(200, function() {
6
+ $(this).html("<%%= escape_javascript render partial: 'thanks' %>").fadeIn(200).delay(8000).fadeOut(200, function() {
7
+ $('.<%= singular_table_name %>-box').html("<%%= escape_javascript render partial: 'form' %>").fadeIn(200);
8
+ });
9
+ });
10
+ <%% end %>
@@ -0,0 +1,67 @@
1
+ require 'pry'
2
+ require 'rails/generators/resource_helpers'
3
+ require 'rails/generators/active_record'
4
+
5
+
6
+ class InheritedResourcesViewsGenerator < Rails::Generators::NamedBase
7
+ include Rails::Generators::ResourceHelpers
8
+ desc "Generates inherited_resource_views templates."
9
+
10
+ source_root File.expand_path('../../templates', __FILE__)
11
+
12
+ argument :attributes, type: :array, default: [], banner: ":field :field"
13
+
14
+ class_option :parent_controller, banner: "admin", type: :string, default: "base",
15
+ desc: "Define the parent controller"
16
+
17
+
18
+ def create_root_folder
19
+ empty_directory File.join(base_directory, controller_file_path)
20
+ end
21
+
22
+ def copy_views
23
+ available_views.each do |file|
24
+ filename = filename_with_extensions(file)
25
+ template_path = "views/#{handler}/#{filename}"
26
+
27
+ filename = "_#{singular_table_name}.html.slim" if filename == '_model.html.slim'
28
+ template template_path, File.join(base_directory, controller_file_path, filename)
29
+ end
30
+ end
31
+
32
+ def create_controller_files
33
+ template "controllers/controller.rb.erb", File.join('app/controllers/admin', class_path, "#{controller_file_name}_controller.rb")
34
+ template "controllers/inherited_resources_controller.rb", File.join('app/controllers/concerns', 'inherited_resources_controller.rb')
35
+ end
36
+
37
+ def copy_translation_files
38
+ template "config/translation.yml.erb", File.join('config/locales/', "#{controller_file_name}.yml")
39
+ end
40
+
41
+ protected
42
+
43
+ def parent_controller_class_name
44
+ options[:parent_controller].capitalize
45
+ end
46
+
47
+ def available_views
48
+ %w(index edit new _form _empty _model)
49
+ end
50
+
51
+ def format
52
+ :html
53
+ end
54
+
55
+ def handler
56
+ :slim
57
+ end
58
+
59
+ def base_directory
60
+ "app/views/admin"
61
+ end
62
+
63
+ def filename_with_extensions(name)
64
+ [name, format, handler].compact.join(".")
65
+ end
66
+
67
+ end
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + "/generators/generator"
@@ -0,0 +1,30 @@
1
+ cs:
2
+ admin:
3
+ <%= "#{plural_table_name}" %>:
4
+ edit:
5
+ back: "zpět"
6
+ edit: "Úprava položky"
7
+ empty:
8
+ <%= "no_#{plural_table_name}" %>: "Nenalezeny žádné položky."
9
+ form:
10
+ main: "Hlavní informace"
11
+ index:
12
+ create: "Vytvořit položku"
13
+ list: "Seznam položek"
14
+ new:
15
+ back: "zpět"
16
+ create: "Vytvořit položku"
17
+
18
+ cs:
19
+ activerecord:
20
+ attributes:
21
+ <%= "#{singular_table_name}" %>:
22
+ <%- for attribute in attributes -%>
23
+ <%= "#{attribute.type}" %>: "<%= "#{attribute.type.upcase}" %>"
24
+ <%- end -%>
25
+ created_at: "Vytvořeno"
26
+
27
+ models:
28
+ <%= "#{singular_table_name}" %>:
29
+ one: "<%= "#{singular_table_name}" %>"
30
+ other: "<%= "#{plural_table_name}" %>"
@@ -0,0 +1,26 @@
1
+ <% module_namespacing do -%>
2
+ module Admin
3
+ class <%= controller_class_name %>Controller < <%= parent_controller_class_name %>Controller
4
+ include InheritedResourcesController
5
+
6
+ private
7
+
8
+ def <%= "#{singular_table_name}_params" %>
9
+ <%- if attributes_names.empty? -%>
10
+ params[<%= ":#{singular_table_name}" %>]
11
+ <%- else -%>
12
+ params
13
+ .require(<%= ":#{singular_table_name}" %>)
14
+ .permit(<%= attributes.map { |attribute| ":#{attribute.type}" }.join(', ') %>)
15
+ <%- end -%>
16
+ end
17
+
18
+ def collection
19
+ <%= "@#{plural_table_name}_params" %> ||= end_of_association_chain
20
+ .page(params[:page])
21
+ .per(10)
22
+ .decorate
23
+ end
24
+ end
25
+ end
26
+ <% end -%>
@@ -0,0 +1,17 @@
1
+ module InheritedResourcesController
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ inherit_resources
6
+
7
+ def create
8
+ create! { collection_url }
9
+ end
10
+
11
+ def update
12
+ update! { collection_url }
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,23 @@
1
+ <table class="<%= collection.first.class.to_s.downcase.pluralize %> collection">
2
+ <thead>
3
+ <tr>
4
+ <% collection.first.attributes.each_pair do |field, value| %>
5
+ <% next if ['id', 'created_at', 'updated_at'].include?(field) %>
6
+ <th><%= field.titleize %></th>
7
+ <% end %>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% collection.each do |r| %>
12
+ <tr>
13
+ <% r.attributes.each_pair do |field, value| %>
14
+ <% next if ['id', 'created_at', 'updated_at'].include?(field) %>
15
+ <td><%= value %></td>
16
+ <% end %>
17
+ <td><%= link_to "Show", resource_url(r) %></td>
18
+ <td><%= link_to "Edit", edit_resource_url(r) %></td>
19
+ <td><%= link_to "Destroy", resource_url(r), :confirm => 'Are you sure?', :method => :delete %></td>
20
+ </tr>
21
+ <% end %>
22
+ </tbody>
23
+ </table>
@@ -0,0 +1,2 @@
1
+ <p><%= link_to "Show", resource_url(resource) %></p>
2
+ <p><%= link_to "Back", collection_url %></p>
@@ -0,0 +1,29 @@
1
+ <table>
2
+ <%- form_for("#{resource_instance_name.to_s.downcase}",
3
+ resource,
4
+ :url => resource.new_record? ? collection_url : resource_url(resource),
5
+ :html => { :method => (resource.new_record? ? "post" : "put") }) do |f| %>
6
+ <% if resource.errors.any? %>
7
+ <tr>
8
+ <td colspan="2">
9
+ <h2><%= pluralize(resource.errors.count, "error") %> prohibited this testa from being saved:</h2>
10
+ <ul>
11
+ <% resource.errors.full_messages.each do |msg| %>
12
+ <li><%= msg %></li>
13
+ <% end %>
14
+ </ul>
15
+ </td>
16
+ </tr>
17
+ <% end %>
18
+ <% resource.attributes.each_pair do |field, value| %>
19
+ <% next if ['id', 'created_at', 'updated_at'].include?(field) %>
20
+ <tr>
21
+ <td><%= field.titleize %></td>
22
+ <td><%= f.text_field field.to_sym %></td>
23
+ </tr>
24
+ <% end %>
25
+ <tr>
26
+ <td colspan="2"><%= f.submit %></td>
27
+ </tr>
28
+ <% end %>
29
+ </table>
@@ -0,0 +1,9 @@
1
+ <table class="<%= collection.first.class.to_s.downcase %> detail">
2
+ <% resource.attributes.each_pair do |attr, value| %>
3
+ <% next if ['id', 'created_at', 'updated_at'].include?(attr) %>
4
+ <tr>
5
+ <th><%= attr.titleize %></th>
6
+ <td><%= value %></td>
7
+ </tr>
8
+ <% end %>
9
+ </table>
@@ -0,0 +1,2 @@
1
+ <p><%= link_to "Edit", edit_resource_url(resource) %></p>
2
+ <p><%= link_to "Back", collection_url %></p>
@@ -0,0 +1,5 @@
1
+ <h1>Edit <%= resource.class.name.titleize %></h1>
2
+
3
+ <%= render "form" %>
4
+
5
+ <%= render "edit_navigation" %>
@@ -0,0 +1,7 @@
1
+ <h1><%= controller.controller_name.titleize %></h1>
2
+
3
+ <%= render "index_navigation" %>
4
+
5
+ <% if collection.any? %>
6
+ <%= render "collection_table" %>
7
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <h1>New <%= resource.class.name.titleize %></h1>
2
+
3
+ <%= render "form" %>
4
+
5
+ <%= render "new_navigation" %>
@@ -0,0 +1,5 @@
1
+ <h1><%= resource.class.name.titleize %></h1>
2
+
3
+ <%= render "resource_detail" %>
4
+
5
+ <%= render "show_navigation" %>
@@ -0,0 +1,5 @@
1
+ - if f.error_notification
2
+ div class='alert alert-danger'
3
+ - f.object.errors.full_messages.each do |message|
4
+ = message
5
+ br
@@ -0,0 +1,6 @@
1
+ => link_to t('.edit'), edit_resource_path(resource.id),
2
+ class: 'btn btn-xs btn-gray'
3
+
4
+ = link_to t('.destroy'), resource_path(resource.id), method: :delete,
5
+ class: 'btn btn-xs btn-gray',
6
+ data: { confirm: local_assigns.has_key?(:confirm) ? confirm : t('.you_sure') }
@@ -0,0 +1,3 @@
1
+
2
+ tr
3
+ td colspan=<%= "#{attributes.size+3} = t '.no_#{plural_table_name}'" %>
@@ -0,0 +1,13 @@
1
+ .row
2
+ .col-md-10.body
3
+ .row
4
+ .col-md-8
5
+ .row
6
+ .col-md-12
7
+ h3 = t '.main'
8
+ .row
9
+ <%- for attribute in attributes -%>
10
+ .col-md-12 = f.input <%= ":#{attribute.type}" %>
11
+ <%- end -%>
12
+
13
+ = overview_box_submit f
@@ -0,0 +1,14 @@
1
+ tr<%= ".#{singular_table_name}" %> id=<%= "#{singular_table_name}.id" %>
2
+ td = <%= "#{singular_table_name}.id" %>
3
+ <%- for attribute in attributes -%>
4
+ <%- if attribute.to_s == 'active' -%>
5
+ td.text-center class=s_w_bool("#{singular_table_name}.#{attribute.type}")
6
+ span.glyphicon class=glyph_bool("#{singular_table_name}.#{attribute.type}")
7
+ <%- else -%>
8
+ td = <%= "#{singular_table_name}.#{attribute.type}" %>
9
+ <%- end -%>
10
+ <%- end -%>
11
+ td = l <%= "#{singular_table_name}.created_at" %>, format: :short
12
+
13
+ td.actions.text-right
14
+ = render 'admin/partials/standard_actions', resource: <%= "#{singular_table_name}" %>
@@ -0,0 +1,17 @@
1
+ = simple_form_for [:admin, resource] do |f|
2
+ .overview-box
3
+ .overview-box-header.no-filter
4
+ .overview-box-heading
5
+ h2
6
+ span.glyphicon.glyphicon-envelope
7
+ span.text
8
+ = t '.edit'
9
+
10
+ .overview-box-action
11
+ = link_to t('.back'), <%= "admin_#{plural_table_name}_path" %>, class: 'btn btn-back'
12
+ = f.button :submit, class: 'btn btn-primary'
13
+
14
+ .row
15
+ .col-md-12
16
+ = render 'admin/partials/form_errors', f: f
17
+ = render 'form', f: f
@@ -0,0 +1,29 @@
1
+ .overview-box
2
+ .overview-box-header.no-filter
3
+
4
+ .overview-box-heading
5
+ h2
6
+ span.glyphicon.glyphicon-envelope
7
+ span.text = t '.list'
8
+
9
+ .overview-box-action
10
+ = link_to t('.create'), <%= "new_admin_#{singular_table_name}_path" %>,
11
+ class: 'btn btn-success pull-right'
12
+
13
+ .overview-box-content
14
+ .row
15
+ .col-md-12
16
+ table.users.table.table-overview
17
+ thead
18
+ tr
19
+ th = <%= "#{singular_table_name.camelize}.human_attribute_name :id" %>
20
+ <%- for attribute in attributes -%>
21
+ th = <%= "#{singular_table_name.camelize}.human_attribute_name :#{attribute.type}" %>
22
+ <%- end -%>
23
+ th = <%= "#{singular_table_name.camelize}.human_attribute_name :created_at" %>
24
+ th
25
+ tbody
26
+ = render collection.any? ? collection : 'empty'
27
+
28
+ .paginator
29
+ = paginate collection.object
@@ -0,0 +1,17 @@
1
+ = simple_form_for [:admin, resource] do |f|
2
+ .overview-box
3
+ .overview-box-header.no-filter
4
+
5
+ .overview-box-heading
6
+ h2
7
+ span.glyphicon.glyphicon-envelope
8
+ span.text = t '.create'
9
+
10
+ .overview-box-action
11
+ = link_to t('.back'), <%= "admin_#{plural_table_name}_path" %>, class: 'btn btn-back'
12
+ = f.button :submit, class: 'btn btn-primary'
13
+
14
+ .row
15
+ .col-md-12
16
+ = render 'admin/partials/form_errors', f: f
17
+ = render 'form', f: f
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blueberry_form
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Tonda Pleskac
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Write a longer description or delete this line.
42
+ email:
43
+ - pleskac@gmail.com
44
+ executables:
45
+ - heroku-setup
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - CODE_OF_CONDUCT.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/heroku-setup
57
+ - bin/setup
58
+ - blueberry_form.gemspec
59
+ - lib/blueberry_form.rb
60
+ - lib/blueberry_form/version.rb
61
+ - lib/generators/blueberry/form/form_generator.rb
62
+ - lib/generators/blueberry/form/templates/controllers/railties/controller.rb.erb
63
+ - lib/generators/blueberry/form/templates/views/slim/_form.html.slim
64
+ - lib/generators/blueberry/form/templates/views/slim/_state.html.slim
65
+ - lib/generators/blueberry/form/templates/views/slim/_thanks.html.slim
66
+ - lib/generators/blueberry/form/templates/views/slim/create.js.erb
67
+ - lib/generators/inherited_resources_views/generators/generator.rb
68
+ - lib/generators/inherited_resources_views/inherited_resources_views_generator.rb
69
+ - lib/generators/inherited_resources_views/templates/config/translation.yml.erb
70
+ - lib/generators/inherited_resources_views/templates/controllers/controller.rb.erb
71
+ - lib/generators/inherited_resources_views/templates/controllers/inherited_resources_controller.rb
72
+ - lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_collection_table.html.erb
73
+ - lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_edit_navigation.html.erb
74
+ - lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_form.html.erb
75
+ - lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_index_navigation.html.erb
76
+ - lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_new_navigation.html.erb
77
+ - lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_resource_detail.html.erb
78
+ - lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/_show_navigation.html.erb
79
+ - lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/edit.html.erb
80
+ - lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/index.html.erb
81
+ - lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/new.html.erb
82
+ - lib/generators/inherited_resources_views/templates/views/inherited_resourcesa/show.html.erb
83
+ - lib/generators/inherited_resources_views/templates/views/partials/_form_errors.html.slim
84
+ - lib/generators/inherited_resources_views/templates/views/partials/_standard_actions.html.slim
85
+ - lib/generators/inherited_resources_views/templates/views/slim/_empty.html.slim
86
+ - lib/generators/inherited_resources_views/templates/views/slim/_form.html.slim
87
+ - lib/generators/inherited_resources_views/templates/views/slim/_model.html.slim
88
+ - lib/generators/inherited_resources_views/templates/views/slim/edit.html.slim
89
+ - lib/generators/inherited_resources_views/templates/views/slim/index.html.slim
90
+ - lib/generators/inherited_resources_views/templates/views/slim/new.html.slim
91
+ homepage: http://github.com
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.5
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Write a short summary, because Rubygems requires one.
115
+ test_files: []