11 Replies Latest reply on Jun 28, 2016 10:55 PM by bharatpec

    Setting Default Tile Config Values

    tyishikawa

      Hi, I'm trying to create a custom tile with configuration and would like to know how to set default values for the options. I've followed the instructions given at Creating Custom View Tiles. The way this handles default data works in most cases. However, a problem comes up if the user placing a tile decides to click outside of the config page instead of clicking the "Submit" button. In this case, strings get assigned to the empty string and numbers get assigned to 0. I would like to set default values so this does not happen. How can I pre-set the config values for this tile? Thank you.

        • Re: Setting Default Tile Config Values
          bharatpec

          Let's take the case where user clicks outside of the iframe and closes it.

           

          According to the docs:

           

          In order to pass configuration information to your view, you need to call jive.tile.close with a configuration object. This object must contain a "data" object within it. Everything in that data object gets passed into your view function. For example:

           

           

           

          1. "data": { 
          2.     "config" : "data", 
          3.     "goes" : "here" 
          4.                     

           

          I. In docs, it's written that to close the configuration and pass config's information to your tile's view, you need to call jive.tile.close in config's logic. Please see if it also gets called when user decides to click outside of the config's page. If this happens, manipulate the 'data' inside this function.

           

          II. If the above approach fails, you can try one thing.

          This 'data.config' is read when your tile is initialized. Just manipulate this data field while initializing your tile and add default values
          Example: this.configString = data.configString || "I'm taking default string if this string is empty"

           

          B.

            • Re: Setting Default Tile Config Values
              tyishikawa

              1. jive.tile.close is not called when clicked outside the config page (or, if it is, it's called with an empty object and the call is not available to be modified)

               

              2. When do you suggest setting the config value? On the configuration page or when the actual tile loads?

                • Re: Setting Default Tile Config Values
                  bharatpec

                  In the 2nd approach, try setting the default values on actual tile load. Does that work? I reckon that you're facing issues on tile load when values are null or 0. Try doing this on tile load to avoid that.

                    • Re: Setting Default Tile Config Values
                      tyishikawa

                      I have considered this approach, but the issue is that since the data isn't being written, I have to hardcode this default value twice (once in the config and once in the view). This seems like a bad approach, because if I ever need to change these default values, I have to make sure to change them in two different files and ensure that they are the same.

                       

                      By the way, can I ask how much experience you have with building custom Jive tiles? If you have any previous experience, I'd appreciate it if I could message you with a few questions.

                • Re: Setting Default Tile Config Values
                  bharatpec

                  We've made some tiles here in our organization. We are also into Jive application development. We use purely javascript frameworks (AngularJS and jQuery) for front end and node.js in back end.
                  Please pm me if you think I can help you. I'll try my best.

                   

                  Thanks, Bharat.

                  • Re: Setting Default Tile Config Values
                    bharatpec

                    What I've done is:

                    1. Create a route (app folder) [In tiles > sampletile-app-simple > backend > routes > getHardcodedDefaultValues]

                    2. In your tile's front end script, call this route.

                    osapi.http.get({
                            href: "localhost:9000/sampletile-app-simple/getHardcodedDefaultValues",
                            'refreshInterval': 0
                        }).execute(function(response) {
                              //You will get your default values (which you send from the back end)
                        })
                    

                     

                    Please note that we are using node.js back end. (get.js file)

                     

                    exports.route = function(req, res) {
                         var data = {/* Set of values */}
                         res.send({'data':data})
                    }
                    

                     

                    Bharat.