Commit da6e4fd8 authored by catch's avatar catch

Issue #2119903 by mparker17, vijaycs85, evilehk: Fixed Show locked date formats in the UI.

parent 8d37d8f3
......@@ -55,15 +55,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
);
}
/**
* {@inheritdoc}
*/
public function load() {
return array_filter(parent::load(), function ($entity) {
return !$entity->isLocked();
});
}
/**
* {@inheritdoc}
*/
......@@ -78,7 +69,12 @@ public function buildHeader() {
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
$row['id'] = $entity->id();
if ($entity->isLocked()) {
$row['id'] = $this->t('@entity_id (locked)', array('@entity_id' => $entity->id()));
}
else {
$row['id'] = $entity->id();
}
$row['label'] = $this->getLabel($entity);
$row['pattern'] = $this->dateService->format(REQUEST_TIME, $entity->id());
return $row + parent::buildRow($entity);
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\system\DateFormatInterface;
/**
......@@ -104,4 +105,16 @@ public function isLocked() {
return (bool) $this->locked;
}
/**
* {@inheritdoc}
*/
public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
if ($a->isLocked() == $b->isLocked()) {
$a_label = $a->label();
$b_label = $b->label();
return strnatcasecmp($a_label, $b_label);
}
return $a->isLocked() ? 1 : -1;
}
}
......@@ -31,10 +31,14 @@ public static function getInfo() {
public function testDateLocking() {
$this->drupalLogin($this->root_user);
// Locked date formats do not show on the listing page.
// Locked date formats are not linked on the listing page, locked date
// formats are clearly marked as such; unlocked formats are not marked as
// "locked".
$this->drupalGet('admin/config/regional/date-time');
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/short');
$this->assertNoLinkByHref('admin/config/regional/date-time/formats/manage/html_date');
$this->assertText('fallback (locked)');
$this->assertNoText('short (locked)');
// Locked date formats are not editable.
$this->drupalGet('admin/config/regional/date-time/formats/manage/short');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment