custom link-multiple-role field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cossplay
    Junior Member
    • Aug 2021
    • 18

    custom link-multiple-role field

    Hello!

    I rewrited the link-multiple-role.js view client/src/views/fields/link-multiple-with-role.js. But i dont know how to put my customed view to custom folder.

    Where i need to write path to my customed view? I tried to write it like others customed fields in custom/Espo/Custom/Resources/metadata/fields/link-multiple-with-role.json but this doesnt work.

    Thanks for any replies.



  • telecastg
    Active Community Member
    • Jun 2018
    • 907

    #2
    Hello,

    These are the steps to take if you would like to customize the script client/src/views/fields/link-multiple-with-role,js

    1) create file client/custom/src/views/fields/link-multiple-with-role.js (never modify the base code because any changes will be wiped out in the next update) and write there any customizations like this:
    Code:
    define('custom:views/fields/link-multiple-with-role', 'views/fields/link-multiple-with-role', function (Dep) {
        return Dep.extend({
    
        WRITE YOUR CUSTOM CODE HERE
    
        );}
    
    });
    2) You have the option to specify the custom view directly for any field at a parent entity's custom entityDefs metadata file, for example to use it for the field "leads" in Meeting entity
    custom/Espo/Custom/Resources/metadata/entityDefs/Meeting.json
    Code:
    {
        "fields": {
            "leads": {
                "type": "linkMultiple",
                "view": "custom:views/fields/link-multiple-with-role",
                "layoutDetailDisabled": true,
                "layoutListDisabled": true,
                "columns": {
                    "status": "acceptanceStatus"
                },
                "additionalAttributeList": ["columns"],
                "orderBy": "name"
            }
        }
    }
    3) Or use your custom view as "extend from" reference to define another custom view like this
    client/custom/src/views/meeting/fields/attendees.js
    Code:
    define('custom:views/meeting/fields/attendees', 'custom:views/fields/link-multiple-with-role', function (Dep) {
    return Dep.extend({
    
            WRITE ADDITIONAL CUSTOM CODE HERE
    
        );}
    
    });
    and then use this reference (client/custom/src/views/meeting/fields/attendees.js) in the parent entity's entityDefs metadata script as done in step 2 above

    The metadata "fields" definitions like application/Espo/Resources/metadata/fields/linkMultiple.json are used by Espo to describe the specifications of fields or links to include (core or custom) when defining a custom entity through the Admin panel.
    Last edited by telecastg; 08-30-2021, 05:42 PM.

    Comment


    • cossplay
      cossplay commented
      Editing a comment
      Everything works! Thank you!

    • telecastg
      telecastg commented
      Editing a comment
      You're welcome
  • dimyy
    Active Community Member
    • Jun 2018
    • 569

    #3
    For existing field jsonObject:
    /application/Espo/Modules/jsonObjectViewer/Resources/metadata/fields/jsonObject.json
    Code:
    {
    "view": "jsonObjectViewer:views/fields/json-object"
    }
    work fine

    Comment


    • telecastg
      telecastg commented
      Editing a comment
      If you specify a customized "view" in a field metadata definition, then ALL entities using that type of field will by default use the modified not the original view, unless otherwise specified in the parent entity's entityDefs metadata file.

      So, unless you are trying to customize a field type for application wide purposes, it is better practice to atomize the changes to the specific entity or module in which you want to use the modifications.

      Lastly, the question referred to the link-multiple-with-role.js view which does not have a field metadata definition, this view is extended from the link-multiple.js field class which has a "type" defined as "linkMultiple" and that type is defined in application/Espo/Resources/metadata/fields/linkMultiple.json

      If cossplay was to modify this file (application/Espo/Resources/metadata/fields/linkMultiple.json) and specify a custom view there, then ALL linkMultiple fields, not just link-multiple-with-role fields would use his/hers custom view.
      Last edited by telecastg; 08-30-2021, 05:40 PM.
Working...