super_tools 0.0.14 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/super_form/concerns/atomic_save.rb +23 -12
- data/lib/super_interaction/command.rb +1 -1
- data/lib/super_interaction/engine.rb +4 -2
- data/lib/super_interaction/layout.rb +29 -0
- data/lib/super_interaction/views/layouts/{interaction_modal.html.haml → modal_bs3.haml} +5 -1
- data/lib/super_interaction/views/layouts/modal_bs4.haml +28 -0
- data/lib/super_tools.rb +1 -0
- data/lib/super_tools/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af3ee2961bfd642dbdefa9f348ac6170641954b3
|
4
|
+
data.tar.gz: 4b4138e6842c4579768b7f2025989c07b1a6ab23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ce3520f560f7f10d557b2cd96cbcf3670b29149d806f810547bfcc496049adbf67f2b5c6f689bc4a67b44ac89a45d82f5ce749e1fa4278eeb7501e220a6781f
|
7
|
+
data.tar.gz: 797bf949ca35a2bf9d7aa63cfea0194ae7b22317f0791c535b22f057d5ec20162d7d03cfcfe31930f28a16e0f2c8ad5ab0086140b6db560be43da30a1ecf129c
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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:
|
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,29 @@
|
|
1
|
+
module SuperInteraction
|
2
|
+
module Layout
|
3
|
+
|
4
|
+
FRAMEWORKS = [ :bootstrap3, :bootstrap4, :beyond ]
|
5
|
+
|
6
|
+
def self.framework=(f)
|
7
|
+
raise "Not support framework: #{f}" if FRAMEWORKS.include?(f) == false
|
8
|
+
@@framework = f
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.framework
|
12
|
+
@@framework
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.modal_layout
|
16
|
+
case @@framework
|
17
|
+
when :bootstrap3
|
18
|
+
"modal_bs3.haml"
|
19
|
+
when :bootstrap4
|
20
|
+
"modal_bs4.haml"
|
21
|
+
when :beyond
|
22
|
+
"modal_beyond.haml"
|
23
|
+
else
|
24
|
+
# Default
|
25
|
+
"modal_bs3.haml"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -8,10 +8,14 @@
|
|
8
8
|
.modal-content
|
9
9
|
.modal-header
|
10
10
|
%button.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
|
11
|
-
|
11
|
+
- if respond_to?(:fa_icon)
|
12
|
+
= fa_icon('times')
|
13
|
+
- else
|
14
|
+
= fas_icon('times')
|
12
15
|
= yield :header
|
13
16
|
- if title.present?
|
14
17
|
%h4.modal-title= title
|
18
|
+
|
15
19
|
= yield
|
16
20
|
= yield :before_body
|
17
21
|
- body_html = capture { yield :body }
|
@@ -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
|
data/lib/super_tools.rb
CHANGED
data/lib/super_tools/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- eddie
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -319,7 +319,9 @@ files:
|
|
319
319
|
- lib/super_interaction/command.rb
|
320
320
|
- lib/super_interaction/controller_helper.rb
|
321
321
|
- lib/super_interaction/engine.rb
|
322
|
-
- lib/super_interaction/
|
322
|
+
- lib/super_interaction/layout.rb
|
323
|
+
- lib/super_interaction/views/layouts/modal_bs3.haml
|
324
|
+
- lib/super_interaction/views/layouts/modal_bs4.haml
|
323
325
|
- lib/super_logger/formatter.rb
|
324
326
|
- lib/super_process/core.rb
|
325
327
|
- lib/super_search/scroll.rb
|