Skip to content

Commit

Permalink
Merge 366d6ba into cd4ee5e
Browse files Browse the repository at this point in the history
  • Loading branch information
klikstermkd committed Nov 8, 2019
2 parents cd4ee5e + 366d6ba commit d85e17e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
11 changes: 1 addition & 10 deletions ckanext/visualize/fanstatic/js/modules/visualize-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,7 @@ ckan.module('visualize-data', function($) {
{
label: 'Some dataset label',
data: [],
backgroundColor: [
'#332288',
'#117733',
'#44AA99',
'#88CCEE',
'#DDCC77',
'#CC6677',
'#AA4499',
'#882255'
]
backgroundColor: '#332288'
}
]
};
Expand Down
2 changes: 1 addition & 1 deletion ckanext/visualize/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def get_fields_without_id(resource_id):
:rtype: list """

fields = _get_fields(resource_id)
return [{'value': v['id']} for v in fields if v['id'] != '_id']
return [{'value': v['id'], 'type': v['type']} for v in fields if v['id'] != '_id']


def _get_fields(resource_id):
Expand Down
21 changes: 20 additions & 1 deletion ckanext/visualize/templates/snippets/visualize_view_show.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,27 @@
<section class="col-md-10">
<ul id="all-columns" class="list-group group-items-select list-group-horizontal">
{% for field in fields %}
{% if field.type == 'text' %}
{% set column_color = '#332288' %}
{% elif field.type == 'numeric' %}
{% set column_color = '#117733' %}
{% elif field.type == 'date' %}
{% set column_color = '#44AA99' %}
{% elif field.type == 'time' %}
{% set column_color = '#88CCEE' %}
{% elif field.type == 'timestamp' %}
{% set column_color = '#DDCC77' %}
{% elif field.type == 'bool' %}
{% set column_color = '#CC6677' %}
{% elif field.type == 'int' %}
{% set column_color = '#AA4499' %}
{% elif field.type == 'float' %}
{% set column_color = '#882255' %}
{% else %}
{% set column_color = '#332288' %}
{% endif %}
<li class="list-group-item column" data-column="{{ field.value }}">
<span class="badge-pill color-secondary column-pill">{{ field.value }}</span>
<span class="badge-pill column-pill" style="background-color: {{ column_color }};">{{ field.value }}</span>
</li>
{% endfor %}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion ckanext/visualize/tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_setup_template_variables(self):
assert result == {
'resource': {'id': resource.get('id')},
'resource_view': {},
'fields': [{'value': u'Age'}, {'value': u'Name'}],
'fields': [{'value': u'Age', 'type': 'numeric'}, {'value': u'Name', 'type': 'text'}],
}

def test_view_template(self):
Expand Down

0 comments on commit d85e17e

Please sign in to comment.