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-397: Implement the new design for content item editing screen #1770

Conversation

lucasOsti
Copy link
Contributor

@lucasOsti lucasOsti commented Jun 1, 2021

@lucasOsti lucasOsti force-pushed the IBX-397-Implement-the-new-design-for-Content-item-editing-screen branch from 723d539 to 2db6c51 Compare June 1, 2021 14:05
@lucasOsti lucasOsti changed the title Ibx 397 implement the new design for content item editing screen IBX-397: Implement the new design for content item editing screen Jun 2, 2021
const navigateTo = (event) => {
const { anchorTargetSection } = event.currentTarget.dataset;

getSectionsCords();
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe put definition of this func before?

};

doc.querySelectorAll('.ibexa-anchor-navigation-menu__btn').forEach((button) => {
button.addEventListener('click', navigateTo);
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
button.addEventListener('click', navigateTo);
button.addEventListener('click', navigateTo, false);

});

doc.addEventListener('scroll', (event) => {
const pos = global.scrollY + scrollOffset;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe position insead of pos? No need to shorten it

@@ -105,4 +141,4 @@

{% block stylesheets %}
{% include '@ezdesign/content/edit/stylesheets.html.twig' %}
{% endblock %}
{% endblock %}
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary change

@lucasOsti lucasOsti force-pushed the IBX-397-Implement-the-new-design-for-Content-item-editing-screen branch 2 times, most recently from f25465f to 03b091e Compare June 9, 2021 12:07
let endSection = 0;
const { anchorTargetSectionId } = event.currentTarget.dataset;

doc.querySelectorAll('.ibexa-anchor-navigation-sections__section').forEach((section) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

what would you say for sth like

let prevSection = 0;
doc.querySelectorAll('.ibexa-anchor-navigation-sections__section').forEach((section) => {
    const { anchorSectionId } = section.dataset;

    sectionsPosition[anchorSectionId] = prevSection;
    prevSection = section.offsetHeight;
});

as far as I understand you dont need both variables

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure what you are proposing, @GrabowskiM. You only changed startSection name to prevSection and position of its declaration? Maybe I missed something in your code excerpt.

I like change of the variable name, but I wonder, do we even need sectionsPosition, @lucasOsti?
Because it is used only in 1 place AFAIK:
https://github.com/ezsystems/ezplatform-admin-ui/pull/1770/files#diff-2b5ffe8475c06a6575af7905596bab7de43658bb4bd13a9b658da19d8d5de2b1R36
top: sectionsPosition[anchorTargetSectionId],

My proposition in other comment.

const button = primaryButtons[i];
const isLastButton = i === primaryButtons.length - 1;
const allPreviousButtonVisible = hiddenPrimaryButtons.length === 0;
const isButtonNarrowerThanMoreButton = button.offsetWidth < moreButton.offsetWidth + BUTTON_MARGIN; // ??
Copy link
Contributor

Choose a reason for hiding this comment

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

comment?

@lucasOsti lucasOsti requested a review from GrabowskiM June 9, 2021 21:19
@lucasOsti lucasOsti requested a review from dew326 June 10, 2021 06:32
const invalidTabLink = doc.querySelector(`a[href="#${invalidTab.id}"]`);

invalidTabLink.click();
invalidButton.click();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we click it to basically call navigateTo function from admin.anchor.navigation.js?

Comment on lines 83 to 84
validationResults.filter((result) => !result.isValid).reduce((total, result) => {
total.add(result.validatorName);
Copy link
Contributor

Choose a reason for hiding this comment

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

For me it is confusing to have reduce, which acts basically as map and at the same time adds items to Set to take only unique results. What do you think about approach, which splits reduce into map and [...new Set()]:

const allValidatorsWithErrors = validationResults.filter((result) => !result.isValid).map((result) => result.validatorName);
btn.dataset.validatorsWithErrors = [...new Set(allValidatorsWithErrors)].join();

I have just noticed, that it is old code and you only formatted it. :D
Too much writing to delete it :P

let endSection = 0;
const { anchorTargetSectionId } = event.currentTarget.dataset;

doc.querySelectorAll('.ibexa-anchor-navigation-sections__section').forEach((section) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure what you are proposing, @GrabowskiM. You only changed startSection name to prevSection and position of its declaration? Maybe I missed something in your code excerpt.

I like change of the variable name, but I wonder, do we even need sectionsPosition, @lucasOsti?
Because it is used only in 1 place AFAIK:
https://github.com/ezsystems/ezplatform-admin-ui/pull/1770/files#diff-2b5ffe8475c06a6575af7905596bab7de43658bb4bd13a9b658da19d8d5de2b1R36
top: sectionsPosition[anchorTargetSectionId],

My proposition in other comment.

Comment on lines 23 to 32
const navigateTo = (event) => {
let startSection = 0;
const { anchorTargetSectionId } = event.currentTarget.dataset;

doc.querySelectorAll('.ibexa-anchor-navigation-sections__section').forEach((section) => {
const { anchorSectionId } = section.dataset;

sectionsPosition[anchorSectionId] = startSection;
startSection = section.offsetHeight;
});

if (isVerticalScrollVisible()) {
formContainerNode.scrollTo({
top: sectionsPosition[anchorTargetSectionId],
behavior: 'smooth',
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think? Am I missing something? @lucasOsti

Suggested change
const navigateTo = (event) => {
let startSection = 0;
const { anchorTargetSectionId } = event.currentTarget.dataset;
doc.querySelectorAll('.ibexa-anchor-navigation-sections__section').forEach((section) => {
const { anchorSectionId } = section.dataset;
sectionsPosition[anchorSectionId] = startSection;
startSection = section.offsetHeight;
});
if (isVerticalScrollVisible()) {
formContainerNode.scrollTo({
top: sectionsPosition[anchorTargetSectionId],
behavior: 'smooth',
const navigateTo = (event) => {
const { anchorTargetSectionId } = event.currentTarget.dataset;
const anchorTargetSection = doc.querySelector(`.ibexa-anchor-navigation-sections__section[data-anchor-section-id=${anchorTargetSectionId}]`);
const anchorTargetSectionPreviousSibling = anchorTargetSection.previousSibling;
const scrollTop = anchorTargetSectionPreviousSibling?.offsetHeight ?? 0;
if (isVerticalScrollVisible()) {
formContainerNode.scrollTo({
top: scrollTop,
behavior: 'smooth',

Comment on lines 52 to 51
doc.querySelectorAll('.ibexa-anchor-navigation-sections__section').forEach((section) => {
const { anchorSectionId } = section.dataset;
const start = section.offsetTop;
const end = section.offsetHeight + section.offsetTop;

if (position > start && position < end) {
showSection(anchorSectionId);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

From my perspective, you basically try to find one and only one section and then call showSection on it, so in my opinion it would be more expressive to do it this way:

Suggested change
doc.querySelectorAll('.ibexa-anchor-navigation-sections__section').forEach((section) => {
const { anchorSectionId } = section.dataset;
const start = section.offsetTop;
const end = section.offsetHeight + section.offsetTop;
if (position > start && position < end) {
showSection(anchorSectionId);
}
});
const allSections = doc.querySelectorAll('.ibexa-anchor-navigation-sections__section');
const activeSection = allSelections.find((section) => {
const { anchorSectionId } = section.dataset;
const start = section.offsetTop;
const end = section.offsetHeight + section.offsetTop;
return position > start && position < end;
});
const activeSectionId = activeSection.dataset.anchorSectionId
showSection(activeSectionId);

@lucasOsti lucasOsti requested a review from tischsoic June 10, 2021 10:39
@lucasOsti lucasOsti force-pushed the IBX-397-Implement-the-new-design-for-Content-item-editing-screen branch 6 times, most recently from 44efa2a to 0be377a Compare June 30, 2021 10:30
@lucasOsti lucasOsti force-pushed the IBX-397-Implement-the-new-design-for-Content-item-editing-screen branch 3 times, most recently from 363bbfd to e8f125a Compare July 1, 2021 11:12
@lucasOsti lucasOsti requested a review from GrabowskiM July 1, 2021 11:55
@lucasOsti lucasOsti force-pushed the IBX-397-Implement-the-new-design-for-Content-item-editing-screen branch 5 times, most recently from 9a3bec0 to 4bd77d4 Compare July 4, 2021 13:28
z-index: 1000;
}

.ez-icon {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.ez-icon {
.ibexa-icon {

?

border-bottom-right-radius: $ibexa-border-radius;
}

.ez-icon {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.ez-icon {
.ibexa-icon {

}
}

.btn-dark {
Copy link
Member

Choose a reason for hiding this comment

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

probably should not be styled by this class

{% endblock %}

{% block label %}
<span class="ez-btn__label">{{ parent() }}</span>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<span class="ez-btn__label">{{ parent() }}</span>
<span class="ibexa-btn__label">{{ parent() }}</span>

?

@@ -177,3 +177,12 @@
}
}
}

// TO DO: remove when redesigning !!
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it stay? If so:

Suggested change
// TO DO: remove when redesigning !!
// TODO: remove when redesigning !!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should it stay? If so:

yes, because after whole redesign we have to change it

itemHiddenClass: 'ibexa-context-menu__item--hidden',
container: adapatItemsContainer,
getActiveItem: () => {
return adapatItemsContainer.querySelectorAll('.ibexa-context-menu__item')[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe 🤔

Suggested change
return adapatItemsContainer.querySelectorAll('.ibexa-context-menu__item')[0];
return adapatItemsContainer.querySelector('.ibexa-context-menu__item');

const popupMenuElement = adapatItemsContainer.querySelector('.ibexa-popup-menu');
const showPopupButton = adapatItemsContainer.querySelector('.ibexa-btn--more');
const adaptiveItems = new eZ.core.AdaptiveItems({
items: [...adapatItemsContainer.querySelectorAll('.ibexa-context-menu__item:not(.ibexa-context-menu__item--more)')],
Copy link
Contributor

Choose a reason for hiding this comment

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

You can add a special class to the items and AdaptiveItems will find items on its own.

Comment on lines 31 to 33
position: () => {
popupMenuElement.style.right = 0;
},
Copy link
Contributor

Choose a reason for hiding this comment

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

And proper styles in CSS. Would it work?

Suggested change
position: () => {
popupMenuElement.style.right = 0;
},
position: () => {},

border: calculateRem(1px) solid transparent;
border-radius: $ibexa-border-radius;

&:before {
Copy link
Contributor

Choose a reason for hiding this comment

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

CSS3 syntax - here and in other places

Suggested change
&:before {
&::before {

ref. https://developer.mozilla.org/en-US/docs/Web/CSS/::before#syntax

'label': label,
'class': item.class|default('')
}) }}
{% endfor %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Bad indentation?

@@ -1,3 +1,3 @@
<li class="ibexa-popup-menu__item {{ class|default('') }}">
{{ label }}
{{ label }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Tab instead of 4 spaces? What about other places?

{% extends '@KnpMenu/menu.html.twig' %}

{% block root %}
<ul class="ibexa-context-menu">
Copy link
Contributor

Choose a reason for hiding this comment

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

Tabs should be changed to spaces?

@@ -25,9 +25,9 @@ public function __construct(BrowserContext $context)
parent::__construct($context);
$this->fields = [
'formElement' => '[name=ezplatform_content_forms_content_edit],[name=ezplatform_content_forms_user_create],[name=ezplatform_content_forms_user_update]',
'closeButton' => '.ez-content-edit-container__close',
'closeButton' => '.ez-content-edit-container__close, .ibexa-content-edit-sidebar__header .ibexa-content-edit-sidebar__back', // TO DO: Set one selector after redesign
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO? Here and in other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO? Here and in other places.

yes, because after whole redesign we have to change it

{% block root %}
<ul class="ibexa-context-menu">
{% for item in item.children %}
{ block('item') }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing {

@lucasOsti lucasOsti force-pushed the IBX-397-Implement-the-new-design-for-Content-item-editing-screen branch from 026a744 to 2670c61 Compare July 8, 2021 07:13
@lucasOsti lucasOsti force-pushed the IBX-397-Implement-the-new-design-for-Content-item-editing-screen branch from 0b34056 to 889e745 Compare July 9, 2021 13:25
@sonarcloud
Copy link

sonarcloud bot commented Jul 12, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
1.9% 1.9% Duplication

@dew326 dew326 merged commit 77e126d into ezsystems:master Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants