advanced_haml_scaffold_generator 2.3.0 → 3.0.0

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: 8f344a99c22cc17f0c6eb832e9b8cdf303abbd31b4739be7307b83e2885b6d1a
4
- data.tar.gz: 3ae39730efadad38720846993251b3f29380bf9419dec47b7d8d87f7cea16c65
3
+ metadata.gz: b6d25a9edb3f1b1ac72084b51d395b32ae9c359ab4f68b0b90e36bb99fdcc50a
4
+ data.tar.gz: 11fc63307b1aca5830bf3f3da11c9c27e4c8193ccb6c748bc1c61daf324b1e2a
5
5
  SHA512:
6
- metadata.gz: 645ebab9eb58aa1b262c667f372031fbed893103ae83ffdfb161e372c345866b4aa1f313124bb91fe95e8e320c00a22732e78ab6aa2c87b9e761fc02d5a9876d
7
- data.tar.gz: 3ff6be8a5c3a8ec21d1dce75d093069819994a7e24784677b63de7ddd1ed437cb6d181b51848513182ad4398a8ea87353c48884458d06839aa13abc16ddff786
6
+ metadata.gz: f55b57a38e48b253506c6711896b6cbf2b72169a10b592727bf3b951d119c951151596c1013be1b75e6408849e062a8a562db312d3f6516b53e9a53d26f8376e
7
+ data.tar.gz: 263440c745d138bd7e354dcd8293e7d892365f3968f76d002d7525e5172a920b5ae3c793a0c52d9b91c88bb8aa4ae996076e708d1e812abf047fe9fbb09bf3ff
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Change log
2
+
3
+ ## 3.0.0 (15 Nov, 2024)
4
+
5
+ - Added button "Back" and Stimulus controller to navigate back in history when Stimulus is present.
6
+ - Old button "Back" is renamed to "index" and its class is also changed to "index".
data/Gemfile CHANGED
@@ -6,9 +6,9 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "rspec", "~> 3.1"
10
- gem "rdoc", "~> 4.1"
11
- gem "bundler", "~> 1.6"
12
- gem "jeweler", "~> 2.0"
13
- gem "simplecov", "~> 0.0"
9
+ gem "rspec"
10
+ gem "rdoc"
11
+ gem "bundler"
12
+ gem "jeweler"
13
+ gem "simplecov"
14
14
  end
data/Rakefile CHANGED
@@ -19,8 +19,8 @@ Jeweler::Tasks.new do |gem|
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{Extention of the haml generator that is aware of i18n and so forth}
21
21
  gem.description = %Q{Extention of the haml generator that generates templates with the use of i18n, cancan and WiceGrid, adds classes to buttons and uses :title helper}
22
- gem.email = "dima@koulikoff.ru"
23
- gem.authors = ["Dmitri Koulikoff"]
22
+ gem.email = "dimi@kulk.eu"
23
+ gem.authors = ["Dimitri Kulk"]
24
24
  # dependencies defined in Gemfile
25
25
  end
26
26
  Jeweler::RubygemsDotOrgTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.0
1
+ 3.0.0
@@ -2,18 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: advanced_haml_scaffold_generator 2.2.1 ruby lib
5
+ # stub: advanced_haml_scaffold_generator 3.0.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "advanced_haml_scaffold_generator".freeze
9
- s.version = "2.3.0"
9
+ s.version = "3.0.0".freeze
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
- s.authors = ["Dmitri Koulikoff".freeze]
14
- s.date = "2020-06-17"
13
+ s.authors = ["Dimitri Kulk".freeze]
14
+ s.date = "2024-11-15"
15
15
  s.description = "Extention of the haml generator that generates templates with the use of i18n, cancan and WiceGrid, adds classes to buttons and uses :title helper".freeze
16
- s.email = "dima@koulikoff.ru".freeze
16
+ s.email = "dimi@kulk.eu".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
19
19
  "README.rdoc"
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.files = [
22
22
  ".document",
23
23
  ".rspec",
24
+ "CHANGELOG.md",
24
25
  "Gemfile",
25
26
  "LICENSE.txt",
26
27
  "README.rdoc",
@@ -34,6 +35,7 @@ Gem::Specification.new do |s|
34
35
  "lib/rails/generators/haml/scaffold/templates/edit.html.haml",
35
36
  "lib/rails/generators/haml/scaffold/templates/index.html.haml",
36
37
  "lib/rails/generators/haml/scaffold/templates/layout.html.haml",
38
+ "lib/rails/generators/haml/scaffold/templates/navigation_controller.js",
37
39
  "lib/rails/generators/haml/scaffold/templates/new.html.haml",
38
40
  "lib/rails/generators/haml/scaffold/templates/show.html.haml",
39
41
  "spec/advanced_haml_scaffold_generator_spec.rb",
@@ -41,25 +43,15 @@ Gem::Specification.new do |s|
41
43
  ]
42
44
  s.homepage = "http://github.com/dima4p/advanced_haml_scaffold_generator".freeze
43
45
  s.licenses = ["MIT".freeze]
44
- s.rubygems_version = "3.1.2".freeze
46
+ s.rubygems_version = "3.5.11".freeze
45
47
  s.summary = "Extention of the haml generator that is aware of i18n and so forth".freeze
46
48
 
47
- if s.respond_to? :specification_version then
48
- s.specification_version = 4
49
- end
49
+ s.specification_version = 4
50
50
 
51
- if s.respond_to? :add_runtime_dependency then
52
- s.add_development_dependency(%q<rspec>.freeze, ["~> 3.1"])
53
- s.add_development_dependency(%q<rdoc>.freeze, ["~> 4.1"])
54
- s.add_development_dependency(%q<bundler>.freeze, ["~> 1.6"])
55
- s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.0"])
56
- s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.0"])
57
- else
58
- s.add_dependency(%q<rspec>.freeze, ["~> 3.1"])
59
- s.add_dependency(%q<rdoc>.freeze, ["~> 4.1"])
60
- s.add_dependency(%q<bundler>.freeze, ["~> 1.6"])
61
- s.add_dependency(%q<jeweler>.freeze, ["~> 2.0"])
62
- s.add_dependency(%q<simplecov>.freeze, ["~> 0.0"])
63
- end
51
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0".freeze])
52
+ s.add_development_dependency(%q<rdoc>.freeze, [">= 0".freeze])
53
+ s.add_development_dependency(%q<bundler>.freeze, [">= 0".freeze])
54
+ s.add_development_dependency(%q<jeweler>.freeze, [">= 0".freeze])
55
+ s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
64
56
  end
65
57
 
@@ -10,7 +10,7 @@ module Haml
10
10
 
11
11
  class_option :layout, type: :boolean
12
12
  class_option :singleton, type: :boolean, desc: "Supply to skip index view"
13
- class_option :cancan, type: :boolean, desc: "Use cancan patterns"
13
+ class_option :cancan, type: :string, desc: "Use cancan patterns"
14
14
 
15
15
  def create_root_folder
16
16
  empty_directory File.join("app/views", controller_file_path)
@@ -43,17 +43,28 @@ module Haml
43
43
 
44
44
  def copy_layout_file
45
45
  return unless options[:layout]
46
- template "layout.html.haml", File.join("app/views/layouts", controller_class_path, "#{controller_file_name}.html.haml")
46
+ template "layout.html.haml",
47
+ File.join("app/views/layouts", controller_class_path, "#{controller_file_name}.html.haml")
48
+ end
49
+
50
+ def copy_controller
51
+ return unless defined? Stimulus
52
+ filename = 'navigation_controller.js'
53
+ path = 'app/javascript/controllers/' + filename
54
+ return if File.file? path
55
+ template filename, path
47
56
  end
48
57
 
49
58
  protected
50
59
 
51
60
  def copy_coffee(view)
52
- template "#{view}.js.coffee", File.join("app/views", controller_file_path, "#{view}.js.coffee")
61
+ template "#{view}.js.coffee",
62
+ File.join("app/views", controller_file_path, "#{view}.js.coffee")
53
63
  end
54
64
 
55
65
  def copy_view(view)
56
- template "#{view}.html.haml", File.join("app/views", controller_file_path, "#{view}.html.haml")
66
+ template "#{view}.html.haml",
67
+ File.join("app/views", controller_file_path, "#{view}.html.haml")
57
68
  end
58
69
  end
59
70
  end
@@ -1,13 +1,30 @@
1
1
  - title t('.title')
2
2
 
3
+ <% if turbo = defined? Stimulus -%>
4
+ %p.nav{data: {controller: "navigation"}}
5
+ <% else -%>
3
6
  %p.nav
7
+ <% end -%>
4
8
  <% if options[:cancan] -%>
5
9
  - if can? :index, <%= class_name %>
6
- = link_to t('back'), <%= plural_name %>_path, class: 'index'
10
+ <% if turbo -%>
11
+ = link_to t('Back'), <%= plural_name %>_path, class: 'back',
12
+ data: {action: "navigation#back", turbo_action: 'replace'}
13
+ <% end -%>
14
+ = link_to t('index'), <%= plural_name %>_path, class: 'index'
15
+ <% if turbo -%>
16
+ - else
17
+ = link_to t('Back'), '', class: 'back',
18
+ data: {action: "navigation#back", turbo_action: 'replace'}
19
+ <% end -%>
7
20
  - if can? :show, @<%= singular_name %>
8
21
  = link_to t('show'), @<%= singular_name %>, class: 'show'
9
22
  <% else -%>
10
- = link_to t('back'), <%= plural_name %>_path, class: 'index'
23
+ <% if turbo -%>
24
+ = link_to t('Back'), <%= plural_name %>_path, class: 'back',
25
+ data: {action: "navigation#back", turbo_action: 'replace'}
26
+ <% end -%>
27
+ = link_to t('index'), <%= plural_name %>_path, class: 'index'
11
28
  = link_to t('show'), @<%= singular_name %>, class: 'show'
12
29
  <% end -%>
13
30
 
@@ -1,12 +1,20 @@
1
1
  - title t('.title')
2
2
 
3
+ <% if turbo = defined? Stimulus -%>
4
+ %p.nav{data: {controller: "navigation"}}
5
+ <% else -%>
6
+ %p.nav
7
+ <% end -%>
3
8
  <% if options[:cancan] -%>
4
- - if can? :new, <%= class_name %>
5
- %p.nav= link_to t('.new_<%= singular_table_name %>'), new_<%= singular_table_name %>_path, class: 'new'
9
+ <% if turbo -%>
10
+ = link_to t('Back'), <%= plural_name %>_path, class: 'back',
11
+ data: {action: "navigation#back", turbo_action: 'replace'}
12
+ <% end -%>
13
+ - if can? :new, <%= class_name %>
14
+ = link_to t('.new_<%= singular_table_name %>'), new_<%= singular_table_name %>_path, class: 'new'
6
15
  <% else -%>
7
- %p.nav= link_to t('.new_<%= singular_table_name %>'), new_<%= singular_table_name %>_path, class: 'new'
16
+ = link_to t('.new_<%= singular_table_name %>'), new_<%= singular_table_name %>_path, class: 'new'
8
17
  <% end -%>
9
- <% turbo = defined? Turbo -%>
10
18
 
11
19
  - if @<%= plural_table_name %>.limit(1).size > 0
12
20
  <% if defined? Wice::WiceGrid -%>
@@ -0,0 +1,36 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class NavigationController extends Controller {
4
+ connect() {
5
+ let main_nav = this.element
6
+ this.collect_nav_links_into(main_nav)
7
+ this.is_frist_history_entry && this.hide_back_button_in(main_nav)
8
+ }
9
+
10
+ back (event) {
11
+ if (!this.is_frist_history_entry) {
12
+ event.preventDefault()
13
+ window.history.back()
14
+ }
15
+ }
16
+
17
+ //////////////////////////
18
+
19
+ collect_nav_links_into(main_nav) {
20
+ document.querySelectorAll('p.nav').forEach(element => {
21
+ if (element != main_nav) {
22
+ main_nav.append(...element.childNodes)
23
+ }
24
+ })
25
+ }
26
+
27
+ hide_back_button_in(main_nav) {
28
+ let link = main_nav.querySelector("a.back")
29
+ link && link.remove()
30
+ }
31
+
32
+ get is_frist_history_entry () {
33
+ return !window.history.state.turbo ||
34
+ window.history.state.turbo.restorationIndex === 0
35
+ }
36
+ }
@@ -1,10 +1,28 @@
1
1
  - title t('.title')
2
2
 
3
+ <% if turbo = defined? Stimulus -%>
4
+ %p.nav{data: {controller: "navigation"}}
5
+ <% else -%>
6
+ %p.nav
7
+ <% end -%>
3
8
  <% if options[:cancan] -%>
4
- - if can? :index, <%= class_name %>
5
- %p.nav= link_to t('back'), <%= index_helper %>_path, class: 'index'
9
+ - if can? :index, <%= class_name %>
10
+ <% if turbo -%>
11
+ = link_to t('Back'), <%= plural_name %>_path, class: 'back',
12
+ data: {action: "navigation#back", turbo_action: 'replace'}
13
+ <% end -%>
14
+ = link_to t('index'), <%= index_helper %>_path, class: 'index'
15
+ <% if turbo -%>
16
+ - else
17
+ = link_to t('Back'), '', class: 'back',
18
+ data: {action: "navigation#back", turbo_action: 'replace'}
19
+ <% end -%>
6
20
  <% else -%>
7
- %p= link_to t('back'), <%= index_helper %>_path, class: 'index'
21
+ <% if turbo -%>
22
+ = link_to t('Back'), <%= plural_name %>_path, class: 'back',
23
+ data: {action: "navigation#back", turbo_action: 'replace'}
24
+ <% end -%>
25
+ = link_to t('index'), <%= index_helper %>_path, class: 'index'
8
26
  <% end -%>
9
27
 
10
28
  = render 'form', <%= singular_table_name %>: @<%= singular_table_name %>
@@ -1,13 +1,30 @@
1
1
  - title t('.title')
2
2
 
3
+ <% if turbo = defined? Stimulus -%>
4
+ %p.nav{data: {controller: "navigation"}}
5
+ <% else -%>
3
6
  %p.nav
7
+ <% end -%>
4
8
  <% if options[:cancan] -%>
5
9
  - if can? :index, <%= class_name %>
6
- = link_to t('back'), <%= index_helper %>_path, class: 'index'
10
+ <% if turbo -%>
11
+ = link_to t('Back'), <%= plural_name %>_path, class: 'back',
12
+ data: {action: "navigation#back", turbo_action: 'replace'}
13
+ <% end -%>
14
+ = link_to t('index'), <%= index_helper %>_path, class: 'index'
15
+ <% if turbo -%>
16
+ - else
17
+ = link_to t('Back'), '', class: 'back',
18
+ data: {action: "navigation#back", turbo_action: 'replace'}
19
+ <% end -%>
7
20
  - if can? :edit, @<%= singular_table_name %>
8
21
  = link_to t('edit'), edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'edit'
9
22
  <% else -%>
10
- = link_to t('back'), <%= plural_name %>_path, class: 'index'
23
+ <% if turbo -%>
24
+ = link_to t('Back'), <%= plural_name %>_path, class: 'back',
25
+ data: {action: "navigation#back", turbo_action: 'replace'}
26
+ <% end -%>
27
+ = link_to t('index'), <%= plural_name %>_path, class: 'index'
11
28
  = link_to t('edit'), edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'edit'
12
29
  <% end -%>
13
30
 
metadata CHANGED
@@ -1,88 +1,88 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: advanced_haml_scaffold_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Dmitri Koulikoff
7
+ - Dimitri Kulk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-17 00:00:00.000000000 Z
11
+ date: 2024-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.1'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '4.1'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.6'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.6'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: jeweler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '2.0'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '2.0'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '0.0'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '0.0'
82
+ version: '0'
83
83
  description: Extention of the haml generator that generates templates with the use
84
84
  of i18n, cancan and WiceGrid, adds classes to buttons and uses :title helper
85
- email: dima@koulikoff.ru
85
+ email: dimi@kulk.eu
86
86
  executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files:
@@ -91,6 +91,7 @@ extra_rdoc_files:
91
91
  files:
92
92
  - ".document"
93
93
  - ".rspec"
94
+ - CHANGELOG.md
94
95
  - Gemfile
95
96
  - LICENSE.txt
96
97
  - README.rdoc
@@ -104,6 +105,7 @@ files:
104
105
  - lib/rails/generators/haml/scaffold/templates/edit.html.haml
105
106
  - lib/rails/generators/haml/scaffold/templates/index.html.haml
106
107
  - lib/rails/generators/haml/scaffold/templates/layout.html.haml
108
+ - lib/rails/generators/haml/scaffold/templates/navigation_controller.js
107
109
  - lib/rails/generators/haml/scaffold/templates/new.html.haml
108
110
  - lib/rails/generators/haml/scaffold/templates/show.html.haml
109
111
  - spec/advanced_haml_scaffold_generator_spec.rb
@@ -127,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
129
  - !ruby/object:Gem::Version
128
130
  version: '0'
129
131
  requirements: []
130
- rubygems_version: 3.1.4
132
+ rubygems_version: 3.5.11
131
133
  signing_key:
132
134
  specification_version: 4
133
135
  summary: Extention of the haml generator that is aware of i18n and so forth