-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DATASHADES-319 / extension scuffold and tests
- Loading branch information
Showing
9 changed files
with
137 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
ckan.module("charts-json-form", function ($, _) { | ||
"use strict"; | ||
return { | ||
options: {}, | ||
|
||
initialize: function () { | ||
$.proxyAll(this, /_/); | ||
|
||
// var editor = new JSONEditor(document.getElementById('editor_holder'), { | ||
// theme: 'bootstrap5', | ||
// schema: { | ||
// type: "object", | ||
// title: "Car", | ||
// properties: { | ||
// make: { | ||
// type: "string", | ||
// enum: [ | ||
// "Toyota", | ||
// "BMW", | ||
// "Honda", | ||
// "Ford", | ||
// "Chevy", | ||
// "VW" | ||
// ] | ||
// }, | ||
// model: { | ||
// type: "string" | ||
// }, | ||
// year: { | ||
// type: "integer", | ||
// enum: [ | ||
// 1995, 1996, 1997, 1998, 1999, | ||
// 2000, 2001, 2002, 2003, 2004, | ||
// 2005, 2006, 2007, 2008, 2009, | ||
// 2010, 2011, 2012, 2013, 2014 | ||
// ], | ||
// default: 2008 | ||
// }, | ||
// safety: { | ||
// type: "integer", | ||
// format: "rating", | ||
// maximum: "5", | ||
// exclusiveMaximum: false, | ||
// readonly: false | ||
// } | ||
// } | ||
// } | ||
// }); | ||
|
||
// // Hook up the submit button to log to the console | ||
// document.getElementById('submit').addEventListener('click', function () { | ||
// // Get the value from the editor | ||
// console.log(editor.getValue()); | ||
// }); | ||
} | ||
}; | ||
}); |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
{% import "macros/form.html" as form %} | ||
{% asset "charts/plotly" %} | ||
|
||
<fieldset class="charts-view--chart-settings" | ||
hx-get="{{ h.url_for('charts_view.form', resource_id=resource_id) }}" | ||
hx-trigger="submit,change" | ||
hx-include="closest form" | ||
hx-swap="outerHTML" | ||
> | ||
<div id="editor_holder" data-module="charts-json-form"></div> | ||
|
||
<fieldset class="charts-view--chart-settings" hx-get="{{ h.url_for('charts_view.form', resource_id=resource_id) }}" | ||
hx-trigger="submit,change" hx-include="closest form" hx-swap="outerHTML"> | ||
|
||
{{ form.select("engine", label=_("Engine"), selected=settings.engine, options=[ | ||
{"value": "", "text": ""}, | ||
{"value": "plotly", "text": "plotly"}, | ||
]) }} | ||
{"value": "", "text": ""}, | ||
{"value": "plotly", "text": "plotly"}, | ||
]) }} | ||
|
||
{{ form.input("query", label=_("Query"), value=settings.query) }} | ||
|
||
{{settings}} | ||
{% if settings.engine == "plotly" %} | ||
{{ form.select("type", label=_("Type"), selected=settings.type, options=[ | ||
{"value": "", "text": ""}, | ||
{"value": "bar", "text": "Bar"}, | ||
{"value": "line", "text": "Line"}, | ||
{"value": "scatter", "text": "Scatter"}, | ||
]) }} | ||
|
||
{% if settings.type in ["bar", "line", "scatter"] %} | ||
{{ form.select("x", label=_("X Axis"), selected=settings.x, options=column_options) }} | ||
{{ form.checkbox("log_x", label=_("Log-scale x-axis"), checked=settings.log_x, value="yes") }} | ||
|
||
{{ form.select("y", label=_("Y Axis"), selected=settings.y, options=column_options) }} | ||
{{ form.checkbox("log_y", label=_("Log-scale y-axis"), checked=settings.log_y, value="yes") }} | ||
|
||
{{ form.select("color", label=_("Color"), selected=settings.color, options=[{"text": "", "value": ""}] + column_options) }} | ||
|
||
{{ form.select("animation_frame", label=_("Animation frame"), selected=settings.animation_frame, options=[{"text": "", "value": ""}] + column_options) }} | ||
{{ form.select("hover_name", label=_("Tooltip label"), selected=settings.hover_name, options=column_options) }} | ||
{{ form.input("limit", label=_("Limit"), value=settings.limit, type="number", attrs={"max": 10000, "class": "form-control"}) }} | ||
|
||
{{ form.select("size", label=_("Size"), selected=settings.size, options=[{"text": "", "value": ""}] + column_options) }} | ||
{{ form.input("size_max", label=_("Max size"), value=settings.size_max|default(20), type="number") }} | ||
{% endif %} | ||
{{ form.select("type", label=_("Type"), selected=settings.type, options=[ | ||
{"value": "", "text": ""}, | ||
{"value": "bar", "text": "Bar"}, | ||
{"value": "line", "text": "Line"}, | ||
{"value": "scatter", "text": "Scatter"}, | ||
]) }} | ||
|
||
{% if settings.type in ["bar", "line", "scatter"] %} | ||
{{ form.select("x", label=_("X Axis"), selected=settings.x, options=column_options) }} | ||
{{ form.checkbox("log_x", label=_("Log-scale x-axis"), checked=settings.log_x, value="yes") }} | ||
|
||
{{ form.select("y", label=_("Y Axis"), selected=settings.y, options=column_options) }} | ||
{{ form.checkbox("log_y", label=_("Log-scale y-axis"), checked=settings.log_y, value="yes") }} | ||
|
||
{{ form.select("color", label=_("Color"), selected=settings.color, options=[{"text": "", "value": ""}] + | ||
column_options) }} | ||
|
||
{{ form.select("animation_frame", label=_("Animation frame"), selected=settings.animation_frame, options=[{"text": | ||
"", "value": ""}] + column_options) }} | ||
{{ form.select("hover_name", label=_("Tooltip label"), selected=settings.hover_name, options=column_options) }} | ||
{{ form.input("limit", label=_("Limit"), value=settings.limit, type="number", attrs={"max": 10000, "class": | ||
"form-control"}) }} | ||
|
||
{{ form.select("size", label=_("Size"), selected=settings.size, options=[{"text": "", "value": ""}] + | ||
column_options) }} | ||
{{ form.input("size_max", label=_("Max size"), value=settings.size_max|default(20), type="number") }} | ||
{% endif %} | ||
{% endif %} | ||
|
||
<div class="charts-view--preview" id="charts-view--preview"> | ||
{% include ["charts/snippets/" ~ settings.engine ~ "_chart.html", "charts/snippets/unknown_chart.html"] %} | ||
</div> | ||
|
||
<input type="hidden" name="{{ g.csrf_field_name }}" value="{{ csrf_token() }}" | ||
hx-swap-oob='outerHTML:[name="{{ g.csrf_field_name }}"]' | ||
/> | ||
hx-swap-oob='outerHTML:[name="{{ g.csrf_field_name }}"]' /> | ||
|
||
</fieldset> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# encoding: utf-8 | ||
|
||
import pytest | ||
from ckan.common import config | ||
|
||
from urllib.parse import urljoin | ||
|
||
import ckan.lib.helpers as h | ||
import ckanext.textview.plugin as plugin | ||
from ckan.tests import factories | ||
|
||
|
||
@pytest.mark.usefixtures("clean_db", "with_plugins") | ||
class TestAllowedViews: | ||
|
||
def test_not_in_datastore(self): | ||
dataset = factories.Dataset() | ||
resource = factories.Resource(package_id=dataset["id"]) | ||
|
||
assert not h.get_allowed_view_types(resource, dataset) | ||
|
||
def test_in_datastore(self): | ||
dataset = factories.Dataset() | ||
resource = factories.Resource(package_id=dataset["id"], datastore_active=True) | ||
|
||
assert h.get_allowed_view_types(resource, dataset) == [ | ||
("charts_view", "Chart", "chart-line") | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
plotly | ||
pandas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters