Halfway through table redesign, saving to revert to working version

This commit is contained in:
Jason Jordan
2026-03-05 11:30:24 -05:00
parent ea07afb751
commit b5a1517330
86 changed files with 1286 additions and 884 deletions
@@ -1,13 +1,18 @@
import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
static values = {
logoType: String,
employerName: String
}
static targets = ["preview", "previewContainer", "logoSelect", "logofield", "initialLogoFile"];
async connect() {
console.log('in connect');
console.log(this.logofieldTarget.value)
if (this.logofieldTarget.value.includes("Logo.")) {
const response = await fetch(`/card_logo_files/${this.logofieldTarget.value}/image`); // Fetch the binary data
const initValue = this.logofieldTarget.value
console.log(initValue)
if (initValue) {
const response = await fetch(`/id_card/${this.logoTypeValue}_logos/${initValue}/image`); // Fetch the binary data
const blob = await response.blob();
const objectUrl = URL.createObjectURL(blob);
this.previewTarget.src = objectUrl;
@@ -23,7 +28,7 @@ export default class extends Controller {
const file = event.target.files[0];
if (!file) return;
const logoType = event.params.type
const logoType = this.logoTypeValue
let newFileName = file.name
if (logoType == "network") {
@@ -32,14 +37,15 @@ export default class extends Controller {
this.addOptionToSelect(newFileName)
} else if (logoType == "employer") {
newFileName = this.determineEmployerFilename(file)
this.logofieldTarget.value = newFileName;
file.name = newFileName
}
this.previewFile(file);
// this.uploadLogoToServer(file);
this.uploadLogoToServer(file);
this.logofieldTarget.value = newFileName;
}
previewFile(file) {
@@ -55,13 +61,12 @@ export default class extends Controller {
async uploadLogoToServer(file) {
console.log('in uploadLogoToServer');
const formData = new FormData();
formData.append("card_logo_file[logo_file]", file);
formData.append("card_logo_file[logo_type]", "employer");
formData.append(`id_card_${this.logoTypeValue}_logo[logo_file]`, file);
const csrfToken = document.querySelector("meta[name='csrf-token']").content;
try {
const response = await fetch("/card_logo_files/", {
const response = await fetch(`/id_card/${this.logoTypeValue}_logos/`, {
method: "POST",
headers: {
"X-CSRF-Token": csrfToken
@@ -103,7 +108,7 @@ export default class extends Controller {
determineEmployerFilename(file) {
const fileExtension = file.name.split('.').pop();
const employerName = prompt("Enter the name for the new Employer (minus any 'The's, 'LLC', or 'Health Plan'):");
const employerName = this.employerNameValue
const logoFilename = this.titleizeText(employerName).concat("Logo.").concat(fileExtension).replaceAll(' ', '');
return logoFilename