SDK 2: Example of a settings dialog

2019-09-14 15:52发布

Do you have an example posted of a SDK 2 app that adds an entry to its "Gear" menu and allows the user to save settings to a preference object via a dialog window?

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-09-14 15:59

The short answer is that right now that is not possible.

We are trying to figure out the best way to allow users to interact with setting from inside of a custom App. Since each App is sandboxed inside of an IFrame no App code can interact with the gear menu (since it is outside of your frame).

In the future we are looking into ways to make custom Apps and Rally Apps interact with Settings in a unified way.

If you are looking to store settings you can check into the documentation for the App object. In the 2.0p2 version of the SDK we added some functionality to help you manage settings on your Apps. Right now all custom Apps will have to provide their own interface to access settings.

查看更多
可以哭但决不认输i
3楼-- · 2019-09-14 16:23

I ended up using the ExtJS CookieProvider to save my app's state. By using cookies the settings are per user, and I also made them per-project. My code within the App class looks like this:

...
sessionKey: function() {
  return (this.getContext().get('appID') || 'MyAppName') + ':' + this.getContext().getProject()._ref;
},

session: function() {
  if (!this.state)
    this.state = Ext.state.Manager.get(this.sessionKey()) || {};

  return this.state;
},

saveSession: function(newState) {
  var session = this.session();
  Ext.apply(session, newState);
  Ext.state.Manager.set(this.sessionKey(), session);
},

launch: function() {
   Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
   ...

To use it, just call this.session() to get the state, and saveSession() to merge the state back in. Works great!

It will even work in dev mode. Note that Chrome (and other browsers?) will not save cookies in file:// mode unless you tell it to.

查看更多
登录 后发表回答