Skip to content
Snippets Groups Projects
Commit 31a1eb28 authored by catch's avatar catch
Browse files

Issue #293295 by smustgrave, jwilson3, acbramley, pameeela, lendude, nicxvan,...

Issue #293295 by smustgrave, jwilson3, acbramley, pameeela, lendude, nicxvan, daniel korte, izmeez: Pager pagination results should increment ordered list <ol> numbers
parent 174c76f4
No related branches found
No related tags found
2 merge requests!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!10223132456: Fix issue where views instances are emptied before an ajax request is complete
Pipeline #437831 passed with warnings
Pipeline: drupal

#437846

    Pipeline: drupal

    #437843

      Pipeline: drupal

      #437841

        +4
        langcode: en
        status: true
        dependencies:
        module:
        - node
        - user
        id: test_style_html_list_ordered
        label: test_style_html_list_ordered
        module: views
        description: ''
        tag: ''
        base_table: node_field_data
        base_field: nid
        display:
        default:
        id: default
        display_title: Default
        display_plugin: default
        position: 0
        display_options:
        title: test_style_html_list_ordered
        fields:
        title:
        id: title
        table: node_field_data
        field: title
        relationship: none
        group_type: group
        admin_label: ''
        entity_type: node
        entity_field: title
        plugin_id: field
        label: ''
        exclude: false
        alter:
        alter_text: false
        make_link: false
        absolute: false
        word_boundary: false
        ellipsis: false
        strip_tags: false
        trim: false
        html: false
        element_type: ''
        element_class: ''
        element_label_type: ''
        element_label_class: ''
        element_label_colon: false
        element_wrapper_type: ''
        element_wrapper_class: ''
        element_default_classes: true
        empty: ''
        hide_empty: false
        empty_zero: false
        hide_alter_empty: true
        click_sort_column: value
        type: string
        settings:
        link_to_entity: true
        group_column: value
        group_columns: { }
        group_rows: true
        delta_limit: 0
        delta_offset: 0
        delta_reversed: false
        delta_first_last: false
        multi_type: separator
        separator: ', '
        field_api_classes: false
        pager:
        type: full
        options:
        offset: 0
        pagination_heading_level: h4
        items_per_page: 2
        total_pages: null
        id: 0
        tags:
        next: ››
        previous: ‹‹
        first: '« First'
        last: 'Last »'
        expose:
        items_per_page: false
        items_per_page_label: 'Items per page'
        items_per_page_options: '5, 10, 25, 50'
        items_per_page_options_all: false
        items_per_page_options_all_label: '- All -'
        offset: false
        offset_label: Offset
        quantity: 9
        exposed_form:
        type: basic
        options:
        submit_button: Apply
        reset_button: false
        reset_button_label: Reset
        exposed_sorts_label: 'Sort by'
        expose_sort_order: true
        sort_asc_label: Asc
        sort_desc_label: Desc
        access:
        type: perm
        options:
        perm: 'access content'
        cache:
        type: tag
        options: { }
        empty: { }
        sorts: { }
        arguments: { }
        filters: { }
        style:
        type: html_list
        options:
        row_class: ''
        default_row_class: true
        uses_fields: false
        type: ol
        wrapper_class: item-list
        class: ''
        row:
        type: fields
        options:
        default_field_elements: true
        inline: { }
        separator: ''
        hide_empty: false
        query:
        type: views_query
        options:
        query_comment: ''
        disable_sql_rewrite: false
        distinct: false
        replica: false
        query_tags: { }
        relationships: { }
        header: { }
        footer: { }
        display_extenders: { }
        cache_metadata:
        max-age: -1
        contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url.query_args
        - 'user.node_grants:view'
        - user.permissions
        tags: { }
        page_1:
        id: page_1
        display_title: Page
        display_plugin: page
        position: 1
        display_options:
        display_extenders: { }
        path: test-style-html-list-ordered
        cache_metadata:
        max-age: -1
        contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url.query_args
        - 'user.node_grants:view'
        - user.permissions
        tags: { }
        <?php
        declare(strict_types=1);
        namespace Drupal\Tests\views\Functional;
        /**
        * Tests the View HTML List style.
        *
        * @group views
        */
        class ViewStyleHtmlListTest extends ViewTestBase {
        /**
        * Views used by this test.
        *
        * @var array
        */
        public static array $testViews = ['test_style_html_list_ordered'];
        /**
        * {@inheritdoc}
        */
        protected $defaultTheme = 'stark';
        /**
        * {@inheritdoc}
        */
        protected static $modules = ['node'];
        /**
        * {@inheritdoc}
        */
        protected function setUp($import_test_views = TRUE, $modules = ['views_test_config']): void {
        parent::setUp($import_test_views, $modules);
        $this->enableViewsTestModule();
        $this->drupalCreateContentType(['type' => 'page']);
        for ($i = 1; $i < 10; $i++) {
        $this->drupalCreateNode([
        'title' => 'Node ' . $i,
        ]);
        }
        }
        /**
        * Tests ordered list HTML list.
        */
        public function testOrderedList(): void {
        $this->drupalGet('test-style-html-list-ordered');
        // Verify we see the first 2 nodes.
        $this->assertSession()->pageTextContains("Node 1");
        $this->assertSession()->pageTextContains("Node 2");
        $this->assertSession()->elementExists('css', 'ol[start=1]');
        $this->drupalGet('test-style-html-list-ordered', ['query' => ['page' => '1']]);
        // Verify we see the next 2 nodes.
        $this->assertSession()->pageTextContains("Node 3");
        $this->assertSession()->pageTextContains("Node 4");
        $this->assertSession()->elementExists('css', 'ol[start=3]');
        }
        }
        ...@@ -865,12 +865,20 @@ function template_preprocess_views_view_list(&$variables): void { ...@@ -865,12 +865,20 @@ function template_preprocess_views_view_list(&$variables): void {
        $handler = $variables['view']->style_plugin; $handler = $variables['view']->style_plugin;
        // Fetch classes from handler options. // Fetch classes from handler options.
        $variables['list']['attributes'] = new Attribute();
        if ($handler->options['class']) { if ($handler->options['class']) {
        $class = explode(' ', $handler->options['class']); $class = explode(' ', $handler->options['class']);
        $class = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', $class); $class = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', $class);
        // Initialize a new attribute class for $class. // Initialize a new attribute class for $class.
        $variables['list']['attributes'] = new Attribute(['class' => $class]); $variables['list']['attributes']->addClass($class);
        }
        $type = $handler->options['type'];
        if ($type === 'ol') {
        $pager = $variables['view']->getPager();
        $variables['list']['attributes']['start'] = $variables['view']->getCurrentPage() * $pager->options['items_per_page'] + 1;
        } }
        // Fetch wrapper classes from handler options. // Fetch wrapper classes from handler options.
        ...@@ -879,7 +887,7 @@ function template_preprocess_views_view_list(&$variables): void { ...@@ -879,7 +887,7 @@ function template_preprocess_views_view_list(&$variables): void {
        $variables['attributes']['class'] = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', $wrapper_class); $variables['attributes']['class'] = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', $wrapper_class);
        } }
        $variables['list']['type'] = $handler->options['type']; $variables['list']['type'] = $type;
        template_preprocess_views_view_unformatted($variables); template_preprocess_views_view_unformatted($variables);
        } }
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment