Adding an intent to a widget from JavaScript

23 views
Skip to first unread message

Marc Landry

unread,
Jan 6, 2015, 3:59:09 PM1/6/15
to
Hi all,

We currently are in the process of developing a widget that may behave in slightly different ways depending on the connected user. In particular, there is a case where it would be great to have the widget able to manage an extra intent for a given user group.

As of now, I tried to make the modifications to the widget using OWF.Preferences.updateAndDeleteWidgets, like so:

OWF.Preferences.updateAndDeleteWidgets({
    widgetsToUpdate
:[{
        guid
: 'c1aee75e-f29e-0060-0806-b46141fd5e28',
        intents
: {
           
// Replace the existing list of intents, for testing purposes
            receive
: [{
                action
: 'a.new.action.for.user.only',
                dataTypes
: ['a.relevant.datatype']
           
}]
       
}
   
}],
    widgetGuidsToDelete
:[],
    updateOrder
:false,
    onSuccess
: function (e) {
        console
.log('success');

       
// Check that the modifications were properly saved
        OWF
.Preferences.getWidget({
            widgetId
: 'c1aee75e-f29e-0060-0806-b46141fd5e28',
            onSuccess
: function (result) {
                console
.log(result.value.intents.receive.length);
           
}
       
});
   
},

    onFailure
: function (e) {
        console
.log('failure');
   
}
});



The method call succeeds. However, the specified intents seem to be ignored. The console always logs 0 in the success callback of OWF.Preferences.getWidget rather than the expected value of 1. 

Is it possible to modify the list of managed intents using this technique? If not, is there another way to do it? Does Ozone event consider user preferences when filtering the list of widgets that can respond to an intent, or if it only uses the general widget definition?

Thanks!

Tina

unread,
Jan 8, 2015, 11:24:27 PM1/8/15
to ozonepla...@googlegroups.com
Ozone considers the list of widgets available to the current user which can respond to the intent, given the widget definition.  It does not otherwise consider preferences.   

Propose that you may want to wire up the intents overall, and make your decision to fire at run-time, rather than attempt to rewire the intents on the fly.  The code above, if it were working, would impact the intents information overall and thus impact other users in the system at the same time.  You'd have no way to isolate its effects to just the user with the permissions that you need. 

Another possibility is to have two versions of the widget, one granted to your one group of users, and one to another.  This would accomplish the effect of letting you have an extra intent in one group's case.  Well recognize that that has its own issues....   suspect those could be handled by things like WebPacker or things which bring in Javascript modules so that you can build your two versions of the widget consistently...

Tina







--
You received this message because you are subscribed to the Google Groups "ozoneplatform-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ozoneplatform-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marc Landry

unread,
Jan 9, 2015, 8:38:21 AM1/9/15
to ozonepla...@googlegroups.com
All right, that's pretty much what I suspected at this point.

Thanks a lot, your help is always appreciated.
Reply all
Reply to author
Forward
0 new messages