: asapien/signet

commit 9a358a10eda2e331f926fb88805cd1e030d9c957
parent 4cb18866b07590b9868d5b2552a7949ef6c6bbac
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sat, 19 Sep 2026 05:11:37 +0530

Improve error messages and fix scrollbar positioning

Better error messages for submit validation:
- 'Define at least one party to sign this document'
- 'Party X does not have a signer assigned'
- 'Select an organisation to populate organisation-bound fields'
- 'Organisation X does not have attribute Y — check PIM settings'
- 'Signature zone references unknown party X'
- 'Party X has multiple signature zones — each party can only sign once'
- 'Serial number field is used, but no series selected'
- 'Image file not found in the DAM — ensure the file exists'

These messages now guide the user toward fixing the problem instead of
just reporting the error.

Layout fixes:
- Prevent horizontal scrollbar overflow by constraining main content width
- Ensure scrollbar appears only for main content, not the entire viewport
- Fix overflow hidden on body to prevent page-level scrolling
- Right panel remains sticky without affecting page width

Fixes the issue where scrollbar appeared to the right of the side panel.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2 files changed, 16 insertions(+), 14 deletions(-)
M
src/signet-api.c
|
21
+++++++++++----------
M
www/style.css
|
9
+++++----
diff --git a/src/signet-api.c b/src/signet-api.c
@@ -210,13 +210,14 @@ check_submittable(yyjson_val *layout, yyjson_val *route, const char *org_code,
 	}
 	yyjson_val *parties = yyjson_obj_get(route, "parties");
 	if (yyjson_arr_size(parties) < 1) {
-		snprintf(err, errsz, "add at least one party");
+		snprintf(err, errsz, "Define at least one party to sign this document");
 		return -1;
 	}
 	yyjson_arr_foreach(parties, i, max, imp) {
+		const char *party_name = yyjson_get_str(yyjson_obj_get(imp, "name"));
 		const char *party_signer = yyjson_get_str(yyjson_obj_get(imp, "signer"));
 		if (party_signer == NULL || !*party_signer) {
-			snprintf(err, errsz, "all parties must have a signer assigned");
+			snprintf(err, errsz, "Party '%s' does not have a signer assigned", party_name ? party_name : "(unnamed)");
 			return -1;
 		}
 	}

@@ -231,26 +232,26 @@ check_submittable(yyjson_val *layout, yyjson_val *route, const char *org_code,
 			ref = "";
 		if (strcmp(type, "pim_text") == 0) {
 			if (org_code == NULL || !*org_code) {
-				snprintf(err, errsz, "PIM imprints require an organisation");
+				snprintf(err, errsz, "Select an organisation to populate organisation-bound fields");
 				return -1;
 			}
 			rc = redis_get(&cf);
 			r = redisCommand(rc, "HGET %s:metadata %s", org_code, ref);
 			if (r == NULL || r->type != REDIS_REPLY_STRING) {
-				snprintf(err, errsz, "PIM text not found: %s in %s", ref, org_code);
+				snprintf(err, errsz, "Organisation '%s' does not have a '%s' attribute — check PIM settings", org_code, ref);
 				if (r != NULL) freeReplyObject(r);
 				return -1;
 			}
 			freeReplyObject(r);
 		} else if (strcmp(type, "pim_image") == 0) {
 			if (org_code == NULL || !*org_code) {
-				snprintf(err, errsz, "PIM imprints require an organisation");
+				snprintf(err, errsz, "Select an organisation to populate organisation-bound image fields");
 				return -1;
 			}
 			rc = redis_get(&cf);
 			r = redisCommand(rc, "HGET %s:images %s", org_code, ref);
 			if (r == NULL || r->type != REDIS_REPLY_STRING) {
-				snprintf(err, errsz, "PIM image not found: %s in %s", ref, org_code);
+				snprintf(err, errsz, "Organisation '%s' does not have an image attribute '%s' — check PIM settings", org_code, ref);
 				if (r != NULL) freeReplyObject(r);
 				return -1;
 			}

@@ -260,7 +261,7 @@ check_submittable(yyjson_val *layout, yyjson_val *route, const char *org_code,
 			int exists = file_exists(path);
 			freeReplyObject(r);
 			if (!is_safe_relpath(dam_path) || !exists) {
-				snprintf(err, errsz, "PIM image DAM file not found: %s", dam_path);
+				snprintf(err, errsz, "Image file '%s' not found in the DAM — ensure the file exists and the path is correct", dam_path);
 				return -1;
 			}
 		} else if (strcmp(type, "signature_zone") == 0) {

@@ -273,18 +274,18 @@ check_submittable(yyjson_val *layout, yyjson_val *route, const char *org_code,
 				if (pname != NULL && strcmp(pname, party_name) == 0) {
 					found_party = 1;
 					if (seen_zones[party_idx]++) {
-						snprintf(err, errsz, "duplicate signature_zone for party %s", party_name);
+						snprintf(err, errsz, "Party '%s' has multiple signature zones — each party can only sign once", party_name);
 						return -1;
 					}
 					break;
 				}
 			}
 			if (!found_party) {
-				snprintf(err, errsz, "signature_zone references unknown party: %s", party_name);
+				snprintf(err, errsz, "Signature zone references party '%s', which is not defined in the route", party_name ? party_name : "(unknown)");
 				return -1;
 			}
 		} else if (strcmp(type, "serial") == 0 && !has_series) {
-			snprintf(err, errsz, "serial imprint used but no series selected");
+			snprintf(err, errsz, "Serial number field is used, but no series is selected — choose a series or remove the serial field");
 			return -1;
 		}
 	}
diff --git a/www/style.css b/www/style.css
@@ -4,7 +4,8 @@
   --sig: 214, 48, 49; --img: 9, 102, 204; --txt: 34, 139, 84;
 }
 * { box-sizing: border-box; }
-body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); display: flex; flex-direction: column; height: 100vh; }
+html { height: 100%; }
+body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
 a { color: var(--accent); }
 .bar { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.2rem; background: var(--ink); color: #fff; z-index: 100; }
 .bar a { color: #cfd8e3; text-decoration: none; }

@@ -12,7 +13,7 @@ a { color: var(--accent); }
 .bar .brand { font-weight: 700; letter-spacing: .06em; color: #fff; text-transform: uppercase; }
 .bar nav { display: flex; gap: 1rem; flex: 1; }
 #whoami { font-size: 12px; color: #cfd8e3; }
-main { margin-top: 2.8rem; padding: 1.2rem; max-width: 1500px; margin-left: auto; margin-right: auto; flex: 1; overflow-y: auto; }
+main { margin-top: 2.8rem; padding: 1.2rem; width: 100%; max-width: none; flex: 1; overflow-y: auto; overflow-x: hidden; }
 h1 { font-size: 1.25rem; margin: 0 0 1rem; }
 h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 1.2rem 0 .5rem; }
 .card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1rem; }

@@ -43,9 +44,9 @@ tr.click:hover td { background: #f6f9fc; }
 .status.DISAPPROVED { background: #f8d9d8; color: var(--danger); }
 
 /* document workspace */
-.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
+.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; width: 100%; max-width: 1500px; margin: 0 auto; }
 @media (max-width: 900px) { .workspace { grid-template-columns: 1fr; } }
-.side { position: sticky; top: 1.2rem; max-height: calc(100vh - 4rem); overflow-y: auto; }
+.side { position: sticky; top: 1.2rem; max-height: calc(100vh - 4.4rem); overflow-y: auto; flex-shrink: 0; }
 .pages { display: flex; flex-direction: column; gap: 1rem; align-items: center; }
 .page { position: relative; width: 100%; max-width: 1000px; background: #fff; box-shadow: 0 1px 4px rgba(20, 30, 45, .25); line-height: 0; }
 .page > img { width: 100%; height: auto; display: block; user-select: none; -webkit-user-drag: none; }