Skip to content

[4.0][RFC] Custom Element: Joomla! Toolbar button#20650

Merged
wilsonge merged 12 commits intojoomla:4.0-devfrom
Fedik:toolbar-button2
Jun 13, 2018
Merged

[4.0][RFC] Custom Element: Joomla! Toolbar button#20650
wilsonge merged 12 commits intojoomla:4.0-devfrom
Fedik:toolbar-button2

Conversation

@Fedik
Copy link
Copy Markdown
Member

@Fedik Fedik commented Jun 2, 2018

This is redo of #19635

This patch add <joomla-toolbar-button/> custom element, to standard toolbar button.
It allow us to move most of inline onclick="" to separate file.

Currently it only for StandardButton.

Testing Instructions

Click the toolbar buttons here and there, and make sure all works as expected, as before the patch.

ping @dgrammatiko @wilsonge

@joomla-cms-bot joomla-cms-bot added PR-4.0-dev RFC Request for Comment labels Jun 2, 2018

customElements.define('joomla-toolbar-button', JoomlaToolbarButton);

})(customElements);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Block must not be padded by blank lines padded-blocks


}

customElements.define('joomla-toolbar-button', JoomlaToolbarButton);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected indentation of 2 spaces but found 4 indent


}

}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected indentation of 2 spaces but found 4 indent
Block must not be padded by blank lines padded-blocks

throw new Error('Either "task" or "execute" attribute must be preset to perform an action.');
}

}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected indentation of 4 spaces but found 8 indent
Block must not be padded by blank lines padded-blocks

method.call({});
} else {
throw new Error('Either "task" or "execute" attribute must be preset to perform an action.');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected indentation of 6 spaces but found 12 indent

return;
}

if (this.task) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected indentation of 6 spaces but found 12 indent


if (this.confirmMessage && !confirm(this.confirmMessage)) {
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected indentation of 6 spaces but found 12 indent

}

if (this.confirmMessage && !confirm(this.confirmMessage)) {
return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected indentation of 8 spaces but found 16 indent

return;
}

