Help with getting started adding custom view?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • l4k3y
    Junior Member
    • Feb 2024
    • 6

    Help with getting started adding custom view?

    Hi,

    I'm starting to take a look how I can get a custom view on my entity detail template.

    I'm referring to the docs but not sure where I may be going wrong?

    I have the following inside my clientDef:

    HTML Code:
    {
    "controller": "controllers/record",
    "boolFilterList": [
    "onlyMy"
    ],
    "color": "#ffffff",
    "iconClass": "far fa-money-bill-alt",
    "sidePanels": {
    "detail": [
    {
    "name": "testPanel",
    "label": "TestPanel",
    "view": "custom:views/test/test-panel",
    "aclScope": "TestPanel"
    }
    ]
    }
    }​
    I have created client/src/views/test/test-panel.js which includes:

    HTML Code:
    define('custom:views/test/test-panel', ['view'], function (View) {
    return View.extend({
    name: 'test-panel',
    template: 'test/test-panel',
    });
    });
    And I have my tpl file located at client/res/templates/test/test-panel.tpl - which currently only has text inside a div.

    I have cleared cache and rebuilt but I get the following error when viewing my detail template:

    Content-Security-Policy: The page's settings blocked the loading of a resource at inline ("script-src").​
    Uncaught (in promise) Error: Could not fetch asset 'client/custom/src/views/test/test-panel.js?r=1707169764'.​
    Last edited by l4k3y; 02-08-2024, 07:38 PM.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    client/src/views/test/test-panel.js => client/custom/src/views/test/test-panel.js

    The same for template.

    The error message tells by what's wrong.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • l4k3y
      Junior Member
      • Feb 2024
      • 6

      #3
      Thanks Yuri, can't believe I over looked that. Thanks for help.

      I noticed the docs say to have the view as:

      HTML Code:
      define('custom:views/test/test-panel', ['view'], function (View) {
      return View.extend({
      name: 'test-panel',
      template: 'test/test-panel',
      });
      });
      But returned a error saying Dep not defined. I updated to the following:

      HTML Code:
      define('custom:views/test/test-panel', ['view'], function (Dep) {
      return Dep.extend({
      name: 'test-panel',
      template: 'test/test-panel',
      });
      });
      ​
      Is it worth updating the docs here?

      Comment

      • yuri
        Member
        • Mar 2014
        • 8440

        #4
        I updated. It was Dep.protype.setup call. Should be View instead.
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment

        Working...