Skip to content

Commit

Permalink
remove supplement_data
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell committed Oct 4, 2024
1 parent 350e092 commit 2b15e43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/Tags/Dictionary/Dictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ public function index()
}

$search = $this->params->pull('search');
$supplement = $this->params->pull('supplement_data');

if (! $dictionary = Dictionaries::find($handle, $this->params->all())) {
throw new DictionaryNotFoundException($handle);
}

$options = collect($dictionary->options($search))
->map(fn ($label, $value) => new DictionaryItem($supplement ? $dictionary->get($value)->extra() : ['label' => $label, 'value' => $value]))
->map(fn ($label, $value) => new DictionaryItem(array_merge(['label' => $label, 'value' => $value], $dictionary->get($value)->extra())))
->values();

$query = (new ItemQueryBuilder)->withItems(new DataCollection($options));
Expand Down
12 changes: 4 additions & 8 deletions tests/Tags/DictionaryTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,11 @@ public function it_can_search()
}

#[Test]
public function it_can_supplement_data()
public function it_pulls_extra_data_data()
{
$template = '{{ dictionary:countries search="Alg" supplement_data="true" }}{{ region }} - {{ iso2 }}{{ /dictionary:countries }}';
$template = '{{ dictionary:countries search="Alg" }}{{ region }} - {{ iso2 }}{{ /dictionary:countries }}';

$this->assertEquals('Africa - DZ', $this->tag($template));

$template = '{{ dictionary:countries search="Alg" supplement_data="false" }}{{ region }} - {{ iso2 }}{{ /dictionary:countries }}';

$this->assertEquals(' - ', $this->tag($template));
}

#[Test]
Expand All @@ -71,7 +67,7 @@ public function it_can_paginate()
#[Test]
public function it_can_be_filtered_using_conditions()
{
$template = '{{ dictionary:countries supplement_data="true" iso3:is="AUS" }}{{ name }}{{ /dictionary:countries }}';
$template = '{{ dictionary:countries iso3:is="AUS" }}{{ name }}{{ /dictionary:countries }}';

$this->assertEquals('Australia', $this->tag($template));
}
Expand All @@ -81,7 +77,7 @@ public function it_can_be_filtered_using_a_query_scope()
{
app('statamic.scopes')[TestScope::handle()] = TestScope::class;

$template = '{{ dictionary:countries supplement_data="true" query_scope="test_scope" }}{{ name }}{{ /dictionary:countries }}';
$template = '{{ dictionary:countries query_scope="test_scope" }}{{ name }}{{ /dictionary:countries }}';

$this->assertEquals('Australia', $this->tag($template));
}
Expand Down

0 comments on commit 2b15e43

Please sign in to comment.