import React from "react" ; import { gAppRef } from "./App.js" ; import { ImageFileUploader } from "./FileUploader.js" ; import { checkConstraints, confirmDiscardChanges, ciCompare } from "./utils.js" ; // -------------------------------------------------------------------- export class PublisherSearchResult2 { static _doEditPublisher( vals, notify ) { // initialize let refs = {} ; // prepare to save the initial values let initialVals = null ; function onReady() { if ( ! initialVals ) initialVals = unloadVals() ; } // initialize the image let imageFilename=null, imageData=null ; let imageRef=null, uploadImageRef=null, removeImageRef=null ; let imageUrl = gAppRef.makeFlaskImageUrl( "publisher", vals.publ_id ) || "/force-404" ; function onImageLoaded() { onReady() ; } function onMissingImage() { imageRef.src = "/images/placeholder.png" ; removeImageRef.style.display = "none" ; onReady() ; } ; function onUploadImage( evt ) { if ( evt === null && !gAppRef.isFakeUploads() ) { // nb: the publisher image was clicked - trigger an upload request uploadImageRef.click() ; return ; } let fileUploader = new ImageFileUploader() ; fileUploader.getFile( evt, imageRef, removeImageRef, (fname,data) => { imageFilename = fname ; imageData = data ; } ) ; } ; function onRemoveImage() { imageData = "{remove}" ; imageRef.src = "/images/placeholder.png" ; removeImageRef.style.display = "none" ; } // prepare the form content /* eslint-disable jsx-a11y/img-redundant-alt */ const content =
onUploadImage(null) } ref = { r => imageRef=r } alt="Upload image." title="Click to upload an image for this publisher." /> removeImageRef=r } alt="Remove image." title="Remove the publisher's image." /> uploadImageRef=r } />
refs.publ_name=r} />