yafowil.widget.location 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. yafowil_widget_location-2.0.0/.gitignore +20 -0
  2. yafowil_widget_location-2.0.0/CHANGES.rst +106 -0
  3. yafowil_widget_location-2.0.0/LICENSE.rst +27 -0
  4. yafowil_widget_location-2.0.0/PKG-INFO +67 -0
  5. yafowil_widget_location-2.0.0/README.rst +44 -0
  6. yafowil_widget_location-2.0.0/TODO.rst +4 -0
  7. yafowil_widget_location-2.0.0/pyproject.toml +69 -0
  8. yafowil_widget_location-2.0.0/src/yafowil/widget/location/__init__.py +198 -0
  9. yafowil_widget_location-2.0.0/src/yafowil/widget/location/example.py +135 -0
  10. yafowil_widget_location-2.0.0/src/yafowil/widget/location/locales/de/LC_MESSAGES/yafowil.widget.location.mo +0 -0
  11. yafowil_widget_location-2.0.0/src/yafowil/widget/location/locales/de/LC_MESSAGES/yafowil.widget.location.po +44 -0
  12. yafowil_widget_location-2.0.0/src/yafowil/widget/location/locales/en/LC_MESSAGES/yafowil.widget.location.mo +0 -0
  13. yafowil_widget_location-2.0.0/src/yafowil/widget/location/locales/en/LC_MESSAGES/yafowil.widget.location.po +44 -0
  14. yafowil_widget_location-2.0.0/src/yafowil/widget/location/locales/yafowil.widget.location.pot +49 -0
  15. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/bootstrap5/widget.js +277 -0
  16. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/bootstrap5/widget.min.css +1 -0
  17. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/bootstrap5/widget.min.js +1 -0
  18. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/default/widget.js +232 -0
  19. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/default/widget.min.css +1 -0
  20. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/default/widget.min.js +1 -0
  21. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/dist/images/layers-2x.png +0 -0
  22. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/dist/images/layers.png +0 -0
  23. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/dist/images/marker-icon-2x.png +0 -0
  24. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/dist/images/marker-icon.png +0 -0
  25. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/dist/images/marker-shadow.png +0 -0
  26. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/dist/leaflet-src.esm.js +13968 -0
  27. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/dist/leaflet-src.esm.js.map +1 -0
  28. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/dist/leaflet-src.js +14062 -0
  29. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/dist/leaflet-src.js.map +1 -0
  30. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/dist/leaflet.css +640 -0
  31. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/dist/leaflet.js +6 -0
  32. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/dist/leaflet.js.map +1 -0
  33. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/images/layers-2x.png +0 -0
  34. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/images/layers.png +0 -0
  35. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/images/marker-icon-2x.png +0 -0
  36. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/images/marker-icon.png +0 -0
  37. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/images/marker-shadow.png +0 -0
  38. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/leaflet-src.js +14062 -0
  39. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/leaflet-src.js.map +1 -0
  40. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/leaflet.css +640 -0
  41. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/leaflet.js +6 -0
  42. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet/leaflet.js.map +1 -0
  43. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet-geosearch/geosearch.css +240 -0
  44. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet-geosearch/geosearch.umd.js +2 -0
  45. yafowil_widget_location-2.0.0/src/yafowil/widget/location/resources/leaflet-geosearch/geosearch.umd.js.map +1 -0
  46. yafowil_widget_location-2.0.0/src/yafowil/widget/location/tests/test_widget.py +366 -0
  47. yafowil_widget_location-2.0.0/src/yafowil/widget/location/widget.py +291 -0
