Skip to content

Commit

Permalink
mapping page, entries field - retain selected type id
Browse files Browse the repository at this point in the history
  • Loading branch information
i-just committed Dec 6, 2023
1 parent 4f39d42 commit ef89ada
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/templates/_includes/fields/entries.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@
{% endfor %}

{% if sources and sources[0] %}
<div class="element-group element-group-entrytype" data-items="{{ entryTypes|json_encode }}">
{% set selectedTypeId = hash_get(feed.fieldMapping, optionsPath ~ '.group.typeId') ?: '' %}
<div class="element-group element-group-entrytype" data-items="{{ entryTypes|json_encode }}" data-selectedTypeId="{{ selectedTypeId }}">
<span>{{ 'Type:'|t('feed-me') }}</span>

{{ forms.selectField({
name: 'options[group][typeId]',
class: '',
value: hash_get(feed.fieldMapping, optionsPath ~ '.group.typeId') ?: '',
value: selectedTypeId,
options: entryTypes['item_' ~ sources[0].id] ?? [],
}) }}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/feedme/dist/FeedMe.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/feedme/dist/FeedMe.js.map

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/web/assets/feedme/src/js/feed-me.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ $(function () {
.parents('.field-extra-settings')
.find('.element-group-entrytype');
var sections = $container.data('items');
var selectedTypeId = $container.data('selectedtypeid');

// var sections = $(this).parents('.element-sub-group').data('items');
var entryType = 'item_' + $(this).val();
Expand All @@ -199,7 +200,14 @@ $(function () {
var newOptions = '';
$.each(entryTypes, function (index, value) {
if (index) {
newOptions += '<option value="' + index + '">' + value + '</option>';
newOptions +=
'<option value="' +
index +
'"' +
(index == selectedTypeId ? ' selected="selected"' : '') +
'>' +
value +
'</option>';
}
});

Expand Down

0 comments on commit ef89ada

Please sign in to comment.