diff --git a/CHANGELOG.md b/CHANGELOG.md index 55ce5e8..2c95667 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,6 @@ All notable changes to wuttaweb will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## v0.10.2 (2024-08-19) - -### Fix - -- add `render_vue_finalize()` methods for grids, forms -- avoid error when checking model for column property - ## v0.10.1 (2024-08-19) ### Fix diff --git a/pyproject.toml b/pyproject.toml index 5902f86..cc4cdf2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "WuttaWeb" -version = "0.10.2" +version = "0.10.1" description = "Web App for Wutta Framework" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@edbob.org"}] diff --git a/src/wuttaweb/forms/base.py b/src/wuttaweb/forms/base.py index 5acca59..6b16bdd 100644 --- a/src/wuttaweb/forms/base.py +++ b/src/wuttaweb/forms/base.py @@ -918,42 +918,19 @@ class Form: return HTML.tag('b-field', c=[html], **attrs) - def render_vue_finalize(self): - """ - Render the Vue "finalize" script for the form. - - By default this simply returns: - - .. code-block:: html - - - - The actual output may depend on various form attributes, in - particular :attr:`vue_tagname`. - """ - set_data = f"{self.vue_component}.data = function() {{ return {self.vue_component}Data }}" - make_component = f"Vue.component('{self.vue_tagname}', {self.vue_component})" - return HTML.tag('script', c=['\n', - HTML.literal(set_data), - '\n', - HTML.literal(make_component), - '\n']) - def get_vue_model_data(self): """ Returns a dict with form model data. Values may be nested depending on the types of fields contained in the form. - This collects the ``cstruct`` values for all fields which are - present both in :attr:`fields` as well as the Deform schema. + Note that the values need not be "converted" (to be + JSON-compatible) at this stage, for instance ``colander.null`` + is not a problem here. The point is to collect the raw data. - It also converts each as needed, to ensure it is - JSON-serializable. + The dict should have a key/value for each field in the form. - :returns: Dict of field/value items. + This method is called by :meth:`render_vue_model_data()` which + is responsible for ensuring JSON compatibility. """ dform = self.get_deform() model_data = {} diff --git a/src/wuttaweb/grids/base.py b/src/wuttaweb/grids/base.py index 3f22aad..9a6b195 100644 --- a/src/wuttaweb/grids/base.py +++ b/src/wuttaweb/grids/base.py @@ -578,8 +578,7 @@ class Grid: if key in sorters: continue prop = getattr(self.model_class, key, None) - if (prop and hasattr(prop, 'property') - and isinstance(prop.property, orm.ColumnProperty)): + if prop and isinstance(prop.property, orm.ColumnProperty): sorters[prop.key] = self.make_sorter(prop) return sorters @@ -1278,30 +1277,6 @@ class Grid: output = render(template, context) return HTML.literal(output) - def render_vue_finalize(self): - """ - Render the Vue "finalize" script for the grid. - - By default this simply returns: - - .. code-block:: html - - - - The actual output may depend on various grid attributes, in - particular :attr:`vue_tagname`. - """ - set_data = f"{self.vue_component}.data = function() {{ return {self.vue_component}Data }}" - make_component = f"Vue.component('{self.vue_tagname}', {self.vue_component})" - return HTML.tag('script', c=['\n', - HTML.literal(set_data), - '\n', - HTML.literal(make_component), - '\n']) - def get_vue_columns(self): """ Returns a list of Vue-compatible column definitions. diff --git a/src/wuttaweb/templates/form.mako b/src/wuttaweb/templates/form.mako index 9a0d21e..fc6d3c0 100644 --- a/src/wuttaweb/templates/form.mako +++ b/src/wuttaweb/templates/form.mako @@ -3,9 +3,7 @@ <%def name="page_content()">
- % if form is not Undefined: - ${form.render_vue_tag()} - % endif + ${form.render_vue_tag()}
@@ -19,7 +17,10 @@ <%def name="finalize_this_page_vars()"> ${parent.finalize_this_page_vars()} % if form is not Undefined: - ${form.render_vue_finalize()} + % endif diff --git a/src/wuttaweb/templates/grids/vue_template.mako b/src/wuttaweb/templates/grids/vue_template.mako index b161d9f..568cfc7 100644 --- a/src/wuttaweb/templates/grids/vue_template.mako +++ b/src/wuttaweb/templates/grids/vue_template.mako @@ -37,7 +37,7 @@ ## paging % if grid.paginated: paginated - pagination-size="${'small' if request.use_oruga else 'is-small'}" + pagination-size="is-small" :per-page="perPage" :current-page="currentPage" @page-change="onPageChange" diff --git a/src/wuttaweb/templates/master/index.mako b/src/wuttaweb/templates/master/index.mako index 6731f65..2b6f14b 100644 --- a/src/wuttaweb/templates/master/index.mako +++ b/src/wuttaweb/templates/master/index.mako @@ -22,7 +22,10 @@ <%def name="finalize_this_page_vars()"> ${parent.finalize_this_page_vars()} % if grid is not Undefined: - ${grid.render_vue_finalize()} + % endif diff --git a/tests/forms/test_base.py b/tests/forms/test_base.py index 70ee55f..399ecaf 100644 --- a/tests/forms/test_base.py +++ b/tests/forms/test_base.py @@ -405,12 +405,6 @@ class TestForm(TestCase): self.assertIn('