From 1be329706a93cf6df30e36dc4812fe8c32a4a3e3 Mon Sep 17 00:00:00 2001 From: Vitor Baptista Date: Wed, 26 Mar 2014 20:48:19 -0300 Subject: [PATCH] [#23] Move basiccharts_filters_form --- .../basiccharts/theme/public/basiccharts.css | 27 --------- .../theme/public/basiccharts_filters_form.js | 59 ------------------- .../basiccharts/theme/public/resource.config | 6 +- .../theme/templates/basechart_form.html | 4 +- 4 files changed, 3 insertions(+), 93 deletions(-) delete mode 100644 ckanext/basiccharts/theme/public/basiccharts.css delete mode 100644 ckanext/basiccharts/theme/public/basiccharts_filters_form.js diff --git a/ckanext/basiccharts/theme/public/basiccharts.css b/ckanext/basiccharts/theme/public/basiccharts.css deleted file mode 100644 index 793fb67..0000000 --- a/ckanext/basiccharts/theme/public/basiccharts.css +++ /dev/null @@ -1,27 +0,0 @@ -.basicChart { - height: 500px; -} - -.basicChart .error { - display: none; -} - -.dashboard-grid .basicChart { - height: 99%; - width: 100%; -} - -.dashboard-grid .basicChart.pie { - width: 90%; -} - -.basicChart .pieLabel div { - font-size: inherit !important; - color: inherit !important; -} - -.pages-embed .basicChart { - height: 100%; - width: 100%; -} - diff --git a/ckanext/basiccharts/theme/public/basiccharts_filters_form.js b/ckanext/basiccharts/theme/public/basiccharts_filters_form.js deleted file mode 100644 index 34698e9..0000000 --- a/ckanext/basiccharts/theme/public/basiccharts_filters_form.js +++ /dev/null @@ -1,59 +0,0 @@ -ckan.module("basiccharts_filters_form", function (jQuery) { - "use strict"; - - function applyDropdown(selectField, filterValues) { - var inputField = selectField.parent().find('input'), - inputValue = inputField.val(), - valueList = filterValues[selectField.val()]; - - if (valueList) { - inputField.select2({ - data: valueList, - width: '220px' - }); - } - } - - function initialize() { - var self = this, - templateFilterInputs = self.options.templateFilterInputs, - inputFieldTemplateEl = $(templateFilterInputs).find('input[type="text"][name]'), - filtersDiv = self.el.find(self.options.filtersSelector), - addFilterEl = self.el.find(self.options.addFilterSelector), - removeFilterSelector = self.options.removeFilterSelector, - filterValues = self.options.filterValues || {}; - - var selects = filtersDiv.find('select'); - selects.each(function (i, select) { - applyDropdown($(select), filterValues); - }); - - addFilterEl.click(function (evt) { - var selectField; - evt.preventDefault(); - filtersDiv.append(templateFilterInputs); - selectField = filtersDiv.children().last().find('select'); - applyDropdown(selectField, filterValues); - }); - - filtersDiv.on('click', removeFilterSelector, function (evt) { - evt.preventDefault(); - $(this).parent().remove(); - }); - - filtersDiv.on('change', 'select', function (evt) { - var el = $(this), - parentEl = el.parent(), - inputField = parentEl.find('input'), - select2Container = parentEl.find('.select2-container'); - evt.preventDefault(); - select2Container.remove(); - inputField.replaceWith(inputFieldTemplateEl.clone()); - applyDropdown(el, filterValues); - }); - } - - return { - initialize: initialize - }; -}); diff --git a/ckanext/basiccharts/theme/public/resource.config b/ckanext/basiccharts/theme/public/resource.config index bf38a6d..67d43ce 100644 --- a/ckanext/basiccharts/theme/public/resource.config +++ b/ckanext/basiccharts/theme/public/resource.config @@ -6,7 +6,7 @@ lte IE 8 = [depends] -main = base/main +main = viewhelpers/main [groups] @@ -23,7 +23,3 @@ main = basiccharts_view.js basiccharts.css - -form = - basiccharts_filters_form.js - basechart_form.css diff --git a/ckanext/basiccharts/theme/templates/basechart_form.html b/ckanext/basiccharts/theme/templates/basechart_form.html index d06bc84..2c85009 100644 --- a/ckanext/basiccharts/theme/templates/basechart_form.html +++ b/ckanext/basiccharts/theme/templates/basechart_form.html @@ -1,5 +1,5 @@ {% import 'macros/form.html' as form %} -{% resource 'basiccharts/form' %} +{% resource 'viewhelpers/form' %} {% macro filtersInputs(name, selectName, inputName, label='', options='', error='', filters={}, classes=[], attrs={}, is_required=false) %} {% set classes = (classes|list) %} @@ -35,7 +35,7 @@ {% set filters = { 'fields': resource_view['filter_fields'], 'values': resource_view['filter_values'] } %}