Problem with custom views

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Darkcromb
    Member
    • Aug 2019
    • 40

    Problem with custom views

    Hello,

    I would like to create a custom view for the "call" entity.
    I have read the documentations, the different posts on the forum but it still doesn't work!
    I would like to change the detail page of the call entity to show an additional item below "Print in PDF".

    Click image for larger version

Name:	thumb_8618.png
Views:	392
Size:	2.7 KB
ID:	88255
    I created my new details.js file and put it in :
    client/custom/src/views/call/record
    where I added in the define :
    define('custom:views/call/record/detail', ['views/record/base', 'view-record-helper', 'helpers/action-item-setup'],

    In custom/Espo/Custom/Resources/metadata/clientsDefs/Call.json I added :
    },
    "recordViews": {
    "detail": "custom:views/call/record/detail"
    },

    I did a rebuild, but when I click on a record, I get a 404 error.
    Where did I go wrong?


    Thanks!​
  • Kharg
    Senior Member
    • Jun 2021
    • 410

    #2
    Hi,

    if you just want to add a custom dropdown to detail action list then it would be just better to define the dropdown in the metadata and create a custom action handler instead of defining a full custom view.

    Comment

    • Darkcromb
      Member
      • Aug 2019
      • 40

      #3
      Thank you, I will try that.
      In fact, I want to create a new item that opens the email modal and allows you to send the contents of the call by email, similar to printing by PDF.​

      Comment


      • esforim
        esforim commented
        Editing a comment
        Hope you share your success
    • Kharg
      Senior Member
      • Jun 2021
      • 410

      #4
      Oh, it's not that hard to develop, if you ever get stuck just write back!

      Comment

      • Darkcromb
        Member
        • Aug 2019
        • 40

        #5
        Thanks again.

        I added my
        Code:
        "detailActionList": [
                    "__APPEND__",
                    {
                        "label": "Envoyer par email",
                        "name": "modalemail",
                        "acl": "edit",
                        "data": {
                            "handler": "custom:modalemail-handler"
                        },
                        "initFunction": "initModalemail"
                    }
                ],​
        in Call.json

        and created modalemail-handler.js
        with :

        Code:
        actionModalemail: function (data,e) {
                    this.createView('composeEmail', 'views/modals/select-template', {
                        entityType: this.model.name
                    }, function (view) {
                        view.render();
                        this.listenToOnce(view, 'select', function (model) {
                            this.notify('Loading...');
                            this.ajaxPostRequest('action/getAttributesForEmail', {
                                callId: this.model.id,
                                templateId: model.id
                            }).done(function (attributes) {
                                var viewName = this.getMetadata().get('clientDefs.Email.modalViews.compose') || 'views/modals/compose-email';
                                this.createView('composeEmail', viewName, {
                                    attributes: attributes,
                                    keepAttachmentsOnSelectTemplate: true
                                }, function (view) {
                                    view.render();
                                    this.notify(false);
                                }, this);
                            }.bind(this));
                        }, this);
                    }, this);
                },​
        The item appears well but nothing happens for the moment, my function does not work.​

        Comment


        • Kharg
          Kharg commented
          Editing a comment
          I'll make a working handler for you in some hours.
          Should the Email subject be the call title and the email body be the call description?
      • Darkcromb
        Member
        • Aug 2019
        • 40

        #6
        Thank you so much !
        Yes, just for the email subject but no need for the body.
        I'd just like the email panel to open and then just select a pre-defined email template manually.

        Comment

        • Kharg
          Senior Member
          • Jun 2021
          • 410

          #7
          Call.json
          PHP Code:
          {
              "detailActionList": [
                  "__APPEND__",
                  {
                      "label": "Envoyer par email",
                      "name": "ModalEmail",
                      "acl": "edit",
                      "data": {
                          "handler": "custom:modalemail-handler"
                      }
                  }
              ]
          }
          modalemail-handler.js

          PHP Code:
          define('custom:modalemail-handler', ['action-handler'], function (Dep) {
          
             return Dep.extend({
          
          
           actionModalEmail: function() {
             this.view.notify('Loading...');
             var attributes = {};
             attributes.name = this.view.model.get('name');
             attributes.subject = this.view.model.get('name');
             attributes.parentId = this.view.model.get('id');
             attributes.isHtml = true;
             attributes.parentType = "Call";
             attributes.parentName = this.view.model.get('name');
             var viewName = this.getMetadata().get('clientDefs.Email.modalviews.compose') || 'views/modals/compose-email';
             this.view.createView('quickCreate', viewName, {
                 scope: 'Email',
                 attributes: attributes,
            }, function (view) {
                 view.render();
                 view.notify(false);
                 view.listenToOnce(view, 'after:save', () => {
                   this.view.model.fetch();
                 });
           }.bind(this));
           }
                });
          });

          Comment

          • Darkcromb
            Member
            • Aug 2019
            • 40

            #8
            It works perfectly!
            Thanks a lot for your help!
            For exercise, I will try to integrate it as an extension.
            Thanks again.​

            Comment


            • Kharg
              Kharg commented
              Editing a comment
              Oh, If you told me sooner I would have done it as an extension, I am glad it’s working fine for you.
          • Darkcromb
            Member
            • Aug 2019
            • 40

            #9
            Thank you!
            But I'm taking this as an exercise and I just passed!
            Now I'm still going to try to figure out why I can't make custom views.
            I must have missed something!
            Thanks again for your help.​

            Comment

            Working...