This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Messsaging new conversation form (#53)
* chore: so far * chore: so far * chore: so far * olcs-transfer bump * feat: use GOVUK-SELECT class * chore: code clean-up * bump: olcs-common
- Loading branch information
Showing
7 changed files
with
263 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Olcs\Form\Model\Fieldset\Message; | ||
|
||
use Common\Form\Element\DynamicSelect; | ||
use Common\Form\Elements\InputFilters\ActionButton; | ||
use Common\Form\Elements\Types\GuidanceTranslated; | ||
use Laminas\Form\Annotation as Form; | ||
use Laminas\Form\Element\Textarea; | ||
|
||
class Create | ||
{ | ||
/** | ||
* @Form\Options({ | ||
* "label": "messaging.subject", | ||
* "empty_option": "Please select", | ||
* "disable_inarray_validator": false, | ||
* "service_name": \Common\Service\Data\MessagingSubject::class | ||
* }) | ||
* @Form\Attributes({ | ||
* "class": "govuk-select" | ||
* }) | ||
* @Form\Type(\Common\Form\Element\DynamicSelect::class) | ||
* @Form\Required(true) | ||
*/ | ||
public ?DynamicSelect $messageSubject; | ||
|
||
/** | ||
* @Form\Options({ | ||
* "label": "messaging.app-or-lic-no", | ||
* "empty_option": "Please select", | ||
* "disable_inarray_validator": false, | ||
* "service_name": \Olcs\Service\Data\MessagingAppOrLicNo::class, | ||
* "use_groups": true | ||
* }) | ||
* @Form\Attributes({ | ||
* "class": "govuk-select" | ||
* }) | ||
* @Form\Type(\Common\Form\Element\DynamicSelect::class) | ||
* @Form\Required(true) | ||
*/ | ||
public ?DynamicSelect $appOrLicNo; | ||
|
||
/** | ||
* @Form\Attributes({ | ||
* "class": "extra-long", | ||
* "maxlength": 1000 | ||
* }) | ||
* @Form\Options({ | ||
* "label": "", | ||
* "hint": "You can enter up to 1000 characters" | ||
* }) | ||
* @Form\Required(true) | ||
* @Form\Type(\Laminas\Form\Element\Textarea::class) | ||
* @Form\Filter({"name": \Laminas\Filter\StringTrim::class}) | ||
* @Form\Validator({ | ||
* "name": \Laminas\Validator\StringLength::class, | ||
* "options": {"min": 5, "max" :1000} | ||
* }) | ||
*/ | ||
public ?TextArea $messageContent = null; | ||
|
||
/** | ||
* @Form\Attributes({"value": "markup-messaging-new-conversation-timeframe"}) | ||
* @Form\Type(\Common\Form\Elements\Types\GuidanceTranslated::class) | ||
*/ | ||
public ?GuidanceTranslated $guidance; | ||
|
||
/** | ||
* @Form\Attributes({ | ||
* "type": "submit", | ||
* "data-module": "govuk-button", | ||
* "class": "govuk-button govuk-button--default", | ||
* "id": "send" | ||
* }) | ||
* @Form\Options({ | ||
* "label": "Send message", | ||
* }) | ||
* @Form\Type(\Common\Form\Elements\InputFilters\ActionButton::class) | ||
*/ | ||
public ?ActionButton $create = null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Olcs\Form\Model\Form\Message; | ||
|
||
use Laminas\Form\Annotation as Form; | ||
use Olcs\Form\Model\Fieldset\Message\Reply as ReplyFieldset; | ||
|
||
class Create | ||
{ | ||
/** | ||
* @Form\Name("form-actions") | ||
* @Form\ComposedObject(\Olcs\Form\Model\Fieldset\Message\Create::class) | ||
*/ | ||
public ?ReplyFieldset $formActions = null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Olcs\Service\Data; | ||
|
||
use Common\Exception\DataServiceException; | ||
use Common\Service\Data\AbstractListDataService; | ||
use Dvsa\Olcs\Transfer\Query as TransferQry; | ||
|
||
class MessagingAppOrLicNo extends AbstractListDataService | ||
{ | ||
public const PREFIX_APPLICATION = 'A'; | ||
public const PREFIX_LICENCE = 'L'; | ||
|
||
/** | ||
* @throws DataServiceException | ||
*/ | ||
public function fetchListData($context = null): array | ||
{ | ||
$data = (array)$this->getData('licapp'); | ||
|
||
if (count($data) !== 0) { | ||
return $data; | ||
} | ||
|
||
$response = $this->handleQuery( | ||
TransferQry\Messaging\ApplicationLicenceList\ByOrganisation::create([]) | ||
); | ||
|
||
if (!$response->isOk()) { | ||
throw new DataServiceException('Unknown Error - ' . json_encode($response)); | ||
} | ||
|
||
$result = $response->getResult(); | ||
|
||
$this->setData('licapp', ($result['results'] ?? null)); | ||
|
||
return $this->getData('licapp'); | ||
} | ||
|
||
public function formatDataForGroups(array $data): array | ||
{ | ||
$optionData = [ | ||
[ | ||
'label' => 'Licence', | ||
'options' => [] | ||
], | ||
[ | ||
'label' => 'Application', | ||
'options' => [] | ||
] | ||
]; | ||
|
||
$optionData[0]['options'] = $data['licences']; | ||
$optionData[1]['options'] = $data['applications']; | ||
|
||
$this->prefixArrayKey($optionData[0]['options'], static::PREFIX_LICENCE); | ||
$this->prefixArrayKey($optionData[1]['options'], static::PREFIX_APPLICATION); | ||
|
||
return $optionData; | ||
} | ||
|
||
private function prefixArrayKey(array &$array, string $prefix): void | ||
{ | ||
foreach ($array as $k => $v) | ||
{ | ||
$array[$prefix . $k] = $v; | ||
unset($array[$k]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters