From 6d875abbeb4e9f7671bc49e13cf7c752220d9610 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Thu, 7 Nov 2024 07:34:17 -0500 Subject: [PATCH] improve mocha TMS, should refactor dialog.js into phast --- mocha-php/src/mocha-tms/api.php | 9 ++++-- mocha-php/src/mocha-tms/app.js | 9 +++++- mocha-php/src/mocha-tms/dialog.js | 49 +++++++++++++++++++++---------- mocha-php/src/mocha-tms/index.php | 2 +- 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/mocha-php/src/mocha-tms/api.php b/mocha-php/src/mocha-tms/api.php index 1fc7b1e..6202aa9 100644 --- a/mocha-php/src/mocha-tms/api.php +++ b/mocha-php/src/mocha-tms/api.php @@ -23,15 +23,17 @@ $tenantName = $json["tenantName"]; $tenantType = $json["tenantType"]; $tenantCount = $json["tenantCount"]; + $purpose = $json["purpose"]; - $stmt = $pdo->prepare("INSERT INTO mocha_tenants (tenant_name, global_identifier, effective_date, is_library) VALUES (:tenant_name, mocha_uuid_v4(), NOW(), 0)"); + $stmt = $pdo->prepare("INSERT INTO mocha_tenants (tenant_name, global_identifier, effective_date, is_library, tenant_purpose) VALUES (:tenant_name, mocha_uuid_v4(), NOW(), 0, :tenant_purpose)"); $stmt2 = $pdo->prepare("INSERT INTO mocha_tenant_references (source_tenant_id, target_tenant_id) VALUES (:source_tenant_id, 1)"); if ($tenantCount == 1) { $result = $stmt->execute(array ( - "tenant_name" => $tenantName + "tenant_name" => $tenantName, + "tenant_purpose" => $purpose )); $lastInsertId = $pdo->lastInsertId(); @@ -48,7 +50,8 @@ { $result = $stmt->execute(array ( - "tenant_name" => $tenantName . ($i + 1) + "tenant_name" => $tenantName . ($i + 1), + "tenant_purpose" => $purpose )); $lastInsertId = $pdo->lastInsertId(); diff --git a/mocha-php/src/mocha-tms/app.js b/mocha-php/src/mocha-tms/app.js index d765106..105ec4d 100644 --- a/mocha-php/src/mocha-tms/app.js +++ b/mocha-php/src/mocha-tms/app.js @@ -64,7 +64,8 @@ window.addEventListener("load", function() "action": "createTenant", "tenantName": dlg.getField("tenant_name").getValue(), "tenantType": dlg.getField("tenant_type").getValue(), - "tenantCount": dlg.getField("tenant_count").getValue() + "tenantCount": dlg.getField("tenant_count").getValue(), + "purpose": dlg.getField("tenant_purpose").getValue() }, function() { window.location.reload(); @@ -136,6 +137,12 @@ window.addEventListener("load", function() "value": 1, "minimumValue": 1, "maximumValue": 9 + }, + { + "id": "tenant_purpose", + "type": "text", + "multiline": true, + "title": "Purpose" } ] ); diff --git a/mocha-php/src/mocha-tms/dialog.js b/mocha-php/src/mocha-tms/dialog.js index b6b5f2e..6982200 100644 --- a/mocha-php/src/mocha-tms/dialog.js +++ b/mocha-php/src/mocha-tms/dialog.js @@ -124,27 +124,46 @@ Dialog.ShowDialog = function(title, prompt, buttons, fields, callback) } else if (fields[i].type == "text" || fields[i].type == "numeric") { - var input = document.createElement("input"); - if (fields[i].type == "numeric") + if (typeof(fields[i].multiline) === 'undefined' || fields[i].multiline !== true) { - input.type = "number"; + var input = document.createElement("input"); + if (fields[i].type == "numeric") + { + input.type = "number"; + } + else + { + input.type = "text"; + } + td.appendChild(input); + + if (typeof(fields[i].value) !== 'undefined') + { + input.value = fields[i].value; + } + + fields[i].element = input; + fields[i].getValue = function() + { + return this.element.value; + }; } else { - input.type = "text"; - } - td.appendChild(input); + var input = document.createElement("textarea"); + td.appendChild(input); - if (typeof(fields[i].value) == 'number') - { - input.value = fields[i].value; + if (typeof(fields[i].value) !== 'undefined') + { + input.value = fields[i].value; + } + + fields[i].element = input; + fields[i].getValue = function() + { + return this.element.value; + }; } - - fields[i].element = input; - fields[i].getValue = function() - { - return this.element.value; - }; } else if (fields[i].type == "choice") { diff --git a/mocha-php/src/mocha-tms/index.php b/mocha-php/src/mocha-tms/index.php index 4ebbff1..dad8ff3 100644 --- a/mocha-php/src/mocha-tms/index.php +++ b/mocha-php/src/mocha-tms/index.php @@ -149,7 +149,7 @@ - +