common_core_js 0.3.1 → 0.3.6

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: 2219c80f29355076e17de37d99966e7b491aa09f255a911ec907b32a983bfa1c
4
- data.tar.gz: 00dab2e16fc5145aff949648dcdddd60993aa99862b18319117d521c9ab78b16
3
+ metadata.gz: 0c741cb686a2b2cdbaf0c78412ef5733e82e048d6cd94507675a14288464b617
4
+ data.tar.gz: fb86d6cabe810f86faca72ecc1a7cf6045bb24df6fd6124de82289ec70d4386c
5
5
  SHA512:
6
- metadata.gz: 731c8e6ef809fcade1810f67a389606f0abb62a58fe54dfcb8baa6a6b741986511cc0df2a180f390a4b55c3aee52682b91a2a64902629ac2b4fef57ef7d737a3
7
- data.tar.gz: 5a34083277277efbf9b4ef9ed7a949156489d4fbc71a14b00105ff0a169ff9a0b469e6b2ceb90a8727d86fc6f8a3ff2ac3291aeac9aaf45f650fd098fb1e9b50
6
+ metadata.gz: aff7ba81411119d30bc13f18b0fcbdc5bf2d27353758d8795d1d8184a766636fa47faae4f3a9eee294e51ff6ed4a148817065ff51d8f0eef4407bee162e8a971
7
+ data.tar.gz: 0b863a346bc88ff5e12f3a942183f8a9f37c527721545a8a353cd16d957d24a176ce0f9751f333906c208b5a0484b367b1cc21096391c5db10e15ae825c76ec3
data/.gitignore CHANGED
@@ -11,4 +11,6 @@ test/dummy/tmp/
11
11
 
12
12
  .idea/
13
13
  *.gem
14
- .DS_Store
14
+ .DS_Store
15
+
16
+ dump.rdb
data/LICENSE CHANGED
@@ -1,8 +1,8 @@
1
1
  Permission is hereby granted to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2
2
 
3
- Any users of this software agree to work to dismantle systemic racism in American society, seek justice for black, brown, trans-people, women, and LTBQIAA+ representation and inclusion.
3
+ Any users of this software agree to work to dismantle systemic racism, seek justice for black, brown, transgender people, women, and LTBQIAA+ representation and inclusion.
4
4
 
5
- Organizations using this software agree to center the narratives of black, brown, and trans people in the self vision and imagary.
5
+ Organizations using this software agree to center the narratives of black, brown, and transgender people people.
6
6
 
7
7
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
8
 
@@ -0,0 +1,79 @@
1
+ module CommonCoreHelper
2
+
3
+ def timezonize(tz)
4
+ tz = tz.to_i
5
+ (tz >= 0 ? "+" : "-") + sprintf('%02d',tz.abs) + ":00"
6
+ end
7
+
8
+
9
+ def datetime_field_localized(form_object, field_name, value, label, timezone = nil )
10
+
11
+ res = form_object.label(label,
12
+ field_name,
13
+ class: 'small form-text text-muted')
14
+
15
+ res << form_object.text_field(field_name, class: 'form-control',
16
+ type: 'datetime-local',
17
+ value: date_to_current_timezone(value, timezone))
18
+
19
+ res << timezonize(timezone)
20
+ res
21
+ end
22
+
23
+
24
+ def date_field_localized(form_object, field_name, value, label, timezone = nil )
25
+ res = form_object.label(label,
26
+ field_name,
27
+ class: 'small form-text text-muted')
28
+
29
+ res << form_object.text_field(field_name, class: 'form-control',
30
+ type: 'date',
31
+ value: value )
32
+
33
+ res
34
+ end
35
+
36
+ def time_field_localized(form_object, field_name, value, label, timezone = nil )
37
+ res = form_object.label(label,
38
+ field_name,
39
+ class: 'small form-text text-muted')
40
+
41
+ res << form_object.text_field(field_name, class: 'form-control',
42
+ type: 'time',
43
+ value: date_to_current_timezone(value, timezone))
44
+
45
+ res << timezonize(tz)
46
+ res
47
+ end
48
+
49
+ def current_timezone
50
+ if controller.try(:current_timezone)
51
+ controller.current_timezone
52
+ elsif defined?(current_user)
53
+ if current_user.try(:timezone)
54
+ Time.now.in_time_zone(current_user.timezone).strftime("%z").to_i/100
55
+ else
56
+ Time.now.strftime("%z").to_i/100
57
+ end
58
+ else
59
+ raise "no method current_user is available or it does not implement timezone; please implement/override the method current_timezone IN YOUR CONTROLLER"
60
+ end
61
+ end
62
+
63
+
64
+ def date_to_current_timezone(date, timezone = nil)
65
+
66
+ # if the timezone is nil, use the server date'
67
+ if timezone.nil?
68
+ timezone = Time.now.strftime("%z").to_i/100
69
+ end
70
+
71
+ return nil if date.nil?
72
+
73
+ begin
74
+ return date.in_time_zone(timezone).strftime("%Y-%m-%dT%H:%M")
75
+ rescue
76
+ return nil
77
+ end
78
+ end
79
+ end
@@ -8,7 +8,7 @@
8
8
 
9
9
  <% if object.errors.any? %>
10
10
  $(".flash-notices").html("<%= j render 'layouts/flash_notices' %>");
11
- $("<%= (scope + " ") if controller.common_scope %> .new-<%=singular%>-form").html("<%= j render(partial: '#{controller.namespace}errors', locals: {resource: object}) %>")
11
+ $("<%= (scope + " ") if controller.common_scope %> .new-<%=singular%>-form").html('<%= j render(partial: "#{controller.namespace}errors", locals: {resource: object}) %>')
12
12
  $("<%= (scope + " ") if controller.common_scope %> .new-<%=singular%>-form").append("<%= j render(partial: "new", locals: { singular.to_sym => object}) %><i class='fa fa-times-circle fa-2x' data-name='<%=singular%>' data-role='close-button' />").slideDown();
13
13
  <% else %>
14
14
  $("<%= (scope + " ") if controller.common_scope %> .new-<%=singular%>-form").slideUp();
@@ -1,4 +1,8 @@
1
1
  %td{style: "position: relative;", colspan: controller.default_colspan}
2
+ - if object.errors.any?
3
+ = render(partial: "#{controller.namespace}errors", locals: {resource: object})
4
+
5
+
2
6
  Editing
3
7
  - if object.try(:to_label)
4
8
  = object.to_label
@@ -1,6 +1,7 @@
1
1
  <% if object.errors.any? %>
2
2
  <% pass_through_locals ||= {} %>
3
- $(".<%= singular %>-table tr[data-id=<%= object.id %>][data-edit='true']").html("<%= j render(partial: '#{controller.namespace}errors', locals: {resource: object}) %><%= j render partial: 'edit', locals: {singular.to_sym => object, url: url, colspan: controller.default_colspan}.merge(pass_through_locals || {}) %>")
3
+ $(".<%= singular %>-table tr[data-id=<%= object.id %>][data-edit='true']").html("<%= j render partial: 'edit', locals: {singular.to_sym => object, url: url, colspan: controller.default_colspan}.merge(pass_through_locals || {}) %>")
4
+
4
5
  $(".flash-notices").html("<%= j render 'layouts/flash_notices' %>");
5
6
  <% else %>
6
7
  $(".<%= singular %>-table tr[data-id=<%= object.id %>]:not([data-edit='true'])").replaceWith("<%= j render partial: 'line', locals: {singular.to_sym => object } %>").fadeIn()
@@ -6,4 +6,24 @@ require 'haml-rails'
6
6
 
7
7
  module CommonCoreJs
8
8
  # Your code goes here...
9
+ #
10
+ module ControllerHelpers
11
+ def modify_date_inputs_on_params(modified_params)
12
+ use_timezone = authenticated_user.timezone || Time.now.strftime("%z")
13
+
14
+ modified_params = modified_params.tap do |params|
15
+ params.keys.each{|k|
16
+ if k.ends_with?("_at") || k.ends_with?("_date")
17
+
18
+ begin
19
+ params[k] = DateTime.strptime("#{params[k]} #{use_timezone}", '%Y-%m-%dT%H:%M %z')
20
+ rescue StandardError
21
+
22
+ end
23
+ end
24
+ }
25
+ end
26
+ modified_params
27
+ end
28
+ end
9
29
  end
@@ -1,5 +1,7 @@
1
1
  module CommonCoreJs
2
2
  class Engine < ::Rails::Engine
3
3
  # isolate_namespace CommonCoreJs
4
+
5
+
4
6
  end
5
7
  end
@@ -1,3 +1,3 @@
1
1
  module CommonCoreJs
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.6'
3
3
  end
@@ -10,12 +10,11 @@ module CommonCore
10
10
 
11
11
  def initialize(*args) #:nodoc:
12
12
  super
13
-
14
- copy_file "common_core.js", "vendor/assets/javascripts/common_core.js"
15
- copy_file "common_core.scss", "vendor/assets/stylesheets/common_core.scss"
13
+ copy_file "common_core.js", "app/javascript/common_core.js"
14
+ copy_file "common_core.scss", "app/assets/stylesheets/common_core.scss"
15
+ copy_file "_flash_notices.haml", "app/views/layouts/_flash_notices.haml"
16
16
 
17
17
  end
18
-
19
18
  end
20
19
  end
21
20
 
@@ -1,7 +1,36 @@
1
1
  require 'rails/generators/erb/scaffold/scaffold_generator'
2
2
  require 'ffaker'
3
3
 
4
+
5
+
4
6
  module CommonCore
7
+
8
+ module GeneratorHelper
9
+ def text_area_output(col, field_length)
10
+ lines = field_length % 40
11
+ if lines > 5
12
+ lines = 5
13
+ end
14
+
15
+ ".row
16
+ %div{class: \"form-group col-md-4 \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\"}
17
+ = f.text_area :#{col.to_s}, class: 'form-control', cols: 40, rows: '#{lines}'
18
+ %label.form-text
19
+ #{col.to_s.humanize}\n"
20
+ end
21
+
22
+
23
+
24
+ def field_output(col, type = nil, width)
25
+ ".row
26
+ %div{class: \"form-group col-md-4 \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\"}
27
+ = f.text_field :#{col.to_s}, value: @#{singular}.#{col.to_s}, size: #{width}, class: 'form-control', type: '#{type}'
28
+ %label.form-text
29
+ #{col.to_s.humanize}\n"
30
+ end
31
+ end
32
+
33
+
5
34
  class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
6
35
  hook_for :form_builder, :as => :scaffold
7
36
 
@@ -9,6 +38,9 @@ module CommonCore
9
38
  attr_accessor :path, :singular, :plural, :singular_class, :nest_with
10
39
 
11
40
 
41
+ include GeneratorHelper
42
+
43
+
12
44
  def initialize(*meta_args) #:nodoc:
13
45
  super
14
46
 
@@ -19,12 +51,7 @@ module CommonCore
19
51
  exit
20
52
  end
21
53
 
22
- begin
23
- @columns = object.columns.map(&:name).map(&:to_sym).reject{|x| x==:updated_at || x==:created_at || x==:id}
24
- rescue StandardError => e
25
- puts "Ooops... it looks like is an object for #{class_name}. Please create the database table with fields first. "
26
- exit
27
- end
54
+
28
55
 
29
56
  args = meta_args[0]
30
57
  @singular = args[0].tableize.singularize # should be in form hello_world
@@ -56,6 +83,18 @@ module CommonCore
56
83
  end
57
84
  end
58
85
 
86
+ auth_assoc = @auth.gsub("current_","")
87
+ auth_assoc_field = auth_assoc + "_id"
88
+
89
+
90
+ begin
91
+ @columns = object.columns.map(&:name).map(&:to_sym).reject{|field| field==:updated_at ||
92
+ field==:created_at || field==:id || field == auth_assoc_field.to_sym }
93
+ rescue StandardError => e
94
+ puts "Ooops... it looks like is an object for #{class_name}. Please create the database table with fields first. "
95
+ exit
96
+ end
97
+
59
98
  flags = meta_args[1]
60
99
  flags.each do |f|
61
100
  case (f)
@@ -107,6 +146,8 @@ module CommonCore
107
146
  unless @no_specs
108
147
  template "controller_spec.rb", File.join("spec/controllers#{namespace_with_dash}", "#{plural}_controller_spec.rb")
109
148
  end
149
+
150
+ template "_errors.haml", File.join("app/views#{namespace_with_dash}", "_errors.haml")
110
151
  end
111
152
 
112
153
  def list_column_headings
@@ -323,9 +364,7 @@ module CommonCore
323
364
 
324
365
  def all_form_fields
325
366
  res = @columns.map { |col|
326
- # if eval("#{singular_class}.columns_hash['#{col}']").nil?
327
- # byebug
328
- # end
367
+
329
368
 
330
369
  type = eval("#{singular_class}.columns_hash['#{col}']").type
331
370
  limit = eval("#{singular_class}.columns_hash['#{col}']").limit
@@ -335,47 +374,77 @@ module CommonCore
335
374
  when :integer
336
375
  # look for a belongs_to on this object
337
376
  if col.to_s.ends_with?("_id")
377
+ # guess the association name label
378
+
338
379
 
339
380
  assoc_name = col.to_s.gsub("_id","")
340
- assoc = eval("#{singular_class}.reflect_on_association(':#{assoc_name}')")
381
+ assoc = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
382
+ if assoc.nil?
383
+ puts "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
384
+ exit
385
+ end
386
+
387
+ if assoc.active_record.column_names.include?("name")
388
+ display_column = "name"
389
+ elsif assoc.active_record.column_names.include?("to_label")
390
+ display_column = "to_label"
391
+ elsif assoc.active_record.column_names.include?("full_name")
392
+ display_column = "full_name"
393
+ elsif assoc.active_record.column_names.include?("display_name")
394
+ display_column = "display_name"
395
+ elsif assoc.active_record.column_names.include?("email")
396
+ display_column = "email"
397
+ end
398
+
341
399
  ".row
342
- .form-group.col-md-4
343
- = f.collection_select(:#{col.to_s}, #{assoc_name.titleize}.all, :id, :to_label, {:prompt => true}, class: 'form-control')
400
+ %div{class: \"form-group col-md-4 \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{assoc_name.to_s})}\"}
401
+ = f.collection_select(:#{col.to_s}, #{assoc_name.titleize}.all, :id, :#{display_column}, {prompt: true, selected: @#{singular}.#{col.to_s} }, class: 'form-control')
344
402
  %label.small.form-text.text-muted
345
403
  #{col.to_s.humanize}"
346
404
 
347
405
  else
348
406
  ".row
349
- .form-group.col-md-4
350
- = f.text_field :#{col.to_s}, class: 'form-control', size: 4, type: 'number'
407
+ %div{class: \"form-group col-md-4 \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\"}
408
+ = f.text_field :#{col.to_s}, value: @#{singular}.#{col.to_s}, class: 'form-control', size: 4, type: 'number'
351
409
  %label.form-text
352
410
  #{col.to_s.humanize}\n"
353
411
  end
354
412
  when :string
355
- width = (limit && limit < 40) ? limit : (40)
356
- ".row
357
- .form-group.col-md-4
358
- = f.text_field :#{col.to_s}, size: #{width}, class: 'form-control'
359
- %label.form-text
360
- #{col.to_s.humanize}\n"
413
+ limit ||= 256
414
+ if limit < 256
415
+ field_output(col, nil, limit)
416
+ else
417
+ text_area_output(col, limit)
418
+ end
419
+
361
420
  when :text
362
- # width = (limit && limit < 40) ? limit : (40)
363
- ".row
364
- .form-group.col-md-4
365
- = f.text_area :#{col.to_s}, rows: 4, cols: 40, class: 'form-control'
366
- %label.form-text
367
- #{col.humanize}\n"
368
- when :datetime
369
- ".row
370
- .form-group.col-md-4
371
- = f.text_field :#{col.to_s}, class: 'form-control', type: 'datetime-local'
372
- %label.form-text
373
- #{col.to_s.humanize}\n"
421
+ limit ||= 256
422
+ if limit < 256
423
+ field_output(col, nil, limit)
424
+ else
425
+ text_area_output(col, limit)
374
426
  end
375
- }.join("\n")
427
+
428
+ when :datetime
429
+ ".row
430
+ %div{class: \"form-group col-md-4 \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\"}
431
+ = datetime_field_localized(f, :#{col.to_s}, @#{singular}.#{col.to_s}, '#{col.to_s.humanize}', #{@auth ? @auth+'.timezone' : 'nil'})"
432
+ when :date
433
+ ".row
434
+ %div{class: \"form-group col-md-4 \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\"}
435
+ = date_field_localized(f, :#{col.to_s}, @#{singular}.#{col.to_s}, '#{col.to_s.humanize}', #{@auth ? @auth+'.timezone' : 'nil'})"
436
+ when :time
437
+ ".row
438
+ %div{class: \"form-group col-md-4 \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\"}
439
+ = time_field_localized(f, :#{col.to_s}, @#{singular}.#{col.to_s}, '#{col.to_s.humanize}', #{@auth ? @auth+'.timezone' : 'nil'})"
440
+
441
+ end
442
+
443
+ }.join("\n")
376
444
  return res
377
445
  end
378
446
 
447
+
379
448
  def all_line_fields
380
449
  res = "%tr{'data-id': #{singular}.id, 'data-edit': 'false'}\n"
381
450
 
@@ -395,11 +464,26 @@ module CommonCore
395
464
  assoc = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
396
465
 
397
466
  if assoc.nil?
398
- raise "can't find assocation for #{assoc_name}"
467
+ puts "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
468
+ exit
469
+ end
470
+
471
+ if assoc.active_record.column_names.include?("name")
472
+ display_column = "name"
473
+ elsif assoc.active_record.column_names.include?("to_label")
474
+ display_column = "to_label"
475
+ elsif assoc.active_record.column_names.include?("full_name")
476
+ display_column = "full_name"
477
+ elsif assoc.active_record.column_names.include?("display_name")
478
+ display_column = "display_name"
479
+ elsif assoc.active_record.column_names.include?("email")
480
+ display_column = "email"
481
+ else
482
+ puts "cant find any column to use as label for #{assoc.name.to_s}; any of name, to_labe, full_name, display_name, or email"
399
483
  end
400
484
 
401
485
  " %td
402
- = #{singular}.#{assoc.name.to_s}.to_label"
486
+ = #{singular}.#{assoc.name.to_s}.#{display_column}"
403
487
 
404
488
  else
405
489
  " %td
@@ -414,13 +498,43 @@ module CommonCore
414
498
  = #{singular}.#{col}"
415
499
  when :datetime
416
500
  " %td
417
- = #{singular}.#{col}"
501
+ - unless #{singular}.#{col}.nil?
502
+ = #{singular}.#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ') + timezonize(current_timezone)
503
+ - else
504
+ %span.alert-danger
505
+ MISSING
506
+ "
507
+ when :date
508
+ " %td
509
+ - unless #{singular}.#{col}.nil?
510
+ = #{singular}.#{col}
511
+ - else
512
+ %span.alert-danger
513
+ MISSING
514
+ "
515
+ when :time
516
+ " %td
517
+ - unless #{singular}.#{col}.nil?
518
+ = #{singular}.#{col}.in_time_zone(current_timezone).strftime('%l:%M %p ') + timezonize(current_timezone)
519
+ - else
520
+ %span.alert-danger
521
+ MISSING
522
+ "
523
+
418
524
  end
419
525
  }.join("\n")
420
526
  return res
421
527
  end
422
528
 
423
529
 
530
+ def controller_descends_from
531
+ if defined?(@namespace.titlecase + "::BaseController")
532
+ @namespace.titlecase + "::BaseController"
533
+ else
534
+ "ApplicationController"
535
+ end
536
+ end
537
+
424
538
 
425
539
  private # thor does something fancy like sending the class all of its own methods during some strange run sequence
426
540
  # does not like public methods
@@ -0,0 +1,5 @@
1
+ - if resource.errors.any?
2
+ #error_explanation
3
+ - resource.errors.full_messages.each do |message|
4
+ %div.alert.alert-danger
5
+ = message
@@ -0,0 +1,7 @@
1
+ - unless notice.nil?
2
+ %div.alert.alert-notice.alert-dismissible
3
+ = notice
4
+
5
+ - unless alert.nil?
6
+ %div.alert.alert-danger.alert-dismissible
7
+ = alert
@@ -1,3 +1,5 @@
1
1
  <%= all_line_fields %>
2
2
  %td
3
- = 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 pull-right "
3
+ = 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
+ &nbsp;
5
+ = 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 "
@@ -1,4 +1,5 @@
1
1
  .container-fluid
2
2
  .row
3
3
  .col-md-12
4
- = render partial: "<%= namespace_with_trailing_dash %><%= plural %>/list", locals: {<%= plural %>: <%= all_objects_root %>.order("created_at DESC").page(1)}
4
+ .<%= singular %>-list
5
+ = render partial: "<%= namespace_with_trailing_dash %><%= plural %>/list", locals: {<%= plural %>: <%= all_objects_root %>.order("created_at DESC").page(1)}
@@ -1,16 +1,31 @@
1
1
 
2
2
  require("jquery")
3
- console.log("loading common core...")
3
+ // console.log("loading common core...")
4
+
5
+ // require("jstimezonedetect/dist/jstz.min")
6
+ // var JSTZ = require('jstimezonedetect');
7
+
8
+
4
9
 
5
- $(function(){
6
- // always pass csrf tokens on ajax calls
7
- $.ajaxSetup({
8
- headers: { 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content') }
9
- });
10
- });
11
10
 
12
11
  $(document).on('turbolinks:load', function() {
12
+
13
13
  $(document).ready(() => {
14
+ var user_timezone = '';
15
+ try {user_timezone = JSTZ.determine().name();} catch(e){}
16
+ // always pass csrf tokens on ajax calls
17
+
18
+
19
+ // $.ajaxSetup({
20
+ // beforeSend: (xhr) => {
21
+ //
22
+ // xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))
23
+ // xhr.setRequestHeader( 'X-User-Timezone', user_timezone)
24
+ //
25
+ //
26
+ // }
27
+ // })
28
+
14
29
  $("body").on("click", "[data-role='close-button']", (event) => {
15
30
  var form_name;
16
31
  form_name = $(event.currentTarget).data("name");
@@ -30,7 +45,7 @@ $(document).on('turbolinks:load', function() {
30
45
  $form.find("i").remove()
31
46
  }
32
47
  })
33
- })
48
+ });
34
49
  });
35
50
 
36
51
 
@@ -0,0 +1,5 @@
1
+ [data-role='close-button'] {
2
+ position: absolute;
3
+ top: 0;
4
+ right: 0;
5
+ }
@@ -1,4 +1,4 @@
1
- class <%= controller_class_name %> < ApplicationController
1
+ class <%= controller_class_name %> < <%= controller_descends_from %>
2
2
  <% unless @auth_identifier.nil? %>
3
3
  before_action :authenticate_<%= auth_identifier %>!
4
4
 
@@ -6,7 +6,7 @@ class <%= controller_class_name %> < ApplicationController
6
6
  <% if any_nested? %> <% @nested_args.each do |arg| %>
7
7
  before_action :load_<%= arg %><% end %> <% end %>
8
8
  before_action :load_<%= singular_name %>, only: [:show, :edit, :update, :destroy]
9
-
9
+ helper :common_core
10
10
 
11
11
  <% if any_nested? %><% nest_chain = [] %> <% @nested_args.each do |arg| %>
12
12
  <% if nest_chain.empty?
@@ -40,14 +40,14 @@ class <%= controller_class_name %> < ApplicationController
40
40
  end
41
41
 
42
42
  def create
43
- @<%=singular_name %> = <%=class_name %>.create(<%=singular_name %>_params<% if !create_merge_params.empty? %>.merge!(<%= create_merge_params %>)<%end%>)
43
+ modified_params = modify_date_inputs_on_params(<%=singular_name %>_params.dup<% if !create_merge_params.empty? %>.merge!(<%= create_merge_params %>)<%end%> , <%= @auth ? @auth : "nil" %>)
44
+ @<%=singular_name %> = <%=class_name %>.create(modified_params)
44
45
  respond_to do |format|
45
46
  if @<%= singular_name %>.save
46
- format.js
47
47
  else
48
48
  flash[:alert] = "Oops, your <%=singular_name %> could not be saved."
49
- format.js
50
49
  end
50
+ format.js
51
51
  end
52
52
  end
53
53
 
@@ -65,7 +65,7 @@ class <%= controller_class_name %> < ApplicationController
65
65
 
66
66
  def update
67
67
  respond_to do |format|
68
- if !@<%=singular_name %>.update(<%= singular %>_params)
68
+ if !@<%=singular_name %>.update(modify_date_inputs_on_params(<%= singular %>_params ))
69
69
  flash[:alert] = "<%=singular_name.titlecase %> could not be saved"
70
70
  end
71
71
  format.js {}
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.1
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
@@ -142,7 +142,7 @@ files:
142
142
  - app/assets/stylesheets/common_core_js/application.css
143
143
  - app/assets/stylesheets/common_core_js/common_core.scss
144
144
  - app/controllers/common_core_js/application_controller.rb
145
- - app/helpers/common_core_js/application_helper.rb
145
+ - app/helpers/common_core_helper.rb
146
146
  - app/jobs/common_core_js/application_job.rb
147
147
  - app/mailers/common_core_js/application_mailer.rb
148
148
  - app/models/common_core_js/application_record.rb
@@ -169,6 +169,8 @@ files:
169
169
  - lib/generators/common_core/install_generator.rb
170
170
  - lib/generators/common_core/scaffold_generator.rb
171
171
  - lib/generators/common_core/templates/_edit.haml
172
+ - lib/generators/common_core/templates/_errors.haml
173
+ - lib/generators/common_core/templates/_flash_notices.haml
172
174
  - lib/generators/common_core/templates/_form.haml
173
175
  - lib/generators/common_core/templates/_line.haml
174
176
  - lib/generators/common_core/templates/_list.haml
@@ -1,4 +0,0 @@
1
- module CommonCoreJs
2
- module ApplicationHelper
3
- end
4
- end