kablam 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/{data_controller.rb → kablam_controller.rb} +1 -1
- data/app/views/{data → kablam}/create.js.erb +1 -1
- data/app/views/{data → kablam}/destroy.js.erb +1 -1
- data/app/views/{data → kablam}/form.html.erb +0 -0
- data/app/views/{data → kablam}/undo.js.erb +0 -0
- data/app/views/{data → kablam}/update.js.erb +1 -1
- data/app/views/kablam_forms/_form_generator.html.erb +1 -1
- data/config/routes.rb +7 -0
- data/kablam.gemspec +3 -3
- data/lib/generators/kablam/forms_generator.rb +2 -0
- data/lib/generators/kablam/install_generator.rb +11 -6
- data/lib/generators/kablam/templates/_sample_target_item.html.erb +25 -0
- data/lib/kablam/forms.rb +8 -0
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca66e443b91e7d0343983aa56ff183eaa4a9497aeec5aa80f608e23db08060f8
|
4
|
+
data.tar.gz: 39c970580855e0063ece5d79f0b794354058f7474685017b9469c079f0301edb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dced7f9382e138a51dd307ab981bb1fd4d0ca374c2f4f7a38b47664b5cbe9b473daa9492327f33c8005c1fd0414d42b9108f3818d511d75cd3e069e0c54ab0d5
|
7
|
+
data.tar.gz: 7380749f0aadb71e1741120cad316aca1d6886d8b0b2691e6129a32113e595e5d310cafe2a2b4c79d01578110775b5557e1bbc83bc3122493162d38faaef1186
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
|
3
|
-
class
|
3
|
+
class KablamController < ApplicationController
|
4
4
|
protect_from_forgery with: :exception
|
5
5
|
before_action :set_model, only: [:create, :update, :undo, :destroy, :form]
|
6
6
|
before_action :set_object, only: [:update, :destroy]
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= hide @object %>
|
2
2
|
<% if @object.undoable? %>
|
3
3
|
<%= render_flash message: 'Deleted', partial: 'application/flash_undo',
|
4
|
-
link: button_to('Undo',
|
4
|
+
link: button_to('Undo', kablam_undo_path(@object.class.table_name, @object,
|
5
5
|
@object.model_name.singular.to_sym => { destroyed_at: nil }),
|
6
6
|
{data: { disable_with: 'Restoring…' },
|
7
7
|
class: 'no-underline mt3 f4 tc pv2 ph4 white bg-black hover-bg-green shadow-5',
|
File without changes
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<% if params[:target].present? %>
|
2
2
|
|
3
3
|
var objRow = byId('<%= @object.html_id %>')
|
4
|
-
var content = `<%= j render "
|
4
|
+
var content = `<%= j render "kablam/models/#{@object.model_name.singular}", obj: @object %>`
|
5
5
|
var newRow = HTMLElement.From(content);
|
6
6
|
|
7
7
|
objRow.innerHTML = newRow.innerHTML
|
@@ -5,7 +5,7 @@
|
|
5
5
|
@method = (obj.id.blank? ? :post : :patch)
|
6
6
|
@form_name = @model.to_s.underscore
|
7
7
|
@form_id = "#{obj.id.blank? ? "new" : "update"}_#{@form_name}_form"
|
8
|
-
@url = (@method == :post ?
|
8
|
+
@url = (@method == :post ? kablam.create_path(@table_name) : kablam.update_path(@table_name, obj.id))
|
9
9
|
%>
|
10
10
|
|
11
11
|
<%= form_with model: obj, url: @url, method: @method, id: @form_id, class: classes[:form_wrapper] do |f| %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Kablam::Engine.routes.draw do
|
2
|
+
get '/:name/form' => 'kablam#form', as: 'form'
|
3
|
+
post '/:name' => 'kablam#create', as: 'create'
|
4
|
+
patch '/:name/:id' => 'kablam#update', as: 'update'
|
5
|
+
delete '/:name/:id' => 'kablam#destroy', as: 'destroy'
|
6
|
+
put '/:name/:id' => 'kablam#undo', as: 'undo'
|
7
|
+
end
|
data/kablam.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'kablam'
|
3
|
-
s.version = '0.0
|
3
|
+
s.version = '0.1.0'
|
4
4
|
s.date = '2018-09-14'
|
5
|
-
s.summary = "
|
6
|
-
s.description = "Gem to make development of everything in rails even
|
5
|
+
s.summary = "Kablam! All the things you hate. But Faster."
|
6
|
+
s.description = "Gem to make development of everything in rails faster. Form creation & styling, all the resource routes, even actioncable messaging!"
|
7
7
|
s.authors = ["Sergio Rivas"]
|
8
8
|
s.email = 'sergiorivas@163.com'
|
9
9
|
s.files = `git ls-files`.split("\n")
|
@@ -74,7 +74,9 @@ module Kablam
|
|
74
74
|
|
75
75
|
def gen_yaml(db_index)
|
76
76
|
path = "config/locales/kablam-forms.#{name}.yml"
|
77
|
+
original = YAML.load_file(path)
|
77
78
|
yml_hash = {name => {"kablam_forms" => db_to_hash(db_index)}}
|
79
|
+
yml_hash.merge!(original) if original.present?
|
78
80
|
|
79
81
|
File.write(path, yml_hash.to_yaml)
|
80
82
|
dump_yaml_with_double_quotes(path)
|
@@ -13,14 +13,19 @@ module Kablam
|
|
13
13
|
|
14
14
|
# Setup Initializer
|
15
15
|
template "kablam.rb", "config/initializers/kablam.rb"
|
16
|
+
template "_sample_target_item.html.erb", "app/views/kablam/models/_sample_target_item.html.erb"
|
16
17
|
|
17
18
|
def setup_routes
|
18
|
-
route "# form/create/update/destroy/undo for all models"
|
19
|
-
route "
|
20
|
-
route "
|
21
|
-
route "
|
22
|
-
route "
|
23
|
-
route "
|
19
|
+
route "# KABLAM! form/create/update/destroy/undo for all models"
|
20
|
+
route "# Note: Make sure Kablam engine is at the BOTTOM of routes"
|
21
|
+
route "# helpers to use KABLAM! [examples w/ 'posts' model)"
|
22
|
+
route "# ---> kablam.form_path('posts')"
|
23
|
+
route "# (if edit form, must add '?id=\#\{@post.id\}' at end of path)"
|
24
|
+
route "# ---> kablam.create_path('posts')"
|
25
|
+
route "# ---> kablam.delete_path('posts', @post)"
|
26
|
+
route "# ---> kablam.update_path('posts', @post)"
|
27
|
+
route "# ---> kablam.undo_path('posts', @post)"
|
28
|
+
route "mount Kablam::Engine => '/kablam', as: 'kablam'"
|
24
29
|
end
|
25
30
|
|
26
31
|
def setup_assets
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!-- If rendering things to a table after form submission,
|
2
|
+
create a partial with the model name in this folder.
|
3
|
+
example: for User, create a file '_user.html.erb'
|
4
|
+
Then follow the following format:
|
5
|
+
|
6
|
+
note: THE ACTIVERECORD OBJECT muse be called 'obj' in your partial!
|
7
|
+
note: obj.html_id is a helper method included in Kablam.
|
8
|
+
-->
|
9
|
+
|
10
|
+
<tr id="<%= obj.html_id %>" class="some_tr_class_you_want">
|
11
|
+
<td class="some_td_class"><%= obj.some_column %></td>
|
12
|
+
<td class="some_td_class"><%= obj.another_column %></td>
|
13
|
+
|
14
|
+
<td class="some_td_class">
|
15
|
+
<%= raw Kablam::Forms.render_edit(obj, 'form_div_id', 'table_div_id') %>
|
16
|
+
<!-- Can also give params in a hash, {class: "class", text: "edit" } -->
|
17
|
+
</td>
|
18
|
+
<td class="">
|
19
|
+
<%= raw Kablam::Forms.render_destroy(obj) %>
|
20
|
+
<!-- Can also give params in a hash, {class: "class", text: "edit" } -->
|
21
|
+
</td>
|
22
|
+
</tr>
|
23
|
+
|
24
|
+
|
25
|
+
|
data/lib/kablam/forms.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
module Kablam
|
2
2
|
class Forms
|
3
|
+
def self.render_edit(obj, target_id, table_id, opt={})
|
4
|
+
"<a class='#{opt[:class]}' onclick='event.preventDefault();load('#{target_id}', '/kablam/#{obj.class.table_name}/form?id=#{obj.id}&target=#{table_id}')' href='#'>#{opt[:text] || "Edit"}</a>"
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.render_destroy(obj, opt={})
|
8
|
+
"<a data-disable-with='…' class='#{opt[:class]}' data-remote='true' rel='nofollow' data-method='delete' href='/kablam/#{obj.class.table_name}/#{obj.id}'>#{opt[:text] || "Remove"}</a>"
|
9
|
+
end
|
10
|
+
|
3
11
|
def self.default_classes
|
4
12
|
{
|
5
13
|
# Generally used classes for everything.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kablam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Rivas
|
@@ -52,7 +52,8 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description: Gem to make development of everything in rails
|
55
|
+
description: Gem to make development of everything in rails faster. Form creation
|
56
|
+
& styling, all the resource routes, even actioncable messaging!
|
56
57
|
email: sergiorivas@163.com
|
57
58
|
executables: []
|
58
59
|
extensions: []
|
@@ -69,13 +70,13 @@ files:
|
|
69
70
|
- app/assets/stylesheets/kablam.scss
|
70
71
|
- app/channels/chat_channel.rb
|
71
72
|
- app/controllers/concerns/api_settings.rb
|
72
|
-
- app/controllers/
|
73
|
+
- app/controllers/kablam_controller.rb
|
73
74
|
- app/views/.DS_Store
|
74
|
-
- app/views/
|
75
|
-
- app/views/
|
76
|
-
- app/views/
|
77
|
-
- app/views/
|
78
|
-
- app/views/
|
75
|
+
- app/views/kablam/create.js.erb
|
76
|
+
- app/views/kablam/destroy.js.erb
|
77
|
+
- app/views/kablam/form.html.erb
|
78
|
+
- app/views/kablam/undo.js.erb
|
79
|
+
- app/views/kablam/update.js.erb
|
79
80
|
- app/views/kablam_forms/.DS_Store
|
80
81
|
- app/views/kablam_forms/_form_generator.html.erb
|
81
82
|
- app/views/kablam_forms/_kablam_form.html.erb
|
@@ -89,11 +90,13 @@ files:
|
|
89
90
|
- app/views/kablam_forms/fields/_pretext.html.erb
|
90
91
|
- app/views/kablam_forms/fields/_select.html.erb
|
91
92
|
- app/views/kablam_forms/fields/_text.html.erb
|
93
|
+
- config/routes.rb
|
92
94
|
- kablam.gemspec
|
93
95
|
- lib/generators/kablam/USAGE
|
94
96
|
- lib/generators/kablam/forms_generator.rb
|
95
97
|
- lib/generators/kablam/install_generator.rb
|
96
98
|
- lib/generators/kablam/messaging_generator.rb
|
99
|
+
- lib/generators/kablam/templates/_sample_target_item.html.erb
|
97
100
|
- lib/generators/kablam/templates/chat.rb
|
98
101
|
- lib/generators/kablam/templates/kablam.rb
|
99
102
|
- lib/generators/kablam/templates/message.rb
|
@@ -125,5 +128,5 @@ rubyforge_project:
|
|
125
128
|
rubygems_version: 2.7.6
|
126
129
|
signing_key:
|
127
130
|
specification_version: 4
|
128
|
-
summary:
|
131
|
+
summary: Kablam! All the things you hate. But Faster.
|
129
132
|
test_files: []
|