Skip to content

Commit

Permalink
Refactoring and improving validation error handling (#2285)
Browse files Browse the repository at this point in the history
Refactoring and improving validation error handling
  • Loading branch information
swissspidy authored May 15, 2019
2 parents c195425 + 6978673 commit b1993bf
Show file tree
Hide file tree
Showing 50 changed files with 2,279 additions and 2,207 deletions.
733 changes: 366 additions & 367 deletions assets/src/amp-validation/amp-validated-url-post-edit-screen.js

Large diffs are not rendered by default.

48 changes: 14 additions & 34 deletions assets/src/amp-validation/amp-validated-urls-index.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,14 @@
/* exported ampValidatedUrlsIndex */

const ampValidatedUrlsIndex = ( function() { // eslint-disable-line no-unused-vars
const component = {
classes: {},
};

/**
* The class for the new status
*
* @type {string}
*/
component.classes.new = 'new';

/**
* Boot.
*/
component.boot = function boot() {
component.highlightRowsWithNewStatus();
};

/**
* Highlight rows with new status.
*/
component.highlightRowsWithNewStatus = function highlightRowsWithNewStatus() {
document.querySelectorAll( 'tr[id^="post-"]' ).forEach( function( row ) {
if ( row.querySelector( 'span.status-text.' + component.classes.new ) ) {
row.classList.add( 'new' );
}
} );
};

return component;
}() );
/**
* WordPress dependencies
*/
import domReady from '@wordpress/dom-ready';

const CLASS_NAME = 'new';

domReady( () => {
document.querySelectorAll( 'tr[id^="post-"]' ).forEach( function( row ) {
if ( row.querySelector( 'span.status-text.' + CLASS_NAME ) ) {
row.classList.add( CLASS_NAME );
}
} );
} );
10 changes: 3 additions & 7 deletions assets/src/amp-validation/amp-validation-detail-toggle.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
/**
* External dependencies
*/
import { detailToggleBtnAriaLabel, sourcesToggleBtnAriaLabel } from 'amp-validation-i18n';

/**
* WordPress dependencies
*/
import domReady from '@wordpress/dom-ready';
import { __ } from '@wordpress/i18n';

const OPEN_CLASS = 'is-open';

Expand Down Expand Up @@ -80,7 +76,7 @@ function addTermListTableRowClasses() {
}

domReady( () => {
addToggleButtons( 'th.column-details.manage-column', detailToggleBtnAriaLabel )
addToggleButtons( 'th.column-details.manage-column', __( 'Toggle all details', 'amp' ) )
.forEach( ( btn ) => {
addToggleAllListener( {
btn,
Expand All @@ -89,7 +85,7 @@ domReady( () => {
} );
} );

addToggleButtons( 'th.manage-column.column-sources_with_invalid_output', sourcesToggleBtnAriaLabel )
addToggleButtons( 'th.manage-column.column-sources_with_invalid_output', __( 'Toggle all sources', 'amp' ) )
.forEach( ( btn ) => {
addToggleAllListener( {
btn,
Expand Down
Loading

0 comments on commit b1993bf

Please sign in to comment.