[DE] Cross-references: save last used settings
This commit is contained in:
parent
1e9d6650a9
commit
aa9c3e3c02
|
@ -460,11 +460,15 @@ define([
|
||||||
var me = this;
|
var me = this;
|
||||||
me.dlgCrossRefDialog = new DE.Views.CrossReferenceDialog({
|
me.dlgCrossRefDialog = new DE.Views.CrossReferenceDialog({
|
||||||
api: me.api,
|
api: me.api,
|
||||||
|
crossRefProps: me.crossRefProps,
|
||||||
handler: function (result, settings) {
|
handler: function (result, settings) {
|
||||||
if (result != 'ok')
|
if (result != 'ok')
|
||||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
me.dlgCrossRefDialog.on('close', function(obj){
|
||||||
|
me.crossRefProps = me.dlgCrossRefDialog.getSettings();
|
||||||
|
});
|
||||||
me.dlgCrossRefDialog.show();
|
me.dlgCrossRefDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ define([
|
||||||
'</div>'
|
'</div>'
|
||||||
].join('');
|
].join('');
|
||||||
|
|
||||||
this.props = options.props;
|
this.crossRefProps = options.crossRefProps;
|
||||||
this.api = options.api;
|
this.api = options.api;
|
||||||
this.options.tpl = _.template(this.template)(this.options);
|
this.options.tpl = _.template(this.template)(this.options);
|
||||||
this._locked = false;
|
this._locked = false;
|
||||||
|
@ -197,12 +197,12 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
afterRender: function() {
|
afterRender: function() {
|
||||||
this._setDefaults(this.props);
|
this._setDefaults();
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleInput: function(state) {
|
_handleInput: function(state) {
|
||||||
if (this.options.handler) {
|
if (this.options.handler) {
|
||||||
this.options.handler.call(this, state, {});
|
this.options.handler.call(this, state);
|
||||||
}
|
}
|
||||||
if (state=='ok') {
|
if (state=='ok') {
|
||||||
this.insertReference();
|
this.insertReference();
|
||||||
|
@ -220,11 +220,19 @@ define([
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
_setDefaults: function (props) {
|
getSettings: function() {
|
||||||
this.cmbType.setValue(0);
|
return {type: this.cmbType.getValue(), refType: this.cmbReference.getValue()};
|
||||||
this.onTypeSelected(this.cmbType, this.cmbType.getSelectedRecord());
|
},
|
||||||
if (props) {
|
|
||||||
|
_setDefaults: function () {
|
||||||
|
var rec,
|
||||||
|
currentRef;
|
||||||
|
if (this.crossRefProps) {
|
||||||
|
rec = this.cmbType.store.findWhere({value: this.crossRefProps.type});
|
||||||
|
rec && (currentRef = this.crossRefProps.refType);
|
||||||
}
|
}
|
||||||
|
rec ? this.cmbType.selectRecord(rec) : this.cmbType.setValue(0);
|
||||||
|
this.refreshReferenceTypes(this.cmbType.getSelectedRecord(), currentRef);
|
||||||
},
|
},
|
||||||
|
|
||||||
insertReference: function() {
|
insertReference: function() {
|
||||||
|
@ -260,6 +268,10 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onTypeSelected: function (combo, record) {
|
onTypeSelected: function (combo, record) {
|
||||||
|
this.refreshReferenceTypes(record);
|
||||||
|
},
|
||||||
|
|
||||||
|
refreshReferenceTypes: function(record, currentRef) {
|
||||||
var arr = [],
|
var arr = [],
|
||||||
str = this.textWhich, type = 5;
|
str = this.textWhich, type = 5;
|
||||||
if (record.type==1 || record.value > 4) {
|
if (record.type==1 || record.value > 4) {
|
||||||
|
@ -328,7 +340,7 @@ define([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.cmbReference.setData(arr);
|
this.cmbReference.setData(arr);
|
||||||
this.cmbReference.setValue(arr[0].value);
|
this.cmbReference.setValue(currentRef ? currentRef : arr[0].value);
|
||||||
this.onReferenceSelected(this.cmbReference, this.cmbReference.getSelectedRecord());
|
this.onReferenceSelected(this.cmbReference, this.cmbReference.getSelectedRecord());
|
||||||
this.lblWhich.text(str);
|
this.lblWhich.text(str);
|
||||||
this.refreshReferences(type);
|
this.refreshReferences(type);
|
||||||
|
|
Loading…
Reference in a new issue