Skip to content

Commit

Permalink
Enable preview button on data node type (#4000)
Browse files Browse the repository at this point in the history
  • Loading branch information
janette authored Aug 22, 2023
1 parent cb7fdee commit f0e4418
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
8 changes: 3 additions & 5 deletions cypress/integration/07_admin_dataset_json_form.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ context('Admin dataset json form', () => {
.click({ force: true });
cy.get('input[aria-controls="select2-edit-field-json-metadata-0-value-keyword-keyword-0-results"]').type('open data{enter}')
// End filling up keyword.
cy.wait(2000)
cy.get('#edit-actions').within(() => {
cy.get('#edit-preview').should('not.exist')
cy.get('#edit-preview').should('exist')
})
cy.get('#edit-submit').click({ force:true })
cy.get('.button').contains('Yes').click({ force:true });
Expand All @@ -73,9 +74,6 @@ context('Admin dataset json form', () => {
cy.get('#edit-field-json-metadata-0-value-distribution-distribution-0-distribution-title').type('DKANTEST distribution title text', { force:true })
cy.get('#edit-field-json-metadata-0-value-distribution-distribution-0-distribution-description').type('DKANTEST distribution description text', { force:true })
cy.get('#edit-field-json-metadata-0-value-distribution-distribution-0-distribution-format-select').select('csv', { force:true })
cy.get('#edit-actions').within(() => {
cy.get('#edit-preview').should('not.exist')
})
cy.get('#edit-submit').click({ force:true })
cy.get('.button').contains('Yes').click({ force:true });
cy.get('.messages--status').should('contain','has been updated')
Expand All @@ -87,7 +85,7 @@ context('Admin dataset json form', () => {
cy.get('#edit-submit--2').click({ force:true })
cy.get('.button').contains('Yes').click({ force:true });
cy.get('input[value="Delete"]').click({ force:true })
cy.get('.messages').should('contain','Deleted 1 content item.')
cy.get('.messages__content').should('contain','Deleted 1 content item.')
})

})
2 changes: 1 addition & 1 deletion modules/metastore/config/install/node.type.data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ type: data
description: ''
help: ''
new_revision: true
preview_mode: 0
preview_mode: 1
display_submitted: true
8 changes: 8 additions & 0 deletions modules/metastore/metastore.install
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,11 @@ function metastore_update_8006() {
$index_settings->set('processor_settings.dkan_dataset_filter_unpublished', []);
$index_settings->save();
}

/**
* Restore the preveiw button on data form.
*/
function metastore_update_8007() {
$config = \Drupal::service('config.factory')->getEditable('node.type.data');
$config->set('preview_mode', 1)->save();
}
14 changes: 8 additions & 6 deletions modules/metastore/templates/node--data.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@
{% if page %}
<p>Last updated: {{ dataset.modified|date("m/d/Y") }}</p>
{{ dataset.description | drupal_escape }}
{% if dataset.distributions|length > 0 %}
<h2>Downloads</h2>
<ul>
{% for distribution in dataset.distributions %}
<li><a href="{{distribution.downloadURL}}">{{distribution.title}} ({{distribution.format}})</a></li>
{% endfor %}
</ul>
{% endif %}
{% if dataset.themes|length > 1 %}
<h2>Themes</h2>
{% elseif dataset.themes|length == 1 %}
Expand All @@ -118,12 +126,6 @@
<li>{{ theme }}</li>
{% endfor %}</ul>
{% endif %}
<h2>Downloads</h2>
<ul>
{% for distribution in dataset.distributions %}
<li><a href="{{distribution.downloadURL}}">{{distribution.title}} ({{distribution.format}})</a></li>
{% endfor %}
</ul>
{% if dataset.keywords|length > 1 %}
<h2>Keywords</h2>
{% elseif dataset.keywords|length == 1 %}
Expand Down

0 comments on commit f0e4418

Please sign in to comment.