7 Replies Latest reply on Aug 6, 2013 4:37 PM by sonny.lau

    where is jive.invite.create being called (overriding invite.soy)

    kathy.nguyen

      In invite.soy there is a .create template where I need to pass in a couple more parameters to display on the 'send invitation' modal that pops up when you click on the "Invite people to join this group" action link, but I cannot track down where this is being called from to do this.

      What I've tried so far is add the params to the data object in socialgroup-actions.ftl where it's calling the jive.invite.jsInit and also added these params in the .jsInit and .create templates in invite.soy to be used, but it's always coming back as undefined.

       

      <@soy.render template="jive.invite.jsInit" data={

          'container_id': '${socialGroup.ID?c}',

         ...

         ...

          'trigger': "#jive-link-inviteToGroup a",

          'trackingID': '',

          'invitationsRemaining': '5',

          'maxAllowedInvitations': '4'

          }/>



      Am I missing something? Any help would be appreciated, thanks much.

        • Re: where is jive.invite.create being called (overriding invite.soy)

          I find that using the following procedure usually helps me find what I'm looking for when I want to override something on the Front end of Jive.

           

          1. Check if the template is being called from within that file, if it is, then you can modify that file and pass your extra parameters.
          2. Next, check if it's being called in any other Soy or Freemarker files.
            1. To do this, you'll need to have an extracted Jive WAR file somewhere.
              • If you have a local development instance of Jive, this will be at <project root directory>\web\target\<project final name>\WEB-INF\classes.
              • You may optionally move into the soy or template directories if you know what you are looking for is definitely a Soy or Freemarker file.
            2. Once you are here, use a tool to search through the directory. I use grep on Windows through the Git Bash terminal.
              • In your case this would be grep -r "jive.invite.create" * which will recursively search through all files in the classes directory to find if jive.invite.create is being called.
              • Any files that are listed here indicate that the string has been found and you should probably take a look at them to see if it's the file you want to modify.
          3. If you still can't find your file, it's likely that it is located as Javascript in the jive-core JAR file. In this case, as far as I know, you'll probably need to make your modifications through the Overlay.
            1. This time, you'll need to either extract the jive-core JAR file somewhere or use an IDE (like IntelliJ) to search through the JAR.
              • It'll be easier if you have the source downloaded if what you're looking for is in a Java class.
            2. In the jive-core extracted directory (or through your IDE), go to <extracted jive-core directory>/resources/scripts and search for jive.invite.create.
              • In this case, this is how I've found the definition to jive.invite.create. It is called in the <jive-core JAR>/resources/scripts/apps/invitation/views/invite_view.js file.
          4. Finally, you can also check the Spring or Struts definitions to see if your template is being called there.
            1. Just simply search through the whole jive-core JAR file for any references in *.xml files.
          1 person found this helpful
            • Re: where is jive.invite.create being called (overriding invite.soy)
              kathy.nguyen

              Hi Sonny,

              Thanks for the thorough steps. I do see the reference to jive.invite.create in the invite_view.js. Looks like I should be able to pass in extra parameters in the protect.initialize, but everything I'm trying does not seem to work =T

               

              protect.initialize = function(){

                          this.invitees = {};

                          this.inviteeLists = {};

                          this.content = this.$template = $j(this.getSoyTemplate(this.params));

                          var view = this;

                          this.$form = this.$template.find("#jive-invite-form");

                          this.autocomplete = new jive.UserPicker.Main({

                              emailAllowed: this.params.inviteEmail,

                              userAllowed: this.params.inviteUsers,

                              ....

                              ....

                              trial: this.params.trial,

                              maxSelectedCount: this.params.maxInviteCount,

                              maxSelectedMessage: $j(jive.invite.maxInvitationsError(this.params)),

                              selectionCallbacks: [this.updateInvitees],

                              $input : this.$template.find("#invitees"),

                              invitationsRemaining: this.params.invitationsRemaining,

                              maxAllowedInvitations: 7,

                              placeholder : " "

                          });

               

              This is the .create template header

              /**

              * @param message The content of the personalized message sent to the user

              * @param container  {name : "string", id : int, type : "string"}

              * @param inviteUsers

              * @param inviteEmail

              * @param trial  Are we in a trial or not?

              * @param systemInvite  Are we inviting users to the system or to a specific place?

              * @param domains

              * @param invitationsRemaining

              * @param maxAllowedInvitations

              * @depends i18nKeys=send.invite.*

              * @depends template=jive.UserPicker.soy.inputPlaceholder

              */

              {template .create}

              <div class="jive-modal j-modal jive-modal-invite" id="jive-modal-invite">

               

              The other part of my question is, what java classes support this invite.soy? Before JIVE 6.0 it was invite.ftl and InviteAction but now these do not exist anymore. There is custom logic that needs to happen when the invitations are sent. Any ideas?

                • Re: Re: where is jive.invite.create being called (overriding invite.soy)

                  I think that in Jive 6 this got moved into it's own little self-contained app so it doesn't have a Java backend that is used to support it; instead I think the Javascript in invite_view.js does that. I know it does talk with an internal service to create the invites though (that's what I was customising when I was looking at this) but I don't think that will help you.

                   

                  After staring at the code for a minute or two, I've noticed you may have made a mistake. You probably want to put invitationsRemaining: this.params.invitationsRemaining, and maxAllowedInvitations: 7, under this.init like (lines 20-21):

                   

                  this.init = function(container, company, domains, allowEmail, allowUsers, canInvitePartners, canInviteJustPartners, canInvitePreprovisioned, invitePreprovisionedDomainRestricted, maxInvite, invitePeriod, message, trial, trigger){
                      this.invitees = {};
                      this.inviteeLists = {};
                      var view = this;
                      this.params = {
                          message : message,
                          container : container,
                          inviteEmail : allowEmail,
                          inviteUsers : allowUsers,
                          canInvitePartners : canInvitePartners,
                          canInviteJustPartners : canInviteJustPartners,
                          canInvitePreprovisioned :  canInvitePreprovisioned,
                          invitePreprovisionedDomainRestricted : invitePreprovisionedDomainRestricted,
                          domains : domains,
                          companyName : company,
                          maxInviteCount : maxInvite,
                          invitePeriodHours : invitePeriod,
                          trial: trial,
                          systemInvite: (container == null || (container.id == 1 && container.type == 'community')),
                          invitationsRemaining: 5,
                          maxAllowedInvitations: 7
                      };
                      this.$trigger = $j(trigger || "#j-invite-button");
                      this.$trigger.click(function(click){
                          view.open();
                          click.preventDefault();
                      });
                  };
                  
                  

                   

                  The line that renders the soy template looks like it is this.content = this.$template = $j(this.getSoyTemplate(this.params)); in protect.initialise so adding your variables to params should do the trick.

                  1 person found this helpful
                    • Re: Re: Re: where is jive.invite.create being called (overriding invite.soy)
                      kathy.nguyen

                      Yeah.. so I kept the params in protect.initialize and added the params in the this.init like you described, but the values still don't pass through correctly, it still shows 'undefined'

                      Then I tried just having the params in this.init (removed them from protect.initialize), but still doesn't work.

                       

                      This is what I've done in invite.soy to try to display the values of the params passed in from this.init and protect.initialize

                       

                      /**
                      * @param message The content of the personalized message sent to the user
                      * @param container  {name : "string", id : int, type : "string"}
                      * @param inviteUsers
                      * @param inviteEmail
                      * @param trial  Are we in a trial or not?
                      * @param systemInvite  Are we inviting users to the system or to a specific place?
                      * @param domains
                      * @param invitationsRemaining
                      * @param maxAllowedInvitations
                      * @depends i18nKeys=send.invite.*
                      * @depends template=jive.UserPicker.soy.inputPlaceholder
                      */
                      {template .create}
                      <div class="jive-modal j-modal jive-modal-invite" id="jive-modal-invite">
                          <div>Number of invitations remaining (max allowed): {$maxAllowedInvitations}</div>
                          <div>Number of invitations remaining: {$invitationsRemaining}</div>
                      ...
                      ...
                      
                      

                       

                      I'm stumped.

                      BTW your experience with customizing the internal service that exists now for creating invites will definitely help because part of the customization I'm working on now will require extra logic to perform on the list of invitees.