mirror of https://github.com/keeweb/keeweb.git
open-config view
This commit is contained in:
parent
6277a48419
commit
f8f8a7c1d1
|
@ -38,7 +38,7 @@ class ModalView extends View {
|
|||
document.activeElement.blur();
|
||||
}, 20);
|
||||
if (this.model.view) {
|
||||
this.model.view.setElement(this.$el.find('.modal__body'));
|
||||
this.model.view.parent = '.modal__body';
|
||||
this.model.view.render();
|
||||
}
|
||||
return this;
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
import Backbone from 'backbone';
|
||||
import { View } from 'view-engine/view';
|
||||
import { Keys } from 'const/keys';
|
||||
import { Locale } from 'util/locale';
|
||||
import template from 'templates/open-config.hbs';
|
||||
|
||||
const OpenConfigView = Backbone.View.extend({
|
||||
template: require('templates/open-config.hbs'),
|
||||
class OpenConfigView extends View {
|
||||
template = template;
|
||||
|
||||
events: {
|
||||
events = {
|
||||
'click .open__config-btn-cancel': 'cancel',
|
||||
'click .open__config-btn-ok': 'apply',
|
||||
'input input': 'changeInput',
|
||||
'keyup input': 'keyup'
|
||||
},
|
||||
};
|
||||
|
||||
render() {
|
||||
this.renderTemplate(this.model);
|
||||
super.render(this.model);
|
||||
this.$el.find(':input:first').focus();
|
||||
this.checkValidity();
|
||||
return this;
|
||||
},
|
||||
}
|
||||
|
||||
cancel() {
|
||||
this.trigger('cancel');
|
||||
},
|
||||
this.emit('cancel');
|
||||
}
|
||||
|
||||
apply() {
|
||||
const data = this.getData();
|
||||
if (data) {
|
||||
this.trigger('apply', data);
|
||||
this.emit('apply', data);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
changeInput() {
|
||||
this.checkValidity();
|
||||
},
|
||||
}
|
||||
|
||||
keyup(e) {
|
||||
if (e.which === Keys.DOM_VK_RETURN) {
|
||||
this.apply();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
checkValidity() {
|
||||
const isValid = this.getData();
|
||||
this.$el.find('.open__config-btn-ok').prop('disabled', !isValid);
|
||||
},
|
||||
}
|
||||
|
||||
getData() {
|
||||
let data = { storage: this.model.id };
|
||||
|
@ -58,7 +58,7 @@ const OpenConfigView = Backbone.View.extend({
|
|||
return true;
|
||||
}, this);
|
||||
return data;
|
||||
},
|
||||
}
|
||||
|
||||
setDisabled(disabled) {
|
||||
disabled = !!disabled;
|
||||
|
@ -67,7 +67,7 @@ const OpenConfigView = Backbone.View.extend({
|
|||
if (disabled) {
|
||||
this.$el.find('.open__config-error').text('');
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
setError(err) {
|
||||
const errText =
|
||||
|
@ -76,6 +76,6 @@ const OpenConfigView = Backbone.View.extend({
|
|||
: Locale.openConfigError.replace('{}', err);
|
||||
this.$el.find('.open__config-error').text(errText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export { OpenConfigView };
|
||||
|
|
|
@ -811,12 +811,12 @@ const OpenView = Backbone.View.extend({
|
|||
},
|
||||
storage.getOpenConfig()
|
||||
);
|
||||
this.views.openConfig = new OpenConfigView({
|
||||
el: this.$el.find('.open__config-wrap'),
|
||||
model: config
|
||||
}).render();
|
||||
this.views.openConfig = new OpenConfigView(config, {
|
||||
parent: '.open__config-wrap'
|
||||
});
|
||||
this.views.openConfig.on('cancel', this.closeConfig.bind(this));
|
||||
this.views.openConfig.on('apply', this.applyConfig.bind(this));
|
||||
this.views.openConfig.render();
|
||||
this.$el.find('.open__pass-area').addClass('hide');
|
||||
this.$el.find('.open__icons--lower').addClass('hide');
|
||||
},
|
||||
|
|
|
@ -292,7 +292,7 @@ const SettingsFileView = Backbone.View.extend({
|
|||
},
|
||||
storage.getOpenConfig()
|
||||
);
|
||||
const openConfigView = new OpenConfigView({ model: config });
|
||||
const openConfigView = new OpenConfigView(config);
|
||||
Alerts.alert({
|
||||
header: '',
|
||||
body: '',
|
||||
|
|
Loading…
Reference in New Issue