hot-glue 0.6.0 → 0.6.0.1

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: 822437dfda890941c29f2ff18b927c60a84279306c0937d354f69e18c67f51e5
4
- data.tar.gz: 193b9bb92313ae7440c72d8d7598f918400136f7edabc70bf7ec7def1b4f96ed
3
+ metadata.gz: 8ffc84538112521ab7f15e7c0d234de7ffc5e5231e49a6ffb3cb3fd77c4f0545
4
+ data.tar.gz: f9e7c8e6b171aace305d5fae08ee24d08f6304c0127e5044579e8d3c30cc6ca6
5
5
  SHA512:
6
- metadata.gz: '0210383122eded31e46b9cc02bc6a7c230d95936f13635149c884774e762b178eb326e3722466a6ff8e365fd3d45782a05c0a60733d678499762ff49d6f7b58d'
7
- data.tar.gz: 8cc9ed4dc85875d66dbd66ecac22908bfd6a8759588e37a2b26bb03522a16b8559ca0bc0ee0311a28a627f2f25af703ed744ea1aba6f8f1d48c5fbc35d28748a
6
+ metadata.gz: 53da97a3e0c570c41594ae47ed50149a5519e512d1677c38dc70fb118e69893d67165b7f7de89e0e8f56325f766934225f810c52fba501c9b9a1a71943cdc365
7
+ data.tar.gz: f6fd036dd5abeb33724927a6a25e2fab560f553f4df23cf186438f09036e68f147aef50ce356b7c9c3858cd3fbe81c02bc9649b46076562da3a3cf43f0cf0530
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.5.26)
4
+ hot-glue (0.6.0)
5
5
  ffaker (~> 2.16)
6
6
  kaminari (~> 1.2)
7
7
  rails (> 5.1)
@@ -139,7 +139,7 @@ GEM
139
139
  mini_mime (1.1.2)
140
140
  mini_portile2 (2.8.4)
141
141
  minitest (5.16.3)
142
- net-imap (0.4.2)
142
+ net-imap (0.4.4)
143
143
  date
144
144
  net-protocol
145
145
  net-pop (0.1.2)
data/README.md CHANGED
@@ -64,25 +64,23 @@ _If you are on Rails 6, see [LEGACY SETUP FOR RAILS 6](https://github.com/jasonf
64
64
 
65
65
  ## The Super-Quick Setup
66
66
 
67
- https://jasonfleetwoodboldt.com/courses/stepping-up-rails/rails-quick-scripts/
67
+ https://jasonfleetwoodboldt.com/courses/stepping-up-rails/jason-fleetwood-boldts-rails-cookbook/
68
68
 
69
- Copy & paste the whole code block from each section into your terminal. (Pick only ONE option for each section.)
69
+ Copy & paste the whole code block from each section into your terminal. Remember, there is a small "Copy" button at the top-right of each code block to help you copy & paste the script into your terminal.
70
70
 
71
+ These are the sections you need, you can ignore any others:
71
72
 
72
- From section #1 (`rails new`), choose either (1) ImportMap Rails, (2) JSBundling, or (3) Shakapacker.
73
-
74
- For Hot Glue, you will need:
75
-
76
- Section #1 is to create a new Rails app. (Or you can do that yourself.)
77
-
78
- Section #2 is to setup Rspec, FactoryBot, and Faker choose 2B for Rspec0
79
-
80
- Skip #3 and #4 is optional. #5 is optional but recommended.
81
-
82
- Sectoin #6 is for Hot Glue itself, and Section #7 is for Kaminari
83
-
84
- You will also need section #8 to setup Devise if you want authentication.
73
+ * Section 1A for a new JS Bundling app, then skip down to
74
+ * Section 2B: Rspec + Friends
75
+ * Section 2B-Capy: Capybara for Rspec, then skip down to
76
+ * Section 3 for a welcome controller
77
+ ( you can skip everything in Section 4 )
78
+ * Section 5 for debugging tools
79
+ * _Section 6 is the Hot Glue installer itself_ (this gem) - for Bootstrap, choose section 6A
80
+ * Section 7A to install Bootstrap along with CSSBundling
81
+ * Section 8 to set up Devise if you want authentication. (See how Hot Glue interacts with Devise below.)
85
82
 
83
+ If you do this through the quick setup above, you can then skip down past the next section to the "HOT GLUE DOCS" below.
86
84
 
87
85
  ## Step-By-Step Setup
88
86
 
@@ -294,10 +292,21 @@ Alternatively, you can define your own driver like so:
294
292
 
295
293
  # HOT GLUE DOCS
296
294
 
295
+ Remember: Use `bin/rails generate model Thing` to generate models. Then add `has_many`, `belongs_to`, and _migrate your database_ before building the scaffold with Hot Glue.
296
+
297
+ You will also need every Rails model to contain _either_ a database column _or_ an object-level method named one of these five things:
298
+ `name`
299
+ `to_label`
300
+ `full_name`
301
+ `display_name`
302
+ `email`
303
+
304
+ If your database doesn't contain one of these five, add a method to your model using `def to_label`. This will be used as the default label for the object throughout the Hot Glue build system.
305
+
297
306
  ## First Argument
298
307
  (no double slash)
299
308
 
300
- TitleCase class name of the thing you want to build a scaffoling for.
309
+ TitleCase class name of the thing you want to build a scaffolding for.
301
310
 
302
311
  ```
303
312
  ./bin/rails generate hot_glue:scaffold Thing
@@ -1393,7 +1402,7 @@ You can now use a typeahead when editing the book. Instead of displaying the aut
1393
1402
  You will do these three things:
1394
1403
 
1395
1404
  1. As a one-time setup step for your app, run
1396
- `bin/rails generate hot_glue:install_typeahead`
1405
+ `bin/rails generate hot_glue:typeahead_install`
1397
1406
  2. When generating a scaffold you want to make a typeahead association, use `--modify='parent_id{typeahead}'` where `parent_id` is the foreign key
1398
1407
  `bin/rails generate hot_glue:scaffold Book --include=title,author_id --modify='author_id{typeahead}'`
1399
1408
  3. Within each namespace, you will generate a special typeahead controller (it exists for the associated object to be searched on
@@ -1476,7 +1485,7 @@ from a searchable typehead input.
1476
1485
  The typeahead is implemented with a native Stimulus JS pair of controllers and is a modern & clean replacement to the old typeahead options.
1477
1486
 
1478
1487
  1. As a one-time setup step for your app, run
1479
- `bin/rails generate hot_glue:install_typeahead`
1488
+ `bin/rails generate hot_glue:typeahead_install`
1480
1489
  2. When generating a scaffold you want to make a typeahead association, use `--modify='parent_id{typeahead}'` where `parent_id` is the foreign key
1481
1490
  `bin/rails generate hot_glue:scaffold Book --include=title,author_id --modify='author_id{typeahead}'`
1482
1491
  3. Within each namespace, you will generate a special typeahead controller (it exists for the associated object to be searched on
@@ -44,7 +44,6 @@ class FieldFactory
44
44
  AttachmentField
45
45
  end
46
46
  @class_name = class_name
47
-
48
47
  @field = field_class.new(name: name,
49
48
  layout_strategy: generator.layout_strategy,
50
49
  form_placeholder_labels: generator.form_placeholder_labels,
@@ -80,20 +80,20 @@ class AssociationField < Field
80
80
  assoc = eval("#{class_name}.reflect_on_association(:#{assoc_name})")
81
81
 
82
82
  if modify_as && modify_as[:typeahead]
83
- search_url = "#{namespace ? namespace + "_" : ""}#{assoc.plural_name}_typeahead_index_url"
84
-
85
- "<div class='typeahead typeahead--#{singular}--#{assoc.name}_id'
86
- data-controller='typeahead'
87
- data-typeahead-url-value='<%= #{search_url} %>'
88
- data-typeahead-typeahead-results-outlet='#search-results'>
89
- <%= text_field_tag :#{assoc.plural_name}_query, '', placeholder: 'Search #{assoc.plural_name}', class: 'search__input',
90
- data: { action: 'keyup->typeahead#fetchResults keydown->typeahead#navigateResults', typeahead_target: 'query' },
91
- autofocus: true,
92
- autocomplete: 'off',
93
- value: #{singular}.try(:#{assoc.name}).try(:name) %>
94
- <%= f.hidden_field :#{assoc.name}_id, value: #{singular}.try(:#{assoc.name}).try(:id), 'data-typeahead-target': 'hiddenFormValue' %>
95
- <div data-typeahead-target='results'></div>
96
- </div>"
83
+ search_url = "#{namespace ? namespace + "_" : ""}#{assoc.plural_name}_typeahead_index_url"
84
+ "<div class='typeahead typeahead--#{assoc.name}_id'
85
+ data-controller='typeahead'
86
+ data-typeahead-url-value='<%= #{search_url} %>'
87
+ data-typeahead-typeahead-results-outlet='#search-results'>
88
+ <%= text_field_tag :#{assoc.plural_name}_query, '', placeholder: 'Search #{assoc.plural_name}', class: 'search__input',
89
+ data: { action: 'keyup->typeahead#fetchResults keydown->typeahead#navigateResults', typeahead_target: 'query' },
90
+ autofocus: true,
91
+ autocomplete: 'off',
92
+ value: #{singular}.try(:#{assoc.name}).try(:name) %>
93
+ <%= f.hidden_field :#{assoc.name}_id, value: #{singular}.try(:#{assoc.name}).try(:id), 'data-typeahead-target': 'hiddenFormValue' %>
94
+ <div data-typeahead-target='results'></div>
95
+ <div data-typeahead-target='classIdentifier' data-id=\"typeahead--#{assoc_name}_id\"></div>
96
+ </div>"
97
97
  else
98
98
  if assoc.nil?
99
99
  exit_message = "*** Oops. on the #{class_name} object, there doesn't seem to be an association called '#{assoc_name}'"
@@ -43,7 +43,7 @@ class Field
43
43
 
44
44
  @self_auth = self_auth
45
45
  @default_boolean_display = default_boolean_display
46
- @namesapce = namespace
46
+ @namespace = namespace
47
47
 
48
48
  # TODO: remove knowledge of subclasses from Field
49
49
  unless self.class == AttachmentField
@@ -6,7 +6,7 @@ class <%= ((@namespace.titleize.gsub(" ", "") + "::" if @namespace) || "") + @pl
6
6
 
7
7
  def index
8
8
  query = params[:query]
9
-
9
+ @typeahead_identifier = params[:typeahead_identifier]
10
10
  @<%= @plural %> = <%= @singular.titleize.gsub(" ", "") %>.where("<%= @search_by.collect{|search| "LOWER(#{search}) LIKE ?" }.join(" OR ") %>", <%= @search_by.collect{|search| "\"%\#{query.downcase}%\"" }.join(", ") %>).limit(10)
11
11
 
12
12
  render layout: false
@@ -1,7 +1,7 @@
1
1
 
2
2
  <div class="typeahead-results__<%= @plural %>"
3
3
  data-controller="typeahead-results"
4
- data-typeahead-results-typeahead-outlet=".typeahead--book--<%= @singular %>_id"
4
+ data-typeahead-results-typeahead-outlet=".<\%= @typeahead_identifier %>"
5
5
  data-typeahead-results-current-class="search__result--current" >
6
6
  <ul class="search__results" data-typeahead-results-target="result">
7
7
  <\% if @<%= @plural %>.any? %>
@@ -1,7 +1,8 @@
1
1
  import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
- static targets = [ "query", "results", "hiddenFormValue" ]
4
+ static targets = [ "query", "results", "hiddenFormValue",
5
+ "classIdentifier"]
5
6
  static values = { url: String }
6
7
  static outlets = [ "typeahead-results" ]
7
8
 
@@ -10,6 +11,10 @@ export default class extends Controller {
10
11
  }
11
12
 
12
13
  fetchResults() {
14
+
15
+
16
+ var typeaheadIdentifier = this.classIdentifierTarget.dataset.id
17
+
13
18
  if(this.query == "") {
14
19
  this.reset()
15
20
  return
@@ -22,6 +27,7 @@ export default class extends Controller {
22
27
 
23
28
  const url = new URL(this.urlValue)
24
29
  url.searchParams.append("query", this.query)
30
+ url.searchParams.append("typeahead_identifier", typeaheadIdentifier)
25
31
 
26
32
  this.abortPreviousFetchRequest()
27
33
 
@@ -12,7 +12,6 @@ export default class extends Controller {
12
12
 
13
13
  connect() {
14
14
  this.currentResultIndex = 0
15
-
16
15
  const allElements = this.resultTarget.querySelectorAll(".search-result-item");
17
16
 
18
17
  allElements.forEach((element, index) => {
@@ -29,7 +28,6 @@ export default class extends Controller {
29
28
  const result_id = element.dataset.id;
30
29
 
31
30
  // how to pass this to the search controller, set the field value and clear out the search
32
- console.log("search item clicked...", result_value, result_id)
33
31
 
34
32
  this.typeaheadOutlets.forEach(outlet => {
35
33
  outlet.hiddenFormValueTarget.value = result_id;
@@ -1,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.6.0'
3
+ CURRENT = '0.6.0.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hot-glue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-03 00:00:00.000000000 Z
11
+ date: 2023-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails