Skip to content

Commit

Permalink
OEL-1676: Rename new formatter field to 'Properties'.
Browse files Browse the repository at this point in the history
  • Loading branch information
drishu committed Nov 25, 2022
1 parent b301c3e commit 6b7a95d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ field.formatter.settings.oe_whitelabel_helper_address_inline:
delimiter:
type: string
label: 'Delimiter for address items.'
fields_display:
properties:
type: sequence
sequence:
type: string
label: 'Field'
label: 'Properties'
condition.plugin.oe_whitelabel_helper_current_component_library:
type: condition.plugin
mapping:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AddressInlineFormatter extends AddressDefaultFormatter {
public static function defaultSettings() {
return [
'delimiter' => ', ',
'fields_display' => [],
'properties' => [],
];
}

Expand All @@ -49,12 +49,12 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
'#required' => TRUE,
];

$form['fields_display'] = [
$form['properties'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Fields to display'),
'#default_value' => $this->getSetting('fields_display'),
'#description' => $this->t('Which fields should be displayed. Leave empty for all.'),
'#options' => $this->getFieldsDisplayOptions(),
'#title' => $this->t('Properties'),
'#default_value' => $this->getSetting('properties'),
'#description' => $this->t('Which properties should be displayed. Leave empty for all.'),
'#options' => $this->getPropertiesDisplayOptions(),
];

return $form;
Expand All @@ -68,8 +68,8 @@ public function settingsSummary() {
$this->t('Delimiter: @delimiter', [
'@delimiter' => $this->getSetting('delimiter'),
]),
$this->t('Fields to display: @fields', [
'@fields' => implode(', ', array_filter($this->getSetting('fields_display'))),
$this->t('Properties: @properties', [
'@properties' => implode(', ', array_filter($this->getSetting('properties'))),
]),
];
}
Expand Down Expand Up @@ -170,12 +170,12 @@ protected function extractAddressItems(string $string, array $replacements): arr
}

/**
* Provides the options for the fields display setting.
* Provides the options for the properties display setting.
*
* @return array
* The fields display options.
* The properties display options.
*/
protected function getFieldsDisplayOptions(): array {
protected function getPropertiesDisplayOptions(): array {
return [
'country' => $this->t('The country'),
] + LabelHelper::getGenericFieldLabels();
Expand All @@ -191,11 +191,11 @@ protected function getFieldsDisplayOptions(): array {
* The altered format string.
*/
protected function alterFormatString(string $format_string): string {
$options_selected = array_filter($this->getSetting('fields_display'));
$options_selected = array_filter($this->getSetting('properties'));
if (empty($options_selected)) {
return $format_string;
}
$options_list = array_keys($this->getFieldsDisplayOptions());
$options_list = array_keys($this->getPropertiesDisplayOptions());
// Negate the selected options against the list.
$fields = array_diff($options_list, $options_selected);
// Prepend % to all items.
Expand Down

0 comments on commit 6b7a95d

Please sign in to comment.