Skip to content

Commit 4f79ff7

Browse files
committed
chore(Admin): Run prettier on js files
Adjust the syntax of all admin js files to prettier config.
1 parent a70fcf9 commit 4f79ff7

File tree

15 files changed

+78
-78
lines changed

15 files changed

+78
-78
lines changed

admin/app/components/solidus_admin/layout/navigation/component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
44
static values = {
5-
cookie: String
5+
cookie: String,
66
}
77

88
setCookie(event) {
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Controller } from '@hotwired/stimulus'
1+
import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
44
static targets = ["addresses"]
55

66
close() {
7-
this.addressesTarget.removeAttribute('open')
7+
this.addressesTarget.removeAttribute("open")
88
}
99
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Controller } from '@hotwired/stimulus'
1+
import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
44
closeMenus() {
5-
this.element.querySelectorAll('details').forEach(details => details.removeAttribute('open'))
5+
this.element.querySelectorAll("details").forEach((details) => details.removeAttribute("open"))
66
}
77
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import { Controller } from '@hotwired/stimulus'
1+
import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
44
static values = { customersUrl: String }
55

66
async search({ detail: { query, controller } }) {
7-
controller.resultsValue =
8-
(await (await fetch(`${this.customersUrlValue}?q[name_or_variants_including_master_sku_cont]=${query}`)).text())
7+
controller.resultsValue = await (
8+
await fetch(`${this.customersUrlValue}?q[name_or_variants_including_master_sku_cont]=${query}`)
9+
).text()
910
}
1011

1112
submit(event) {
12-
event.detail.resultTarget.querySelector('form').submit()
13+
event.detail.resultTarget.querySelector("form").submit()
1314
}
1415
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import { Controller } from '@hotwired/stimulus'
1+
import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
44
static values = {
55
initialCountOnHand: Number,
66
}
77

8-
static targets = ['countOnHand', 'quantityAdjustment']
8+
static targets = ["countOnHand", "quantityAdjustment"]
99

1010
connect() {
1111
this.updateCountOnHand()
1212
}
1313

1414
updateCountOnHand() {
15-
this.countOnHandTarget.value = parseInt(this.initialCountOnHandValue) + parseInt(this.quantityAdjustmentTarget.value)
15+
this.countOnHandTarget.value =
16+
parseInt(this.initialCountOnHandValue) + parseInt(this.quantityAdjustmentTarget.value)
1617
}
1718
}

admin/app/components/solidus_admin/ui/dropdown/component.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Controller } from '@hotwired/stimulus'
2-
import { useClickOutside } from 'stimulus-use'
1+
import { Controller } from "@hotwired/stimulus"
2+
import { useClickOutside } from "stimulus-use"
33

