-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-230 Move feedback messages to their own component
- Loading branch information
Showing
6 changed files
with
83 additions
and
19 deletions.
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
...screens/Overview/components/FeedbackMessagesDisplay/FeedbackMessagesDisplay.component.php
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,39 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Overview\Screens\Overview\Components\FeedbackMessagesDisplay; | ||
|
||
use UniEngine\Engine\Modules\Overview\Screens\Overview\Components\FeedbackMessagesDisplay; | ||
|
||
/** | ||
* @param array $props | ||
* @param arrayRef $props['input'] | ||
*/ | ||
function render($props) { | ||
$messages = FeedbackMessagesDisplay\Utils\getMessagesToDisplay($props); | ||
|
||
if (empty($messages)) { | ||
return [ | ||
'componentHTML' => '', | ||
]; | ||
} | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
$tplBodyCache = [ | ||
'messageRow' => $localTemplateLoader('messageRow'), | ||
]; | ||
|
||
$parsedMessages = array_map_withkeys($messages, function ($message) use (&$tplBodyCache) { | ||
return parsetemplate( | ||
$tplBodyCache['messageRow'], | ||
$message | ||
); | ||
}); | ||
|
||
$componentHTML = implode('', $parsedMessages); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML, | ||
]; | ||
} | ||
|
||
?> |
29 changes: 29 additions & 0 deletions
29
...iew/screens/Overview/components/FeedbackMessagesDisplay/FeedbackMessagesDisplay.utils.php
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,29 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Overview\Screens\Overview\Components\FeedbackMessagesDisplay\Utils; | ||
|
||
/** | ||
* @param array $props | ||
* @param arrayRef $props['input'] | ||
*/ | ||
function getMessagesToDisplay($props) { | ||
global $_Lang; | ||
|
||
$input = &$props['input']; | ||
|
||
$messages = []; | ||
|
||
if ( | ||
!empty($input['showmsg']) && | ||
$input['showmsg'] == 'abandon' | ||
) { | ||
$messages[] = [ | ||
'messageContent' => $_Lang['Abandon_ColonyAbandoned'], | ||
'colorClass' => 'lime', | ||
]; | ||
} | ||
|
||
return $messages; | ||
} | ||
|
||
?> |
5 changes: 5 additions & 0 deletions
5
modules/overview/screens/Overview/components/FeedbackMessagesDisplay/index.php
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,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |
5 changes: 5 additions & 0 deletions
5
modules/overview/screens/Overview/components/FeedbackMessagesDisplay/messageRow.tpl
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,5 @@ | ||
<tr> | ||
<th colspan="3" class="pad5 {colorClass}"> | ||
{messageContent} | ||
</th> | ||
</tr> |
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