通过阅读拉力赛文档,自定义拉力赛应用程序中的状态持久性限定为当前用户:“App SDK中的状态实现由Ext.state.Stateful mixin提供。值存储在CA Agile中的Preference对象中中心作用于应用和当前用户。“
我的问题是,有没有办法让这些Preference对象作为整个订阅的范围,而不仅仅是当前用户?因此,如果我有自定义应用程序,我们的拉力赛订阅中的所有用户都可以登录自己和其他人所做的更改。谢谢。
修改
这是代码,我只是在添加对话框后通过向数组添加数字来测试状态。我根据Kyle的回答使用了initComponent,但是当包含它时,状态就停止了工作(它现在被注释掉了):
Ext.define('CustomApp', {
extend: 'Rally.app.App',
stateful: true,
componentCls: 'app',
// initComponent: function() {
// console.log('called initComponent');
// this.stateId = Ext.create('Rally.state.ScopedStateUtil').getScopedStateId('appState', {
// appID: this.getContext().getAppId(),
// workspace: this.getContext().getWorkspaceRef()
// });
// this.callParent(arguments);
// },
getState: function() {
console.log('getting state');
if(this.dialogs.length > 0) {
var newState = {
currentDialogs: [].concat(this.dialogs)
};
console.log('this is the new state:', newState);
return newState;
}
console.log('returning null from getState');
return null;
},
applyState: function(state) {
console.log('applying state');
console.log('current state:', state);
if(state.currentDialogs) {
this.dialogs = state.currentDialogs;
console.log('this.dialogs after applying state:', this.dialogs);
}
else {
this.dialogs = [];
console.log('this.dialogs did not exit before. just created it.');
}
},
doLayout: function() {
var me = this;
var textField = Ext.create('Rally.ui.TextField', {
fieldLabel: 'Add task:',
listeners: {
scope: me,
specialkey: me._checkEnter
}
});
me.add(textField);
},
launch: function() {
if(!this.dialogs) {
this.dialogs = [];
console.log('just created dialogs');
}
this.doLayout();
this.taskCounter = 0;
this.yPosition = 50;
},
_checkEnter: function(field, event) {
if (event.getKey() === event.ENTER) {
this._onEnter(field);
}
},
_onEnter: function(field) {
this.taskCounter = this.taskCounter + 1;
var dialog = Ext.create(Rally.ui.dialog.Dialog, {
context: this.getContext(),
autoShow: true,
autoCenter: false,
draggable: false,
closable: true,
modal: false,
width: 300,
x: 100,
y: this.yPosition,
title: 'Task ' + this.taskCounter,
items: {
xtype: 'component',
html: field.getRawValue(),
padding: 10
}
});
this.yPosition = this.yPosition + 100;
this.dialogs.push((99990 + this.taskCounter).toString());
this.saveState();
}
});
答案 0 :(得分:0)
所以我进行了一些调查,看起来有状态是很难为每个用户工作的,并且很难解决。相反,您应该可以使用设置来执行此操作:
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
doLayout: function() {
var me = this;
var textField = Ext.create('Rally.ui.TextField', {
fieldLabel: 'Add task:',
listeners: {
scope: me,
specialkey: me._checkEnter
}
});
me.add(textField);
},
launch: function() {
var dialogs = this.getSetting('dialogs');
this.dialogs = (dialogs || '').split(',');
console.log(this.dialogs);
//TODO: if dialogs exist draw them
this.doLayout();
this.taskCounter = 0;
this.yPosition = 50;
},
_checkEnter: function(field, event) {
if (event.getKey() === event.ENTER) {
this._onEnter(field);
}
},
_onEnter: function(field) {
this.taskCounter = this.taskCounter + 1;
var dialog = Ext.create(Rally.ui.dialog.Dialog, {
context: this.getContext(),
autoShow: true,
autoCenter: false,
draggable: false,
closable: true,
modal: false,
width: 300,
x: 100,
y: this.yPosition,
title: 'Task ' + this.taskCounter,
items: {
xtype: 'component',
html: field.getRawValue(),
padding: 10
}
});
this.yPosition = this.yPosition + 100;
this.dialogs.push((99990 + this.taskCounter).toString());
this._persistDialogs();
},
_persistDialogs: function() {
this.updateSettingsValues({
settings: {
dialogs: this.dialogs
}
});
}
});