44
export default class extends Controller {
55
connect() {
@@ -11,6 +11,6 @@ export default class extends Controller {
1111
}
1212

1313
close() {
14-
this.element.removeAttribute('open')
14+
this.element.removeAttribute("open")
1515
}
1616
}

admin/app/components/solidus_admin/ui/forms/address/component.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Controller } from '@hotwired/stimulus'
1+
import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
44
static targets = ["country", "state", "stateName", "stateWrapper", "stateNameWrapper"]
@@ -7,8 +7,8 @@ export default class extends Controller {
77
const countryId = this.countryTarget.value
88

99
fetch(`/admin/countries/${countryId}/states`)
10-
.then(response => response.json())
11-
.then(data => {
10+
.then((response) => response.json())
11+
.then((data) => {
1212
this.updateStateOptions(data)
1313
})
1414
}
@@ -30,13 +30,12 @@ export default class extends Controller {
3030
const stateSelect = this.stateTarget
3131
const stateName = this.stateNameTarget
3232

33-
3433
if (showSelect) {
3534
// Show state select dropdown.
3635
stateSelect.disabled = false
3736
stateName.value = ""
38-
stateWrapper.classList.remove('hidden')
39-
stateNameWrapper.classList.add('hidden')
37+
stateWrapper.classList.remove("hidden")
38+
stateNameWrapper.classList.add("hidden")
4039
} else {
4140
// Show state name text input if no states to choose from.
4241
stateSelect.disabled = true
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import { Controller } from '@hotwired/stimulus'
1+
import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
44
static values = {
55
customValidity: String,
66
}
77

88
connect() {
9-
if (this.customValidityValue)
10-
this.element.setCustomValidity(this.customValidityValue)
9+
if (this.customValidityValue) this.element.setCustomValidity(this.customValidityValue)
1110
}
1211

1312
clearCustomValidity() {
14-
this.element.setCustomValidity('')
13+
this.element.setCustomValidity("")
1514
}
1615
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Controller } from "@hotwired/stimulus";
1+
import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
44
connect() {
5-
this.element.showModal();
5+
this.element.showModal()
66
}
77
}

admin/app/components/solidus_admin/ui/table/component.js

+12-16
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export default class extends Controller {
3636
const shouldSetSortable = this.sortableValue && this.modeValue !== "batch" && this.modeValue !== "search"
3737

3838
if (shouldSetSortable) {
39-
this.tableBodyTarget.setAttribute('data-controller', 'sortable')
39+
this.tableBodyTarget.setAttribute("data-controller", "sortable")
4040
} else {
41-
this.tableBodyTarget.removeAttribute('data-controller')
41+
this.tableBodyTarget.removeAttribute("data-controller")
4242
}
4343
}
4444

@@ -54,13 +54,13 @@ export default class extends Controller {
5454
}
5555

5656
clearSearch() {
57-
this.searchFieldTarget.value = ''
57+
this.searchFieldTarget.value = ""
5858
this.search()
5959
}
6060

6161
resetSearchAndFilters() {
6262
if (this.hasFilterToolbarTarget) {
63-
this.filterToolbarTarget.querySelectorAll('fieldset').forEach(fieldset => fieldset.disabled = true)
63+
this.filterToolbarTarget.querySelectorAll("fieldset").forEach((fieldset) => (fieldset.disabled = true))
6464
}
6565

6666
this.searchFieldTarget.disabled = true
@@ -70,7 +70,7 @@ export default class extends Controller {
7070
selectRow(event) {
7171
if (this.checkboxTargets.some((checkbox) => checkbox.checked)) {
7272
this.modeValue = "batch"
73-
} else if (this.hasSearchFieldTarget && (this.searchFieldTarget.value !== '')) {
73+
} else if (this.hasSearchFieldTarget && this.searchFieldTarget.value !== "") {
7474
this.modeValue = "search"
7575
} else if (this.hasScopesToolbarTarget) {
7676
this.modeValue = "scopes"
@@ -84,7 +84,7 @@ export default class extends Controller {
8484
selectAllRows(event) {
8585
if (event.target.checked) {
8686
this.modeValue = "batch"
87-
} else if (this.hasSearchFieldTarget && (this.searchFieldTarget.value !== '')) {
87+
} else if (this.hasSearchFieldTarget && this.searchFieldTarget.value !== "") {
8888
this.modeValue = "search"
8989
} else if (this.hasScopesToolbarTarget) {
9090
this.modeValue = "scopes"
@@ -106,18 +106,18 @@ export default class extends Controller {
106106
} else {
107107
const url = new URL(event.params.url, "http://dummy.com")
108108
const params = new URLSearchParams(url.search)
109-
const frameId = params.get('_turbo_frame')
109+
const frameId = params.get("_turbo_frame")
110110
const frame = frameId ? { frame: frameId } : {}
111111
// remove the custom _turbo_frame param from url search:
112-
params.delete('_turbo_frame')
112+
params.delete("_turbo_frame")
113113
url.search = params.toString()
114114

115115
window.Turbo.visit(url.pathname + url.search, frame)
116116
}
117117
}
118118

119119
toggleCheckbox(row) {
120-
const checkbox = this.checkboxTargets.find(selection => row.contains(selection))
120+
const checkbox = this.checkboxTargets.find((selection) => row.contains(selection))
121121

122122
if (checkbox) {
123123
checkbox.checked = !checkbox.checked
@@ -131,14 +131,10 @@ export default class extends Controller {
131131

132132
confirmAction(event) {
133133
const message = event.params.message
134+
.replace("${count}", this.selectedRows().length)
134135
.replace(
135-
"${count}",
136-
this.selectedRows().length
137-
).replace(
138136
"${resource}",
139-
this.selectedRows().length > 1 ?
140-
event.params.resourcePlural :
141-
event.params.resourceSingular
137+
this.selectedRows().length > 1 ? event.params.resourcePlural : event.params.resourceSingular
142138
)
143139

144140
if (!confirm(message)) {
@@ -167,7 +163,7 @@ export default class extends Controller {
167163

168164
// Update the rows background color
169165
this.checkboxTargets.filter((checkbox) =>
170-
checkbox.closest("tr").classList.toggle(this.selectedRowClass, checkbox.checked),
166+
checkbox.closest("tr").classList.toggle(this.selectedRowClass, checkbox.checked)
171167
)
172168

173169
// Update the selected rows count

admin/app/components/solidus_admin/ui/table/ransack_filter/component.js

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Controller } from '@hotwired/stimulus'
2-
import { useClickOutside, useDebounce } from 'stimulus-use'
1+
import { Controller } from "@hotwired/stimulus"
2+
import { useClickOutside, useDebounce } from "stimulus-use"
33

4-
const BG_GRAY = 'bg-gray-100'
4+
const BG_GRAY = "bg-gray-100"
55

66
export default class extends Controller {
7-
static targets = ['details', 'summary', 'option', 'checkbox', 'menu']
8-
static debounces = ['init']
7+
static targets = ["details", "summary", "option", "checkbox", "menu"]
8+
static debounces = ["init"]
99

1010
connect() {
1111
useDebounce(this, { wait: 50 })
@@ -37,7 +37,7 @@ export default class extends Controller {
3737
filterOptions(event) {
3838
const query = event.currentTarget.value.toLowerCase()
3939
this.optionTargets.forEach((option) => {
40-
option.style.display = option.textContent.toLowerCase().includes(query) ? 'block' : 'none'
40+
option.style.display = option.textContent.toLowerCase().includes(query) ? "block" : "none"
4141
})
4242
}
4343

@@ -50,24 +50,26 @@ export default class extends Controller {
5050
this.checkboxTargets.forEach((checkbox) => {
5151
const hiddenElements = checkbox.parentElement.querySelectorAll("input[type='hidden']")
5252
checkbox.checked
53-
? hiddenElements.forEach(e => e.removeAttribute("disabled"))
54-
: hiddenElements.forEach(e => e.setAttribute("disabled", true))
53+
? hiddenElements.forEach((e) => e.removeAttribute("disabled"))
54+
: hiddenElements.forEach((e) => e.setAttribute("disabled", true))
5555
})
5656
}
5757

5858
sortCheckboxes() {
5959
const checkboxes = this.checkboxTargets
6060

61-
checkboxes.sort((a, b) => {
62-
if (a.checked && !b.checked) return -1
63-
if (!a.checked && b.checked) return 1
64-
return 0
65-
}).forEach(checkbox => {
66-
this.menuTarget.appendChild(checkbox.closest('div'))
67-
})
61+
checkboxes
62+
.sort((a, b) => {
63+
if (a.checked && !b.checked) return -1
64+
if (!a.checked && b.checked) return 1
65+
return 0
66+
})
67+
.forEach((checkbox) => {
68+
this.menuTarget.appendChild(checkbox.closest("div"))
69+
})
6870
}
6971

7072
isAnyCheckboxChecked() {
71-
return this.checkboxTargets.some(checkbox => checkbox.checked)
73+
return this.checkboxTargets.some((checkbox) => checkbox.checked)
7274
}
7375
}

admin/app/components/solidus_admin/ui/toast/component.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Controller } from '@hotwired/stimulus'
1+
import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
4-
static targets = ['closeButton']
5-
static classes = ['animation']
4+
static targets = ["closeButton"]
5+
static classes = ["animation"]
66
static values = { transition: Number }
77

88
connect() {
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
import { Controller } from '@hotwired/stimulus'
2-
import { useClickOutside } from 'stimulus-use'
1+
import { Controller } from "@hotwired/stimulus"
2+
import { useClickOutside } from "stimulus-use"
33

44
export default class extends Controller {
5-
static targets = ['bubble']
5+
static targets = ["bubble"]
66

7-
connect () {
7+
connect() {
88
useClickOutside(this)
99
this.open = false
1010
}
1111

12-
clickOutside () {
12+
clickOutside() {
1313
this.close()
1414
}
1515

16-
toggle (e) {
16+
toggle(e) {
1717
e.preventDefault()
1818
this.open = !this.open
1919
this.render()
2020
}
2121

22-
open () {
22+
open() {
2323
this.open = true
2424
this.render()
2525
}
2626

27-
close () {
27+
close() {
2828
this.open = false
2929
this.render()
3030
}
@@ -35,10 +35,12 @@ export default class extends Controller {
3535

3636
if (needsPositioning) {
3737
const bubbleRect = this.bubbleTarget.getBoundingClientRect()
38-
if (bubbleRect.right > window.innerWidth) this.bubbleTarget.style.left = `${window.innerWidth - bubbleRect.width}px`
39-
if (bubbleRect.bottom > window.innerHeight) this.bubbleTarget.style.top = `${window.innerHeight - bubbleRect.height}px`
40-
if (bubbleRect.left < 0) this.bubbleTarget.style.left = '0px'
41-
if (bubbleRect.top < 0) this.bubbleTarget.style.top = '0px'
38+
if (bubbleRect.right > window.innerWidth)
39+
this.bubbleTarget.style.left = `${window.innerWidth - bubbleRect.width}px`
40+
if (bubbleRect.bottom > window.innerHeight)
41+
this.bubbleTarget.style.top = `${window.innerHeight - bubbleRect.height}px`
42+
if (bubbleRect.left < 0) this.bubbleTarget.style.left = "0px"
43+
if (bubbleRect.top < 0) this.bubbleTarget.style.top = "0px"
4244
}
4345
}
4446
}

admin/app/components/solidus_admin/users/store_credits/index/component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ export default class extends Controller {
44
actionButtonClicked(event) {
55
const url = new URL(event.params.url, "http://dummy.com")
66
const params = new URLSearchParams(url.search)
7-
const frameId = params.get('_turbo_frame')
7+
const frameId = params.get("_turbo_frame")
88
const frame = frameId ? { frame: frameId } : {}
99
// remove the custom _turbo_frame param from url search:
10-
params.delete('_turbo_frame')
10+
params.delete("_turbo_frame")
1111
url.search = params.toString()
1212

1313
window.Turbo.visit(url.pathname + url.search, frame)

0 commit comments

Comments
 (0)