Open full form directly when add

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • scratch
    Junior Member
    • Sep 2016
    • 15

    Open full form directly when add

    Hello all!
    i need a little help for change a default settings.
    When i'm inside a Company or offers or some other, is possible to go directly to the full form without having the small form before when adding a new "sub-info"?
    i add an image for better understand what i mean


    Many thanks!

    p.s.
    i see at /client/src/views/record/list.js
    at line 200 and 202
    200 - quickDetailDisabled: false,
    202 - quickEditDisabled: false,
    i maybe have to change it to "true"?
    Last edited by scratch; 03-30-2017, 12:16 PM.
  • scratch
    Junior Member
    • Sep 2016
    • 15

    #2
    please, someone can help me?

    Comment

    • tanya
      Senior Member
      • Jun 2014
      • 4308

      #3
      Hi
      the main code is in client/src/views/detail.js, method actionCreateRelated
      you can change the path to your file in clientDefs of entity or change this file, if you want modify the logic for whole crm (but this way is not upgrade safe)

      Comment

      • scratch
        Junior Member
        • Sep 2016
        • 15

        #4
        Hi and sorry if i reply again to this post but after many time this is the last one editing than i need to do.
        i see your last post and i try to edit this in client/src/views/detail.js;

        PHP Code:
        this.notify('Loading...');
        
        var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') || 'views/modals/edit';
        this.createView('quickCreate', viewName, {
        scope: scope,
        relate: {
        model: this.model,
        link: foreignLink,
                        }, 
        

        i have to edit 'quickCreate' to 'Create' or 'fullCreate' 'but the small form are showed again.
        Can you please help me to edit this ?

        Many thanks

        p.s.
        i have also found this post: http://forum.espocrm.com/forum/devel...-form-directly but the solution are not available for the latest version
        Last edited by scratch; 10-17-2017, 03:17 PM.

        Comment

        • tanya
          Senior Member
          • Jun 2014
          • 4308

          #5
          instead of creating view, route to entity creating
          here you can see, how to do this
          /client/src/views/modals/edit.js actionFullForm

          Comment

          • manuel7b
            Member
            • Sep 2017
            • 33

            #6
            I am facing a similar problem.

            I modified actionCreateRelated in client/src/view/detail.js. Instead of creating the view, I added this:

            PHP Code:
            var url = '#' + scope + '/create';
            var router = this.getRouter();
            
            attributes = _.extend(attributes, this.model.getClonedAttributes());
            
            router.dispatch(scope, 'create', {
              attributes: attributes,
              relate: this.options.relate
            });
            
            router.navigate(url, {trigger: false}); 
            
            The problem is, for instance, when trying to create a new Task from the relationship panel in Meeting. I can see the full form straight away, but the Meeting field in Task create page is empty.

            Comment

            • manuel7b
              Member
              • Sep 2017
              • 33

              #7
              I think I fixed it with this:

              PHP Code:
              
              var url = '#' + scope + '/create';
              var router = this.getRouter();
              
              attributes = _.extend(attributes, this.model.getClonedAttributes());
              
              router.dispatch(scope, 'create', {
                 attributes: attributes,
                 relate: {
                         model: this.model,
                         link: foreignLink,
                 }
              }); 
              

              Comment

              • scratch
                Junior Member
                • Sep 2016
                • 15

                #8
                Hi manuel7b,
                Tnx at all for reply. i try to edit this from a lot of time but without succes.
                i'm not good with js but i try your method and edit client/src/view/detail.js from this:

                PHP Code:
                       actionCreateRelated: function (data) {
                            data = data || {};
                
                            var link = data.link;
                            var scope = this.model.defs['links'][link].entity;
                            var foreignLink = this.model.defs['links'][link].foreign;
                
                            var attributes = {};
                
                
                            if (this.relatedAttributeFunctions[link] && typeof this.relatedAttributeFunctions[link] == 'function') {
                                attributes = _.extend(this.relatedAttributeFunctions[link].call(this), attributes);
                            }
                
                            Object.keys(this.relatedAttributeMap[link] || {}).forEach(function (attr) {
                                attributes[this.relatedAttributeMap[link][attr]] = this.model.get(attr);
                            }, this);
                
                
                
                            this.notify('Loading...'); 
                
                to this:

                PHP Code:
                        actionCreateRelated: function (data) {
                            data = data || {};
                
                            var link = data.link;
                            var scope = this.model.defs['links'][link].entity;
                            var foreignLink = this.model.defs['links'][link].foreign;
                
                            var attributes = {};
                
                
                            if (this.relatedAttributeFunctions[link] && typeof this.relatedAttributeFunctions[link] == 'function') {
                                attributes = _.extend(this.relatedAttributeFunctions[link].call(this), attributes);
                            }
                
                            Object.keys(this.relatedAttributeMap[link] || {}).forEach(function (attr) {
                                attributes[this.relatedAttributeMap[link][attr]] = this.model.get(attr);
                            }, this);
                
                            var url = '#' + scope + '/create';
                            var router = this.getRouter();
                
                            attributes = _.extend(attributes, this.model.getClonedAttributes());
                
                            router.dispatch(scope, 'create', {
                            attributes: attributes,
                            relate: {
                            model: this.model,
                            link: foreignLink,
                   }
                });  
                            this.notify('Loading...'); 
                

                Now i see instantly the full form when i click ok "+" for example in the single company page, i see the attributes are pick from original but when i try to save i get: "Error 404: Not found"



                you don't have this problem?
                Many thanks again

                Comment

                • manuel7b
                  Member
                  • Sep 2017
                  • 33

                  #9
                  You're right, I have the same problem.

                  Hopefully, tanya can help us here.

                  Comment

                  • manuel7b
                    Member
                    • Sep 2017
                    • 33

                    #10
                    scratch, I fixed it. Just remove this line and try again:

                    PHP Code:
                    attributes = _.extend(attributes, this.model.getClonedAttributes()); 
                    

                    Comment

                    • scratch
                      Junior Member
                      • Sep 2016
                      • 15

                      #11
                      yes now save
                      but sometimes i get a mixed layout like this:



                      I think that we need to remove something in the original code.

                      Comment

                      • manuel7b
                        Member
                        • Sep 2017
                        • 33

                        #12
                        That's not happening to me, so far. I don't know how to help you, to be honest. Not that great with JS either. :-)

                        Comment

                        • scratch
                          Junior Member
                          • Sep 2016
                          • 15

                          #13
                          ok i try to edit it again and if i remove some code the problem was solved.
                          But i don't know if is a best solution

                          Before:
                          PHP Code:
                          actionCreateRelated: function (data) {
                                      data = data || {};
                          
                                      var link = data.link;
                                      var scope = this.model.defs['links'][link].entity;
                                      var foreignLink = this.model.defs['links'][link].foreign;
                          
                                      var attributes = {};
                          
                          
                                      if (this.relatedAttributeFunctions[link] && typeof this.relatedAttributeFunctions[link] == 'function') {
                                          attributes = _.extend(this.relatedAttributeFunctions[link].call(this), attributes);
                                      }
                          
                                      Object.keys(this.relatedAttributeMap[link] || {}).forEach(function (attr) {
                                          attributes[this.relatedAttributeMap[link][attr]] = this.model.get(attr);
                                      }, this);
                          /*    */
                                      var url = '#' + scope + '/create';
                                      var router = this.getRouter();
                          
                                      attributes = _.extend(attributes, this.model.getClonedAttributes());  
                          
                          
                                      router.dispatch(scope, 'create', {
                                      attributes: attributes,
                                      relate: {
                                      model: this.model,
                                      link: foreignLink,
                             }
                          });  
                          
                          
                                      this.notify('Loading...');
                          
                                      var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') || 'views/modals/edit';
                                      this.createView('quickCreate', viewName, {
                                          scope: scope,
                                          relate: {
                                              model: this.model,
                                              link: foreignLink,
                                          },
                                          attributes: attributes,
                                      }, function (view) {
                                          view.render();
                                          view.notify(false);
                                          this.listenToOnce(view, 'after:save', function () {
                                              this.updateRelationshipPanel(link);
                                              this.model.trigger('after:relate');
                                          }, this);
                                      }.bind(this));
                                  }, 
                          


                          After:
                          PHP Code:
                                  actionCreateRelated: function (data) {
                                      data = data || {};
                          
                                      var link = data.link;
                                      var scope = this.model.defs['links'][link].entity;
                                      var foreignLink = this.model.defs['links'][link].foreign;
                          
                                      var attributes = {};
                          
                          
                                      if (this.relatedAttributeFunctions[link] && typeof this.relatedAttributeFunctions[link] == 'function') {
                                          attributes = _.extend(this.relatedAttributeFunctions[link].call(this), attributes);
                                      }
                          
                                      Object.keys(this.relatedAttributeMap[link] || {}).forEach(function (attr) {
                                          attributes[this.relatedAttributeMap[link][attr]] = this.model.get(attr);
                                      }, this);
                          /*    */
                                      var url = '#' + scope + '/create';
                                      var router = this.getRouter();
                          
                          
                                      router.dispatch(scope, 'create', {
                                      attributes: attributes,
                                      relate: {
                                      model: this.model,
                                      link: foreignLink,
                             }
                          });  
                          
                          
                                      var viewName = this.getMetadata().get('clientDefs.' + scope ) || 'views/modals/edit';
                                      this.createView('quickCreate', viewName, {
                                          scope: scope,
                                          relate: {
                                              model: this.model,
                                              link: foreignLink,
                                          },
                                          attributes: attributes,
                                      }, function (view) {
                                          view.render();
                                          view.notify(false);
                                          this.listenToOnce(view, 'after:save', function () {
                                              this.updateRelationshipPanel(link);
                                              this.model.trigger('after:relate');
                                          }, this);
                                      }.bind(this));
                                  }, 
                          

                          for fix I remove "+ '.modalViews.edit'" in the var viewName.

                          Comment

                          • manuel7b
                            Member
                            • Sep 2017
                            • 33

                            #14
                            I am not creating the view at all though. I completely removed this code:

                            PHP Code:
                            var viewName = this.getMetadata().get('clientDefs.' + scope ) || 'views/modals/edit';
                                        this.createView('quickCreate', viewName, {
                                            scope: scope,
                                            relate: {
                                                model: this.model,
                                                link: foreignLink,
                                            },
                                            attributes: attributes,
                                        }, function (view) {
                                            view.render();
                                            view.notify(false);
                                            this.listenToOnce(view, 'after:save', function () {
                                                this.updateRelationshipPanel(link);
                                                this.model.trigger('after:relate');
                                            }, this);
                                        }.bind(this)); 
                            

                            Comment

                            • scratch
                              Junior Member
                              • Sep 2016
                              • 15

                              #15
                              yes i have do the same now and work !
                              i maybe think this is the best solution

                              Comment

                              Working...