kablam 0.3.5 → 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: d0870b7d145b1cfc130362b9b81d8b75a792c1e64af27a4be8cbf523c2fbaa96
4
- data.tar.gz: bf3628876f40c3c2b46c47a43c8b5d269e64a07343d453fb1a66f7cfc0694ca0
3
+ metadata.gz: 844e20a6b77e991b17e78586160b713b57134f5f0cef806bebe1077415f24d5e
4
+ data.tar.gz: 17bc14cc1eb940e97d0d0f1c5bae1e16b02eaebd0b93095c7de119583685a7f5
5
5
  SHA512:
6
- metadata.gz: e01613faec8c519fdadf72ce6faef0e468f47bb06c0498105403518c3dab9dba7bc07866b131da8bf8cc0146d29e85d970180b44ea151b1a0dc8af9e53aa1306
7
- data.tar.gz: 5bfddaf63d0e56a84472c1847db3fc6adc6917120470118f584a3af92f6a4ddf19e45f9db6ffc0eb230807d9ab81d4d443d442240399743f9515c6be84bbb795
6
+ metadata.gz: 27dd4f187625cf129af98e99863db3aa8750031627da7dcedf3d5d16051b224caa6b8d2b808ef1002bccbbfde8e8e6360a3c9baf30b4fc3d4fb3e2b59ee642ef
7
+ data.tar.gz: 9ce64047a88ce76de4cd473f57770e1579c57d32ed1cbf69c9c3f27d0f44d383977b71aaaab32502d8f0f9ea0b096360d5bbe8d9124df24dd610c28bc69655df
@@ -105,28 +105,28 @@ function rmParent(el){
105
105
 
106
106
 
107
107
  Object.defineProperty(HTMLElement, 'From', {
108
- enumerable: false,
109
- value: (function (document) {
110
- //https://www.measurethat.net/Benchmarks/Show/2149/0/element-creation-speed
111
- var rgx = /(\S+)=(["'])(.*?)(?:\2)|(\w+)/g;
112
- return function CreateElementFromHTML(html) {
113
- html = html.trim();
114
- var bodystart = html.indexOf('>') + 1, bodyend = html.lastIndexOf('<');
115
- var elemStart = html.substr(0, bodystart);
116
- var innerHTML = html.substr(bodystart, bodyend - bodystart);
117
- rgx.lastIndex = 0;
118
- var elem = document.createElement(rgx.exec(elemStart)[4]);
119
- var match; while ((match = rgx.exec(elemStart))) {
120
- if (match[1] === undefined) {
121
- elem.setAttribute(match[4], "");
122
- } else {
123
- elem.setAttribute(match[1], match[3]);
124
- }
125
- }
126
- elem.innerHTML = innerHTML;
127
- return elem;
128
- };
129
- }(window.document))
108
+ enumerable: false,
109
+ value: (function (document) {
110
+ //https://www.measurethat.net/Benchmarks/Show/2149/0/element-creation-speed
111
+ var rgx = /(\S+)=(["'])(.*?)(?:\2)|(\w+)/g;
112
+ return function CreateElementFromHTML(html) {
113
+ html = html.trim();
114
+ var bodystart = html.indexOf('>') + 1, bodyend = html.lastIndexOf('<');
115
+ var elemStart = html.substr(0, bodystart);
116
+ var innerHTML = html.substr(bodystart, bodyend - bodystart);
117
+ rgx.lastIndex = 0;
118
+ var elem = document.createElement(rgx.exec(elemStart)[4]);
119
+ var match; while ((match = rgx.exec(elemStart))) {
120
+ if (match[1] === undefined) {
121
+ elem.setAttribute(match[4], "");
122
+ } else {
123
+ elem.setAttribute(match[1], match[3]);
124
+ }
125
+ }
126
+ elem.innerHTML = innerHTML;
127
+ return elem;
128
+ };
129
+ }(window.document))
130
130
  });
131
131
 
132
132
 
@@ -138,6 +138,14 @@ function submitRemove(form_id){
138
138
  });
139
139
  }
140
140
 
141
+ function submitClear(form_id){
142
+ var form = document.getElementById(form_id);
143
+ form.addEventListener("ajax:success", function(e) {
144
+ e.preventDefault();
145
+ form.reset();
146
+ });
147
+ }
148
+
141
149
  function submitRedirect(form_id){
142
150
  var form = document.getElementById(form_id),
143
151
  path = document.getElementById(form_id+'_redirect').value;
@@ -3,11 +3,13 @@ module Concerns
3
3
  extend ActiveSupport::Concern
4
4
  require 'securerandom'
5
5
  protected
6
- def send_to_bucket(bucket, upload_item)
6
+ def send_to_bucket(upload_item)
7
7
  puts "uploading..."
8
8
  path = ENV.fetch("BUCKET_TRANSFER_API")
9
9
  bucket = ENV.fetch("BUCKET_NAME")
10
-
10
+ puts "path: #{path}"
11
+ puts "bucket: #{bucket}"
12
+ puts "#{upload_item.class}"
11
13
 
12
14
  post_params = {"oss"=> {
13
15
  "bucket" => bucket,
@@ -1,4 +1,4 @@
1
- # require 'rest-client'
1
+ require 'rest-client'
2
2
  require 'json'
3
3
 
4
4
  class KablamController < ApplicationController
@@ -1,12 +1,14 @@
1
1
  <% if params[:target].present? %>
2
2
  var content = `<%= j render "kablam/models/#{@object.model_name.singular}", obj: @object %>`
3
-
4
- document
3
+ var newMessage = HTMLElement.From(content);
4
+ var target = document
5
5
  .getElementById('<%= params[:target] || "target_index" %>')
6
- .insertAdjacentHTML('beforeend', content)
7
6
 
8
- document
9
- .querySelector('[action$="/<%= params[:target] || "target_index" %>"]')
10
- .reset()
7
+ <% if Kablam.render_item["#{@object.class.table_name}"] == "top" %>
8
+ target.innerHTML = newMessage.outerHTML + target.innerHTML;
9
+ <% elsif Kablam.render_item["#{@object.class.table_name}"] == "bottom" %>
10
+ target.innerHTML = target.innerHTML + newMessage.outerHTML;
11
+ <% end %>
12
+
11
13
  <% end %>
12
14
  <%= render_flash message: 'Created' %>
@@ -2,8 +2,8 @@ var content = `<%= j render "kablam/message", message: @message %>`;
2
2
  var newMessage = HTMLElement.From(content);
3
3
  var target = document.getElementById("kablam-chat-window");
4
4
 
5
- <% if Kablam.message_location == "start" %>
5
+ <% if Kablam.render_item["message"] == "top" %>
6
6
  target.innerHTML = newMessage.outerHTML + target.innerHTML;
7
- <% elsif Kablam.message_location == "end" %>
7
+ <% elsif Kablam.render_item["message"] == "bottom" %>
8
8
  target.innerHTML = target.innerHTML + newMessage.outerHTML;
9
9
  <% end %>
@@ -8,7 +8,7 @@
8
8
  @url = (@method == :post ? Kablam::Engine.routes.url_helpers.create_path(@table_name) : Kablam::Engine.routes.url_helpers.update_path(@table_name, obj.id))
9
9
  %>
10
10
 
11
- <%= form_with model: obj, url: @url, method: @method, id: @form_id, class: classes[:form_wrapper] do |f| %>
11
+ <%= form_with model: obj, url: @url, method: @method, id: @form_id, class: classes[:form_wrapper], multipart: true do |f| %>
12
12
  <% if redirect.present? %>
13
13
  <input id="<%= @form_id %>_redirect" type="hidden" name="redirect" value="<%= redirect %>">
14
14
  <% end %>
@@ -37,6 +37,7 @@
37
37
 
38
38
  <script>
39
39
  initFileUploads({'class': '<%= classes[:file_upload]%>', 'icon': '<%= classes[:file_upload_icon] %>'});
40
+ submitClear('<%= @form_id %>');
40
41
  <% if ajax_remove.present? %>
41
42
  submitRemove('<%= @form_id %>');
42
43
  <% end %>
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'kablam'
3
- s.version = '0.3.5'
3
+ s.version = '0.3.6'
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.}"
@@ -13,5 +13,6 @@ Gem::Specification.new do |s|
13
13
 
14
14
  s.add_dependency("rails", ">= 5.1.6")
15
15
  s.add_dependency('rails-i18n', ">= 5.1.1")
16
+ s.add_dependency('rest-client')
16
17
  s.add_dependency('puma')
17
18
  end
@@ -12,8 +12,8 @@ Kablam.setup do |config|
12
12
  # for the datetime_handler.
13
13
  # ===========================================================
14
14
  # .___
15
- # [__ _ ._.._ _ Classes &
16
- # | (_)[ [ | ) Handlers
15
+ # [__ _ ._.._ _ Classes
16
+ # | (_)[ [ | )
17
17
  # ===========================================================
18
18
 
19
19
  # These classes are used for the labels/group-wrappers, etc.
@@ -31,7 +31,6 @@ Kablam.setup do |config|
31
31
  config.dropdown_select = "ba bg-white b--black-20 pa2 mb2 db w-100"
32
32
  config.file_upload = "ba b--black-20 pa5 mb2 db w-100 b--dashed b--red"
33
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
35
34
 
36
35
  # Checkbox Classes
37
36
  config.checkbox_group_wrapper = "" # Wrapper around all checkboxes
@@ -49,7 +48,8 @@ Kablam.setup do |config|
49
48
  config.multi_remove_icon = "fa fa-trash"
50
49
 
51
50
  # ============================================================
52
- # KABLAM MESSAGING
51
+ # KABLAM OPTIONS
53
52
  # ============================================================
54
- config.message_location = "start" # Accepted values are "start" and "end"
53
+ config.datetime_handler = nil
54
+ config.render_item["message"] = "top" #also accepts bottom
55
55
  end
@@ -14,7 +14,6 @@ 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
18
17
 
19
18
  # Checkbox classes
20
19
  mattr_accessor :checkbox_group_wrapper
@@ -29,8 +28,9 @@ module Kablam
29
28
  mattr_accessor :multi_add_icon
30
29
  mattr_accessor :multi_remove_icon
31
30
 
32
- # Message settings
33
- mattr_accessor :message_location
31
+ # Options settings
32
+ mattr_accessor :datetime_handler
33
+ mattr_accessor :render_item, default: {}
34
34
 
35
35
  module ClassMethods
36
36
 
@@ -28,7 +28,7 @@ module Kablam
28
28
  hint: I18n.translate(:hint, scope: kablam_scope, default: ""),
29
29
  choices: self.class.choices(field, I18n.locale),
30
30
  onchange: I18n.translate(:onchange, scope: kablam_scope, default: ""),
31
- true_statement: I18n.translate(:hint, scope: kablam_scope, default: "")
31
+ true_statement: I18n.translate(:true_statement, scope: kablam_scope, default: "")
32
32
  }
33
33
  end
34
34
 
@@ -96,6 +96,7 @@ module Kablam
96
96
  text: [],
97
97
  hidden: [],
98
98
  select: [],
99
+ datetime: [],
99
100
  checkbox_array: [],
100
101
  checkbox_boolean: [],
101
102
  multi_inputs: [],
@@ -112,11 +113,13 @@ module Kablam
112
113
  # This method will prepare hash of hashes
113
114
  # for each data-field w/ the form input type.
114
115
  # ex: date, radio, select, etc.
116
+
115
117
  obj = self.new
116
118
  hashy = {}
117
119
  fields_array = self.fields
118
120
  fields_array.each do |k|
119
- hashy[k] = obj.column_for_attribute(k).type
121
+ hashy[k] = :not_set
122
+ hashy[k] = obj.column_for_attribute(k).type if obj.column_for_attribute(k).type
120
123
  hashy[k] = :input if [:string, :float, :integer].include? hashy[k]
121
124
  hashy[k] = :checkbox_boolean if [:boolean].include? hashy[k]
122
125
  self.field_set.keys.each{|type| hashy[k] = type if self.field_set[type].include?(k)}
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.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Rivas
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 5.1.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: puma
43
57
  requirement: !ruby/object:Gem::Requirement