hook multifile to ui

This commit is contained in:
Emily 2018-07-31 11:09:18 -07:00
parent e42ad175db
commit c9ae76b209
77 changed files with 1528 additions and 1111 deletions

View file

@ -1,25 +1,26 @@
const html = require('choo/html');
const passwordInput = require('../passwordInput');
module.exports = function(state, emit) {
const file = state.storage.getFileById(state.params.id);
module.exports = function(state) {
const checked = state.password ? 'checked' : '';
const label = state.password ? 'addPasswordLabel' : 'addPasswordMessage';
return html`
<div class="setPasswordSection">
<div class="checkbox">
<input
${file.hasPassword ? 'disabled' : ''}
${file.hasPassword || state.passwordSetError ? 'checked' : ''}
class="checkbox__input"
id="add-password"
class="checkbox__input" id="add-password"
type="checkbox"
${checked}
autocomplete="off"
onchange=${togglePasswordInput}/>
<label class="checkbox__label" for="add-password">
${state.translate('requirePasswordCheckbox')}
${state.translate(label)}
</label>
</div>
${passwordInput(file, state, emit)}
${passwordInput(state)}
</div>`;
function togglePasswordInput(e) {
@ -28,9 +29,13 @@ module.exports = function(state, emit) {
document
.querySelector('.passwordInput')
.classList.toggle('passwordInput--hidden', !boxChecked);
const label = document.querySelector('.checkbox__label');
if (boxChecked) {
label.innerHTML = state.translate('addPasswordLabel');
unlockInput.focus();
} else {
label.innerHTML = state.translate('addPasswordMessage');
unlockInput.value = '';
}
}