@@ -0,0 +1,20 @@
1
+ *.egg-info
2
+ *.pyc
3
+ *.pyo
4
+ /.coverage
5
+ /.mxmake/
6
+ /build
7
+ /constraints-mxdev.txt
8
+ /coverage/
9
+ /dist/
10
+ /htmlcov/
11
+ /js/karma/
12
+ /node_modules/
13
+ /package-lock.json
14
+ /pnpm-lock.yaml
15
+ /py2/
16
+ /py3/
17
+ /pypy3/
18
+ /requirements-mxdev.txt
19
+ /sources/
20
+ /venv/
@@ -0,0 +1,106 @@
1
+ Changes
2
+ =======
3
+
4
+ 2.0.0 (2026-02-03)
5
+ ------------------
6
+
7
+ - Refactor package layout to use ``pyproject.toml`` and implicit namespace packages.
8
+ [rnix]
9
+
10
+ - Introduce ``disable_interaction`` widget property and ``location_display_renderer``.
11
+ [lenadax]
12
+
13
+ - Update jQuery to version ``4.0.0-beta.2``.
14
+ [lenadax]
15
+
16
+ - Use Bootstrap icons as custom Leaflet markers.
17
+ [lenadax]
18
+
19
+ - Implement dark theme for ``Bootstrap5`` dark theme mode using css filters.
20
+ [lenadax]
21
+
22
+ - Use rollup for bundling scss. Use ``make rollup`` to compile js and scss.
23
+ [lenadax]
24
+
25
+ - Use ``webtestrunner`` instead of ``karma`` for js tests. Use ``make wtr`` to run tests.
26
+ [lenadax]
27
+
28
+ - Use ``pnpm`` as package manager.
29
+ [lenadax]
30
+
31
+ - Use default ``zoom`` if ``extract_zoom`` is ``True`` but no zoom given on
32
+ request.
33
+ [rnix]
34
+
35
+ - Prevent initialize if widget is part of array template.
36
+ [lenadax]
37
+
38
+ - Extend JS by ``location_on_array_add`` and ``register_array_subscribers``
39
+ functions to enable usage in ``yafowil.widget.array``.
40
+ [lenadax]
41
+
42
+ - Rewrite JavaScript using ES6.
43
+ [rnix]
44
+
45
+ - Introduce ``show_lat_lon`` widget property. If True, latitude and longtude
46
+ additionally can be entered manually in inpuf fields.
47
+ [rnix]
48
+
49
+ - Consider ``emptyvalue`` at extraction time.
50
+ [rnix]
51
+
52
+ - Introdude ``factory`` widget property. Defines a factory which is used to
53
+ instance ectraction value.
54
+ [rnix]
55
+
56
+ - Introduce ``extract_zoom`` widget property. Defines whether to include
57
+ zoom level on extracted value.
58
+ [rnix]
59
+
60
+ - Create Bootstrap5 widget version.
61
+ [lenadax]
62
+
63
+ - Rewrite Javascript with ES6 classes.
64
+ [rnix]
65
+
66
+ - Update leaflet to 1.7.1 and leaflet-geosearch to 3.5.0.
67
+ [rnix]
68
+
69
+ **Breaking changes**
70
+
71
+ - Empty extration value is ``None`` instead of empty dictionary.
72
+ [rnix]
73
+
74
+
75
+ 1.3 (2025-11-03)
76
+ ----------------
77
+
78
+ - Pin upper versions of dependencies.
79
+ [lenadax]
80
+
81
+
82
+ 1.2 (2018-07-16)
83
+ ----------------
84
+
85
+ - Python 3 compatibility.
86
+ [rnix]
87
+
88
+ - Convert doctests to unittests.
89
+ [rnix]
90
+
91
+
92
+ 1.1 (2017-03-01)
93
+ ----------------
94
+
95
+ - Use ``yafowil.utils.entry_point`` decorator.
96
+ [rnix, 2016-06-28]
97
+
98
+ - Raise ``ValueError`` in ``location_extractor`` if malformed request is
99
+ received.
100
+ [rnix]
101
+
102
+ 1.0 (2015-01-23)
103
+ ----------------
104
+
105
+ - Make it work.
106
+ [rnix]
@@ -0,0 +1,27 @@
1
+ License
2
+ =======
3
+
4
+ Copyright (c) 2014-2021, BlueDynamics Alliance, Austria, Germany, Switzerland
5
+ Copyright (c) 2021-2025, Yafowil Contributors
6
+ All rights reserved.
7
+
8
+ Redistribution and use in source and binary forms, with or without
9
+ modification, are permitted provided that the following conditions are met:
10
+
11
+ * Redistributions of source code must retain the above copyright notice, this
12
+ list of conditions and the following disclaimer.
13
+
14
+ * Redistributions in binary form must reproduce the above copyright notice, this
15
+ list of conditions and the following disclaimer in the documentation and/or
16
+ other materials provided with the distribution.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.4
2
+ Name: yafowil.widget.location
3
+ Version: 2.0.0
4
+ Summary: Location picker widget for YAFOWIL
5
+ Author-email: Yafowil Contributors <dev@conestack.org>
6
+ License: Simplified BSD
7
+ License-File: LICENSE.rst
8
+ Classifier: Environment :: Web Environment
9
+ Classifier: License :: OSI Approved :: BSD License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
18
+ Requires-Dist: yafowil>3.99
19
+ Provides-Extra: test
20
+ Requires-Dist: lxml; extra == 'test'
21
+ Requires-Dist: pytest; extra == 'test'
22
+ Description-Content-Type: text/x-rst
23
+
24
+ .. image:: https://img.shields.io/pypi/v/yafowil.widget.location.svg
25
+ :target: https://pypi.python.org/pypi/yafowil.widget.location
26
+ :alt: Latest PyPI version
27
+
28
+ .. image:: https://img.shields.io/pypi/dm/yafowil.widget.location.svg
29
+ :target: https://pypi.python.org/pypi/yafowil.widget.location
30
+ :alt: Number of PyPI downloads
31
+
32
+ .. image:: https://github.com/conestack/yafowil.widget.location/actions/workflows/test_py.yaml/badge.svg
33
+ :target: https://github.com/conestack/yafowil.widget.location/actions/workflows/test_py.yaml
34
+ :alt: Test yafowil.widget.location Python
35
+
36
+ .. image:: https://github.com/conestack/yafowil.widget.location/actions/workflows/test_js.yaml/badge.svg
37
+ :target: https://github.com/conestack/yafowil.widget.location/actions/workflows/test_js.yaml
38
+ :alt: Test yafowil.widget.location JS
39
+
40
+ This is the location widget for `yafowil <http://pypi.python.org/pypi/yafowil>`_,
41
+ based on `Leaflet <http://leafletjs.org>`_
42
+
43
+ - `Documentation <http://docs.yafowil.info/en/latest/blueprints.html#location>`_
44
+
45
+ - `DEMO - see it Live <http://demo.yafowil.info/++widget++yafowil.widget.location/index.html>`_
46
+
47
+ - This widget uses `leaflet <https://leafletjs.com/>`_ (1.7.1) and
48
+ `leaflet-geosearch <https://smeijer.github.io/leaflet-geosearch>`_ (3.5.0).
49
+
50
+
51
+ Source Code
52
+ ===========
53
+
54
+ The sources are in a GIT DVCS with its main branches at
55
+ `github <http://github.com/conestack/yafowil.widget.location>`_.
56
+
57
+ We'd be happy to see many forks and pull-requests to make YAFOWIL even better.
58
+
59
+
60
+ Contributors
61
+ ============
62
+
63
+ - Robert Niederreiter
64
+
65
+ - Georg Bernhard
66
+
67
+ - Lena Daxenbichler
@@ -0,0 +1,44 @@
1
+ .. image:: https://img.shields.io/pypi/v/yafowil.widget.location.svg
2
+ :target: https://pypi.python.org/pypi/yafowil.widget.location
3
+ :alt: Latest PyPI version
4
+
5
+ .. image:: https://img.shields.io/pypi/dm/yafowil.widget.location.svg
6
+ :target: https://pypi.python.org/pypi/yafowil.widget.location
7
+ :alt: Number of PyPI downloads
8
+
9
+ .. image:: https://github.com/conestack/yafowil.widget.location/actions/workflows/test_py.yaml/badge.svg
10
+ :target: https://github.com/conestack/yafowil.widget.location/actions/workflows/test_py.yaml
11
+ :alt: Test yafowil.widget.location Python
12
+
13
+ .. image:: https://github.com/conestack/yafowil.widget.location/actions/workflows/test_js.yaml/badge.svg
14
+ :target: https://github.com/conestack/yafowil.widget.location/actions/workflows/test_js.yaml
15
+ :alt: Test yafowil.widget.location JS
16
+
17
+ This is the location widget for `yafowil <http://pypi.python.org/pypi/yafowil>`_,
18
+ based on `Leaflet <http://leafletjs.org>`_
19
+
20
+ - `Documentation <http://docs.yafowil.info/en/latest/blueprints.html#location>`_
21
+
22
+ - `DEMO - see it Live <http://demo.yafowil.info/++widget++yafowil.widget.location/index.html>`_
23
+
24
+ - This widget uses `leaflet <https://leafletjs.com/>`_ (1.7.1) and
25
+ `leaflet-geosearch <https://smeijer.github.io/leaflet-geosearch>`_ (3.5.0).
26
+
27
+
28
+ Source Code
29
+ ===========
30
+
31
+ The sources are in a GIT DVCS with its main branches at
32
+ `github <http://github.com/conestack/yafowil.widget.location>`_.
33
+
34
+ We'd be happy to see many forks and pull-requests to make YAFOWIL even better.
35
+
36
+
37
+ Contributors
38
+ ============
39
+
40
+ - Robert Niederreiter
41
+
42
+ - Georg Bernhard
43
+
44
+ - Lena Daxenbichler
@@ -0,0 +1,4 @@
1
+ TODO
2
+ ====
3
+
4
+ - Refactor server side to render widget as compound.
@@ -0,0 +1,69 @@
1
+ [build-system]
2
+ requires = ["hatchling", "hatch-fancy-pypi-readme"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "yafowil.widget.location"
7
+ version = "2.0.0"
8
+ description = "Location picker widget for YAFOWIL"
9
+ readme = "README.rst"
10
+ license = {text = "Simplified BSD"}
11
+ authors = [{name = "Yafowil Contributors", email = "dev@conestack.org"}]
12
+ classifiers = [
13
+ "Environment :: Web Environment",
14
+ "Operating System :: OS Independent",
15
+ "Programming Language :: Python",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Programming Language :: Python :: 3.14",
21
+ "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
22
+ "License :: OSI Approved :: BSD License",
23
+ ]
24
+ dependencies = [
25
+ "yafowil>3.99",
26
+ ]
27
+
28
+ [project.optional-dependencies]
29
+ test = [
30
+ "lxml",
31
+ "pytest",
32
+ ]
33
+
34
+ [project.entry-points."yafowil.plugin"]
35
+ register = "yafowil.widget.location:register"
36
+ example = "yafowil.widget.location.example:get_example"
37
+
38
+ [tool.hatch.metadata.hooks.fancy-pypi-readme]
39
+ content-type = "text/x-rst"
40
+ fragments = [
41
+ {path = "README.rst"},
42
+ {text = "\n\n"},
43
+ {path = "CHANGES.rst"},
44
+ {text = "\n\n"},
45
+ {path = "LICENSE.rst"},
46
+ ]
47
+
48
+ [tool.hatch.build.targets.sdist]
49
+ exclude = [
50
+ "/.github/",
51
+ "/js/",
52
+ "/Makefile",
53
+ "/mx.ini",
54
+ "/mxmake.yaml",
55
+ "/package.json",
56
+ "/pnpm-lock.yaml",
57
+ "/scss",
58
+ ]
59
+
60
+ [tool.hatch.build.targets.wheel]
61
+ packages = ["src/yafowil"]
62
+
63
+ [tool.pytest.ini_options]
64
+ consider_namespace_packages = true
65
+ addopts = ["--import-mode=importlib"]
66
+ pythonpath = "src"
67
+
68
+ [tool.zest-releaser]
69
+ create-wheel = true
@@ -0,0 +1,198 @@
1
+ from yafowil.base import factory
2
+ from yafowil.utils import entry_point
3
+ import os
4
+ import webresource as wr
5
+
6
+
7
+ resources_dir = os.path.join(os.path.dirname(__file__), 'resources')
8
+
9
+
10
+ ##############################################################################
11
+ # Leaflet
12
+ ##############################################################################
13
+
14
+ # webresource ################################################################
15
+
16
+ leaflet_js = wr.ScriptResource(
17
+ name='leaflet-js',
18
+ directory=os.path.join(resources_dir, 'leaflet'),
19
+ path='yafowil-location/leaflet',
20
+ resource='leaflet-src.js',
21
+ compressed='leaflet.js'
22
+ )
23
+ leaflet_css = wr.StyleResource(
24
+ name='leaflet-css',
25
+ directory=os.path.join(resources_dir, 'leaflet'),
26
+ path='yafowil-location/leaflet',
27
+ resource='leaflet.css'
28
+ )
29
+ leaflet_geosearch_js = wr.ScriptResource(
30
+ name='leaflet-geosearch-js',
31
+ depends='leaflet-js',
32
+ directory=os.path.join(resources_dir, 'leaflet-geosearch'),
33
+ path='yafowil-location/leaflet-geosearch',
34
+ resource='geosearch.umd.js'
35
+ )
36
+ leaflet_geosearch_css = wr.StyleResource(
37
+ name='leaflet-geosearch-css',
38
+ depends='leaflet-css',
39
+ directory=os.path.join(resources_dir, 'leaflet-geosearch'),
40
+ path='yafowil-location/leaflet-geosearch',
41
+ resource='geosearch.css'
42
+ )
43
+
44
+ ##############################################################################
45
+ # Default
46
+ ##############################################################################
47
+
48
+ # webresource ################################################################
49
+
50
+ resources = wr.ResourceGroup(
51
+ name='yafowil.widget.location',
52
+ directory=resources_dir,
53
+ path='yafowil-location'
54
+ )
55
+ resources.add(leaflet_js)
56
+ resources.add(leaflet_css)
57
+ resources.add(leaflet_geosearch_js)
58
+ resources.add(leaflet_geosearch_css)
59
+ resources.add(wr.ScriptResource(
60
+ name='yafowil-location-js',
61
+ directory=os.path.join(resources_dir, 'default'),
62
+ path='yafowil-location/default',
63
+ depends=['jquery-js', 'leaflet-geosearch-js'],
64
+ resource='widget.js',
65
+ compressed='widget.min.js'
66
+ ))
67
+ resources.add(wr.StyleResource(
68
+ name='yafowil-location-css',
69
+ directory=os.path.join(resources_dir, 'default'),
70
+ path='yafowil-location/default',
71
+ depends='leaflet-geosearch-css',
72
+ resource='widget.min.css'
73
+ ))
74
+
75
+ # B/C resources ##############################################################
76
+
77
+ js = [{
78
+ 'group': 'yafowil.widget.location.dependencies',
79
+ 'resource': 'leaflet/leaflet.js',
80
+ 'order': 20,
81
+ }, {
82
+ 'group': 'yafowil.widget.location.dependencies',
83
+ 'resource': 'leaflet-geosearch/geosearch.umd.js',
84
+ 'order': 21,
85
+ }, {
86
+ 'group': 'yafowil.widget.location.common',
87
+ 'resource': 'default/widget.js',
88
+ 'order': 23,
89
+ }]
90
+ css = [{
91
+ 'group': 'yafowil.widget.location.dependencies',
92
+ 'resource': 'leaflet/leaflet.css',
93
+ 'order': 20,
94
+ }, {
95
+ 'group': 'yafowil.widget.location.dependencies',
96
+ 'resource': 'leaflet-geosearch/geosearch.css',
97
+ 'order': 21,
98
+ }, {
99
+ 'group': 'yafowil.widget.location.common',
100
+ 'resource': 'default/widget.min.css',
101
+ 'order': 22,
102
+ }]
103
+
104
+
105
+ ##############################################################################
106
+ # Bootstrap 5
107
+ ##############################################################################
108
+
109
+ # webresource ################################################################
110
+
111
+ bootstrap5_resources = wr.ResourceGroup(
112
+ name='yafowil.widget.location',
113
+ directory=resources_dir,
114
+ path='yafowil-location'
115
+ )
116
+ bootstrap5_resources.add(leaflet_js)
117
+ bootstrap5_resources.add(leaflet_css)
118
+ bootstrap5_resources.add(leaflet_geosearch_js)
119
+ bootstrap5_resources.add(leaflet_geosearch_css)
120
+ bootstrap5_resources.add(wr.ScriptResource(
121
+ name='yafowil-location-js',
122
+ directory=os.path.join(resources_dir, 'bootstrap5'),
123
+ path='yafowil-location/bootstrap5',
124
+ depends=['jquery-js', 'leaflet-geosearch-js'],
125
+ resource='widget.js',
126
+ compressed='widget.min.js'
127
+ ))
128
+ bootstrap5_resources.add(wr.StyleResource(
129
+ name='yafowil-location-css',
130
+ directory=os.path.join(resources_dir, 'bootstrap5'),
131
+ path='yafowil-location/bootstrap5',
132
+ depends='leaflet-geosearch-css',
133
+ resource='widget.min.css'
134
+ ))
135
+
136
+ # B/C resources ##############################################################
137
+
138
+ bootstrap5_js = [{
139
+ 'group': 'yafowil.widget.location.dependencies',
140
+ 'resource': 'leaflet/leaflet.js',
141
+ 'order': 20,
142
+ }, {
143
+ 'group': 'yafowil.widget.location.dependencies',
144
+ 'resource': 'leaflet-geosearch/geosearch.umd.js',
145
+ 'order': 21,
146
+ }, {
147
+ 'group': 'yafowil.widget.location.common',
148
+ 'resource': 'bootstrap5/widget.js',
149
+ 'order': 23,
150
+ }]
151
+ bootstrap5_css = [{
152
+ 'group': 'yafowil.widget.location.dependencies',
153
+ 'resource': 'leaflet/leaflet.css',
154
+ 'order': 20,
155
+ }, {
156
+ 'group': 'yafowil.widget.location.dependencies',
157
+ 'resource': 'leaflet-geosearch/geosearch.css',
158
+ 'order': 21,
159
+ }, {
160
+ 'group': 'yafowil.widget.location.common',
161
+ 'resource': 'bootstrap5/widget.min.css',
162
+ 'order': 22,
163
+ }]
164
+
165
+ ##############################################################################
166
+ # Registration
167
+ ##############################################################################
168
+
169
+ @entry_point(order=10)
170
+ def register():
171
+ from yafowil.widget.location import widget # noqa
172
+
173
+ widget_name = 'yafowil.widget.location'
174
+
175
+ # Default
176
+ factory.register_theme(
177
+ 'default',
178
+ widget_name,
179
+ resources_dir,
180
+ js=js,
181
+ css=css
182
+ )
183
+ factory.register_resources('default', widget_name, resources)
184
+
185
+ # Bootstrap 5
186
+ factory.register_theme(
187
+ ['bootstrap5'],
188
+ widget_name,
189
+ resources_dir,
190
+ js=bootstrap5_js,
191
+ css=bootstrap5_css
192
+ )
193
+
194
+ factory.register_resources(
195
+ ['bootstrap5'],
196
+ widget_name,
197
+ bootstrap5_resources
198
+ )
@@ -0,0 +1,135 @@
1
+ from yafowil.base import factory
2
+
3
+
4
+ DOC_LOCATION = """
5
+ Location
6
+ --------
7
+
8
+ Location picker widget.
9
+
10
+ .. code-block:: python
11
+
12
+ location = factory('#field:location', props={
13
+ 'label': 'Location',
14
+ 'help': 'Search and pick a location on the map',
15
+ 'required': 'Location is required',
16
+ 'lat': 47.2667,
17
+ 'lon': 11.3833,
18
+ 'zoom': 14,
19
+ })
20
+ """
21
+
22
+
23
+ def location_example():
24
+ form = factory('fieldset', name='yafowil.widget.location.location')
25
+ form['location'] = factory('#field:location', props={
26
+ 'label': 'Location',
27
+ 'help': 'Search and pick a location on the map',
28
+ 'required': 'Location is required',
29
+ 'lat': 47.2667,
30
+ 'lon': 11.3833,
31
+ 'zoom': 14,
32
+ })
33
+ return {
34
+ 'widget': form,
35
+ 'doc': DOC_LOCATION,
36
+ 'title': 'Location',
37
+ }
38
+
39
+
40
+ DOC_LOCATION_WITH_PRESET_VALUE = """
41
+ Location with preset value
42
+ --------------------------
43
+
44
+ Location picker widget with preset value.
45
+
46
+ .. code-block:: python
47
+
48
+ value = {
49
+ 'lat': 47.2667,
50
+ 'lon': 11.3833,
51
+ 'zoom': 14,
52
+ }
53
+ location = factory('#field:location', value=value, props={
54
+ 'label': 'Location',
55
+ 'help': 'Search and pick a location on the map',
56
+ 'required': 'Location is required',
57
+ })
58
+ """
59
+
60
+
61
+ def location_with_preset_value_example():
62
+ name = 'yafowil.widget.location.location_with_preset_value'
63
+ form = factory('fieldset', name=name)
64
+ value = {
65
+ 'lat': 47.2667,
66
+ 'lon': 11.3833,
67
+ 'zoom': 14,
68
+ }
69
+ form['location'] = factory('#field:location', value=value, props={
70
+ 'label': 'Location',
71
+ 'help': 'Search and pick a location on the map',
72
+ 'required': 'Location is required',
73
+ })
74
+ return {
75
+ 'widget': form,
76
+ 'doc': DOC_LOCATION_WITH_PRESET_VALUE,
77
+ 'title': 'Location with preset value',
78
+ }
79
+
80
+
81
+ DOC_LOCATION_DISPLAY = """
82
+ Display Mode / Disabled Mode
83
+ ----------------------------
84
+
85
+ The ``disable_interaction`` widget attribute prevents interaction with the widget.
86
+ The widget's display mode automatically sets ``disable_interaction`` to True.
87
+
88
+ Zooming and panning is still supported, but Markers cannot be added, edited or removed.
89
+
90
+ The wrapper div can receive additional classes via the ``display_class``
91
+ widget attribute.
92
+
93
+ .. code-block:: python
94
+
95
+ value = {
96
+ 'lat': 47.2667,
97
+ 'lon': 11.3833,
98
+ 'zoom': 14,
99
+ }
100
+ location = factory('#field:location', value=value, mode='display', props={
101
+ 'label': 'Location in Display Mode',
102
+ 'help': 'Search and pick a location on the map',
103
+ 'required': 'Location is required',
104
+ # 'disable_interaction': True, # manually disable interaction
105
+ # 'display_class': 'my-additional-class'
106
+ })
107
+ """
108
+
109
+
110
+ def location_display():
111
+ name = 'yafowil.widget.location.display'
112
+ form = factory('fieldset', name=name)
113
+ value = {
114
+ 'lat': 47.2667,
115
+ 'lon': 11.3833,
116
+ 'zoom': 14,
117
+ }
118
+ form['location'] = factory('#field:location', value=value, mode='display', props={
119
+ 'label': 'Location in Display Mode',
120
+ 'help': 'Search and pick a location on the map',
121
+ 'required': 'Location is required'
122
+ })
123
+ return {
124
+ 'widget': form,
125
+ 'doc': DOC_LOCATION_DISPLAY,
126
+ 'title': 'Display Mode',
127
+ }
128
+
129
+
130
+ def get_example():
131
+ return [
132
+ location_example(),
133
+ location_with_preset_value_example(),
134
+ location_display()
135
+ ]