Skip to content

Add priority to jahiaComponent definition to break a tie between several matching templates/views #39

@hduchesne

Description

@hduchesne
Old ticket

Environment and versions used

Jahia 8.2 latest
javascript-modules-engin 0.3.0

Steps to reproduce

In luxe create a content template for jmix:mainResource like this one :

import React from 'react';
import {defineJahiaComponent, Render, useServerContext} from '@jahia/javascript-modules-library';
import {MainLayout} from '../../layouts';

export const MainRessourceDefault = () => {
    const {currentNode} = useServerContext();
    return (
        <MainLayout>
            <Render node={currentNode} view="fullPage"/>
        </MainLayout>

    );
};

MainRessourceDefault.jahiaComponent = defineJahiaComponent({
    nodeType: 'jmix:mainResource',
    name: 'default',
    displayName: 'Default Main Resource',
    componentType: 'template'
});

Current Behavior

This new content template for jmix:mainResource is used prior the content template for luxe:agency (https://github.com/Jahia/luxe-jahia-demo/blob/main/src/server/templates/agency/AgencyDefault.jsx) or any other content type with jmix:mainResource.

To start investigation : https://github.com/Jahia/javascript-modules/blob/6ca44ec37b3f0ca9bd9b37eb7bb8d63af[…]odules/javascript/modules/engine/registrars/ViewsRegistrar.java

Image

Desired Behavior

The jmix:mainResource template should be a fallback. The content template of the mainNodeType should be used prior the one of the mixin.

Image

New component definition property: priority

Works like CSS z-index: the biggest number wins. When not defined, value is 0. Negative numbers can be used to reduce priority.

This decides what template should be rendered when several match for a resource given.

TODO:

  • New property in jahiaComponent definition
  • Proper JSDoc definition
  • Automated tests
  • Make MainResource template in Hello World -1 priority + comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions