[DE] Cross-references: save last used settings

This commit is contained in:
Julia Radzhabova 2020-09-24 17:03:46 +03:00
parent 1e9d6650a9
commit aa9c3e3c02
2 changed files with 24 additions and 8 deletions

View file

@ -460,11 +460,15 @@ define([
var me = this;
me.dlgCrossRefDialog = new DE.Views.CrossReferenceDialog({
api: me.api,
crossRefProps: me.crossRefProps,
handler: function (result, settings) {
if (result != 'ok')
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}
});
me.dlgCrossRefDialog.on('close', function(obj){
me.crossRefProps = me.dlgCrossRefDialog.getSettings();
});
me.dlgCrossRefDialog.show();
}

View file

@ -97,7 +97,7 @@ define([
'</div>'
].join('');
this.props = options.props;
this.crossRefProps = options.crossRefProps;
this.api = options.api;
this.options.tpl = _.template(this.template)(this.options);
this._locked = false;
@ -197,12 +197,12 @@ define([
},
afterRender: function() {
this._setDefaults(this.props);
this._setDefaults();
},
_handleInput: function(state) {
if (this.options.handler) {
this.options.handler.call(this, state, {});
this.options.handler.call(this, state);
}
if (state=='ok') {
this.insertReference();
@ -220,11 +220,19 @@ define([
return false;
},
_setDefaults: function (props) {
this.cmbType.setValue(0);
this.onTypeSelected(this.cmbType, this.cmbType.getSelectedRecord());
if (props) {
getSettings: function() {
return {type: this.cmbType.getValue(), refType: this.cmbReference.getValue()};
},
_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() {
@ -260,6 +268,10 @@ define([
},
onTypeSelected: function (combo, record) {
this.refreshReferenceTypes(record);
},
refreshReferenceTypes: function(record, currentRef) {
var arr = [],
str = this.textWhich, type = 5;
if (record.type==1 || record.value > 4) {
@ -328,7 +340,7 @@ define([
}
}
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.lblWhich.text(str);
this.refreshReferences(type);