README.md in ntq_excelsior-1.0.3 vs README.md in ntq_excelsior-1.1.0
- old
+ new
@@ -30,11 +30,12 @@
name: 'Utilisateurs',
extra_headers: [
[
{
title: "Utilisateurs",
- width: 4,
+ width: -> (context) { context[:current_user].can?(:access_to_email, User) ? 4 : 3 }
+ # width: 4,
styles: [:bold]
}
],
],
columns: [
@@ -44,15 +45,17 @@
styles: [:bold, :blue]
},
{
title: 'Email',
header_styles: [:blue],
- resolve: 'email'
+ resolve: 'email',
+ visible: -> (record, context) { context[:current_user].can?(:access_to_email, User) }
},
{
title: 'Birthdate',
- resolve: 'birthdate'
+ resolve: 'birthdate',
+ visible: true # Optional
}
{
title: 'Address (nested)',
resolve: ['address', 'address_one']
},
@@ -69,9 +72,11 @@
})
end
exporter = UserExporter.new(@users)
+# Optional : Context can be passed to exporter
+exporter.context = { current_user: current_user }
stream = exporter.export.to_stream.read
# In ruby file
File.open("export.xlsx", "w") do |tpm|
tpm.binmode