Skip to content

Commit

Permalink
MinimalFileInput - Add the ability to select one or more files.
Browse files Browse the repository at this point in the history
  • Loading branch information
csavelief committed Oct 14, 2024
1 parent 6c01980 commit a0de445
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 19 deletions.
27 changes: 24 additions & 3 deletions dist/cjs/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/main.js.map

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions dist/esm/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/esm/main.js.map

Large diffs are not rendered by default.

27 changes: 21 additions & 6 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
<script>

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

Expand All @@ -83,6 +83,7 @@
const httpClient = new com.computablefacts.platform.HttpClient();
httpClient.init(baseUrl, apiKey);
httpClient.whoAmI().then(response => console.log(response));

/*
httpClient.findObjects({
format: 'arrays', dataset: 'rnic-t4-2023', sample_size: 10, cursor: null, json_query: 'TEXT:vérif*',
Expand All @@ -92,23 +93,36 @@
json_ids: response.data,
});
}).then(response => console.log(response));
*/
*//*
httpClient.findObjects({
format: 'arrays',dataset: 'job-syndics-clients-avec-codes-communes-2', sample_size: 10, json_query: 'NOM:"sevig*"',
}).then(response => console.log(response));
httpClient.findObjects({
format: 'arrays',dataset: 'job-syndics-clients-avec-codes-communes-2', sample_size: 10, json_query: 'CAGTCO:[94 TO 94]',
}).then(response => console.log(response));
*/
httpClient.findObjects({
format: 'arrays',dataset: 'job-syndics-clients-avec-codes-communes-2', sample_size: 10, json_query: 'NOM:"sevig*" AND CAGTCO:[94 TO 94]',
}).then(response => console.log(response));

/*
httpClient.findTerms({
dataset: 'test-ocr-irve', sample_size: 10, json_query: 'TEXT:blabla*',
dataset: 'job-syndics-clients-avec-codes-communes-2', sample_size: 10, json_query: 'NOM:"sevig*"',
}).then(response => console.log(response));
*/
*/
/*
httpClient.executeSqlQuery({
format: 'arrays_with_header', invalidate_cache: true, force_rebuild: true, sql_query: 'SELECT ID FROM tmp_docs_irve LIMIT 30',
}).then(response => console.log(response));
*/
/*
httpClient.executeSqlQuery({
format: 'arrays_with_header',
invalidate_cache: true,
sql_query: 'SELECT ID FROM tmp_copros_clientes_2_3_denormalise LIMIT 30',
}).then(response => console.log(response));

*/
/*
httpClient.getObjects({
dataset: 'test-ocr-irve',
Expand Down Expand Up @@ -532,6 +546,7 @@
container: 'file-input',
text: 'Sélectionner un fichier...',
buttonText: 'Rechercher...',
multiple: true,
on_selection_change: file => console.log(file),
});
}
Expand Down
2 changes: 1 addition & 1 deletion dist/main.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main.min.js.map

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions src/blueprintjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ blueprintjs.Blueprintjs = class extends widgets.Widget {
break;
}
case 'FileInput': {
obj.el = new blueprintjs.MinimalFileInput(container);
const multiple = obj.multiple;
obj.el = new blueprintjs.MinimalFileInput(container, multiple);
break;
}
case 'RadioGroup': {
Expand Down Expand Up @@ -2314,15 +2315,17 @@ blueprintjs.MinimalFileInput = class extends blueprintjs.Blueprintjs {

/**
* @param {Element} container the parent element.
* @param {boolean} multiple true iif the user must be able to select one or more files.
* @constructor
*/
constructor(container) {
constructor(container, multiple) {
super(container);
this.observers_ = new observers.Subject();
this.disabled_ = false;
this.text_ = null;
this.buttonText_ = null;
this.fill_ = true;
this.multiple_ = multiple === true;
this.render();
}

Expand Down Expand Up @@ -2362,6 +2365,15 @@ blueprintjs.MinimalFileInput = class extends blueprintjs.Blueprintjs {
this.render();
}

get multiple() {
return this.multiple_;
}

set multiple(value) {
this.multiple_ = value;
this.render();
}

/**
* Listen to the `selection-change` event.
*
Expand All @@ -2380,8 +2392,17 @@ blueprintjs.MinimalFileInput = class extends blueprintjs.Blueprintjs {
}

_newElement() {
const props = {};
if (this.multiple) {
props.multiple = 'multiple';
}
return React.createElement(FileInput, {
disabled: this.disabled, text: this.text, buttonText: this.buttonText, fill: this.fill, onInputChange: (el) => {
inputProps: props,
disabled: this.disabled,
text: this.text,
buttonText: this.buttonText,
fill: this.fill,
onInputChange: (el) => {
this.text = el.target.files[0].name;
this.render();
this.observers_.notify('selection-change', el.target.files[0]);
Expand Down

0 comments on commit a0de445

Please sign in to comment.