mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
Merge remote-tracking branch 'upstream/main' into sso-upgrades
# Conflicts: # app/views/simplefin_items/_simplefin_item.html.erb # db/schema.rb
This commit is contained in:
@@ -42,4 +42,27 @@ export default class extends Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clearWarning(event) {
|
||||
// When user selects a subtype value, clear all warning styling
|
||||
const select = event.target
|
||||
if (select.value) {
|
||||
// Clear the subtype dropdown warning
|
||||
const warningContainer = select.closest('.ring-2')
|
||||
if (warningContainer) {
|
||||
warningContainer.classList.remove('ring-2', 'ring-warning/50', 'rounded-md', 'p-2', '-m-2')
|
||||
const warningText = warningContainer.querySelector('.text-warning')
|
||||
if (warningText) {
|
||||
warningText.remove()
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the parent card's warning border
|
||||
const card = this.element.closest('.border-2.border-warning')
|
||||
if (card) {
|
||||
card.classList.remove('border-2', 'border-warning', 'bg-warning/5')
|
||||
card.classList.add('border', 'border-primary')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["input", "form", "overlay"]
|
||||
|
||||
dragDepth = 0
|
||||
|
||||
connect() {
|
||||
this.boundDragOver = this.dragOver.bind(this)
|
||||
this.boundDragEnter = this.dragEnter.bind(this)
|
||||
this.boundDragLeave = this.dragLeave.bind(this)
|
||||
this.boundDrop = this.drop.bind(this)
|
||||
|
||||
// Listen on the document to catch drags anywhere
|
||||
document.addEventListener("dragover", this.boundDragOver)
|
||||
document.addEventListener("dragenter", this.boundDragEnter)
|
||||
document.addEventListener("dragleave", this.boundDragLeave)
|
||||
document.addEventListener("drop", this.boundDrop)
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
document.removeEventListener("dragover", this.boundDragOver)
|
||||
document.removeEventListener("dragenter", this.boundDragEnter)
|
||||
document.removeEventListener("dragleave", this.boundDragLeave)
|
||||
document.removeEventListener("drop", this.boundDrop)
|
||||
}
|
||||
|
||||
dragEnter(event) {
|
||||
event.preventDefault()
|
||||
this.dragDepth++
|
||||
if (this.dragDepth === 1) {
|
||||
this.overlayTarget.classList.remove("hidden")
|
||||
}
|
||||
}
|
||||
|
||||
dragOver(event) {
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
dragLeave(event) {
|
||||
event.preventDefault()
|
||||
this.dragDepth--
|
||||
if (this.dragDepth <= 0) {
|
||||
this.dragDepth = 0
|
||||
this.overlayTarget.classList.add("hidden")
|
||||
}
|
||||
}
|
||||
|
||||
drop(event) {
|
||||
event.preventDefault()
|
||||
this.dragDepth = 0
|
||||
this.overlayTarget.classList.add("hidden")
|
||||
|
||||
if (event.dataTransfer.files.length > 0) {
|
||||
const file = event.dataTransfer.files[0]
|
||||
// Simple validation
|
||||
if (file.type === "text/csv" || file.name.toLowerCase().endsWith(".csv")) {
|
||||
this.inputTarget.files = event.dataTransfer.files
|
||||
this.formTarget.requestSubmit()
|
||||
} else {
|
||||
alert("Please upload a valid CSV file.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["moveRadio", "targetSelect"]
|
||||
static values = { accountId: String }
|
||||
|
||||
connect() {
|
||||
this.updateTargetVisibility()
|
||||
}
|
||||
|
||||
updateTargetVisibility() {
|
||||
if (!this.hasTargetSelectTarget || !this.hasMoveRadioTarget) return
|
||||
|
||||
const moveRadio = this.moveRadioTarget
|
||||
const targetSelect = this.targetSelectTarget
|
||||
|
||||
if (moveRadio?.checked) {
|
||||
targetSelect.disabled = false
|
||||
targetSelect.classList.remove("opacity-50", "cursor-not-allowed")
|
||||
} else {
|
||||
targetSelect.disabled = true
|
||||
targetSelect.classList.add("opacity-50", "cursor-not-allowed")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user