super_tools 0.0.13 → 0.0.21

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
- SHA256:
3
- metadata.gz: 0335c45c48a1df81df191c9f0b0ee4f4d7529af6407fdb8aeecca380847e5675
4
- data.tar.gz: 149c4a2c0118d5cce4df3ca6d16a8ef53ac4e8c4ff994172c964887ad689a461
2
+ SHA1:
3
+ metadata.gz: 6be00d675e4acb60dfe108767a76d81adf7c6abe
4
+ data.tar.gz: 6a4746a52d0f6642fa2c62756171c0b8fa9868c7
5
5
  SHA512:
6
- metadata.gz: c59b31cf7a51ae06c595f958cad780fc36169290cc4be478ecee84aaa15cd84fcc34fd665f83858cb977d52104c3efa43f99b78f0f685f3047add33ff30bee69
7
- data.tar.gz: 42d10f4c9a3cd07527f64fb962c032a74b869d4d5b6965284bb3186b3ec0d16a7321b2061dcfa7b64d6693a2f5d3911761c556e27554a095ffe13f32f5ab3c2a
6
+ metadata.gz: 9c21b893f721de909aec9dfe8884045e42870bb228e9bc67ea1b59ae52ad03bc82030195a805e7ca558506ff52e26b4940ed9a7ad5981b530e3ae7ebe01469a0
7
+ data.tar.gz: 13bb0a158189a27e3252a8663ac71ce84b41e297f20f20563ad588d105f5d6c0949d3b5668aa43f3873d7939240cc51562303d428fb7b40f2ec8f6d4daf8126c
@@ -144,7 +144,7 @@ GEM
144
144
  nio4r (2.3.1)
145
145
  nokogiri (1.9.1)
146
146
  mini_portile2 (~> 2.4.0)
147
- rack (2.0.7)
147
+ rack (2.0.8)
148
148
  rack-test (1.1.0)
149
149
  rack (>= 1.0, < 3)
150
150
  rails (5.2.3)
@@ -7,28 +7,39 @@ module SuperForm
7
7
 
8
8
  define_callbacks :transaction, :queries, :validations
9
9
 
10
- def self.before_transaction(method_name)
11
- set_callback :transaction, :before, method_name
10
+ def self.before_transaction(method_name=nil, &block)
11
+ set_defined_callback(:transaction, :before, method_name, &block)
12
12
  end
13
13
 
14
- def self.before_queries(method_name)
15
- set_callback :queries, :before, method_name
14
+ def self.before_queries(method_name=nil, &block)
15
+ set_defined_callback(:queries, :before, method_name, &block)
16
16
  end
17
17
 
18
- def self.before_commit(method_name)
19
- set_callback :queries, :after, method_name
18
+ def self.before_commit(method_name=nil, &block)
19
+ set_defined_callback(:queries, :after, method_name, &block)
20
20
  end
21
21
 
22
- def self.after_commit(method_name)
23
- set_callback :transaction, :after, method_name
22
+ def self.after_commit(method_name=nil, &block)
23
+ set_defined_callback(:transaction, :after, method_name, &block)
24
24
  end
25
25
 
26
- def self.before_validations(method_name)
27
- set_callback :validations, :after, method_name
26
+ def self.before_validations(method_name=nil, &block)
27
+ set_defined_callback(:validations, :before, method_name, &block)
28
28
  end
29
29
 
30
- def self.after_validations(method_name)
31
- set_callback :validations, :after, method_name
30
+ def self.after_validations(method_name=nil, &block)
31
+ set_defined_callback(:validations, :after, method_name, &block)
32
+ end
33
+
34
+ protected
35
+
36
+ def self.set_defined_callback(event, callback, method_name=nil, &block)
37
+ raise "wrong number of arguments ('method_name' or 'block' choose one)" if method_name.nil? == false && block.present?
38
+ if block_given?
39
+ set_callback event, callback, &block
40
+ else
41
+ set_callback event, callback, method_name
42
+ end
32
43
  end
33
44
  end
34
45
 
@@ -32,7 +32,7 @@ module SuperInteraction
32
32
  # 注意:不要包 respond_to :js 會有問題
33
33
  def modal(partial: nil, size: 'md', title: '', desc: '')
34
34
  partial ||= context.action_name
35
- modal_html = context.render_to_string(partial, layout: 'modal.html.haml', locals: { bs_modal_size: size, title: title, desc: desc })
35
+ modal_html = context.render_to_string(partial, layout: ::SuperInteraction::Layout.modal_layout, locals: { bs_modal_size: size, title: title, desc: desc })
36
36
  cmd("$(function() { $.modal.show('#{helpers.j(modal_html)}'); });")
37
37
  end
38
38
 
@@ -0,0 +1,7 @@
1
+ module SuperInteraction
2
+ if defined?(Rails::Engine)
3
+ class Engine < Rails::Engine
4
+ paths["app/views"] = "lib/super_interaction/views"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ module SuperInteraction
2
+ module Layout
3
+ mattr_accessor :framework
4
+ self.framework = :bootstrap3
5
+
6
+ def self.modal_layout
7
+ case framework
8
+ when :bootstrap3
9
+ "modal_bs3.haml"
10
+ when :bootstrap4
11
+ "modal_bs4.haml"
12
+ when :beyond
13
+ "modal_beyond.haml"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,28 @@
1
+ - if Rails.version[0].to_i >= 5
2
+ - bs_modal_size = local_assigns[:bs_modal_size]
3
+ - title = local_assigns[:title]
4
+ - desc = local_assigns[:desc]
5
+ .modal
6
+ = yield :wrapper
7
+ .modal-dialog{ class: "modal-#{bs_modal_size}" }
8
+ .modal-content
9
+ .modal-header
10
+ %button.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
11
+ - if respond_to?(:fa_icon)
12
+ = fa_icon('times')
13
+ - else
14
+ = fas_icon('times')
15
+ = yield :header
16
+ - if title.present?
17
+ %h4.modal-title= title
18
+
19
+ = yield
20
+ = yield :before_body
21
+ - body_html = capture { yield :body }
22
+ - if body_html.present?
23
+ .modal-body= body_html
24
+ = yield :after_body
25
+
26
+ - footer_html = capture { yield :footer }
27
+ - if footer_html.present?
28
+ .modal-footer= footer_html
@@ -0,0 +1,28 @@
1
+ - if Rails.version[0].to_i >= 5
2
+ - bs_modal_size = local_assigns[:bs_modal_size]
3
+ - title = local_assigns[:title]
4
+ - desc = local_assigns[:desc]
5
+ .modal
6
+ = yield :wrapper
7
+ .modal-dialog{ class: "modal-#{bs_modal_size}" }
8
+ .modal-content
9
+ .modal-header
10
+ = yield :header
11
+ - if title.present?
12
+ %h5.modal-title
13
+ = title
14
+ - if desc.present?
15
+ %small.text-secondary= desc
16
+ %button.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
17
+ = fas_icon('times')
18
+
19
+ = yield
20
+ = yield :before_body
21
+ - body_html = capture { yield :body }
22
+ - if body_html.present?
23
+ .modal-body= body_html
24
+ = yield :after_body
25
+
26
+ - footer_html = capture { yield :footer }
27
+ - if footer_html.present?
28
+ .modal-footer= footer_html
@@ -42,6 +42,8 @@ require 'super_search/scroll'
42
42
  # ZIP CODE
43
43
  require 'super_zipcode/taiwan'
44
44
  # INTERACTION
45
+ require 'super_interaction/layout'
46
+ require 'super_interaction/engine'
45
47
  require 'super_interaction/command'
46
48
  require 'super_interaction/controller_helper'
47
49
  # FORMATTER
@@ -1,3 +1,3 @@
1
1
  module SuperTools
2
- VERSION = '0.0.13'
2
+ VERSION = '0.0.21'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - eddie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-31 00:00:00.000000000 Z
11
+ date: 2021-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -318,6 +318,10 @@ files:
318
318
  - lib/super_formatter/tcat/row.rb
319
319
  - lib/super_interaction/command.rb
320
320
  - lib/super_interaction/controller_helper.rb
321
+ - lib/super_interaction/engine.rb
322
+ - lib/super_interaction/layout.rb
323
+ - lib/super_interaction/views/layouts/modal_bs3.haml
324
+ - lib/super_interaction/views/layouts/modal_bs4.haml
321
325
  - lib/super_logger/formatter.rb
322
326
  - lib/super_process/core.rb
323
327
  - lib/super_search/scroll.rb
@@ -352,7 +356,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
352
356
  version: '0'
353
357
  requirements: []
354
358
  rubyforge_project:
355
- rubygems_version: 2.7.6.2
359
+ rubygems_version: 2.4.8
356
360
  signing_key:
357
361
  specification_version: 4
358
362
  summary: Rails 開發環境常用工具 Forms/Process/Spreadsheet