Documentation

Component details customization

Details interface customization is a quite a standard objective. Usually, the complete component had to be moved to local (and sometimes, several components), copy it and support.

This process is a little less complex for SPA and Quote updated details.

First, re-define [link=13982576]routing service[/link], as in [link=14018116]previous examples[/link].

use Bitrix\Crm\Service;
use Bitrix\Crm\Service\Router;

class MyContainer extends Service\Container {
    public function getRouter(): Router
    {
        return new class extends Router {
            public function parseRequest(HttpRequest $httpRequest = null): Router\ParseResult {
                $result = parent::parseRequest($httpRequest);
                
                if (!defined('SUPER_ENTITY_TYPE_ID'))
                {
                    return $result;
                }
            
                if ($result->getComponentName() === 'bitrix:crm.item.details')
                {
                    $parameters = $result->getComponentParameters();
                    $entityTypeId = $parameters['ENTITY_TYPE_ID'] ?? $parameters['entityTypeId'] ?? null;
                    if ((int)$entityTypeId === SUPER_ENTITY_TYPE_ID)
                    {
                        $result = new Router\ParseResult(
                            'dev:crm.item.details',
                            $parameters,
                            $result->getTemplateName()
                        );
                    }
                }
            
                return $result;
            }
        };
    }
};

Now, an individual component for rendering details is responsible for a single SPA.

Component class code is very compact, consisting of a single method. The majority of logic is concentrated in [link=14008704]parent class[/link].

Template code is also not very extensive. Complete javascript-code is dedicated to a single JS-extension [link=14009616]crm.item-details-component.[/link].

You can inherit this extension and connect its in the template for your re-defined component.



© «Bitrix24», 2001-2024
Up