super_tools 0.0.26 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +2 -1
- data/lib/super_interaction/beyond.rb +77 -0
- data/lib/super_interaction/beyond_helper.rb +13 -0
- data/lib/super_interaction/{command.rb → bootstrap.rb} +2 -2
- data/lib/super_interaction/{controller_helper.rb → bootstrap_helper.rb} +2 -2
- data/lib/super_interaction/engine.rb +4 -0
- data/lib/super_interaction/views/layouts/beyond.haml +27 -0
- data/lib/super_interaction/views/layouts/modal_bs3.haml +2 -2
- data/lib/super_interaction/views/layouts/modal_bs4.haml +2 -2
- data/lib/super_tools.rb +4 -2
- data/lib/super_tools/version.rb +1 -1
- metadata +12 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 248f805a4956e73dcc11f4623ebfeb7f124c0d49
|
4
|
+
data.tar.gz: f24028ac4d9d1a4f80f8bd0e5552174fc735f4da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ec67d9425ff7fa208a0cadd4682eb4a0e1b63dde2eb3e22b9715f679d9a3bd22534b56e65a7f8e792061a8e97686ceccd7f2b78b21afabcfb5e1cacfd93a59d
|
7
|
+
data.tar.gz: 6447defbdd74912a56d187406c3d80e0890b037062c96d06a3d02ac7f6c4074949772321d24ad85b8147908e5def0ff5cdd5340a387c085bd3cabcadaac16847
|
data/README.md
CHANGED
@@ -84,7 +84,8 @@ SuperTable::Tableable.send(:include, ::Rails.application.routes.url_helpers)
|
|
84
84
|
|
85
85
|
```ruby
|
86
86
|
class ApplicationController < ActionController::Base
|
87
|
-
include SuperInteraction::
|
87
|
+
include SuperInteraction::BootstrapHelper
|
88
|
+
include SuperInteraction::BeyondrHelper
|
88
89
|
end
|
89
90
|
```
|
90
91
|
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module SuperInteraction
|
2
|
+
class Beyond < Struct.new(:context)
|
3
|
+
|
4
|
+
attr_accessor :commands
|
5
|
+
|
6
|
+
delegate :helpers, to: :context
|
7
|
+
|
8
|
+
def run
|
9
|
+
context.render js: (commands || []).join(";"), layout: false
|
10
|
+
end
|
11
|
+
|
12
|
+
def b_notice(message)
|
13
|
+
b_alert('info', message)
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def b_danger(message)
|
18
|
+
b_alert('danger', message)
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def b_success(message)
|
23
|
+
b_alert('success', message)
|
24
|
+
end
|
25
|
+
|
26
|
+
def alert(message)
|
27
|
+
cmd("alert('#{helpers.j(message)}');")
|
28
|
+
end
|
29
|
+
|
30
|
+
# modal 裡如果有 javascript 需寫在 .modal 層
|
31
|
+
# size: sm / md / lg / xl / xxl
|
32
|
+
# 注意:不要包 respond_to :js 會有問題
|
33
|
+
def modal(partial: nil, size: 'md', title: '', desc: '', classname: '')
|
34
|
+
partial ||= context.action_name
|
35
|
+
locals = { size: size, title: title, desc: desc, classname: classname }
|
36
|
+
modal_html = context.render_to_string(partial, layout: "beyond.haml", locals: locals)
|
37
|
+
cmd("$(function() { $.uniqModal().modal('show', '#{helpers.j(modal_html)}'); });")
|
38
|
+
end
|
39
|
+
|
40
|
+
# 關閉 Modal
|
41
|
+
def close
|
42
|
+
cmd("$.uniqModal().modal('hide');")
|
43
|
+
end
|
44
|
+
|
45
|
+
# 重新讀取頁面
|
46
|
+
def reload
|
47
|
+
cmd("Turbolinks.visit(location.toString());");
|
48
|
+
end
|
49
|
+
|
50
|
+
# 導入頁面
|
51
|
+
def redirect_to(url)
|
52
|
+
cmd("Turbolinks.visit('#{url}');");
|
53
|
+
end
|
54
|
+
|
55
|
+
def modal_saved_rediret_to(message, redirect_url)
|
56
|
+
close.alert(message).redirect_to(redirect_url)
|
57
|
+
end
|
58
|
+
|
59
|
+
def modal_saved_reload(message)
|
60
|
+
close.alert(message).reload
|
61
|
+
end
|
62
|
+
|
63
|
+
def ajax_get(url)
|
64
|
+
cmd("$.get('#{url}');")
|
65
|
+
end
|
66
|
+
|
67
|
+
def b_alert(class_type, text)
|
68
|
+
cmd("if (typeof($.alert) == undefined) { alert('#{helpers.j(text)}'); } else { $.alert.#{class_type}('#{helpers.j(text)}'); }")
|
69
|
+
end
|
70
|
+
|
71
|
+
def cmd(js_code)
|
72
|
+
self.commands ||= []
|
73
|
+
self.commands.push(js_code)
|
74
|
+
self
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module SuperInteraction
|
2
|
-
class
|
2
|
+
class Bootstrap < Struct.new(:context)
|
3
3
|
|
4
4
|
attr_accessor :commands
|
5
5
|
|
@@ -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: ::SuperInteraction::Layout.modal_layout, locals: {
|
35
|
+
modal_html = context.render_to_string(partial, layout: ::SuperInteraction::Layout.modal_layout, locals: { size: size, title: title, desc: desc })
|
36
36
|
cmd("$(function() { $.modal.show('#{helpers.j(modal_html)}'); });")
|
37
37
|
end
|
38
38
|
|
@@ -2,6 +2,10 @@ module SuperInteraction
|
|
2
2
|
if defined?(Rails::Engine)
|
3
3
|
class Engine < Rails::Engine
|
4
4
|
paths["app/views"] = "lib/super_interaction/views"
|
5
|
+
|
6
|
+
initializer 'beyond.assets.precompile' do |app|
|
7
|
+
app.config.assets.paths << root.join('lib', 'super_interaction', 'javascripts').to_s
|
8
|
+
end
|
5
9
|
end
|
6
10
|
end
|
7
11
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
- if Rails.version[0].to_i >= 5
|
2
|
+
- size = local_assigns[:size]
|
3
|
+
- title = local_assigns[:title]
|
4
|
+
- desc = local_assigns[:desc]
|
5
|
+
- classname = local_assigns[:classname]
|
6
|
+
|
7
|
+
.modal{"aria-labelledby" => "modalLabel", "data-modal" => "box-modal", :role => "dialog", :tabindex => "-1"}
|
8
|
+
.modal-dialog{ role: 'document', class: "modal-#{size} #{classname}" }
|
9
|
+
.modal-content
|
10
|
+
.modal-header
|
11
|
+
= yield :header
|
12
|
+
- if title.present?
|
13
|
+
%h4.modal-title
|
14
|
+
= title
|
15
|
+
%small= desc if desc
|
16
|
+
%button.btn-close{'aria-label': 'Close', 'data-close': true, 'type': 'button'}
|
17
|
+
= b_icon('cross')
|
18
|
+
= yield
|
19
|
+
= yield :before_body
|
20
|
+
- body_html = capture { yield :body }
|
21
|
+
- if body_html.present?
|
22
|
+
.modal-body.bg-content= body_html
|
23
|
+
= yield :after_body
|
24
|
+
- footer_html = capture { yield :footer }
|
25
|
+
- if footer_html.present?
|
26
|
+
.modal-footer
|
27
|
+
= footer_html
|
@@ -1,10 +1,10 @@
|
|
1
1
|
- if Rails.version[0].to_i >= 5
|
2
|
-
-
|
2
|
+
- size = local_assigns[:size]
|
3
3
|
- title = local_assigns[:title]
|
4
4
|
- desc = local_assigns[:desc]
|
5
5
|
.modal
|
6
6
|
= yield :wrapper
|
7
|
-
.modal-dialog{ class: "modal-#{
|
7
|
+
.modal-dialog{ class: "modal-#{size}" }
|
8
8
|
.modal-content
|
9
9
|
.modal-header
|
10
10
|
%button.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
- if Rails.version[0].to_i >= 5
|
2
|
-
-
|
2
|
+
- size = local_assigns[:size]
|
3
3
|
- title = local_assigns[:title]
|
4
4
|
- desc = local_assigns[:desc]
|
5
5
|
.modal
|
6
6
|
= yield :wrapper
|
7
|
-
.modal-dialog{ class: "modal-#{
|
7
|
+
.modal-dialog{ class: "modal-#{size}" }
|
8
8
|
.modal-content
|
9
9
|
.modal-header
|
10
10
|
= yield :header
|
data/lib/super_tools.rb
CHANGED
@@ -44,8 +44,10 @@ require 'super_zipcode/taiwan'
|
|
44
44
|
# INTERACTION
|
45
45
|
require 'super_interaction/layout'
|
46
46
|
require 'super_interaction/engine'
|
47
|
-
require 'super_interaction/
|
48
|
-
require 'super_interaction/
|
47
|
+
require 'super_interaction/beyond'
|
48
|
+
require 'super_interaction/beyond_helper'
|
49
|
+
require 'super_interaction/bootstrap'
|
50
|
+
require 'super_interaction/bootstrap_helper'
|
49
51
|
# FORMATTER
|
50
52
|
require 'super_logger/formatter'
|
51
53
|
# Values
|
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:
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- eddie
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01
|
11
|
+
date: 2021-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -310,10 +310,13 @@ files:
|
|
310
310
|
- lib/super_formatter/tcat/head.rb
|
311
311
|
- lib/super_formatter/tcat/import.rb
|
312
312
|
- lib/super_formatter/tcat/row.rb
|
313
|
-
- lib/super_interaction/
|
314
|
-
- lib/super_interaction/
|
313
|
+
- lib/super_interaction/beyond.rb
|
314
|
+
- lib/super_interaction/beyond_helper.rb
|
315
|
+
- lib/super_interaction/bootstrap.rb
|
316
|
+
- lib/super_interaction/bootstrap_helper.rb
|
315
317
|
- lib/super_interaction/engine.rb
|
316
318
|
- lib/super_interaction/layout.rb
|
319
|
+
- lib/super_interaction/views/layouts/beyond.haml
|
317
320
|
- lib/super_interaction/views/layouts/modal_bs3.haml
|
318
321
|
- lib/super_interaction/views/layouts/modal_bs4.haml
|
319
322
|
- lib/super_logger/formatter.rb
|
@@ -334,7 +337,7 @@ homepage: https://github.com/superlanding/super_tools
|
|
334
337
|
licenses:
|
335
338
|
- MIT
|
336
339
|
metadata: {}
|
337
|
-
post_install_message:
|
340
|
+
post_install_message:
|
338
341
|
rdoc_options: []
|
339
342
|
require_paths:
|
340
343
|
- lib
|
@@ -349,8 +352,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
349
352
|
- !ruby/object:Gem::Version
|
350
353
|
version: '0'
|
351
354
|
requirements: []
|
352
|
-
|
353
|
-
|
355
|
+
rubyforge_project:
|
356
|
+
rubygems_version: 2.4.8
|
357
|
+
signing_key:
|
354
358
|
specification_version: 4
|
355
359
|
summary: Rails 開發環境常用工具 Forms/Process/Spreadsheet
|
356
360
|
test_files: []
|