Skip to content

Commit

Permalink
PHRAS-3873: prod -advance search - field , leave only label and real …
Browse files Browse the repository at this point in the history
…field name (#4335)

* field label then fieldname

* separate with pipe
  
* add backup and ftp folder to gitignore
  • Loading branch information
aynsix authored Jul 12, 2023
1 parent e935f8a commit 12851c1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
# Exclude log folder
/logs

# Exclude backup folder
/backup
!/backup/.gitkeep

# Exclude ftp folder
/ftp
!/ftp/.gitkeep

# Exclude plugin folder
/plugins
# Excluse assets plugin folder
Expand Down
6 changes: 3 additions & 3 deletions lib/Alchemy/Phrasea/Helper/Prod.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function get_search_datas()
'sbas' => array($sbasId),
'fieldname' => $name,
'type' => $type,
'label' => ($name === $label) ? [$label] : [$name . ' - ' .trim($label)], // add the fieldname in the label
'label' => ($name === $label) ? [] : [trim($label)],
'id' => $id
);

Expand All @@ -108,7 +108,7 @@ public function get_search_datas()
$dates[$name]['sbas'][] = $sbasId;

// add different label for the same field if exist
if (!isset($dates[$name]['label']) || !in_array(strtolower($label), array_map('strtolower', $dates[$name]['label']))) {
if ($name !== $label && (!isset($dates[$name]['label']) || !in_array(strtolower($label), array_map('strtolower', $dates[$name]['label'])))) {
$dates[$name]['label'][] = trim($label);
}
}
Expand All @@ -126,7 +126,7 @@ public function get_search_datas()
$fields[$name]['sbas'][] = $sbasId;

// add different label for the same field if exist
if (!in_array(strtolower($label), array_map('strtolower', $fields[$name]['label']))) {
if ($name !== $label && (!in_array(strtolower($label), array_map('strtolower', $fields[$name]['label'])))) {
$fields[$name]['label'][] = trim($label);
}
} else {
Expand Down
17 changes: 14 additions & 3 deletions templates/web/prod/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,13 @@
<option value="">{{ 'Select a field' | trans }}</option>
{% for field_id, field in search_datas['fields'] %}
{# {% if field['type'] != 'date' %}#}
<option class="dbx db_{{field['sbas']|join(' db_')}}" data-fieldtype="{{ field['type'] }}-FIELD" value="{{field_id}}">{{ field['label'] | join(' - ') }}</option>
<option class="dbx db_{{field['sbas']|join(' db_')}}" data-fieldtype="{{ field['type'] }}-FIELD" value="{{field_id}}">
{% if field['label'] is empty %}
{{ field['fieldname'] }}
{% else %}
{{ field['label'] | join(' | ') ~ " ( " ~ field['fieldname'] ~ " )"}}
{% endif %}
</option>
{#{% endif %}#}
{% endfor %}
</select>
Expand Down Expand Up @@ -637,8 +643,13 @@
<option selected="selected"
value="">{{ 'Rechercher dans un champ date' | trans }}</option>
{% for fieldname, date in search_datas['dates'] %}
<option
class="dbx db_{{date['sbas']|join(' db_')}}" value="{{ fieldname }}">{{ date['label'] | join(' - ') }}</option>
<option class="dbx db_{{date['sbas']|join(' db_')}}" value="{{ fieldname }}">
{% if date['label'] is empty %}
{{ fieldname }}
{% else %}
{{ date['label'] | join(' | ') ~ " ( " ~ fieldname ~ " )" }}
{% endif %}
</option>
{% endfor %}
</select>
</span>
Expand Down

0 comments on commit 12851c1

Please sign in to comment.