headmin 0.6.2 → 0.6.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ec99ac85337bc096a16478a65e5434f37209281e861043a59f8cd4692197851
4
- data.tar.gz: e3c9bf55658ce12c6d96ca0791ffa7e2dae14df3df9798e4ee21dc4b07b2f994
3
+ metadata.gz: 819c038f09a0d2dab83f4931d67256dd6130244afcff409af0580d8abf72d02c
4
+ data.tar.gz: 28fa2501518683ed07ce67315a42b62b1f2d8749208196a84ef20642125b815b
5
5
  SHA512:
6
- metadata.gz: c0eaf4ed9453bbc2cf383c82d050c708f7f8e7ba930c58fb9a0c2432ada5f4e928644b2d2e26ba331bd793bd4d58e5cca261f8e61ee091e987c90b62d6d096da
7
- data.tar.gz: 249378b6c61d2d02b4349af48080fc9c53d8bba28fe41da0d7492c725502f2932384e3b9dfde718be1eca5f1cbc17c4d0ef884ec6dd21be804f0592be10bef7f
6
+ metadata.gz: a117642e4cd9cc87484aa37ca85c0ba95a0e0747111b51ce87c529c92510a4b7dfa715aa432d8993b37b412aab30fa51f4a0b4876e2058d2fd83086ef1145a54
7
+ data.tar.gz: 06247200375b3fa43820d017fd7a174e29e5acea8a8c4fda239c95a8388e6df33918e1995fa4488e77c8c915ea8f9fc715d50f390e11edffc60794ca6eeeb2e3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- headmin (0.6.1)
4
+ headmin (0.6.3)
5
5
  closure_tree (~> 7.4)
6
6
  inline_svg (~> 1.7)
7
7
  redcarpet (~> 3.5)
@@ -218,7 +218,7 @@ GEM
218
218
  zeitwerk (~> 2.5)
219
219
  rainbow (3.1.1)
220
220
  rake (13.0.6)
221
- redcarpet (3.5.1)
221
+ redcarpet (3.6.0)
222
222
  regexp_parser (2.6.2)
223
223
  reline (0.3.2)
224
224
  io-console (~> 0.5)
@@ -288,8 +288,9 @@ GEM
288
288
  websocket-driver (0.7.5)
289
289
  websocket-extensions (>= 0.1.0)
290
290
  websocket-extensions (0.1.5)
291
- with_advisory_lock (4.6.0)
292
- activerecord (>= 4.2)
291
+ with_advisory_lock (5.1.0)
292
+ activerecord (>= 6.1)
293
+ zeitwerk (>= 2.6)
293
294
  xpath (3.2.0)
294
295
  nokogiri (~> 1.8)
295
296
  zeitwerk (2.6.6)
@@ -91,7 +91,7 @@ export default class extends Controller {
91
91
 
92
92
  // Only the visible elements are of interest
93
93
  values = values.filter((element) => {
94
- return element.style.display;
94
+ return element.style.display
95
95
  })
96
96
 
97
97
  // Grab the value of each visible element
@@ -100,7 +100,7 @@ export default class extends Controller {
100
100
  })
101
101
 
102
102
  // Concatenate array to a string
103
- const value = values.join(",")
103
+ const value = values.join(',')
104
104
 
105
105
  string += `${conditional || ''}${operator}:${value}`
106
106
  }
@@ -1,78 +1,78 @@
1
- import {Controller} from '@hotwired/stimulus'
1
+ import { Controller } from '@hotwired/stimulus'
2
2
 
3
3
  export default class extends Controller {
4
- static get targets() {
5
- return ['original', 'operator', 'null']
6
- }
4
+ static get targets () {
5
+ return ['original', 'operator', 'null']
6
+ }
7
7
 
8
- connect() {
9
- this.operatorTarget.addEventListener('change', () => this.handleOperatorChange())
10
- this.handleOperatorChange()
11
- }
8
+ connect () {
9
+ this.operatorTarget.addEventListener('change', () => this.handleOperatorChange())
10
+ this.handleOperatorChange()
11
+ }
12
12
 
13
- handleOperatorChange() {
14
- if (this.operatorTarget.value === 'is_null' || this.operatorTarget.value === 'is_not_null') {
15
- this.toggleNullInput()
16
- } else if (this.operatorTarget.value === 'between' || this.operatorTarget.value === 'not_between') {
17
- this.toggleSecondaryInput()
18
- } else {
19
- this.toggleOriginalInput()
20
- }
13
+ handleOperatorChange () {
14
+ if (this.operatorTarget.value === 'is_null' || this.operatorTarget.value === 'is_not_null') {
15
+ this.toggleNullInput()
16
+ } else if (this.operatorTarget.value === 'between' || this.operatorTarget.value === 'not_between') {
17
+ this.toggleSecondaryInput()
18
+ } else {
19
+ this.toggleOriginalInput()
21
20
  }
21
+ }
22
22
 
23
- toggleNullInput() {
24
- this.hideOriginal()
25
- this.hideSecondary()
26
- this.showNull()
27
- }
23
+ toggleNullInput () {
24
+ this.hideOriginal()
25
+ this.hideSecondary()
26
+ this.showNull()
27
+ }
28
28
 
29
- toggleOriginalInput() {
30
- this.showOriginal()
31
- this.hideSecondary()
32
- this.hideNull()
33
- }
29
+ toggleOriginalInput () {
30
+ this.showOriginal()
31
+ this.hideSecondary()
32
+ this.hideNull()
33
+ }
34
34
 
35
- toggleSecondaryInput() {
36
- this.showSecondary()
37
- this.hideOriginal()
38
- this.hideNull()
39
- }
35
+ toggleSecondaryInput () {
36
+ this.showSecondary()
37
+ this.hideOriginal()
38
+ this.hideNull()
39
+ }
40
40
 
41
- hideOriginal() {
42
- this.originalTarget.style.display = 'none'
43
- this.originalTarget.setAttribute('data-filter-target', 'value_original')
44
- }
41
+ hideOriginal () {
42
+ this.originalTarget.style.display = 'none'
43
+ this.originalTarget.setAttribute('data-filter-target', 'value_original')
44
+ }
45
45
 
46
- showOriginal() {
47
- this.originalTarget.style.display = 'block'
48
- this.originalTarget.setAttribute('data-filter-target', 'value')
49
- }
46
+ showOriginal () {
47
+ this.originalTarget.style.display = 'block'
48
+ this.originalTarget.setAttribute('data-filter-target', 'value')
49
+ }
50
50
 
51
- hideSecondary() {
52
- for (const [index, value] of this.originalTargets.entries()) {
53
- if (index != 0) {
54
- value.style.display = 'none'
55
- value.setAttribute('data-filter-target', 'value_original')
56
- }
57
- }
51
+ hideSecondary () {
52
+ for (const [index, value] of this.originalTargets.entries()) {
53
+ if (index !== 0) {
54
+ value.style.display = 'none'
55
+ value.setAttribute('data-filter-target', 'value_original')
56
+ }
58
57
  }
58
+ }
59
59
 
60
- showSecondary() {
61
- for (const [index, value] of this.originalTargets.entries()) {
62
- if (index != 0) {
63
- value.style.display = 'block'
64
- value.setAttribute('data-filter-target', 'value')
65
- }
66
- }
60
+ showSecondary () {
61
+ for (const [index, value] of this.originalTargets.entries()) {
62
+ if (index !== 0) {
63
+ value.style.display = 'block'
64
+ value.setAttribute('data-filter-target', 'value')
65
+ }
67
66
  }
67
+ }
68
68
 
69
- hideNull() {
70
- this.nullTarget.style.display = 'none'
71
- this.nullTarget.setAttribute('data-filter-target', 'value_null')
72
- }
69
+ hideNull () {
70
+ this.nullTarget.style.display = 'none'
71
+ this.nullTarget.setAttribute('data-filter-target', 'value_null')
72
+ }
73
73
 
74
- showNull() {
75
- this.nullTarget.style.display = 'block'
76
- this.nullTarget.setAttribute('data-filter-target', 'value')
77
- }
74
+ showNull () {
75
+ this.nullTarget.style.display = 'block'
76
+ this.nullTarget.setAttribute('data-filter-target', 'value')
77
+ }
78
78
  }
@@ -1,30 +1,28 @@
1
- /* global fetch, Event */
2
1
  import { Controller } from '@hotwired/stimulus'
3
2
 
4
3
  export default class extends Controller {
5
- connect() {
4
+ connect () {
6
5
  this.clickWhenInViewport()
7
6
 
8
- document.querySelector(".modal-body").addEventListener("scroll", () => {
7
+ document.querySelector('.modal-body').addEventListener('scroll', () => {
9
8
  this.clickWhenInViewport()
10
9
  })
11
10
  }
12
11
 
13
- clickWhenInViewport() {
12
+ clickWhenInViewport () {
14
13
  if (!this.isLoading() && this.isInViewport()) {
15
- this.element.setAttribute("clicked", 1)
14
+ this.element.setAttribute('clicked', 1)
16
15
  this.element.click()
17
16
  }
18
17
  }
19
18
 
20
- isLoading() {
21
- return this.element.hasAttribute("clicked")
19
+ isLoading () {
20
+ return this.element.hasAttribute('clicked')
22
21
  }
23
22
 
24
- isInViewport() {
23
+ isInViewport () {
25
24
  const rect = this.element.getBoundingClientRect()
26
25
 
27
- return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
26
+ return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth)
28
27
  }
29
-
30
- }
28
+ }
@@ -130,7 +130,7 @@ export default class extends Controller {
130
130
  }
131
131
 
132
132
  addNewItems (items) {
133
- const itemTargetIds = this.itemTargets.map((i) => { return parseInt(i.querySelectorAll("input")[1].value)})
133
+ const itemTargetIds = this.itemTargets.map((i) => { return parseInt(i.querySelectorAll('input')[1].value) })
134
134
  items.forEach((item) => {
135
135
  if (itemTargetIds.includes(item.blobId)) {
136
136
  // Do not add this item (as it is already present)
@@ -205,13 +205,13 @@ export default class extends Controller {
205
205
  }
206
206
 
207
207
  removeDeselectedItems (elements, items) {
208
- const returnedBlobIds = elements.map((e) => { return e.blobId})
208
+ const returnedBlobIds = elements.map((e) => { return e.blobId })
209
209
 
210
210
  items.forEach((item) => {
211
- const blobId = parseInt(item.querySelectorAll("input")[1].value)
211
+ const blobId = parseInt(item.querySelectorAll('input')[1].value)
212
212
  if (returnedBlobIds.includes(blobId)) {
213
213
  // Do not delete this one
214
- return;
214
+ return
215
215
  }
216
216
 
217
217
  this.removeItem(item)
@@ -1,147 +1,147 @@
1
1
  /* global CustomEvent */
2
- import {Controller} from '@hotwired/stimulus'
2
+ import { Controller } from '@hotwired/stimulus'
3
3
 
4
4
  export default class extends Controller {
5
- static get targets() {
6
- return ['idCheckbox', 'item', 'form', 'selectButton', 'placeholder', 'count']
7
- }
8
-
9
- static get values () {
10
- return { ids: Array }
11
- }
12
-
13
- connect() {
14
- this.validate()
15
- this.updateCount()
16
- }
17
-
18
- // Actions
19
- select() {
20
- this.dispatchSelectionEvent()
21
- }
22
-
23
- submitForm() {
24
- this.hidePlaceholder()
25
- this.triggerFormSubmission()
26
- }
27
-
28
- inputChange(event) {
29
- this.handleIdsUpdate(event.target)
30
- this.updateCount()
31
- }
32
-
33
- // Methods
34
- hidePlaceholder() {
35
- this.placeholderTarget.classList.add('d-none')
36
- }
37
-
38
- handleIdsUpdate(element) {
39
- if (element.checked) {
40
- let arr = this.idsValue
41
- arr.push(element.value)
42
- this.idsValue = arr
43
- } else {
44
- this.idsValue = this.idsValue.filter((value) => {
45
- return element.value !== value
46
- })
5
+ static get targets () {
6
+ return ['idCheckbox', 'item', 'form', 'selectButton', 'placeholder', 'count']
7
+ }
8
+
9
+ static get values () {
10
+ return { ids: Array }
11
+ }
12
+
13
+ connect () {
14
+ this.validate()
15
+ this.updateCount()
16
+ }
17
+
18
+ // Actions
19
+ select () {
20
+ this.dispatchSelectionEvent()
21
+ }
22
+
23
+ submitForm () {
24
+ this.hidePlaceholder()
25
+ this.triggerFormSubmission()
26
+ }
27
+
28
+ inputChange (event) {
29
+ this.handleIdsUpdate(event.target)
30
+ this.updateCount()
31
+ }
32
+
33
+ // Methods
34
+ hidePlaceholder () {
35
+ this.placeholderTarget.classList.add('d-none')
36
+ }
37
+
38
+ handleIdsUpdate (element) {
39
+ if (element.checked) {
40
+ const arr = this.idsValue
41
+ arr.push(element.value)
42
+ this.idsValue = arr
43
+ } else {
44
+ this.idsValue = this.idsValue.filter((value) => {
45
+ return element.value !== value
46
+ })
47
+ }
48
+ }
49
+
50
+ itemTargetConnected (element) {
51
+ this.updateItem(element.querySelector('input'))
52
+ }
53
+
54
+ updateItem (element) {
55
+ const arr = this.idsValue
56
+
57
+ if (arr.includes(element.value)) {
58
+ element.checked = true
59
+ } else {
60
+ element.checked = false
61
+ }
62
+ }
63
+
64
+ idsValueChanged () {
65
+ for (const item of this.itemTargets) {
66
+ this.updateItem(item.querySelector('input'))
67
+ }
68
+ this.validate()
69
+ }
70
+
71
+ dispatchSelectionEvent () {
72
+ document.dispatchEvent(
73
+ new CustomEvent(
74
+ 'mediaSelectionSubmitted',
75
+ {
76
+ detail: {
77
+ name: this.element.dataset.name,
78
+ items: this.renderItemsForEvent()
79
+ }
47
80
  }
48
- }
49
-
50
- itemTargetConnected(element) {
51
- this.updateItem(element.querySelector("input"))
52
- }
53
-
54
- updateItem(element) {
55
- const arr = this.idsValue
56
-
57
- if (arr.includes(element.value)) {
58
- element.checked = true
59
- } else {
60
- element.checked = false
61
- }
62
- }
63
-
64
- idsValueChanged() {
65
- for (const item of this.itemTargets) {
66
- this.updateItem(item.querySelector("input"))
67
- }
68
- this.validate()
69
- }
70
-
71
- dispatchSelectionEvent() {
72
- document.dispatchEvent(
73
- new CustomEvent(
74
- 'mediaSelectionSubmitted',
75
- {
76
- detail: {
77
- name: this.element.dataset.name,
78
- items: this.renderItemsForEvent()
79
- }
80
- }
81
- )
82
- )
83
- }
84
-
85
- triggerFormSubmission() {
86
- this.formTarget.requestSubmit()
87
- }
88
-
89
- renderItemsForEvent() {
90
- return this.idsValue.map((item) => this.renderItemForEvent(item)).filter((i) => { return i !== undefined })
91
- }
92
-
93
- renderItemForEvent(item) {
94
- const id = parseInt(item)
95
- const blob_id = `#blob_${id}`
96
- const element = this.element.querySelector(blob_id)
97
-
98
- return {
99
- blobId: id,
100
- thumbnail: element ? element.querySelector('.h-thumbnail') : ""
101
- }
102
- }
103
-
104
- selectedItems() {
105
- return this.itemTargets.filter((item) => {
106
- const checkbox = item.querySelector('input[type="checkbox"]')
107
- return checkbox.checked
108
- })
109
- }
110
-
111
- selectedItemsCount() {
112
- return this.idsValue.length
113
- }
114
-
115
- minSelectedItems() {
116
- return parseInt(this.element.dataset.min, 10) || 0
117
- }
118
-
119
- maxSelectedItems() {
120
- return parseInt(this.element.dataset.max, 10) || Infinity
121
- }
122
-
123
- validate() {
124
- if (this.isValid()) {
125
- this.enableSelectButton()
126
- } else {
127
- this.disableSelectButton()
128
- }
129
- }
130
-
131
- enableSelectButton() {
132
- this.selectButtonTarget.removeAttribute('disabled')
133
- }
134
-
135
- disableSelectButton() {
136
- this.selectButtonTarget.setAttribute('disabled', '')
137
- }
138
-
139
- isValid() {
140
- const count = this.selectedItemsCount()
141
- return count >= this.minSelectedItems() && count <= this.maxSelectedItems()
142
- }
143
-
144
- updateCount() {
145
- this.countTarget.innerHTML = this.selectedItemsCount()
146
- }
81
+ )
82
+ )
83
+ }
84
+
85
+ triggerFormSubmission () {
86
+ this.formTarget.requestSubmit()
87
+ }
88
+
89
+ renderItemsForEvent () {
90
+ return this.idsValue.map((item) => this.renderItemForEvent(item)).filter((i) => { return i !== undefined })
91
+ }
92
+
93
+ renderItemForEvent (item) {
94
+ const id = parseInt(item)
95
+ const blobId = `#blob_${id}`
96
+ const element = this.element.querySelector(blobId)
97
+
98
+ return {
99
+ blobId: id,
100
+ thumbnail: element ? element.querySelector('.h-thumbnail') : ''
101
+ }
102
+ }
103
+
104
+ selectedItems () {
105
+ return this.itemTargets.filter((item) => {
106
+ const checkbox = item.querySelector('input[type="checkbox"]')
107
+ return checkbox.checked
108
+ })
109
+ }
110
+
111
+ selectedItemsCount () {
112
+ return this.idsValue.length
113
+ }
114
+
115
+ minSelectedItems () {
116
+ return parseInt(this.element.dataset.min, 10) || 0
117
+ }
118
+
119
+ maxSelectedItems () {
120
+ return parseInt(this.element.dataset.max, 10) || Infinity
121
+ }
122
+
123
+ validate () {
124
+ if (this.isValid()) {
125
+ this.enableSelectButton()
126
+ } else {
127
+ this.disableSelectButton()
128
+ }
129
+ }
130
+
131
+ enableSelectButton () {
132
+ this.selectButtonTarget.removeAttribute('disabled')
133
+ }
134
+
135
+ disableSelectButton () {
136
+ this.selectButtonTarget.setAttribute('disabled', '')
137
+ }
138
+
139
+ isValid () {
140
+ const count = this.selectedItemsCount()
141
+ return count >= this.minSelectedItems() && count <= this.maxSelectedItems()
142
+ }
143
+
144
+ updateCount () {
145
+ this.countTarget.innerHTML = this.selectedItemsCount()
146
+ }
147
147
  }
@@ -7836,7 +7836,7 @@ var filter_row_controller_default = class extends Controller {
7836
7836
  }
7837
7837
  hideSecondary() {
7838
7838
  for (const [index2, value] of this.originalTargets.entries()) {
7839
- if (index2 != 0) {
7839
+ if (index2 !== 0) {
7840
7840
  value.style.display = "none";
7841
7841
  value.setAttribute("data-filter-target", "value_original");
7842
7842
  }
@@ -7844,7 +7844,7 @@ var filter_row_controller_default = class extends Controller {
7844
7844
  }
7845
7845
  showSecondary() {
7846
7846
  for (const [index2, value] of this.originalTargets.entries()) {
7847
- if (index2 != 0) {
7847
+ if (index2 !== 0) {
7848
7848
  value.style.display = "block";
7849
7849
  value.setAttribute("data-filter-target", "value");
7850
7850
  }
@@ -10359,7 +10359,7 @@ var media_modal_controller_default = class extends Controller {
10359
10359
  }
10360
10360
  handleIdsUpdate(element) {
10361
10361
  if (element.checked) {
10362
- let arr = this.idsValue;
10362
+ const arr = this.idsValue;
10363
10363
  arr.push(element.value);
10364
10364
  this.idsValue = arr;
10365
10365
  } else {
@@ -10403,8 +10403,8 @@ var media_modal_controller_default = class extends Controller {
10403
10403
  }
10404
10404
  renderItemForEvent(item) {
10405
10405
  const id = parseInt(item);
10406
- const blob_id = `#blob_${id}`;
10407
- const element = this.element.querySelector(blob_id);
10406
+ const blobId = `#blob_${id}`;
10407
+ const element = this.element.querySelector(blobId);
10408
10408
  return {
10409
10409
  blobId: id,
10410
10410
  thumbnail: element ? element.querySelector(".h-thumbnail") : ""
@@ -1,7 +1,7 @@
1
1
  @charset "UTF-8";
2
2
  @import "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css";
3
3
 
4
- /* sass-plugin-0:/usr/local/var/www/headmin/src/scss/headmin.scss */
4
+ /* sass-plugin-0:/opt/homebrew/var/www/headmin/src/scss/headmin.scss */
5
5
  :root {
6
6
  --bs-blue: #0d6efd;
7
7
  --bs-indigo: #6610f2;
@@ -1,5 +1,7 @@
1
1
  <%= turbo_stream.prepend "thumbnails" do %>
2
2
  <% @blobs.each do |blob| %>
3
- <%= render "headmin/media/thumbnail", blob: blob %>
3
+ <%= turbo_frame_tag blob, src: headmin_media_item_thumbnail_path(blob), loading: "lazy" do %>
4
+ <%= render "thumbnail" %>
5
+ <% end %>
4
6
  <% end %>
5
7
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module Headmin
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "headmin",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Admin component library",
5
5
  "module": "app/assets/javascripts/headmin.js",
6
6
  "main": "app/assets/javascripts/headmin.js",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: headmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jef Vlamings
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-13 00:00:00.000000000 Z
11
+ date: 2024-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: closure_tree
@@ -573,7 +573,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
573
573
  - !ruby/object:Gem::Version
574
574
  version: '0'
575
575
  requirements: []
576
- rubygems_version: 3.3.3
576
+ rubygems_version: 3.5.6
577
577
  signing_key:
578
578
  specification_version: 4
579
579
  summary: Admin component library