Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapping page, entries field - retain selected type id #1390

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading