mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 00:48:25 +00:00
Add option to generate plaintext files (#2748)
* Add option to generate plaintext files * Default to csv file format for file generator
This commit is contained in:
parent
ee8438c1dc
commit
5779c5b9a5
2 changed files with 12 additions and 4 deletions
|
|
@ -322,8 +322,11 @@ export const EventManager = ({
|
|||
<div className="col-9">
|
||||
<SelectSearch
|
||||
className={`${darkMode ? 'select-search-dark' : 'select-search'}`}
|
||||
options={[{ name: 'CSV', value: 'csv' }]}
|
||||
value={'csv'}
|
||||
options={[
|
||||
{ name: 'CSV', value: 'csv' },
|
||||
{ name: 'Text', value: 'plaintext' },
|
||||
]}
|
||||
value={event.fileType ?? 'csv'}
|
||||
search={true}
|
||||
onChange={(value) => {
|
||||
handlerChanged(index, 'fileType', value);
|
||||
|
|
|
|||
|
|
@ -261,9 +261,14 @@ function executeAction(_ref, event, mode, customVariables) {
|
|||
const data = resolveReferences(event.data, _ref.state.currentState, undefined, customVariables) ?? [];
|
||||
const fileName =
|
||||
resolveReferences(event.fileName, _ref.state.currentState, undefined, customVariables) ?? 'data.txt';
|
||||
const fileType =
|
||||
resolveReferences(event.fileType, _ref.state.currentState, undefined, customVariables) ?? 'csv';
|
||||
|
||||
const csv = generateCSV(data);
|
||||
generateFile(fileName, csv);
|
||||
const fileData = {
|
||||
csv: generateCSV,
|
||||
plaintext: (plaintext) => plaintext,
|
||||
}[fileType](data);
|
||||
generateFile(fileName, fileData);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue