Skip to content

Commit a0de445

Browse files
author
csavelief
committed
MinimalFileInput - Add the ability to select one or more files.
1 parent 6c01980 commit a0de445

File tree

8 files changed

+97
-19
lines changed

8 files changed

+97
-19
lines changed

dist/cjs/main.js

+24-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cjs/main.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/main.js

+24-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/main.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.html

+21-6
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
<script>
7474

7575
const env = 'www';
76-
const client = 'acme';
77-
const apiKey = 'xxx';
76+
const client = 'ista';
77+
const apiKey = '';
7878
const baseUrl = `https://${env}.${client}.computablefacts.com`;
7979
const url = `https://${env}.${client}.computablefacts.com/api/v2/public/json-rpc?api_token=${apiKey}`;
8080

@@ -83,6 +83,7 @@
8383
const httpClient = new com.computablefacts.platform.HttpClient();
8484
httpClient.init(baseUrl, apiKey);
8585
httpClient.whoAmI().then(response => console.log(response));
86+
8687
/*
8788
httpClient.findObjects({
8889
format: 'arrays', dataset: 'rnic-t4-2023', sample_size: 10, cursor: null, json_query: 'TEXT:vérif*',
@@ -92,23 +93,36 @@
9293
json_ids: response.data,
9394
});
9495
}).then(response => console.log(response));
95-
*/
96+
*//*
97+
httpClient.findObjects({
98+
format: 'arrays',dataset: 'job-syndics-clients-avec-codes-communes-2', sample_size: 10, json_query: 'NOM:"sevig*"',
99+
}).then(response => console.log(response));
100+
101+
httpClient.findObjects({
102+
format: 'arrays',dataset: 'job-syndics-clients-avec-codes-communes-2', sample_size: 10, json_query: 'CAGTCO:[94 TO 94]',
103+
}).then(response => console.log(response));
104+
*/
105+
httpClient.findObjects({
106+
format: 'arrays',dataset: 'job-syndics-clients-avec-codes-communes-2', sample_size: 10, json_query: 'NOM:"sevig*" AND CAGTCO:[94 TO 94]',
107+
}).then(response => console.log(response));
108+
96109
/*
97110
httpClient.findTerms({
98-
dataset: 'test-ocr-irve', sample_size: 10, json_query: 'TEXT:blabla*',
111+
dataset: 'job-syndics-clients-avec-codes-communes-2', sample_size: 10, json_query: 'NOM:"sevig*"',
99112
}).then(response => console.log(response));
100-
*/
113+
*/
101114
/*
102115
httpClient.executeSqlQuery({
103116
format: 'arrays_with_header', invalidate_cache: true, force_rebuild: true, sql_query: 'SELECT ID FROM tmp_docs_irve LIMIT 30',
104117
}).then(response => console.log(response));
105118
*/
119+
/*
106120
httpClient.executeSqlQuery({
107121
format: 'arrays_with_header',
108122
invalidate_cache: true,
109123
sql_query: 'SELECT ID FROM tmp_copros_clientes_2_3_denormalise LIMIT 30',
110124
}).then(response => console.log(response));
111-
125+
*/
112126
/*
113127
httpClient.getObjects({
114128
dataset: 'test-ocr-irve',
@@ -532,6 +546,7 @@
532546
container: 'file-input',
533547
text: 'Sélectionner un fichier...',
534548
buttonText: 'Rechercher...',
549+
multiple: true,
535550
on_selection_change: file => console.log(file),
536551
});
537552
}

dist/main.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/blueprintjs.js

+24-3
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ blueprintjs.Blueprintjs = class extends widgets.Widget {
203203
break;
204204
}
205205
case 'FileInput': {
206-
obj.el = new blueprintjs.MinimalFileInput(container);
206+
const multiple = obj.multiple;
207+
obj.el = new blueprintjs.MinimalFileInput(container, multiple);
207208
break;
208209
}
209210
case 'RadioGroup': {
@@ -2314,15 +2315,17 @@ blueprintjs.MinimalFileInput = class extends blueprintjs.Blueprintjs {
23142315

23152316
/**
23162317
* @param {Element} container the parent element.
2318+
* @param {boolean} multiple true iif the user must be able to select one or more files.
23172319
* @constructor
23182320
*/
2319-
constructor(container) {
2321+
constructor(container, multiple) {
23202322
super(container);
23212323
this.observers_ = new observers.Subject();
23222324
this.disabled_ = false;
23232325
this.text_ = null;
23242326
this.buttonText_ = null;
23252327
this.fill_ = true;
2328+
this.multiple_ = multiple === true;
23262329
this.render();
23272330
}
23282331

@@ -2362,6 +2365,15 @@ blueprintjs.MinimalFileInput = class extends blueprintjs.Blueprintjs {
23622365
this.render();
23632366
}
23642367

2368+
get multiple() {
2369+
return this.multiple_;
2370+
}
2371+
2372+
set multiple(value) {
2373+
this.multiple_ = value;
2374+
this.render();
2375+
}
2376+
23652377
/**
23662378
* Listen to the `selection-change` event.
23672379
*
@@ -2380,8 +2392,17 @@ blueprintjs.MinimalFileInput = class extends blueprintjs.Blueprintjs {
23802392
}
23812393

23822394
_newElement() {
2395+
const props = {};
2396+
if (this.multiple) {
2397+
props.multiple = 'multiple';
2398+
}
23832399
return React.createElement(FileInput, {
2384-
disabled: this.disabled, text: this.text, buttonText: this.buttonText, fill: this.fill, onInputChange: (el) => {
2400+
inputProps: props,
2401+
disabled: this.disabled,
2402+
text: this.text,
2403+
buttonText: this.buttonText,
2404+
fill: this.fill,
2405+
onInputChange: (el) => {
23852406
this.text = el.target.files[0].name;
23862407
this.render();
23872408
this.observers_.notify('selection-change', el.target.files[0]);

0 commit comments

Comments
 (0)