Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cto
g1
Commits
9bcf5d40
Commit
9bcf5d40
authored
Mar 14, 2019
by
Tejesh
🖖
Browse files
Merge branch 'fh-link' into t-link
parents
4b7f0bcc
a292322c
Changes
2
Hide whitespace changes
Inline
Side-by-side
docs/formhandler.md
View file @
9bcf5d40
...
...
@@ -61,6 +61,7 @@ The full list of options is below. Simple options can be specified as `data-` at
-
`{'', 'Equals...', '!', 'Does not equal...', ...}`
. The default list of operators is based on the auto-detected type of the column.
-
`link`
: string / function that generates a link for this each cell.
-
If no
`link:`
is specified, clicking on the cell filters by that cell.
-
If
`link: false`
, the cell has no link
-
If
`link:`
is a function, opens a new window with the URL as
`fn(args)`
.
-
function accepts an object with these keys:
-
`name`
: column name
...
...
@@ -70,8 +71,11 @@ The full list of options is below. Simple options can be specified as `data-` at
-
`row`
: row data
-
`data`
: the dataset from
`src`
-
Example:
`function(args) { return 'https://example.org/city/' + args.value }`
-
If
`link:`
is a string, opens a new window with the string URL interpolated as a lodash template with an object (mentioned above) as data.
Example:
`"https://example.org/city/<%- value >"`
-
Example:
`function(args) { return false }`
clears the link
-
If
`link:`
is a URL with a path, opens a new window with the string
URL interpolated as a lodash template with an object (mentioned above)
as data. Example:
`"https://example.org/city/<%- value >"`
-
If
`link:`
is a URL with only query parameters, apply the filters. Example:
`"?name=<%- row.name %>"`
-
`hideable`
:
`true`
(default) /
`false`
. Show or hide
`Hide`
option in header dropdown
-
`hide`
:
`true`
/
`false`
(default). Hides the column
-
`unique`
: TODO: {dict of query parameter and display value} or [list of values] or function?
...
...
@@ -96,11 +100,11 @@ The full list of options is below. Simple options can be specified as `data-` at
-
`false`
: disables the table (and shows nothing for the main content)
-
`count`
: Shows the number of rows. Can be
`true`
(default) /
`false`
-
`page`
: Shows the page control. Can be
`true`
(default) /
`false`
.
-
`pageSize`
: page size. Defaults to 100
-
`pageSize`
: page size
(or via
`data-page-size`
)
. Defaults to 100
-
`size`
: Shows the page size control. Can be
`true`
(default) /
`false`
-
`sizeValues`
: Allowed page size values. Defaults to
`[10, 20, 50, 100, 500, 1000]`
-
`sizeValues`
: Allowed page size values
(or via
`data-size-values`
)
. Defaults to
`[10, 20, 50, 100, 500, 1000]`
-
`export`
: Shows the export control. Can be
`true`
(default) /
`false`
-
`exportFormats`
:
{xlsx: 'Excel'}
-
`exportFormats`
:
Defines export formats to use (or via
`data-export-formats`
). E.g.
`{xlsx: 'Excel', 'csv': 'CSV'}`
-
`filters`
: Shows the applied filters control. Can be
`true`
(default) /
`false`
-
`transform`
: an optional function() that modifies data. It accepts a dict that has keys:
-
`data`
: the FormHandler data
...
...
src/formhandler.template.html
View file @
9bcf5d40
...
...
@@ -392,9 +392,17 @@ Each template receives these variables:
val
)
%
>
<div>
<strong><
%=
colinfo.name
%
></strong>
:
<
%
if
('
link
'
in
colinfo
)
{
var
col_link =
typeof
colinfo.link =
=
'
function
'
?
colinfo.link
({
row:
row
,
value:
val
,
index:
rowIndex
,
name:
colinfo.name
,
data:
data
,
format:
disp
})
:
_.template
(
colinfo.link
)({
row:
row
,
value:
val
,
index:
rowIndex
,
name:
colinfo.name
,
data:
data
,
format:
disp
})
%
>
<a
href=
"<%- col_link %>"
target=
"_blank"
><
%=
disp
%
></a>
<
%
if
('
link
'
in
colinfo
)
{
%
>
<
%
var
col_link =
typeof
colinfo.link =
=
'
function
'
?
colinfo.link
({
row:
row
,
value:
val
,
index:
rowIndex
,
name:
colinfo.name
,
data:
data
,
format:
disp
})
:
_.template
(
colinfo.link
)({
row:
row
,
value:
val
,
index:
rowIndex
,
name:
colinfo.name
,
data:
data
,
format:
disp
})
%
>
<
%
if
(col_link =
==
false
)
{
%
>
<
%=
disp
%
>
<
%
}
else
if
(
col_link
&&
col_link[0] =
=
'?')
{
%
>
<a
class=
"urlfilter"
href=
"<%- col_link %>"
><
%=
disp
%
></a>
<
%
}
else
{
%
>
<a
href=
"<%- col_link %>"
target=
"_blank"
><
%=
disp
%
></a>
<
%
}
%
>
<
%
}
else
{
%
>
<a
class=
"urlfilter"
href=
"?<%- encodeURIComponent(colinfo.name) %>=<%- encodeURIComponent(val) %>&_offset="
>
<
%=
disp
%
>
...
...
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