IEEE.org
|
IEEE Xplore Digital Library
|
IEEE Standards
|
IEEE Spectrum
|
More Sites
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Open at RIT
My Conservation Life
Conservation360
Commits
66ace37b
Commit
66ace37b
authored
Feb 07, 2020
by
APalumbo97
Browse files
Initial code for exporting a template CSV with headers.
parent
b4e6a382
Changes
4
Hide whitespace changes
Inline
Side-by-side
salesforce/my-conservation-life/force-app/main/default/lwc/exportHeaders/exportHeaders.html
0 → 100755
View file @
66ace37b
<template>
<lightning:layout
horizontalalign=
"space"
>
<lightning:layoutItem
size=
"10"
>
<lightning-combobox
name=
"datasource"
label=
"Export a template CSV"
value=
{value}
placeholder=
{value}
options=
{combo_options}
onchange=
{handleChange}
></lightning-combobox>
</lightning:layoutItem>
<br/>
<lightning:layoutItem
size=
"2"
>
<lightning-button
variant=
"success"
label=
"Download"
onclick=
{download}
></lightning-button>
</lightning:layoutItem>
</lightning:layout>
</template>
salesforce/my-conservation-life/force-app/main/default/lwc/exportHeaders/exportHeaders.js
0 → 100755
View file @
66ace37b
import
{
LightningElement
,
track
}
from
'
lwc
'
;
import
{
assetDefinitions
}
from
'
c/controllers
'
;
export
default
class
ExportHeaders
extends
LightningElement
{
@
track
value
=
'
Select an asset type...
'
;
@
track
valueID
=
null
;
@
track
placeholder
=
'
N/A
'
;
@
track
combo_options
=
[];
/**
* Sets the combobox options.
*/
connectedCallback
()
{
var
i
;
assetDefinitions
.
fetchAssetTypes
()
.
then
(
data
=>
{
var
temp_options
=
[];
for
(
i
=
0
;
i
<
data
.
rows
.
length
;
i
++
)
{
temp_options
.
push
({
'
label
'
:
data
.
rows
[
i
][
'
name
'
]
+
'
:
'
+
data
.
rows
[
i
][
'
id
'
],
'
value
'
:
data
.
rows
[
i
][
'
name
'
]
+
'
:
'
+
data
.
rows
[
i
][
'
id
'
]
});
}
this
.
combo_options
=
temp_options
;
})
.
catch
(
e
=>
{
console
.
log
(
'
Exception:
'
,
e
);
});
}
/**
* Event handler for when something is selected from the combobox.
* @param {*} event - the event object
*/
handleChange
(
event
)
{
this
.
value
=
event
.
detail
.
value
;
this
.
valueID
=
event
.
detail
.
value
.
split
(
'
:
'
)[
1
].
trimLeft
();
}
/**
* Event handler for when the download button is pressed.
*/
download
()
{
var
i
;
var
csv_data
=
''
;
var
rows
=
[];
var
hiddenElement
;
assetDefinitions
.
fetchAssetPropTypes
(
this
.
valueID
)
.
then
(
properties
=>
{
rows
=
[
'
asset_id
'
];
for
(
i
=
0
;
i
<
properties
.
rows
.
length
;
i
++
)
{
rows
.
push
(
properties
.
rows
[
i
][
'
name
'
]);
}
csv_data
+=
rows
.
join
(
'
,
'
)
+
'
\n
'
;
// Creates the CSV file and downloads it.
hiddenElement
=
document
.
createElement
(
'
a
'
);
hiddenElement
.
href
=
'
data:text/csv;charset=utf-8,
'
+
encodeURI
(
csv_data
);
hiddenElement
.
target
=
'
_blank
'
;
hiddenElement
.
download
=
this
.
value
+
'
_template.csv
'
;
hiddenElement
.
click
();
})
.
catch
(
e
=>
{
console
.
log
(
'
Exception:
'
,
e
);
});
}
}
salesforce/my-conservation-life/force-app/main/default/lwc/exportHeaders/exportHeaders.js-meta.xml
0 → 100755
View file @
66ace37b
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle
xmlns=
"http://soap.sforce.com/2006/04/metadata"
>
<apiVersion>
47.0
</apiVersion>
<isExposed>
true
</isExposed>
<targets>
<target>
lightning__AppPage
</target>
<target>
lightning__RecordPage
</target>
<target>
lightning__HomePage
</target>
</targets>
</LightningComponentBundle>
salesforce/my-conservation-life/sfdx-project.json
View file @
66ace37b
...
...
@@ -7,5 +7,5 @@
],
"namespace"
:
""
,
"sfdcLoginUrl"
:
"https://login.salesforce.com"
,
"sourceApiVersion"
:
"4
8
.0"
"sourceApiVersion"
:
"4
7
.0"
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment