Skip to content

Commit ce66159

Browse files
committed
Cause refresh on select changed
1 parent b67774a commit ce66159

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

src/client/controllers/convert.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import { syncToLocal } from '../scripts/global';
99

1010
const itSupportsDragging = () => {
1111
const div = document.createElement('div');
12-
return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div);
12+
return 'draggable' in div || ('ondragstart' in div && 'ondrop' in div);
1313
};
1414

1515
const itSupportsFileReader = () => 'FileReader' in window;
1616

1717
const itSupportsFormData = () => 'FormData' in window;
1818

19-
const itSupportsDragDropUpload = () => itSupportsDragging() && itSupportsFileReader()
20-
&& itSupportsFormData();
19+
const itSupportsDragDropUpload = () =>
20+
itSupportsDragging() && itSupportsFileReader() && itSupportsFormData();
2121
const currentCodeSet = {};
2222
const $synonym = { include: {}, exclude: {} };
2323
const $terminologyRadio = {};
@@ -145,26 +145,33 @@ const wireup = () => {
145145
const files = droppedFiles;
146146
const reader = new FileReader();
147147
reader.onload = function readerOnLoad() {
148-
$form.removeClass('is-uploading');// .removeClass('is-error');
148+
$form.removeClass('is-uploading'); // .removeClass('is-error');
149149
const newZip = new JSZip();
150150
// more files !
151151
newZip
152152
.loadAsync(reader.result)
153153
.then((zip) => {
154154
// you now have every files contained in the loaded zip
155155
if (!zip) displayError(null, 'No zip file found.');
156-
else if (!zip.files || Object.keys(zip.files).length !== 2) displayError(null, 'Zip file should contain two files.');
157-
else if (Object.keys(zip.files).filter(v => v.toLowerCase().indexOf('metadata') > -1).length !== 1) {
156+
else if (!zip.files || Object.keys(zip.files).length !== 2)
157+
displayError(null, 'Zip file should contain two files.');
158+
else if (
159+
Object.keys(zip.files).filter((v) => v.toLowerCase().indexOf('metadata') > -1)
160+
.length !== 1
161+
) {
158162
displayError(null, "Need precisely one file with 'metadata' in it's name.");
159163
} else {
160-
const metadataFilename = Object.keys(zip.files).filter(v => v.toLowerCase().indexOf('metadata') > -1)[0];
161-
const codesetFilename = Object.keys(zip.files).filter(v => v.toLowerCase().indexOf('metadata') === -1)[0];
164+
const metadataFilename = Object.keys(zip.files).filter(
165+
(v) => v.toLowerCase().indexOf('metadata') > -1
166+
)[0];
167+
const codesetFilename = Object.keys(zip.files).filter(
168+
(v) => v.toLowerCase().indexOf('metadata') === -1
169+
)[0];
162170

163171
const metaDataPromise = zip.file(metadataFilename).async('string');
164172
const codeSetPromise = zip.file(codesetFilename).async('string');
165173

166-
Promise
167-
.all([metaDataPromise, codeSetPromise])
174+
Promise.all([metaDataPromise, codeSetPromise])
168175
.then((fileContents) => {
169176
readMetaDataFile(fileContents[0]);
170177
readCodeSetFile(fileContents[1]);
@@ -184,7 +191,6 @@ const wireup = () => {
184191
return reader.readAsArrayBuffer(files[0]);
185192
});
186193

187-
188194
// restart the form if has a state of error/success
189195

190196
$restart.on('click', (evt) => {
@@ -204,8 +210,12 @@ const wireup = () => {
204210

205211
// Firefox focus bug fix for file input
206212
$input
207-
.on('focus', () => { $input.addClass('has-focus'); })
208-
.on('blur', () => { $input.removeClass('has-focus'); });
213+
.on('focus', () => {
214+
$input.addClass('has-focus');
215+
})
216+
.on('blur', () => {
217+
$input.removeClass('has-focus');
218+
});
209219
});
210220
};
211221

@@ -215,4 +225,3 @@ const show = () => {
215225
};
216226
// params, state, url
217227
export { show as default };
218-

src/client/controllers/create.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,11 @@ const wireup = () => {
623623
evt.preventDefault();
624624
});
625625

626+
document.querySelector('select[name=terminology]').addEventListener('change', () => {
627+
console.log('Terminology changed. Refreshing...');
628+
refresh();
629+
});
630+
626631
$synonym.include.add.on('click', () => {
627632
addIfLongEnough($synonym.include.input);
628633
});

0 commit comments

Comments
 (0)