-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add status icons to list #41
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\AutomationBundle\Metadata; | ||
|
||
use Sulu\Bundle\AdminBundle\Metadata\ListMetadata\FieldMetadata; | ||
use Sulu\Bundle\AdminBundle\Metadata\ListMetadata\ListMetadata; | ||
use Sulu\Bundle\AdminBundle\Metadata\ListMetadata\ListMetadataLoaderInterface; | ||
use Sulu\Bundle\AdminBundle\Metadata\ListMetadata\XmlListMetadataLoader; | ||
use Sulu\Bundle\AdminBundle\Metadata\MetadataInterface; | ||
|
||
class ListMetadataLoader implements ListMetadataLoaderInterface | ||
{ | ||
/** | ||
* @var XmlListMetadataLoader | ||
*/ | ||
private $xmlListMetadataLoader; | ||
|
||
public function __construct(XmlListMetadataLoader $xmlListMetadataLoader) | ||
{ | ||
$this->xmlListMetadataLoader = $xmlListMetadataLoader; | ||
} | ||
|
||
/** | ||
* @param mixed[] $metadataOptions | ||
*/ | ||
public function getMetadata(string $key, string $locale, array $metadataOptions = []): ?MetadataInterface | ||
{ | ||
if ('tasks' !== $key) { | ||
return null; | ||
} | ||
|
||
if (!method_exists(FieldMetadata::class, 'setTransformerTypeParameters')) { | ||
return null; | ||
} | ||
|
||
$list = $this->xmlListMetadataLoader->getMetadata($key, $locale, $metadataOptions); | ||
|
||
if (!$list instanceof ListMetadata) { | ||
return $list; | ||
} | ||
|
||
foreach ($list->getFields() as $field) { | ||
if ('status' !== $field->getName()) { | ||
continue; | ||
} | ||
|
||
$field->setType('icon'); | ||
$field->setVisibility('always'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the status not also be displayed always also when not having the status with icons /cc @wachterjohannes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are right - @luca-rath can you add this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be okay for me, but i wanted to keep it like it was before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think its the most important information on the list so it should always be displayed |
||
$field->setTransformerTypeParameters([ | ||
'mapping' => [ | ||
'planned' => 'su-clock', | ||
'running' => 'su-process', | ||
'completed' => [ | ||
'icon' => 'su-check-circle', | ||
'color' => '#6ac86b', | ||
], | ||
'failed' => [ | ||
'icon' => 'su-ban', | ||
'color' => '#cf3939', | ||
], | ||
], | ||
]); | ||
|
||
break; | ||
} | ||
|
||
return $list; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this 👍