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

IBX-1802: Update design for location swap and table locations #146

Merged
merged 4 commits into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
(function(global, doc, ibexa) {
const SELECTOR_VISIBILITY_CHECKBOXES = '#ibexa-tab-location-view-locations .ibexa-checkbox-icon__checkbox';
const SELECTOR_VISIBILITY_CHECKBOXES = '#ibexa-tab-location-view-locations .ibexa-content-locations__visibility-checkbox';
const SELECTOR_VISIBILITY_FORM = 'form[name="location_update_visibility_data"]';
const form = doc.querySelector(SELECTOR_VISIBILITY_FORM);
const visibilityCheckboxes = doc.querySelectorAll(SELECTOR_VISIBILITY_CHECKBOXES);
const refreshContentTree = () => {
doc.body.dispatchEvent(new CustomEvent('ibexa-content-tree-refresh'));
};
const onVisibilityUpdated = ({ target }) => {
const { checked: isVisible } = target;
const toggleLabel = target
.closest('.ibexa-content-locations__visibility-toggler')
.querySelector('.ibexa-content-locations__visibility-toggler-label');

target.closest('.ibexa-checkbox-icon').classList.toggle('is-checked', isVisible);
toggleLabel.classList.toggle('ibexa-content-locations__visibility-toggler-label--hidden');
};
const handleUpdateError = ibexa.helpers.notification.showErrorNotification;
const handleUpdateSuccess = (event, { message }) => {
Expand Down
5 changes: 4 additions & 1 deletion src/bundle/Resources/public/js/scripts/core/toggle.button.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@

toggler.querySelector(`.form-check input[value="${valueToSet}"]`).checked = true;
} else {
toggler.querySelector('.ibexa-toggle__input').checked = isChecked;
const toggleInput = toggler.querySelector('.ibexa-toggle__input');

toggleInput.checked = isChecked;
toggleInput.dispatchEvent(new Event('change'));
}
}

Expand Down
22 changes: 22 additions & 0 deletions src/bundle/Resources/public/scss/_content-locations.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.ibexa-content-locations {
&__visibility-toggler-label {
color: $ibexa-color-dark-400;
font-size: $ibexa-text-font-size-small;

.ibexa-icon {
fill: $ibexa-color-dark-400;
}

&--hidden {
display: none;
}
}

.ibexa-table {
&__header-cell {
&--visibility-toggler {
width: calculateRem(300px);
}
}
}
}
12 changes: 12 additions & 0 deletions src/bundle/Resources/public/scss/_form-location-swap.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.ibexa-form-location-swap {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.ibexa-form-location-swap {
.ibexa-location-swap-form {

max-width: calculateRem(700px);
margin-top: calculateRem(24px);
padding: calculateRem(34px) calculateRem(21px);
border-radius: $ibexa-border-radius;
border: calculateRem(1px) solid $ibexa-color-dark-200;

&__label {
font-size: $ibexa-text-font-size-medium;
margin-bottom: calculateRem(42px);
}
}
2 changes: 2 additions & 0 deletions src/bundle/Resources/public/scss/ibexa.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@
@import 'search-links-form';
@import 'custom-url-form';
@import 'details';
@import 'content-locations';
@import 'form-location-swap';
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@
headline: 'tab.locations.location_content_swap'|trans()|desc('Swap Locations'),
} only %}

{{ form_start(form, {'action': path('ezplatform.location.swap')}) }}
<div class="bg-white ml-4">
{{ 'tab.locations.swap_with_another'|trans()|desc('Swap the Content item at this Location with another') }}
{{ form_widget(form.swap, {'attr': {
'disabled': not can_swap,
'class': 'btn ibexa-btn ibexa-btn--secondary ibexa-btn--udw-swap ml-5',
'data-udw-config': ibexa_udw_config('single_container', {})
}}) }}
{{ form_widget(form.current_location) }}
{{ form_widget(form.new_location) }}
</div>
{{ form_start(form, {
'action': path('ezplatform.location.swap'),
'attr': { 'class': 'ibexa-form-location-swap' }
}) }}
<div class="ibexa-form-location-swap__label">
{{ 'tab.locations.swap_with_another'|trans()|desc('Swap the Content item at this Location with another') }}
</div>
<div class="ibexa-form-location-swap__action-content">
{{ form_widget(form.swap, {'attr': {
'disabled': not can_swap,
'class': 'btn ibexa-btn ibexa-btn--secondary ibexa-btn--udw-swap ml-5',
'data-udw-config': ibexa_udw_config('single_container', {})
}}) }}
{{ form_widget(form.current_location) }}
{{ form_widget(form.new_location) }}
</div>
{{ form_end(form) }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,107 +3,116 @@
{% form_theme form_content_location_add '@ibexadesign/ui/form/flat_widgets.html.twig' %}
{% form_theme form_content_location_remove with ['@ibexadesign/ui/form/flat_widgets.html.twig', '@ibexadesign/ui/form_fields.html.twig'] %}

<section>
<section class="ibexa-content-locations">
{{ form(form_content_location_add, {'action': path('ezplatform.location.add')}) }}
{% set body_rows = [] %}
{% if locations is not empty %}
{% for location in locations %}
{% set body_row_cols = [] %}

{% set col_raw %}
{{ form_widget(form_content_location_remove.locations[location.id], {'attr': {'disabled': not location.canDelete}}) }}
{% endset %}
{% set body_row_cols = body_row_cols|merge([{
has_checkbox: true,
content: col_raw,
raw: true,
}]) %}

{% set col_raw %}
{% include '@ibexadesign/ui/location_path.html.twig' with {'locations': location.pathLocations, 'link_last_element': true} %}
{% endset %}
{% set body_row_cols = body_row_cols|merge([{
content: col_raw,
raw: true,
}]) %}

{% set body_row_cols = body_row_cols|merge([
{ content: location.childCount },
]) %}

{% set col_raw %}
<label
class="ibexa-checkbox-icon {{ not location.explicitlyHidden ? 'is-checked' }}{{ not can_hide[location.id] ? 'disabled' }}"
Copy link
Contributor

@tischsoic tischsoic Dec 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete ibexa-checkbox-icon styles? I may be wrong, but it seems that it is only used here.
(There is one occurrence in JS in Page Builder, but it is only JS and probably is a dead code and should be deleted.)

title="{{ 'tab.locations.visibility'|trans|desc('Visibility') }}"
>
<svg class="ibexa-icon ibexa-icon--view">
<use xlink:href="{{ ibexa_icon_path('view') }}"></use>
</svg>
<svg class="ibexa-icon ibexa-icon--view-hide">
<use xlink:href="{{ ibexa_icon_path('view-hide') }}"></use>
</svg>
{% set body_rows = [] %}
{% if locations is not empty %}
{% for location in locations %}
{% set body_row_cols = [] %}

{% set col_raw %}
{{ form_widget(form_content_location_remove.locations[location.id], {'attr': {'disabled': not location.canDelete}}) }}
{% endset %}
{% set body_row_cols = body_row_cols|merge([{
has_checkbox: true,
content: col_raw,
raw: true,
}]) %}

{% set col_raw %}
{% include '@ibexadesign/ui/location_path.html.twig' with {'locations': location.pathLocations, 'link_last_element': true} %}
{% endset %}
{% set body_row_cols = body_row_cols|merge([{
content: col_raw,
raw: true,
}]) %}

{% set body_row_cols = body_row_cols|merge([
{ content: '' },
]) %}

{% set col_raw %}
<input
class="ibexa-checkbox-icon__checkbox"
{{ not location.explicitlyHidden ? 'checked' }}
type="checkbox"
name="updateVisibility"
{{ not can_hide[location.id] ? 'disabled' }}
class="ibexa-input ibexa-input--radio"
type="radio"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? I think that the old type (checkbox) is the correct one.

Suggested change
type="radio"
type="checkbox"

Copy link
Contributor Author

@lucasOsti lucasOsti Dec 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the invsion project, there should be a radio here
Current:
Screenshot 2021-12-30 at 09 23 08
Invsion:
https://projects.invisionapp.com/d/main#/console/21797486/461599772/preview

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you are right, I was confused because the order of the columns has been changed. :)

{{ location.main ? 'checked' }}
{{ not location.canEdit ? 'disabled' }}
name="updateMainLocation"
value="{{ location.id }}"
>
</label>
{% if location.invisible %}
<span class="ml-2">
{{ 'tab.locations.hidden_content_or_superior'|trans|desc('Content or its ancestor is hidden') }}
</span>
{% endif %}
{% endset %}
{% set body_row_cols = body_row_cols|merge([{
content: col_raw,
raw: true,
}]) %}

{% set body_row_cols = body_row_cols|merge([
{ content: '' },
]) %}

{% set col_raw %}
<input
class="ibexa-input ibexa-input--radio"
type="radio"
{{ location.main ? 'checked' }}
{{ not location.canEdit ? 'disabled' }}
name="updateMainLocation"
value="{{ location.id }}"
>
{% endset %}
{% set body_row_cols = body_row_cols|merge([{
content: col_raw,
raw: true,
}]) %}

{% set body_rows = body_rows|merge([{ cols: body_row_cols }]) %}
{% endfor %}
{% endif %}
{% endset %}
{% set body_row_cols = body_row_cols|merge([{
content: col_raw,
raw: true,
}]) %}

{% embed '@ibexadesign/ui/component/table/table.html.twig' with {
headline: 'tab.locations.content_locations'|trans|desc('Content Locations'),
head_cols: [
{ has_checkbox: true },
{ content: 'tab.locations.path'|trans|desc('Path') },
{ content: 'tab.locations.subitems'|trans|desc('Sub-items') },
{ content: 'tab.locations.visibility'|trans|desc('Visibility'), attr: { colspan: 2 } },
{ content: 'tab.locations.main'|trans|desc('Main') },
],
body_rows,
actions: tab.table_header_tools(form_content_location_add, form_content_location_remove, can_add),
} %}
{% block between_header_and_table %}
{{ form_start(form_content_location_remove, {
'action': path('ezplatform.location.remove'),
'attr': { 'class': 'ibexa-toggle-btn-state', 'data-toggle-button-id': '#delete-locations' }
}) }}
{% endblock %}
{% endembed %}
{% set col_raw %}
<div class="ibexa-content-locations__visibility-toggler">
<div class="ibexa-toggle ibexa-toggle--checkbox {{ not can_hide[location.id] ? 'ibexa-toggle--is-disabled' }} {{ not location.explicitlyHidden ? 'ibexa-toggle--is-checked' }}">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we import toggle_widget.html.twig here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I can't use the toggle widget here because it is a block

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in private: for now, it is not possible to include toggle_widget.html.twig.

<label class="ibexa-toggle__switcher">
<span class="ibexa-toggle__indicator"></span>
<input
type="checkbox"
class="ibexa-toggle__input ibexa-content-locations__visibility-checkbox"
{{ not location.explicitlyHidden ? 'checked' }}
type="checkbox"
name="updateVisibility"
{{ not can_hide[location.id] ? 'disabled' }}
value="{{ location.id }}"
/>
</label>
<span class="ibexa-toggle__label ibexa-toggle__label--on">
{{ 'toggle_widget.label.on'|trans|desc('On') }}
</span>
<span class="ibexa-toggle__label ibexa-toggle__label--off mr-2">
{{ 'toggle_widget.label.off'|trans|desc('Off') }}
</span>
</div>
<label class="ibexa-content-locations__visibility-toggler-label {{ not location.invisible ? 'ibexa-content-locations__visibility-toggler-label--hidden' }}">
<svg class="ibexa-icon ibexa-icon--small ">
<use xlink:href="{{ ibexa_icon_path('system-information') }}"></use>
</svg>
{{ 'tab.locations.hidden_content_or_superior'|trans|desc('Content or its ancestor is hidden') }}
</label>
</div>
{% endset %}

{% set body_row_cols = body_row_cols|merge([{
content: col_raw,
raw: true,
}]) %}

{% set body_row_cols = body_row_cols|merge([
{ content: location.childCount },
]) %}

{% set body_rows = body_rows|merge([{ cols: body_row_cols }]) %}
{% endfor %}
{% endif %}

{% embed '@ibexadesign/ui/component/table/table.html.twig' with {
headline: 'tab.locations.content_locations'|trans|desc('Content Locations'),
head_cols: [
{ has_checkbox: true },
{ content: 'tab.locations.path'|trans|desc('Path'),
attr: { colspan: 2 }
},
{ content: 'tab.locations.main'|trans|desc('Main') },
{ content: 'tab.locations.visibility'|trans|desc('Visibility'),
class: 'ibexa-table__header-cell--visibility-toggler'
},
{ content: 'tab.locations.subitems'|trans|desc('Sub-items') },
],
body_rows,
actions: tab.table_header_tools(form_content_location_add, form_content_location_remove, can_add),
} %}
{% block between_header_and_table %}
{{ form_start(form_content_location_remove, {
'action': path('ezplatform.location.remove'),
'attr': { 'class': 'ibexa-toggle-btn-state', 'data-toggle-button-id': '#delete-locations' }
}) }}
{% endblock %}
{% endembed %}
{{ form_end(form_content_location_remove) }}

{% if pager is defined and pager.haveToPaginate %}
Expand All @@ -123,9 +132,15 @@
</div>
{% endif %}

{{ form(form_content_location_update_visibility, {'action': path('ezplatform.location.update_visibility')}) }}
{{ form(form_content_location_main_update, {'action': path('ezplatform.content.update_main_location')}) }}
{{ form_start(form_content_location_update_visibility, {'action': path('ezplatform.location.update_visibility')}) }}
{{ form_row(form_content_location_update_visibility.location) }}
{{ form_row(form_content_location_update_visibility.hidden, {
label_attr: { hidden: true }
}) }}
{{ form_row(form_content_location_update_visibility.set) }}
{{ form_end(form_content_location_update_visibility) }}

{{ form(form_content_location_main_update, {'action': path('ezplatform.content.update_main_location')}) }}
</section>

{% include '@ibexadesign/content/tab/locations/panel_swap.html.twig' with {
Expand Down