if (this.confirmMessage && !confirm(this.confirmMessage)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected indentation of 6 spaces but found 12 indent
Unexpected use of 'confirm' no-restricted-globals

executeTask() {
if (this.disabled) {
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected indentation of 6 spaces but found 12 indent

@dgrammatiko
Copy link
Copy Markdown
Contributor

@Fedik can you check Fedik#8

if (this.task) {
Joomla.submitbutton(this.task, this.form, this.formValidation);
} else if (this.execute) {
let method = new Function(this.execute);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'method' is never reassigned. Use 'const' instead prefer-const
The Function constructor is eval no-new-func

return;
}

if (this.confirmMessage && !confirm(this.confirmMessage)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unexpected use of 'confirm' no-restricted-globals


if (this.listSelection) {
if (!this.formElement) {
throw new Error('The form "' + formSelector + '" is required to perform the task, but the form not found on the page.');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unexpected string concatenation prefer-template

this.addEventListener('click', this.executeTask);

// Check whether we have a form
let formSelector = this.form || '#adminForm';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'formSelector' is never reassigned. Use 'const' instead prefer-const


// Bind neccessary functions
this.executeTask = this.executeTask.bind(this);
setDisabled = setDisabled.bind(this);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'setDisabled' is not defined no-undef

constructor() {
super();

// We need a button to support button behavior, because we cannot currently extend HTMLButtonElement
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line 20 exceeds the maximum line length of 100 max-len

* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
(function (customElements) {
"use strict";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Strings must use singlequote quotes

* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
(function (customElements) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Move the invocation into the parens that contain the function wrap-iife
Unexpected unnamed function func-names

@Fedik
Copy link
Copy Markdown
Member Author

Fedik commented Jun 2, 2018

@dgrammatiko thanks

@infograf768
Copy link
Copy Markdown
Member

Did not remark any change in toolbar behavior after patch.

if (this.task) {
Joomla.submitbutton(this.task, this.form, this.formValidation);
} else if (this.execute) {
const method = new Function(this.execute);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The Function constructor is eval no-new-func

return false;
}

if (this.confirmMessage && !confirm(this.confirmMessage)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unexpected use of 'confirm' no-restricted-globals

}
}

executeTask() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected to return a value at the end of method 'executeTask' consistent-return

// Watch on list selection
this.formElement.boxchecked.addEventListener('change', (event) => {
// Check whether we have selected something
this.setDisabled(event.target.value == 0);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected '===' and instead saw '==' eqeqeq

this.setDisabled(true);
}

this.addEventListener('click', e => this.executeTask());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'e' is defined but never used no-unused-vars

// Attribute getters
get task() {return this.getAttribute('task');}
get execute() {return this.getAttribute('execute');}
get listSelection() {return this.hasAttribute('list-selection');}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Requires a space after '{' block-spacing
Multiple spaces found before '{' no-multi-spaces
Requires a space before '}' block-spacing


// Attribute getters
get task() {return this.getAttribute('task');}
get execute() {return this.getAttribute('execute');}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Multiple spaces found before '{' no-multi-spaces
Requires a space after '{' block-spacing
Requires a space before '}' block-spacing

class JoomlaToolbarButton extends HTMLElement {

// Attribute getters
get task() {return this.getAttribute('task');}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Multiple spaces found before '{' no-multi-spaces
Requires a space after '{' block-spacing
Requires a space before '}' block-spacing

;((customElements) => {
'use strict';

class JoomlaToolbarButton extends HTMLElement {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Block must not be padded by blank lines padded-blocks

* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

;((customElements) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unnecessary semicolon no-extra-semi


customElements.define('joomla-toolbar-button', JoomlaToolbarButton);

})(customElements);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Block must not be padded by blank lines padded-blocks

return true;
}

}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Block must not be padded by blank lines padded-blocks

return false;
}

if (this.confirmMessage && !confirm(this.confirmMessage)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unexpected use of 'confirm' no-restricted-globals

// We need a button to support button behavior,
// because we cannot currently extend HTMLButtonElement
this.buttonElement = this.querySelector('button');
this.disabled = false;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Multiple spaces found before '=' no-multi-spaces

get listSelection() {return this.hasAttribute('list-selection');}
get form() {return this.getAttribute('form');}
get formValidation() {return this.hasAttribute('form-validation');}
get confirmMessage() {return this.getAttribute('confirm-message');}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Requires a space after '{' block-spacing
Requires a space before '}' block-spacing

get task() {return this.getAttribute('task');}
get listSelection() {return this.hasAttribute('list-selection');}
get form() {return this.getAttribute('form');}
get formValidation() {return this.hasAttribute('form-validation');}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Requires a space after '{' block-spacing
Requires a space before '}' block-spacing

// Attribute getters
get task() {return this.getAttribute('task');}
get listSelection() {return this.hasAttribute('list-selection');}
get form() {return this.getAttribute('form');}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Requires a space after '{' block-spacing
Requires a space before '}' block-spacing


// Attribute getters
get task() {return this.getAttribute('task');}
get listSelection() {return this.hasAttribute('list-selection');}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Requires a space after '{' block-spacing
Requires a space before '}' block-spacing

class JoomlaToolbarButton extends HTMLElement {

// Attribute getters
get task() {return this.getAttribute('task');}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Requires a space after '{' block-spacing
Requires a space before '}' block-spacing

((customElements) => {
'use strict';

class JoomlaToolbarButton extends HTMLElement {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Block must not be padded by blank lines padded-blocks

return false;
}

if (this.confirmMessage && !confirm(this.confirmMessage)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unexpected use of 'confirm' no-restricted-globals

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this was expected. deal with it :neckbeard:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

told hound to deal with it :)

@wilsonge wilsonge merged commit 402d3f6 into joomla:4.0-dev Jun 13, 2018
@wilsonge
Copy link
Copy Markdown
Contributor

Awesome work! Thanks for being so patient with this one!

@Fedik Fedik deleted the toolbar-button2 branch June 13, 2018 16:13
@zero-24 zero-24 added this to the Joomla 4.0 milestone Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFC Request for Comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants