kablam 0.3.2 → 0.3.3

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: c2f4163c5cc471de784caaa8b6d8ec7356c0bb97d4ec0dca0318301dc9da05e7
4
- data.tar.gz: af5f6d3377d49ef3c45db564b777611524df966efc07330ed769667032f7bc1c
3
+ metadata.gz: 84d991bbff91946fb3cecd7525ad6daf7677bd4f3a7179d5ca2eee8e00fb769f
4
+ data.tar.gz: 409bdd54c5f61ce048bb41b177ba043de88168f19e83cb38cc666e42c37dd4f5
5
5
  SHA512:
6
- metadata.gz: a1fd55512eb86c82d8d27e15dfbece3c1edea1297ec8f88d765c3186447869898464c3c0e79307dc452d07a2e4f5400970f57bbe87df28ac152ef4f762d1d51f
7
- data.tar.gz: a0a4b55725bc9ab4a9d7ae7704029aa818c62d887225459149a2a520327ff7101498c15751ac3f4c3486a7697727251b2e845cf8d76dc662823fb37d6de99902
6
+ metadata.gz: 1ef896aff4f28a7762f449775b61075c400e6cf9a7f303c06e43f27d03c2ffc39a7aba8f4dc7bbeae4b9d97a50fd3a547e9001cbcfc1c895b73e3cc279f65f9f
7
+ data.tar.gz: 487dee532507b0325726c8944e4e5dbc20e5c3d23dcd463fe5dceef5f4f5275e27e75c5ade57472c7e5e41377d3609220b5c065bc41ff84a62eb5d72607bee56
@@ -50,6 +50,8 @@ function initFileUploads(opt) {
50
50
  fakeFileUpload.className = 'kablam_fakefile';
51
51
  var upload_icon = document.createElement('i');
52
52
  upload_icon.className = opt['icon'];
53
+ upload_icon.innerText = "Upload file here..."
54
+
53
55
  var input = document.createElement('input');
54
56
  input.type = "text";
55
57
  input.className = opt['class'];
@@ -66,7 +68,6 @@ function initFileUploads(opt) {
66
68
  var clone = fakeFileUpload.cloneNode(true);
67
69
  x[i].parentElement.appendChild(clone);
68
70
  x[i].relatedElement = clone.getElementsByTagName('input')[0];
69
-
70
71
  x[i].onchange = x[i].onmouseout = function () {
71
72
  path = this.value
72
73
  path = path.replace( /fakepath\\/, '...' );
@@ -137,7 +138,7 @@ function submitRemove(form_id){
137
138
  });
138
139
  }
139
140
 
140
- function submitRemove(form_id){
141
+ function submitRedirect(form_id){
141
142
  var form = document.getElementById(form_id),
142
143
  path = document.getElementById(form_id+'_redirect').value;
143
144
  form.addEventListener("ajax:success", function(e) {
@@ -26,8 +26,9 @@
26
26
  <% classyy = @model.prep_form_field[field] %>
27
27
  <% next if classyy == :exclude %>
28
28
  <% input = obj.input(field) %>
29
+ <% opt = obj.opt_for(field) %>
29
30
  <%= (render "kablam_forms/fields/pretext", classes: classes, input: input) if input[:pretext].present? %>
30
- <%= render "kablam_forms/fields/#{classyy.to_s}", classes: classes, input: input, f: f %>
31
+ <%= render "kablam_forms/fields/#{classyy.to_s}", classes: classes, input: input, f: f, opt: opt %>
31
32
  <% end %>
32
33
  <%= f.submit(
33
34
  data: { disable_with: 'Submitting' },
@@ -11,7 +11,7 @@
11
11
  scrolltop = scrolltop || false
12
12
  %>
13
13
 
14
- <%= render "kablam_forms/form_generator", classes: classes, obj: obj, target: target, hidden: hidden, ajax_remove: ajax_remove, redirect: redirect, scrolltop: scrolltop %>
14
+ <%= render "kablam_forms/form_generator", classes: classes, obj: obj, target: target, hidden: hidden, ajax_remove: ajax_remove, redirect: redirect, scrolltop: scrolltop %>
15
15
 
16
16
 
17
17
 
@@ -0,0 +1,10 @@
1
+ <div class="<%= classes[:form_group] %>">
2
+ <label for="<%= input[:name] %>" class="<%= classes[:field_label] %>"><%= raw input[:label] %></label>
3
+ <small id="<%= input[:name] %>-desc" class="<%= classes[:field_hint] %>"><%= raw input[:hint] %></small>
4
+ <% case Kablam.datetime_handler %>
5
+ <% when "stimulus-flatpickr" %>
6
+ <%= f.text_field input[:field], placeholder: input[:placeholder], class: classes[:input] || "", id: input[:id] || "", data: {controller: "flatpickr"}.merge((opt[:data]||{})) %>
7
+ <% else %>
8
+ <input id="<%= input[:id] if input[:id].present? %>" name="<%= input[:name] %>" class="<%= classes[:input] %>" type="datetime-local" value="<%= input[:value] %>" style="box-sizing: border-box;">
9
+ <% end %>
10
+ </div>
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'kablam'
3
- s.version = '0.3.2'
3
+ s.version = '0.3.3'
4
4
  s.date = Time.now.strftime("%Y-%m-%d")
5
5
  s.summary = "Kablam! All the things you hate. But Faster."
6
6
  s.description = "Gem to make development of everything in rails faster. Form creation & styling, all the resource routes, even actioncable messaging!\n {NOTE: In Development. NOT READY FOR TESTING.}"
@@ -24,7 +24,7 @@ module Kablam
24
24
  ensure_quotes(v)
25
25
  next
26
26
  end
27
- h[k] = v + "__ensure_quotes__\n "
27
+ h[k] = v + "__ensure_quotes__\n " unless v.blank?
28
28
  end
29
29
  end
30
30
 
@@ -7,9 +7,13 @@ Kablam.setup do |config|
7
7
  # _ _ ____ ___ _ ____ _ _
8
8
  # |_/ |__| |__] | |__| |\/|
9
9
  # | \_ | | |__] |___ | | | |
10
- # .___ __ .
11
- # [__ _ ._.._ _ / `| _. __ __ _ __
12
- # | (_)[ [ | ) \__.|(_]_) _) (/,_)
10
+ # ===========================================================
11
+ # The configurations below are primarily classes. Except
12
+ # for the datetime_handler.
13
+ # ===========================================================
14
+ # .___
15
+ # [__ _ ._.._ _ Classes &
16
+ # | (_)[ [ | ) Handlers
13
17
  # ===========================================================
14
18
 
15
19
  # These classes are used for the labels/group-wrappers, etc.
@@ -27,6 +31,7 @@ Kablam.setup do |config|
27
31
  config.dropdown_select = "ba bg-white b--black-20 pa2 mb2 db w-100"
28
32
  config.file_upload = "ba b--black-20 pa5 mb2 db w-100 b--dashed b--red"
29
33
  config.file_upload_icon = "fa fa-upload absolute left-0 right-0 ml-auto mr-auto top-2 mt3 f1 black-05"
34
+ config.datetime_handler = nil
30
35
 
31
36
  # Checkbox Classes
32
37
  config.checkbox_group_wrapper = "" # Wrapper around all checkboxes
@@ -14,6 +14,7 @@ module Kablam
14
14
  mattr_accessor :dropdown_select
15
15
  mattr_accessor :file_upload
16
16
  mattr_accessor :file_upload_icon
17
+ mattr_accessor :datetime_handler
17
18
 
18
19
  # Checkbox classes
19
20
  mattr_accessor :checkbox_group_wrapper
@@ -20,12 +20,14 @@ module Kablam
20
20
  kablam_scope = "kablam_forms.#{self.class.table_name}.#{field}"
21
21
  {
22
22
  name: "#{form_name}[#{field}]",
23
+ field: field.to_sym,
23
24
  value: send(field),
24
25
  label: I18n.translate(:label, scope: kablam_scope, default: ""),
25
26
  pretext: I18n.translate(:pretext, scope: kablam_scope, default: ""),
26
27
  placeholder: I18n.translate(:placeholder, scope: kablam_scope, default: ""),
27
28
  hint: I18n.translate(:hint, scope: kablam_scope, default: ""),
28
- choices: self.class.choices(field, I18n.locale)
29
+ choices: self.class.choices(field, I18n.locale),
30
+ onchange: I18n.translate(:onchange, scope: kablam_scope, default: "")
29
31
  }
30
32
  end
31
33
 
@@ -33,6 +35,13 @@ module Kablam
33
35
  nil
34
36
  end
35
37
 
38
+ def opt_for(field)
39
+ Hash[self.class.attribute_names.map{|x| [x,{}]}].merge(self.kablam_options)[field]
40
+ end
41
+
42
+ def kablam_options
43
+ {}
44
+ end
36
45
 
37
46
  def slack_message
38
47
  puts "You have not setup slack message for this model.\nto prepare a slack_message, please add method 'slack_message'\nwith content of a hash with keys [:create, :update, :destroy].\n\nFor each key, prepare a value hash like this:\n ...\n create: {\n pretext: 'some text',\n author: 'some name',\n title: 'some title',\n text: ''\n },\n ...\n\nHope this helps!!"
@@ -77,7 +86,7 @@ module Kablam
77
86
  end
78
87
 
79
88
  def self.fields
80
- result = self.attribute_names - ["id", "created_at", "updated_at"]
89
+ result = self.attribute_names - ["id", "created_at", "updated_at", "destroyed_at"]
81
90
  end
82
91
 
83
92
  def self.field_set
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.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Rivas
@@ -88,6 +88,7 @@ files:
88
88
  - app/views/kablam_forms/fields/.DS_Store
89
89
  - app/views/kablam_forms/fields/_checkbox_array.html.erb
90
90
  - app/views/kablam_forms/fields/_checkbox_boolean.html.erb
91
+ - app/views/kablam_forms/fields/_datetime.html.erb
91
92
  - app/views/kablam_forms/fields/_file_upload.html.erb
92
93
  - app/views/kablam_forms/fields/_hidden.html.erb
93
94
  - app/views/kablam_forms/fields/_input.html.erb