UX update for contact create

This commit is contained in:
Pinga 2023-09-03 18:02:28 +03:00
parent fe7d6199bc
commit a5fe1be070
3 changed files with 242 additions and 230 deletions

View file

@ -6,6 +6,7 @@ use App\Models\Contact;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use League\ISO3166\ISO3166;
class ContactsController extends Controller class ContactsController extends Controller
{ {
@ -16,7 +17,15 @@ class ContactsController extends Controller
public function create(Request $request, Response $response) public function create(Request $request, Response $response)
{ {
return view($response,'admin/contacts/create.twig'); $iso3166 = new ISO3166();
} $db = $this->container->get('db');
$countries = $iso3166->all();
$registrars = $db->select("SELECT id, clid, name FROM registrar");
// Default view for GET requests or if POST data is not set
return view($response,'admin/contacts/create.twig', [
'registrars' => $registrars,
'countries' => $countries,
]);
}
} }

View file

@ -14,24 +14,26 @@
"require": { "require": {
"php": "^8.1", "php": "^8.1",
"ext-pdo": "*", "ext-pdo": "*",
"slim/slim": "4.11.0", "slim/slim": "4.12.0",
"slim/twig-view": "^3.3.0", "slim/twig-view": "^3.3.0",
"monolog/monolog": "^3.3.1", "monolog/monolog": "^3.4.0",
"respect/validation": "^2.2.4", "respect/validation": "^2.2.4",
"slim/csrf": "^1.3", "slim/csrf": "^1.3",
"slim/flash": "^0.4", "slim/flash": "^0.4",
"vlucas/phpdotenv": "^5.5", "vlucas/phpdotenv": "^5.5",
"php-di/php-di": "^7.0.2", "php-di/php-di": "^7.0.5",
"nyholm/psr7": "^1.5", "nyholm/psr7": "^1.8",
"nyholm/psr7-server": "^1.0", "nyholm/psr7-server": "^1.0.2",
"pinga/auth": "^0.1.1", "pinga/auth": "^0.1.1",
"phpmailer/phpmailer": "^6.7.1", "phpmailer/phpmailer": "^6.8.1",
"filp/whoops": "^2.14.6", "filp/whoops": "^2.15.3",
"imefisto/psr-swoole-native": "^1.1", "imefisto/psr-swoole-native": "^1.1.2",
"chubbyphp/chubbyphp-static-file": "^1.2", "chubbyphp/chubbyphp-static-file": "^1.2",
"lasserafn/php-initial-avatar-generator": "^4.2", "lasserafn/php-initial-avatar-generator": "^4.3",
"mevdschee/php-crud-api": "^2.14", "mevdschee/php-crud-api": "^2.14",
"gettext/gettext": "^5.7" "gettext/gettext": "^5.7",
"punic/punic": "^3.8",
"league/iso3166": "^4.3"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View file

@ -17,32 +17,13 @@
{{ __('Contacts') }} {{ __('Contacts') }}
</h2> </h2>
</div> </div>
<!-- Page title actions -->
<div class="col-auto ms-auto d-print-none">
<div class="btn-list">
<span class="d-none d-sm-inline">
<a href="#" class="btn">
New view
</a>
</span>
<a href="#" class="btn btn-primary d-none d-sm-inline-block" data-bs-toggle="modal" data-bs-target="#modal-report">
<!-- Download SVG icon from http://tabler-icons.io/i/plus -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><line x1="12" y1="5" x2="12" y2="19" /><line x1="5" y1="12" x2="19" y2="12" /></svg>
Create new report
</a>
<a href="#" class="btn btn-primary d-sm-none btn-icon" data-bs-toggle="modal" data-bs-target="#modal-report" aria-label="Create new report">
<!-- Download SVG icon from http://tabler-icons.io/i/plus -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><line x1="12" y1="5" x2="12" y2="19" /><line x1="5" y1="12" x2="19" y2="12" /></svg>
</a>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
<!-- Page body --> <!-- Page body -->
<div class="page-body"> <div class="page-body">
<div class="container-xl"> <div class="container-xl">
<div class="row"> <div class="row row-cards">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<form action="/your_endpoint" method="post"> <form action="/your_endpoint" method="post">
@ -53,59 +34,74 @@
<!-- Internationalized Name --> <!-- Internationalized Name -->
<div class="mb-3"> <div class="mb-3">
<label for="intName">Name (INT)</label> <label for="intName" class="form-label required">Name</label>
<input type="text" class="form-control" id="intName" name="intName" required> <input type="text" class="form-control" id="intName" name="intName" required="required">
<div class="form-check mt-1"> <label class="form-check form-switch mt-1">
<input type="checkbox" class="form-check-input" id="discloseNameInt" name="disclose_name_int"> <input class="form-check-input" type="checkbox" id="discloseNameInt" name="disclose_name_int">
<label class="form-check-label" for="discloseNameInt">Disclose in WHOIS</label> <span class="form-check-label" for="discloseNameInt">Disclose in WHOIS</span>
</label>
</div> </div>
{% if registrars %}
<div class="form-group mb-3">
<label for="registrarDropdown" class="form-label required">{{ __('Select Registrar') }}:</label>
<select id="registrarDropdown" name="registrar" class="form-control">
{% for registrar in registrars %}
<option value="{{ registrar.id }}">{{ registrar.name }}</option>
{% endfor %}
</select>
</div> </div>
{% endif %}
<!-- Internationalized Organization --> <!-- Internationalized Organization -->
<div class="mb-3"> <div class="mb-3">
<label for="intOrg">Organization (INT)</label> <label for="intOrg" class="form-label required">Organization</label>
<input type="text" class="form-control" id="intOrg" name="org"> <input type="text" class="form-control" id="intOrg" name="org" required="required">
<div class="form-check mt-1"> <label class="form-check form-switch mt-1">
<input type="checkbox" class="form-check-input" id="discloseOrgInt" name="disclose_org_int"> <input class="form-check-input" type="checkbox" id="discloseOrgInt" name="disclose_org_int">
<label class="form-check-label" for="discloseOrgInt">Disclose in WHOIS</label> <span class="form-check-label" for="discloseOrgInt">Disclose in WHOIS</span>
</div> </label>
</div> </div>
<!-- Internationalized Address: Street Details --> <!-- Internationalized Address: Street Details -->
<div class="mb-3"> <div class="mb-3">
<label for="street1">Street 1 (INT)</label> <label for="street1" class="form-label required">Street 1</label>
<input type="text" class="form-control" id="street1" name="street1"> <input type="text" class="form-control" id="street1" name="street1" required="required">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="street2">Street 2 (INT, Optional)</label> <label for="street2" class="form-label">Street 2</label>
<input type="text" class="form-control" id="street2" name="street2"> <input type="text" class="form-control" id="street2" name="street2">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="street3">Street 3 (INT, Optional)</label> <label for="street3" class="form-label">Street 3</label>
<input type="text" class="form-control" id="street3" name="street3"> <input type="text" class="form-control" id="street3" name="street3">
</div> </div>
<!-- Internationalized Address: City, SP, PC, CC --> <!-- Internationalized Address: City, SP, PC, CC -->
<div class="mb-3"> <div class="mb-3">
<label for="city">City (INT)</label> <label for="city" class="form-label required">City</label>
<input type="text" class="form-control" id="city" name="city" required> <input type="text" class="form-control" id="city" name="city" required="required">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="sp">State/Province (INT, Optional)</label> <label for="sp" class="form-label">State/Province</label>
<input type="text" class="form-control" id="sp" name="sp"> <input type="text" class="form-control" id="sp" name="sp">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="pc">Postal Code (INT, Optional)</label> <label for="pc" class="form-label">Postal Code</label>
<input type="text" class="form-control" id="pc" name="pc"> <input type="text" class="form-control" id="pc" name="pc">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="cc">Country Code (INT)</label> <label for="cc" class="form-label required">Country</label>
<input type="text" class="form-control" id="cc" name="cc" required maxlength="2"> <select class="form-select" id="cc" name="cc" required="required">
</div> {% for country in countries %}
<div class="form-check mt-1 mb-3"> <option value="{{ country.alpha2|lower }}">{{ country.name }}</option>
<input type="checkbox" class="form-check-input" id="discloseAddrInt" name="disclose_addr_int"> {% endfor %}
<label class="form-check-label" for="discloseAddrInt">Disclose Address in WHOIS</label> </select>
</div> </div>
<label class="form-check form-switch mt-1">
<input class="form-check-input" type="checkbox" id="discloseAddrInt" name="disclose_addr_int">
<span class="form-check-label" for="discloseAddrInt">Disclose Address in WHOIS</span>
</label>
</div> </div>
<!-- Second Column: Voice, Fax, Email, and other details --> <!-- Second Column: Voice, Fax, Email, and other details -->
@ -114,44 +110,44 @@
<!-- Voice --> <!-- Voice -->
<div class="mb-3"> <div class="mb-3">
<label for="voice">Voice</label> <label for="voice" class="form-label required">Voice</label>
<input type="tel" class="form-control" id="voice" name="voice"> <input type="tel" class="form-control" id="voice" name="voice" required="required">
<div class="form-check mt-1"> <label class="form-check form-switch mt-1">
<input type="checkbox" class="form-check-input" id="discloseVoice" name="discloseVoice"> <input class="form-check-input" type="checkbox" id="discloseVoice" name="disclose_voice">
<label class="form-check-label" for="discloseVoice">Disclose in WHOIS</label> <span class="form-check-label" for="discloseVoice">Disclose in WHOIS</span>
</div> </label>
</div> </div>
<!-- Fax --> <!-- Fax -->
<div class="mb-3"> <div class="mb-3">
<label for="fax">Fax</label> <label for="fax" class="form-label">Fax</label>
<input type="tel" class="form-control" id="fax" name="fax"> <input type="tel" class="form-control" id="fax" name="fax">
<div class="form-check mt-1"> <label class="form-check form-switch mt-1">
<input type="checkbox" class="form-check-input" id="discloseFax" name="discloseFax"> <input class="form-check-input" type="checkbox" id="discloseFax" name="disclose_fax">
<label class="form-check-label" for="discloseFax">Disclose in WHOIS</label> <span class="form-check-label" for="discloseFax">Disclose in WHOIS</span>
</div> </label>
</div> </div>
<!-- Email --> <!-- Email -->
<div class="mb-3"> <div class="mb-3">
<label for="email">Email</label> <label for="email" class="form-label required">Email</label>
<input type="email" class="form-control" id="email" name="email" required> <input type="email" class="form-control" id="email" name="email" required="required">
<div class="form-check mt-1"> <label class="form-check form-switch mt-1">
<input type="checkbox" class="form-check-input" id="discloseEmail" name="discloseEmail"> <input class="form-check-input" type="checkbox" id="discloseEmail" name="disclose_email">
<label class="form-check-label" for="discloseEmail">Disclose in WHOIS</label> <span class="form-check-label" for="discloseEmail">Disclose in WHOIS</span>
</div> </label>
</div> </div>
<!-- AuthInfo for Contact --> <!-- AuthInfo for Contact -->
<div class="mb-3"> <div class="mb-3">
<label for="authInfo">Contact AuthInfo</label> <label for="authInfo" class="form-label required">Contact AuthInfo</label>
<input type="text" class="form-control" id="authInfo" name="authInfo" readonly> <input type="text" class="form-control" id="authInfo" name="authInfo" readonly>
<small class="form-text text-muted">Auto-generated authentication information for the contact.</small> <small class="form-text text-muted">Auto-generated authentication information for the contact.</small>
</div> </div>
<!-- NIN - National Identification Number --> <!-- NIN - National Identification Number -->
<div class="mb-3"> <div class="mb-3">
<label for="nin">NIN - National Identification Number</label> <label for="nin" class="form-label">NIN - National Identification Number</label>
<input type="text" class="form-control" id="nin" name="nin"> <input type="text" class="form-control" id="nin" name="nin">
</div> </div>
@ -184,8 +180,10 @@
<!-- Localized Info Checkbox --> <!-- Localized Info Checkbox -->
<div class="mb-3"> <div class="mb-3">
<input type="checkbox" id="toggleLoc" class="form-check-input"> <label class="form-check form-switch">
<label for="toggleLoc" class="form-check-label">Include Localized Info</label> <input class="form-check-input" type="checkbox" id="toggleLoc">
<span class="form-check-label" for="toggleLoc">Include Localized Info</span>
</label>
</div> </div>
<!-- Hidden Localized Info Rows --> <!-- Hidden Localized Info Rows -->
@ -196,31 +194,31 @@
<!-- Localized Name --> <!-- Localized Name -->
<div class="mb-3"> <div class="mb-3">
<label for="locName">Name (LOC)</label> <label for="locName" class="form-label">Name</label>
<input type="text" class="form-control" id="locName" name="locName"> <input type="text" class="form-control" id="locName" name="locName">
<div class="form-check mt-1"> <label class="form-check form-switch mt-1">
<input type="checkbox" class="form-check-input" id="discloseNameLoc" name="disclose_name_loc"> <input class="form-check-input" type="checkbox" id="discloseNameLoc" name="disclose_name_loc">
<label class="form-check-label" for="discloseNameLoc">Disclose in WHOIS</label> <span class="form-check-label" for="discloseNameLoc">Disclose in WHOIS</span>
</div> </label>
</div> </div>
<!-- Localized Organization --> <!-- Localized Organization -->
<div class="mb-3"> <div class="mb-3">
<label for="locOrg">Organization (LOC)</label> <label for="locOrg" class="form-label">Organization</label>
<input type="text" class="form-control" id="locOrg" name="locOrg"> <input type="text" class="form-control" id="locOrg" name="locOrg">
<div class="form-check mt-1"> <label class="form-check form-switch mt-1">
<input type="checkbox" class="form-check-input" id="discloseOrgLoc" name="disclose_org_loc"> <input class="form-check-input" type="checkbox" id="discloseOrgLoc" name="disclose_org_loc">
<label class="form-check-label" for="discloseOrgLoc">Disclose in WHOIS</label> <span class="form-check-label" for="discloseOrgLoc">Disclose in WHOIS</span>
</div> </label>
</div> </div>
<!-- Localized Street Details --> <!-- Localized Street Details -->
<div class="mb-3"> <div class="mb-3">
<label for="locStreet1">Street 1 (LOC)</label> <label for="locStreet1" class="form-label">Street 1</label>
<input type="text" class="form-control" id="locStreet1" name="locStreet1"> <input type="text" class="form-control" id="locStreet1" name="locStreet1">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="locStreet2">Street 2 (LOC, Optional)</label> <label for="locStreet2" class="form-label">Street 2</label>
<input type="text" class="form-control" id="locStreet2" name="locStreet2"> <input type="text" class="form-control" id="locStreet2" name="locStreet2">
</div> </div>
</div> </div>
@ -231,46 +229,49 @@
<!-- Continued Localized Street Detail --> <!-- Continued Localized Street Detail -->
<div class="mb-3"> <div class="mb-3">
<label for="locStreet3">Street 3 (LOC, Optional)</label> <label for="locStreet3" class="form-label">Street 3</label>
<input type="text" class="form-control" id="locStreet3" name="locStreet3"> <input type="text" class="form-control" id="locStreet3" name="locStreet3">
</div> </div>
<!-- Localized City, SP, PC, CC --> <!-- Localized City, SP, PC, CC -->
<div class="mb-3"> <div class="mb-3">
<label for="locCity">City (LOC)</label> <label for="locCity" class="form-label">City</label>
<input type="text" class="form-control" id="locCity" name="locCity" required> <input type="text" class="form-control" id="locCity" name="locCity">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="locSP">State/Province (LOC, Optional)</label> <label for="locSP" class="form-label">State/Province</label>
<input type="text" class="form-control" id="locSP" name="locSP"> <input type="text" class="form-control" id="locSP" name="locSP">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="locPC">Postal Code (LOC, Optional)</label> <label for="locPC" class="form-label">Postal Code</label>
<input type="text" class="form-control" id="locPC" name="locPC"> <input type="text" class="form-control" id="locPC" name="locPC">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="locCC">Country Code (LOC)</label> <label for="locCC" class="form-label">Country</label>
<input type="text" class="form-control" id="locCC" name="locCC" required maxlength="2"> <select class="form-select" id="locCC" name="locCC">
{% for country in countries %}
<option value="{{ country.alpha2|lower }}">{{ country.name }}</option>
{% endfor %}
</select>
</div> </div>
<div class="form-check mt-1 mb-3"> <label class="form-check form-switch mt-1">
<input type="checkbox" class="form-check-input" id="discloseAddrLoc" name="disclose_addr_loc"> <input class="form-check-input" type="checkbox" id="discloseAddrLoc" name="disclose_addr_loc">
<label class="form-check-label" for="discloseAddrLoc">Disclose Address in WHOIS</label> <span class="form-check-label" for="discloseAddrLoc">Disclose Address in WHOIS</span>
</label>
</div> </div>
</div> </div>
</div> </div>
<div class="card-footer">
<div class="row mt-4"> <div class="row align-items-center">
<div class="col-md-12"> <div class="col-auto">
<!-- Centralized Submit Button --> <button type="submit" class="btn btn-primary">Create Contact</button>
<button type="submit" class="btn btn-primary">Create</button> </div>
</div> </div>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
<footer class="footer footer-transparent d-print-none"> <footer class="footer footer-transparent d-print-none">
<div class="container-xl"> <div class="container-xl">
<div class="col-12 col-lg-auto mt-3 mt-lg-0"> <div class="col-12 col-lg-auto mt-3 mt-lg-0">