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

EZP-29089: Usability bug when deleting containers #704

Merged
merged 1 commit into from
Nov 2, 2018
Merged

EZP-29089: Usability bug when deleting containers #704

merged 1 commit into from
Nov 2, 2018

Conversation

ViniTou
Copy link
Contributor

@ViniTou ViniTou commented Oct 29, 2018

Question Answer
Tickets https://jira.ez.no/browse/EZP-29089
Bug fix? no
New feature? yes
BC breaks? no
Tests pass? yes
Doc needed? no
License GPL-2.0

Description

This checks if location is non-empty container and if it is displays additional info modal. If content have asset fieldtype additional modals are displayed after first one.

Checklist:

  • Coding standards ($ composer fix-cs)
  • Ready for Code Review

@ezrobot

This comment has been minimized.

@ViniTou ViniTou requested review from mikadamczyk, dew326, sunpietro, tischsoic and adamwojs and removed request for dew326 October 30, 2018 07:38
};

toggleForm.addEventListener('submit', openTrashImageAssetModal, false);

Copy link
Contributor

Choose a reason for hiding this comment

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

not needed empty line

{
$children = $this->locationService->loadLocationChildren($item);

return 0 !== $children->totalCount;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe 0 < $children->totalCount

@@ -0,0 +1,17 @@
(function (global, doc) {
const toggleForm = doc.querySelector('form[name="location_trash_container"]');
const haveAsset = toggleForm.dataset.haveAsset;
Copy link
Contributor

Choose a reason for hiding this comment

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

hasAsset

(function (global, doc) {
const toggleForm = doc.querySelector('form[name="location_trash_container"]');
const haveAsset = toggleForm.dataset.haveAsset;
const haveUniqueAsset = toggleForm.dataset.haveUniqueAsset;
Copy link
Contributor

Choose a reason for hiding this comment

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

hasUniqueAsset

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 we not be consistent with how the corresponding class is named?

@@ -0,0 +1,27 @@
(function (global, doc) {
const toggleForms = [...doc.querySelectorAll('.ez-toggle-btn-state-checkbox')];
Copy link
Contributor

Choose a reason for hiding this comment

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

Due to latest changes in the browsers specification implementation, doc.querySelectorAll('.ez-toggle-btn-state-checkbox') is just enough. No need to convert it to an array to use with forEach only.

const ANY_CHECKED = 'any-checked';

toggleForms.forEach((toggleForm) => {
const checkboxInputs = [...toggleForm.querySelectorAll('input[type="checkbox"]')];
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.


toggleForms.forEach((toggleForm) => {
const checkboxInputs = [...toggleForm.querySelectorAll('input[type="checkbox"]')];
const toggleButtonState = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function should be implemented outside of forEach loop. If you want to have an access to the checkboxInputs then a useful piece of information is that a forEach loop callback takes 3 params: item, index, an iterated array with all values. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach

const toggleButtonState = () => {
const button = doc.querySelector(toggleForm.dataset.toggleButtonId);

const anyIsChecked = checkboxInputs.some(el => el.checked);
Copy link
Contributor

Choose a reason for hiding this comment

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

CS: all variables should come one after another without additional empty lines between them.

{{ form_widget(form.trashContainer) }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary btn--no" data-dismiss="modal">
Copy link
Contributor

Choose a reason for hiding this comment

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

According to our style guidelines (https://doc.ezplatform.com/en/2.2/guidelines/components/buttons/) this button probably should have classes btn btn-dark.


const toggleButtonState = (toggleForm, checkboxInputs) => {
const button = doc.querySelector(toggleForm.dataset.toggleButtonId);
const anyIsChecked = checkboxInputs.some(el => el.checked);
Copy link
Contributor

Choose a reason for hiding this comment

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

isAnyChecked

const checkboxInputs = toggleForm.querySelectorAll('input[type="checkbox"]');

checkboxInputs.forEach((input, index, inputs) => {
input.addEventListener('change', toggleButtonState.bind(null, toggleForm, [...inputs]), false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need [...inputs]?

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 can't use .some and .every on Node Collection, unless there is some other way to do this.

const toggleButtonState = (toggleForm, checkboxInputs) => {
const button = doc.querySelector(toggleForm.dataset.toggleButtonId);
const anyIsChecked = checkboxInputs.some(el => el.checked);
const allChecked = checkboxInputs.every(el => el.checked);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this line and the line above can be moved into the line line no. 22 and 23, for better performance.

@lserwatka
Copy link
Member

@mnocon Behat is failing here

@lserwatka
Copy link
Member

Perhaps rebase is needed with master after your fix will be merged up.

@lserwatka
Copy link
Member

@ViniTou could you rebase with master?

@lserwatka lserwatka merged commit 6ea13bb into ezsystems:master Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

7 participants