Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions fractal.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ engine.handlebars.registerHelper('eq', function(a, b) {
engine.handlebars.registerHelper('has', function(array, item) {
return array.includes(item);
});
engine.handlebars.registerHelper('getColFromRow', function(row, val, cols) {
const index = Object.entries(row).findIndex(el => el[1] === val);
const col = cols[index];

return col;
});

// Export
module.exports = fractal;
20 changes: 10 additions & 10 deletions src/lib/_imports/elements/table/table.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@
{{/each}}
{{#each data.rows}}
<tr>
{{#if id}}<td data-col="ID">{{ id }}</td>{{/if}}
{{#if name}}<td data-col="Name">{{ name }}</td>{{/if}}
{{#if name-link}}<td data-col="Name"><a href="#">{{ name-link }}</a></td>{{/if}}
{{#if id}}<td data-col="{{ getColFromRow this id @root.data.cols }}">{{ id }}</td>{{/if}}
{{#if name}}<td data-col="{{ getColFromRow this name @root.data.cols }}">{{ name }}</td>{{/if}}
{{#if name-link}}<td data-col="{{ getColFromRow this name-link @root.data.cols }}"><a href="#">{{ name-link }}</a></td>{{/if}}
{{#if paragraph}}
<td data-col="Summary" title="{{> @text-of-one-paragraph-short }}">
<td data-col="{{ getColFromRow this paragraph @root.data.cols }}" title="{{> @text-of-one-paragraph-short }}">
<p>{{> @text-of-one-paragraph-short }}</p>
</td>
{{/if}}
{{#if sentence}}
<td data-col="Sentence" title="{{> @text-of-one-sentence }}">
<td data-col="{{ getColFromRow this sentence @root.data.cols }}" title="{{> @text-of-one-sentence }}">
<span>{{> @text-of-one-sentence }}</span>
</td>
{{/if}}
{{#if custom-1}}<td data-col="Size">{{{ custom-1 }}}</td>{{/if}}
{{#if custom-2}}<td data-col="">{{{ custom-2 }}}</td>{{/if}}
{{#if custom-3}}<td data-col="">{{{ custom-3 }}}</td>{{/if}}
{{#if time}}<td data-col="Time"><time>{{ time }}</time></td>{{/if}}
{{#if custom-1}}<td data-col="{{ getColFromRow this custom-1 @root.data.cols }}">{{{ custom-1 }}}</td>{{/if}}
{{#if custom-2}}<td data-col="{{ getColFromRow this custom-2 @root.data.cols }}">{{{ custom-2 }}}</td>{{/if}}
{{#if custom-3}}<td data-col="{{ getColFromRow this custom-3 @root.data.cols }}">{{{ custom-3 }}}</td>{{/if}}
{{#if time}}<td data-col="{{ getColFromRow this time @root.data.cols }}"><time>{{ time }}</time></td>{{/if}}
{{#if acts}}
<td data-col="Actions">
<td data-col="{{ getColFromRow this acts @root.data.cols }}">
<ul>
{{#each acts}}
{{#if is-link }}<li><a href="#">{{ text }}</a></li>{{/if}}
Expand Down