From d2402701440e4ef3b3a4c1a954c6e7c381659f14 Mon Sep 17 00:00:00 2001 From: nic Date: Fri, 18 Apr 2025 15:45:28 -0400 Subject: [PATCH] fix: updated styles/workflow/small ui tweaks --- internal/handlers/web/document_remove.go | 16 +++----- internal/handlers/web/documents.go | 28 +++---------- static/css/styles.css | 41 ++++++++++++++++++++ templates/partials/document_remove.html | 11 +----- templates/partials/document_remove_form.html | 23 ----------- templates/partials/document_upload_form.html | 38 ------------------ 6 files changed, 52 insertions(+), 105 deletions(-) delete mode 100644 templates/partials/document_remove_form.html delete mode 100644 templates/partials/document_upload_form.html diff --git a/internal/handlers/web/document_remove.go b/internal/handlers/web/document_remove.go index 8405024..3a0a0b2 100644 --- a/internal/handlers/web/document_remove.go +++ b/internal/handlers/web/document_remove.go @@ -137,25 +137,19 @@ func ProcessRemoveCSVHandler(w http.ResponseWriter, r *http.Request) { // Create a hidden input with the job IDs jobsValue := strings.Join(jobIDs, ",") - jobSampleDisplay := getJobSampleDisplay(jobIDs) // Generate HTML for the main response (hidden input for job-ids-removal-container) var responseHTML bytes.Buffer responseHTML.WriteString(fmt.Sprintf(``, jobsValue)) responseHTML.WriteString(fmt.Sprintf(`

Found %d job(s) in the CSV file

`, totalJobs)) - responseHTML.WriteString(fmt.Sprintf(`

Sample job IDs: %s

`, jobSampleDisplay)) - // Generate out-of-band swap for the preview section + // Generate out-of-band swap for the preview section - simplified version responseHTML.WriteString(fmt.Sprintf(` -
-

Detected Jobs

-
-
-

Sample job IDs: %s

-
-
+
+

✓ Jobs Detected

+

Remove from %d job(s)

- `, jobSampleDisplay)) + `, totalJobs)) // Send the response with the hidden input and preview w.Header().Set("Content-Type", "text/html") diff --git a/internal/handlers/web/documents.go b/internal/handlers/web/documents.go index 12604ce..4a612ef 100644 --- a/internal/handlers/web/documents.go +++ b/internal/handlers/web/documents.go @@ -147,42 +147,24 @@ func ProcessCSVHandler(w http.ResponseWriter, r *http.Request) { // Create a hidden input with the job IDs jobsValue := strings.Join(jobNumbers, ",") - jobSampleDisplay := getJobSampleDisplay(jobNumbers) // Generate HTML for the main response (hidden input for job-ids-container) var responseHTML bytes.Buffer responseHTML.WriteString(fmt.Sprintf(``, jobsValue)) responseHTML.WriteString(fmt.Sprintf(`

Found %d job(s) in the CSV file

`, totalJobs)) - responseHTML.WriteString(fmt.Sprintf(`

Sample job IDs: %s

`, jobSampleDisplay)) - // Generate out-of-band swap for the preview section + // Generate out-of-band swap for the preview section - simplified version responseHTML.WriteString(fmt.Sprintf(` -
-

Detected Jobs

-
-

Found %d job(s) in the CSV file

-
-

Sample job IDs: %s

-
-
+
+

✓ Jobs Detected

+

Upload to %d job(s)

- `, totalJobs, jobSampleDisplay)) + `, totalJobs)) w.Header().Set("Content-Type", "text/html") w.Write(responseHTML.Bytes()) } -// Helper function to show sample job IDs with a limit -func getJobSampleDisplay(jobIDs []string) string { - const maxSamples = 5 - if len(jobIDs) <= maxSamples { - return strings.Join(jobIDs, ", ") - } - - sample := append([]string{}, jobIDs[:maxSamples]...) - return strings.Join(sample, ", ") + fmt.Sprintf(" and %d more...", len(jobIDs)-maxSamples) -} - // UploadDocumentsHandler handles document uploads to jobs func UploadDocumentsHandler(w http.ResponseWriter, r *http.Request) { session, ok := r.Context().Value(middleware.SessionKey).(*api.Session) diff --git a/static/css/styles.css b/static/css/styles.css index b49d3f3..80d9f53 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -862,4 +862,45 @@ html { font-size: 18px; margin: 0; } +} + +#csv-preview, +#csv-preview-removal { + background-color: var(--dashboard-bg); + border-radius: 4px; + margin-top: 15px; + box-shadow: var(--dashboard-shadow); + text-align: center; + padding: 12px 15px 10px 15px; + display: inline-block; + width: 85%; + margin-left: auto; + margin-right: auto; +} + +#csv-preview h4, +#csv-preview-removal h4 { + margin-top: 0; + margin-bottom: 8px; + font-size: 15px; + color: var(--dashboard-header-color); + font-weight: 600; +} + +.job-list { + background-color: transparent; + padding: 0; + font-size: 14px; +} + +#csv-preview-content p, +#csv-preview-content-removal p { + margin: 0; + font-weight: 500; + color: var(--btn-primary-bg); +} + +/* Class for the CSV preview to display properly when initialized */ +.csv-preview-active { + display: block; } \ No newline at end of file diff --git a/templates/partials/document_remove.html b/templates/partials/document_remove.html index 44773e6..c8c13e2 100644 --- a/templates/partials/document_remove.html +++ b/templates/partials/document_remove.html @@ -21,16 +21,7 @@