add password option to input modal

This commit is contained in:
Jiiks 2018-08-14 14:49:50 +03:00
parent 67b554c68f
commit ab03633431
4 changed files with 10 additions and 7 deletions

View File

@ -161,7 +161,7 @@ export default new class E2EE extends BuiltinModule {
seed = Security.randomBytes(); seed = Security.randomBytes();
let newMaster = ''; let newMaster = '';
try { try {
newMaster = await Modals.input('E2EE', 'Master Key:').promise; newMaster = await Modals.input('E2EE', 'Master Key:', true).promise;
} catch (err) { } catch (err) {
Toasts.error('Failed to set master key!'); Toasts.error('Failed to set master key!');
} }

View File

@ -13,7 +13,8 @@
} }
input[type="text"], input[type="text"],
input[type="number"] { input[type="number"],
input[type="password"] {
background: transparent; background: transparent;
border: none; border: none;
color: #b9bbbe; color: #b9bbbe;

View File

@ -12,7 +12,8 @@
<Modal :class="['bd-modal-basic', {'bd-modal-out': modal.closing}]" :headerText="modal.title" @close="modal.close"> <Modal :class="['bd-modal-basic', {'bd-modal-out': modal.closing}]" :headerText="modal.title" @close="modal.close">
<div slot="body" class="bd-modal-basic-body bd-inputModalBody bd-form-textinput"> <div slot="body" class="bd-modal-basic-body bd-inputModalBody bd-form-textinput">
{{ modal.text }} {{ modal.text }}
<input ref="input" type="text" @keyup.stop="keyup"/><!-- TODO Option for masked input --> <input v-if="modal.password" ref="input" type="password" @keyup.stop="keyup" />
<input v-else ref="input" type="text" @keyup.stop="keyup"/>
</div> </div>
<div slot="footer" class="bd-modal-controls"> <div slot="footer" class="bd-modal-controls">
<div class="bd-flex-grow"></div> <div class="bd-flex-grow"></div>
@ -46,6 +47,7 @@
} }
}, },
mounted() { mounted() {
window.t = this;
this.$refs.input.focus(); this.$refs.input.focus();
} }
} }

View File

@ -177,12 +177,12 @@ export default class Modals {
return new Modal(modal, ConfirmModal); return new Modal(modal, ConfirmModal);
} }
static input(title, text) { static input(title, text, password = false) {
return this.add(this.createInputModal(title, text)); return this.add(this.createInputModal(title, text, password));
} }
static createInputModal(title, text) { static createInputModal(title, text, password = false) {
const modal = { title, text }; const modal = { title, text, password };
modal.promise = new Promise((resolve, reject) => { modal.promise = new Promise((resolve, reject) => {
modal.confirm = value => resolve(value); modal.confirm = value => resolve(value);
modal.beforeClose = () => reject(); modal.beforeClose = () => reject();