mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 06:40:33 -04:00
Use @inputmode="number" instead of <input type="number">
This commit is contained in:
parent
39db272cb1
commit
d3bde7d195
5 changed files with 22 additions and 13 deletions
|
@ -58,6 +58,9 @@ class Artist extends PropertiesBase{
|
||||||
// *******
|
// *******
|
||||||
|
|
||||||
public function Validate(): void{
|
public function Validate(): void{
|
||||||
|
$now = new DateTime('now', new DateTimeZone('UTC'));
|
||||||
|
$thisYear = intval($now->format('Y'));
|
||||||
|
|
||||||
$error = new Exceptions\ValidationException();
|
$error = new Exceptions\ValidationException();
|
||||||
|
|
||||||
if($this->Name === null || $this->Name == ''){
|
if($this->Name === null || $this->Name == ''){
|
||||||
|
@ -68,7 +71,7 @@ class Artist extends PropertiesBase{
|
||||||
$error->Add(new Exceptions\StringTooLongException('Artist Name'));
|
$error->Add(new Exceptions\StringTooLongException('Artist Name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->DeathYear !== null && ($this->DeathYear <= 0 || $this->DeathYear > intval(date('Y')) + 50)){
|
if($this->DeathYear !== null && ($this->DeathYear <= 0 || $this->DeathYear > $thisYear + 50)){
|
||||||
$error->Add(new Exceptions\InvalidDeathYearException());
|
$error->Add(new Exceptions\InvalidDeathYearException());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -268,6 +268,8 @@ class Artwork extends PropertiesBase{
|
||||||
* @throws \Exceptions\ValidationException
|
* @throws \Exceptions\ValidationException
|
||||||
*/
|
*/
|
||||||
protected function Validate(array &$uploadedFile = []): void{
|
protected function Validate(array &$uploadedFile = []): void{
|
||||||
|
$now = new DateTime('now', new DateTimeZone('UTC'));
|
||||||
|
$thisYear = intval($now->format('Y'));
|
||||||
$error = new Exceptions\ValidationException();
|
$error = new Exceptions\ValidationException();
|
||||||
|
|
||||||
if($this->Artist === null){
|
if($this->Artist === null){
|
||||||
|
@ -297,7 +299,7 @@ class Artwork extends PropertiesBase{
|
||||||
$error->Add(new Exceptions\StringTooLongException('Artwork Name'));
|
$error->Add(new Exceptions\StringTooLongException('Artwork Name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->CompletedYear !== null && ($this->CompletedYear <= 0 || $this->CompletedYear > intval(date('Y')))){
|
if($this->CompletedYear !== null && ($this->CompletedYear <= 0 || $this->CompletedYear > $thisYear)){
|
||||||
$error->Add(new Exceptions\InvalidCompletedYearException());
|
$error->Add(new Exceptions\InvalidCompletedYearException());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +307,7 @@ class Artwork extends PropertiesBase{
|
||||||
$this->CompletedYearIsCirca = false;
|
$this->CompletedYearIsCirca = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->PublicationYear !== null && ($this->PublicationYear <= 0 || $this->PublicationYear > intval(date('Y')))){
|
if($this->PublicationYear !== null && ($this->PublicationYear <= 0 || $this->PublicationYear > $thisYear)){
|
||||||
$error->Add(new Exceptions\InvalidPublicationYearException());
|
$error->Add(new Exceptions\InvalidPublicationYearException());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
// Auto-included by Composer in composer.json to satisfy PHPStan
|
// Auto-included by Composer in composer.json to satisfy PHPStan
|
||||||
use Safe\DateTime;
|
use Safe\DateTime;
|
||||||
use function Safe\define;
|
use function Safe\define;
|
||||||
use function Safe\strtotime;
|
|
||||||
|
|
||||||
$now = new DateTime('now', new DateTimeZone('UTC'));
|
$now = new DateTime('now', new DateTimeZone('UTC'));
|
||||||
$nowPd = new DateTime('now', new DateTimeZone('America/Juneau')); // Latest continental US time zone
|
$nowPd = new DateTime('now', new DateTimeZone('America/Juneau')); // Latest continental US time zone
|
||||||
|
|
|
@ -95,11 +95,12 @@ catch(Exceptions\InvalidPermissionsException){
|
||||||
<label>
|
<label>
|
||||||
<span>Year of death</span>
|
<span>Year of death</span>
|
||||||
<span>If circa or unknown, enter the latest possible year.</span>
|
<span>If circa or unknown, enter the latest possible year.</span>
|
||||||
|
<? /* Not using <input type="number"> for now, see https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/ */ ?>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="text"
|
||||||
name="artist-year-of-death"
|
name="artist-year-of-death"
|
||||||
min="1"
|
inputmode="numeric"
|
||||||
max="<?= $now->format('Y') ?>"
|
pattern="[0-9]+"
|
||||||
value="<?= $artwork->Artist->DeathYear ?>"
|
value="<?= $artwork->Artist->DeathYear ?>"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
@ -115,10 +116,10 @@ catch(Exceptions\InvalidPermissionsException){
|
||||||
<label>
|
<label>
|
||||||
Year of completion
|
Year of completion
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="text"
|
||||||
name="artwork-year"
|
name="artwork-year"
|
||||||
min="1"
|
inputmode="numeric"
|
||||||
max="<?= $now->format('Y') ?>"
|
pattern="[0-9]+"
|
||||||
value="<?= $artwork->CompletedYear ?>"
|
value="<?= $artwork->CompletedYear ?>"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
@ -181,10 +182,10 @@ catch(Exceptions\InvalidPermissionsException){
|
||||||
<label>
|
<label>
|
||||||
Year of publication
|
Year of publication
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="text"
|
||||||
name="artwork-publication-year"
|
name="artwork-publication-year"
|
||||||
min="1"
|
inputmode="numeric"
|
||||||
max="<?= $now->format('Y') ?>"
|
pattern="[0-9]+"
|
||||||
value="<?= $artwork->PublicationYear ?>"
|
value="<?= $artwork->PublicationYear ?>"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
|
@ -674,6 +674,10 @@ input[type="checkbox"]:focus{
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input[inputmode="numeric"]{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
h1 + .message{
|
h1 + .message{
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue