Skip to content

Commit

Permalink
IBX-7671: Fixed inconsistent behavior for create from context menu (#…
Browse files Browse the repository at this point in the history
…1154)

For more details see https://issues.ibexa.co/browse/IBX-7671 and #1154

Key changes:

* Fixed inconsistent content tree behavior for create from context menu and from action main button
  • Loading branch information
GrabowskiM authored Feb 28, 2024
1 parent cfb5897 commit 7679ace
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
(function (global, doc) {
const createActions = doc.querySelectorAll('.ibexa-extra-actions--create');

if (!createActions.length) {
return;
}

createActions.forEach((container) => {
const bindCreateActionsEvents = (container) => {
const radioInputs = container.querySelectorAll('.form-check [type="radio"]');
const submitBtn = container.querySelector('.ibexa-extra-actions__btn--confirm');

Expand All @@ -24,5 +19,17 @@
false,
),
);
};

doc.body.addEventListener('ibexa-instant-filters:add-group', (event) => {
const createActionsContainer = event.detail.container.closest('.ibexa-extra-actions--create');

bindCreateActionsEvents(createActionsContainer);
});

if (!createActions.length) {
return;
}

createActions.forEach(bindCreateActionsEvents);
})(window, window.document);
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,11 @@
);
};

doc.body.addEventListener('ibexa-instant-filters:add-group', (event) => {
const filterContainer = event.detail.container.closest('.ibexa-instant-filter');

initFilter(filterContainer);
});

filters.forEach(initFilter);
})(window, window.document);
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
<div class="ibexa-instant-filter__desc">
{{ ('content.create.filters.desc'|trans|desc('Select a content type from list')) }}
</div>
<div class="ibexa-instant-filter__items">
<div
class="ibexa-instant-filter__items"
data-group-template="{{ include("@ibexadesign/content/widget/instant_filter_group_template.html.twig")|e('html_attr') }}"
>
{{ form_widget(form.content_type) }}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="ibexa-instant-filter__group">
<div class="ibexa-instant-filter__group-name">
{{ group_name|default('{{ group_name }}') }}
</div>

{{ group_options|default('{{ group_options }}') }}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
{{- block('content_type_choice_widget_options') -}}
</div>
{%- else -%}
<div class="ibexa-instant-filter__group-item">
<div class="ibexa-instant-filter__group-item" data-identifier="{{ option.value }}">
<label class="ibexa-instant-filter__group-item-label-icon" for="{{ form[key].vars.id }}">
<svg class="ibexa-icon ibexa-icon--small">
<use xlink:href="{{ ibexa_content_type_icon(option.value) }}"></use>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export const useFindLocationsByParentLocationIdFetch = (locationData, { sortClau
{
...restInfo,
parentLocationId: locationData.parentLocationId,
limit,
offset,
},
resolve,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ENDPOINT_ACCORDION = '/api/ibexa/v2/module/universal-discovery/accordion';
const ENDPOINT_LOCATION_LIST = '/api/ibexa/v2/module/universal-discovery/locations';

export const QUERY_LIMIT = 50;
export const AGGREGATIONS_LIMIT = 4;

const showErrorNotificationAbortWrapper = (error) => {
if (error?.name === 'AbortError') {
Expand Down Expand Up @@ -483,20 +484,24 @@ export const fetchAdminConfig = async ({ token, siteaccess, accessToken, instanc
return adminUiConfig.ApplicationConfig;
};

export const findSuggestions = ({ siteaccess, token, parentLocationId }, callback) => {
export const findSuggestions = (
{ siteaccess, token, parentLocationId, accessToken, instanceUrl = DEFAULT_INSTANCE_URL, limit = QUERY_LIMIT, offset = 0 },
callback,
) => {
const body = JSON.stringify({
ViewInput: {
identifier: 'view_with_aggregation',
LocationQuery: {
limit: '10',
offset: '0',
limit,
offset,
Filter: {
ParentLocationIdCriterion: parentLocationId,
},
Aggregations: [
{
ContentTypeTermAggregation: {
name: 'suggestions',
limit: AGGREGATIONS_LIMIT,
},
},
],
Expand All @@ -506,9 +511,16 @@ export const findSuggestions = ({ siteaccess, token, parentLocationId }, callbac

const request = new Request(ENDPOINT_CREATE_VIEW, {
method: 'POST',
headers: { ...HEADERS_CREATE_VIEW, 'X-Siteaccess': siteaccess, 'X-CSRF-Token': token },
headers: getRequestHeaders({
token,
siteaccess,
accessToken,
extraHeaders: {
...HEADERS_CREATE_VIEW,
},
}),
body,
mode: 'same-origin',
mode: getRequestMode({ instanceUrl }),
credentials: 'same-origin',
});

Expand Down

0 comments on commit 7679ace

Please sign in to comment.