-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert one event subscriber to another
- Loading branch information
1 parent
8c96385
commit a60b120
Showing
4 changed files
with
37 additions
and
51 deletions.
There are no files selected for viewing
26 changes: 15 additions & 11 deletions
26
docroot/modules/custom/va_gov_api/js/json-schemas-table-filter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
/** | ||
* Attach a behavior to filter out unwanted schemas for OpenAPI UI viewing. | ||
*/ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
// Get all the rows in the table body. | ||
const rows = document.querySelectorAll('#block-vagovclaro-content table tbody tr'); | ||
(function ($, Drupal, drupalSettings) { | ||
Drupal.behaviors.vaGovJsonSchemasTableFilter = { | ||
attach: function (context, settings) { | ||
// Get all the rows in the table body. | ||
const rows = document.querySelectorAll('#block-vagovclaro-content table tbody tr'); | ||
|
||
rows.forEach(function (row) { | ||
// Get the first cell (td) of the row, which contains the schema label. | ||
const schemaLabel = row.cells[0]; | ||
rows.forEach(function(row) { | ||
// Get the first cell (td) of the row, which contains the schema label. | ||
const schemaLabel = row.cells[0]; | ||
|
||
// Remove all but 'VA.gov JSON:API'. | ||
if (schemaLabel.textContent.trim() !== 'VA.gov JSON:API') { | ||
row.remove(); | ||
// Remove all but 'VA.gov JSON:API'. | ||
if (schemaLabel.textContent.trim() !== 'VA.gov JSON:API') { | ||
row.remove(); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
})(jQuery, Drupal, drupalSettings); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
json_schemas_table_filter: | ||
version: 1.x | ||
js: | ||
js/json-schemas-table-filter.js: {} | ||
dependencies: | ||
- core/jquery | ||
- core/drupal | ||
- core/drupalSettings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters