common_core_js 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5bd570ce32ada5b0551a77526d1b25e82f9b10a4ce9199e9abc60c3256a0c824
4
- data.tar.gz: 39d7097d4e3daa434959ec9c72d93f83bee971d715f7ccde0fcb791332b8f490
3
+ metadata.gz: 69b48d2b11f7087d3a842266d1c08df9da022bc7191dbc71f286431ac02112f0
4
+ data.tar.gz: cdc77c41c2dff7e393837fb1954fc0bd599083c2ce305e98416c097866d6c4a8
5
5
  SHA512:
6
- metadata.gz: 344db104a6bcca04942313947217d71f786698f6656590b5f49f03974046a557e8de438c3ba9146c1f2041996926341942f84ef3ff2b947883386e6c7ab2e9c0
7
- data.tar.gz: 5c51d14d8d1055b3652ce5e2351582951a60b0d5cb78b1b91153cbf60aab5e141579f177c4de169dd5de3d9cc059c4795c6b45d3024c9d720dcd361ae37814b9
6
+ metadata.gz: bceefae2fd396020f7225df73e9f74a4f6ea7d06b94250880c872e68c921b43ac1eb0b0f34805098fbab5ca877fe26d54dc152230d2990a9b58428ccf9f6e6ea
7
+ data.tar.gz: d40870c3538adc2a9d687d583e7b3821544eff497425bf00f712d6426945477d7ac0bc191072ef5befbe0f38b9b0eb1b28b81298719d6eec38a427c458299509
@@ -0,0 +1,4 @@
1
+ # repo: your_github_handle/foobar
2
+ # filename: FUNDING.YML
3
+
4
+ github: [jasonfb]
data/README.md CHANGED
@@ -8,25 +8,32 @@ Yes, it's opinionated. Yes, it's metaprogramming. A lot of metaprogramming. Ruby
8
8
  No, I would not use this to build an intricate app. Yes, it's a great tool for prototyping. Yes, I think prototyping is a lost art.
9
9
 
10
10
 
11
- = THE SALES PITCH:
11
+ ## THE SALES PITCH:
12
12
  * Build plug-and-play scaffolding mixing HAML with jQuery-based Javascript
13
13
  * Automatically Reads Your Models (make them before building your scaffolding!)
14
- * Excellent for CRUD, lists with pagination, searching, sorting.
14
+ * Excellent for CRUD, lists with pagination, searching, ~~sorting.~~
15
15
  * Wonderful for prototyping.
16
16
  * Plays nicely with Devise, Kaminari, Haml-Rails, Rspec.
17
- * Create specs autoamatically along with the controllers.
17
+ * Create specs automatically along with the controllers.
18
18
  * Nest your routes model-by-model for built-in poor man's authentication
19
19
  * Throw the scaffolding away when your app is ready to graduate to its next phase.
20
20
 
21
+ ## THE BLOG POST
21
22
 
22
- = HOW EASY?
23
+ It's really easy to get started by following along with this blog post that creates three simple tables (User, Event, and Format).
24
+
25
+ Feel free to build your own tables when you get to the sections for building the 'Event' scaffold:
26
+
27
+ https://blog.jasonfleetwoodboldt.com/common-core-js
28
+
29
+ ## HOW EASY?
23
30
 
24
31
 
25
32
  ```
26
33
  rails generate common_core:scaffold Thing
27
34
  ```
28
35
 
29
- = TO INSTALL
36
+ ## TO INSTALL
30
37
 
31
38
  - Add common_core_js to your Gemfile
32
39
 
@@ -7,7 +7,6 @@ module CommonCoreHelper
7
7
 
8
8
 
9
9
  def datetime_field_localized(form_object, field_name, value, label, timezone = nil )
10
-
11
10
  res = form_object.label(label,
12
11
  field_name,
13
12
  class: 'small form-text text-muted')
@@ -22,6 +21,7 @@ module CommonCoreHelper
22
21
 
23
22
 
24
23
  def date_field_localized(form_object, field_name, value, label, timezone = nil )
24
+
25
25
  res = form_object.label(label,
26
26
  field_name,
27
27
  class: 'small form-text text-muted')
@@ -51,7 +51,7 @@ module CommonCoreHelper
51
51
  controller.current_timezone
52
52
  elsif defined?(current_user)
53
53
  if current_user.try(:timezone)
54
- Time.now.in_time_zone(current_user.timezone).strftime("%z").to_i/100
54
+ Time.now.in_time_zone(current_user.timezone.to_i).strftime("%z").to_i/100
55
55
  else
56
56
  Time.now.strftime("%z").to_i/100
57
57
  end
@@ -62,7 +62,6 @@ module CommonCoreHelper
62
62
 
63
63
 
64
64
  def date_to_current_timezone(date, timezone = nil)
65
-
66
65
  # if the timezone is nil, use the server date'
67
66
  if timezone.nil?
68
67
  timezone = Time.now.strftime("%z").to_i/100
@@ -1,3 +1,3 @@
1
1
  module CommonCoreJs
2
- VERSION = '0.3.7'
2
+ VERSION = '0.3.8'
3
3
  end
@@ -83,15 +83,12 @@ module CommonCore
83
83
  end
84
84
  end
85
85
 
86
-
87
-
88
86
  auth_assoc = @auth.gsub("current_","")
89
87
  auth_assoc_field = auth_assoc + "_id"
90
88
 
91
-
92
-
93
89
  exclude_fields = [auth_assoc_field.to_sym, :id, :created_at, :updated_at, :encrypted_password, :reset_password_token,
94
- :reset_password_sent_at, :remember_created_at]
90
+ :reset_password_sent_at, :remember_created_at, :confirmation_token, :confirmed_at,
91
+ :confirmation_sent_at, :unconfirmed_email]
95
92
  begin
96
93
  @columns = object.columns.map(&:name).map(&:to_sym).reject{|field| exclude_fields.include?(field) }
97
94
  rescue StandardError => e
@@ -99,6 +96,9 @@ module CommonCore
99
96
  exit
100
97
  end
101
98
 
99
+ @no_delete = false
100
+ @no_create = false
101
+
102
102
  flags = meta_args[1]
103
103
  flags.each do |f|
104
104
  case (f)
@@ -110,6 +110,10 @@ module CommonCore
110
110
  @specs_only = true
111
111
  when "--no-specs"
112
112
  @no_specs = true
113
+ when "--no-delete"
114
+ @no_delete = true
115
+ when "--no-create"
116
+ @no_create = true
113
117
  end
114
118
  end
115
119
 
@@ -123,7 +127,7 @@ module CommonCore
123
127
  end
124
128
 
125
129
 
126
- if auth_identifier == @singular
130
+ if @auth && auth_identifier == @singular
127
131
  @self_auth = true
128
132
  end
129
133
 
@@ -150,7 +154,7 @@ module CommonCore
150
154
 
151
155
  unless @specs_only
152
156
  template "controller.rb", File.join("app/controllers#{namespace_with_dash}", "#{plural}_controller.rb")
153
- if @namespace
157
+ if @namespace && defined?(controller_descends_from) == nil
154
158
  template "base_controller.rb", File.join("app/controllers#{namespace_with_dash}", "base_controller.rb")
155
159
  end
156
160
  end
@@ -299,8 +303,12 @@ module CommonCore
299
303
  end
300
304
 
301
305
  def all_objects_variable
306
+
302
307
  # needs the authenticated root user
303
- "#{@auth}.#{ @nested_args.map{|a| "#{@nested_args_plural[a]}.find(@#{a})"}.join('.') + "." if @nested_args.any?}#{plural}"
308
+ # "#{@auth}.#{ @nested_args.map{|a| "#{@nested_args_plural[a]}.find(@#{a})"}.join('.') + "." if @nested_args.any?}#{plural}"
309
+
310
+ all_objects_root + ".page(params[:page])"
311
+
304
312
  end
305
313
 
306
314
  def auth_object
@@ -554,12 +562,12 @@ module CommonCore
554
562
 
555
563
  def destroy_action
556
564
  return false if @self_auth
557
- return true
565
+ return !@no_delete
558
566
  end
559
567
 
560
568
  def create_action
561
569
  return false if @self_auth
562
- return true
570
+ return !@no_create
563
571
  end
564
572
 
565
573
 
@@ -1,7 +1,7 @@
1
1
  <%= all_line_fields %>
2
2
  %td
3
3
  <% if destroy_action %>
4
- = link_to "Delete <i class='fa fa-1x fa-remove'></i>".html_safe, <%= path_helper_singular %>(<%= singular %>), remote: true ,method: :delete, disable_with: "Loading...", class: "delete-<%= singular %>-button btn btn-primary "
4
+ = link_to "Delete <i class='fa fa-1x fa-remove'></i>".html_safe, <%= path_helper_singular %>(<%= singular %>), remote: true, method: :delete, data: {confirm: 'Are you sure?'}, disable_with: "Loading...", class: "delete-<%= singular %>-button btn btn-primary "
5
5
  <% end %>
6
6
  &nbsp;
7
7
  = link_to "Edit <i class='fa fa-1x fa-list-alt'></i>".html_safe, edit_<%= path_helper_singular %>(<%= singular %>), remote: true , disable_with: "Loading...", class: "edit-<%= singular %>-button btn btn-primary "
@@ -50,7 +50,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
50
50
  end
51
51
 
52
52
  def create
53
- modified_params = modify_date_inputs_on_params(<%=singular_name %>_params.dup<% if !create_merge_params.empty? %>.merge!(<%= create_merge_params %>)<%end%> , <%= @auth ? @auth : "nil" %>)
53
+ modified_params = modify_date_inputs_on_params(<%=singular_name %>_params.dup<% if !create_merge_params.empty? %>.merge!(<%= create_merge_params %>)<% end %> <%= @auth ? ",#{@auth}" : "" %>)
54
54
  @<%=singular_name %> = <%=class_name %>.create(modified_params)
55
55
  respond_to do |format|
56
56
  if @<%= singular_name %>.save
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: common_core_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
@@ -131,6 +131,7 @@ files:
131
131
  - ".generators"
132
132
  - ".gitignore"
133
133
  - ".rakeTasks"
134
+ - FUNDING.yml
134
135
  - Gemfile
135
136
  - Gemfile.lock
136
137
  - LICENSE