imio.smartweb.core 1.2.91__py3-none-any.whl → 1.3__py3-none-any.whl

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 (92) hide show
  1. imio/smartweb/core/browser/controlpanel.py +42 -5
  2. imio/smartweb/core/browser/utils.py +4 -1
  3. imio/smartweb/core/configure.zcml +5 -1
  4. imio/smartweb/core/contents/__init__.py +2 -0
  5. imio/smartweb/core/contents/rest/campaign/__init__.py +0 -0
  6. imio/smartweb/core/contents/rest/campaign/configure.zcml +80 -0
  7. imio/smartweb/core/contents/rest/campaign/content.py +83 -0
  8. imio/smartweb/core/contents/rest/campaign/endpoint.py +211 -0
  9. imio/smartweb/core/contents/rest/campaign/view.pt +19 -0
  10. imio/smartweb/core/contents/rest/campaign/view.py +29 -0
  11. imio/smartweb/core/contents/rest/configure.zcml +1 -0
  12. imio/smartweb/core/interfaces.py +4 -0
  13. imio/smartweb/core/overrides.zcml +10 -0
  14. imio/smartweb/core/profiles/default/metadata.xml +1 -1
  15. imio/smartweb/core/profiles/ideabox/browserlayer.xml +7 -0
  16. imio/smartweb/core/profiles/ideabox/metadata.xml +5 -0
  17. imio/smartweb/core/profiles/ideabox/registry/iaideabox.xml +9 -0
  18. imio/smartweb/core/profiles/ideabox/types/imio.smartweb.CampaignView.xml +40 -0
  19. imio/smartweb/core/profiles/ideabox/types/imio.smartweb.Folder.xml +71 -0
  20. imio/smartweb/core/profiles/ideabox/types.xml +17 -0
  21. imio/smartweb/core/profiles/ideabox_uninstall/browserlayer.xml +7 -0
  22. imio/smartweb/core/profiles/ideabox_uninstall/types/imio.smartweb.Folder.xml +25 -0
  23. imio/smartweb/core/profiles/ideabox_uninstall/types.xml +4 -0
  24. imio/smartweb/core/profiles/testing/metadata.xml +1 -0
  25. imio/smartweb/core/profiles/testing/registry.xml +2 -2
  26. imio/smartweb/core/profiles.zcml +18 -0
  27. imio/smartweb/core/subscribers.py +27 -1
  28. imio/smartweb/core/subscribers.zcml +8 -0
  29. imio/smartweb/core/tests/resources/json_ideabox_campaign.json +222 -0
  30. imio/smartweb/core/tests/resources/json_ideabox_campaigns.json +425 -0
  31. imio/smartweb/core/tests/resources/json_ideabox_projects.json +1871 -0
  32. imio/smartweb/core/tests/test_iadeliberations.py +38 -40
  33. imio/smartweb/core/tests/test_ideabox.py +120 -0
  34. imio/smartweb/core/tests/test_procedure.py +7 -3
  35. imio/smartweb/core/tests/test_rest.py +7 -0
  36. imio/smartweb/core/tests/test_vocabularies.py +8 -10
  37. imio/smartweb/core/upgrades/configure.zcml +16 -1
  38. imio/smartweb/core/upgrades/upgrades.py +64 -0
  39. imio/smartweb/core/utils.py +33 -0
  40. imio/smartweb/core/viewlets/ogptags.py +9 -0
  41. imio/smartweb/core/vocabularies.py +35 -4
  42. imio/smartweb/core/vocabularies.zcml +6 -0
  43. imio/smartweb/core/webcomponents/build/css/373.smartweb-webcomponents-compiled.css +1 -1
  44. imio/smartweb/core/webcomponents/build/css/420.smartweb-webcomponents-compiled.css +1 -0
  45. imio/smartweb/core/webcomponents/build/css/486.smartweb-webcomponents-compiled.css +1 -1
  46. imio/smartweb/core/webcomponents/build/css/666.smartweb-webcomponents-compiled.css +1 -0
  47. imio/smartweb/core/webcomponents/build/css/884.smartweb-webcomponents-compiled.css +1 -1
  48. imio/smartweb/core/webcomponents/build/css/smartweb-webcomponents-compiled.css +1 -1
  49. imio/smartweb/core/webcomponents/build/js/141.smartweb-webcomponents-compiled.js +2 -0
  50. imio/smartweb/core/webcomponents/build/js/{828.smartweb-webcomponents-compiled.js.LICENSE.txt → 141.smartweb-webcomponents-compiled.js.LICENSE.txt} +3 -3
  51. imio/smartweb/core/webcomponents/build/js/15.smartweb-webcomponents-compiled.js +2 -0
  52. imio/smartweb/core/webcomponents/build/js/21.smartweb-webcomponents-compiled.js +1 -0
  53. imio/smartweb/core/webcomponents/build/js/218.smartweb-webcomponents-compiled.js +1 -1
  54. imio/smartweb/core/webcomponents/build/js/218.smartweb-webcomponents-compiled.js.LICENSE.txt +0 -5
  55. imio/smartweb/core/webcomponents/build/js/373.smartweb-webcomponents-compiled.js +1 -1
  56. imio/smartweb/core/webcomponents/build/js/486.smartweb-webcomponents-compiled.js +1 -1
  57. imio/smartweb/core/webcomponents/build/js/666.smartweb-webcomponents-compiled.js +1 -0
  58. imio/smartweb/core/webcomponents/build/js/799.smartweb-webcomponents-compiled.js +1 -1
  59. imio/smartweb/core/webcomponents/build/js/824.smartweb-webcomponents-compiled.js +1 -1
  60. imio/smartweb/core/webcomponents/build/js/884.smartweb-webcomponents-compiled.js +1 -1
  61. imio/smartweb/core/webcomponents/build/js/919.smartweb-webcomponents-compiled.js +1 -1
  62. imio/smartweb/core/webcomponents/build/js/922.smartweb-webcomponents-compiled.js +1 -0
  63. imio/smartweb/core/webcomponents/build/js/smartweb-webcomponents-compiled.js +1 -1
  64. imio/smartweb/core/webcomponents/package.json +80 -80
  65. imio/smartweb/core/webcomponents/src/components/Annuaire/Annuaire.scss +1 -0
  66. imio/smartweb/core/webcomponents/src/components/Campaign/Campaign.jsx +306 -0
  67. imio/smartweb/core/webcomponents/src/components/Campaign/Campaign.scss +672 -0
  68. imio/smartweb/core/webcomponents/src/components/Campaign/CampaignCard/CampaignCard.jsx +79 -0
  69. imio/smartweb/core/webcomponents/src/components/Campaign/CampaignContent/CampaignContent.jsx +193 -0
  70. imio/smartweb/core/webcomponents/src/components/Campaign/CampaignList/CampaignList.jsx +67 -0
  71. imio/smartweb/core/webcomponents/src/components/Campaign/Filters/Filter.jsx +259 -0
  72. imio/smartweb/core/webcomponents/src/components/Campaign/index.js +2 -0
  73. imio/smartweb/core/webcomponents/src/components/Filters/MainFilter.scss +1 -0
  74. imio/smartweb/core/webcomponents/src/components/News/NewsContent/NewsContent.jsx +0 -1
  75. imio/smartweb/core/webcomponents/src/hooks/useAxios.js +45 -9
  76. imio/smartweb/core/webcomponents/src/index.jsx +2 -0
  77. imio/smartweb/core/webcomponents/src/index.scss +2 -2
  78. imio/smartweb/core/webcomponents/src/utils/CampaignMap.jsx +177 -0
  79. imio/smartweb/core/webcomponents/src/utils/Map.jsx +1 -1
  80. imio/smartweb/core/webcomponents/src/utils/Map.scss +15 -1
  81. imio/smartweb/core/webcomponents/src/utils/translation.js +235 -199
  82. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.dist-info}/METADATA +8 -1
  83. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.dist-info}/RECORD +90 -57
  84. imio/smartweb/core/webcomponents/build/js/499.smartweb-webcomponents-compiled.js +0 -2
  85. imio/smartweb/core/webcomponents/build/js/828.smartweb-webcomponents-compiled.js +0 -2
  86. /imio/smartweb/core/webcomponents/build/js/{499.smartweb-webcomponents-compiled.js.LICENSE.txt → 15.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
  87. /imio.smartweb.core-1.2.91-py3.12-nspkg.pth → /imio.smartweb.core-1.3-py3.12-nspkg.pth +0 -0
  88. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.dist-info}/LICENSE.GPL +0 -0
  89. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.dist-info}/LICENSE.rst +0 -0
  90. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.dist-info}/WHEEL +0 -0
  91. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.dist-info}/namespace_packages.txt +0 -0
  92. {imio.smartweb.core-1.2.91.dist-info → imio.smartweb.core-1.3.dist-info}/top_level.txt +0 -0
@@ -16,25 +16,61 @@ const useAxios = (params) => {
16
16
  } else {
17
17
  setIsMore(false);
18
18
  }
19
- if (Object.keys(params.params).length == 0) {
19
+
20
+ if (Object.keys(params.params).length === 0) {
20
21
  setResponse(null);
21
22
  return;
22
- } else {
23
- try {
23
+ }
24
+
25
+ try {
26
+ // Handle multiple URLs with identifiers
27
+ if (Array.isArray(params.url)) {
28
+ const requests = params.url.map((urlConfig, index) => {
29
+ const { url, identifier } =
30
+ typeof urlConfig === "string"
31
+ ? { url: urlConfig, identifier: `request_${index}` }
32
+ : urlConfig;
33
+
34
+ return axios
35
+ .request({
36
+ ...params,
37
+ url,
38
+ signal: controller.signal,
39
+ })
40
+ .then((res) => ({
41
+ identifier,
42
+ data: res.data,
43
+ }));
44
+ });
45
+
46
+ const responses = await Promise.all(requests);
47
+ // Convert array to object with identifiers as keys
48
+ const responseObject = responses.reduce((acc, { identifier, data }) => {
49
+ acc[identifier] = data;
50
+ return acc;
51
+ }, {});
52
+
53
+ setResponse(responseObject);
54
+ }
55
+ // Handle single URL
56
+ else {
24
57
  const res = await axios.request(params);
25
58
  setResponse(res.data);
26
- setIsLoading(false);
27
- setError(null);
28
- } catch (err) {
29
- setError(err);
30
59
  }
60
+ setIsLoading(false);
61
+ setError(null);
62
+ } catch (err) {
63
+ setError(err);
64
+ setIsLoading(false);
31
65
  }
32
66
  };
67
+
33
68
  useEffect(() => {
34
69
  fetchData({ ...params, signal: controller.signal });
35
- return () => controller.abort()
70
+ return () => controller.abort();
36
71
  }, [params.params]);
72
+
37
73
  return { response, error, isLoading, isMore };
38
74
  };
39
75
 
40
- export default useAxios;
76
+ export default useAxios;
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import ReactWebComponent from "react-web-component";
3
3
  import Annuaire from "./components/Annuaire";
4
+ import Campaign from "./components/Campaign";
4
5
  import News from "./components/News";
5
6
  import Events from "./components/Events";
6
7
  import Search from "./components/Search";
@@ -11,6 +12,7 @@ import "./index.scss";
11
12
  Note: if your webcomponent depends on external css, disable shadow root
12
13
  */
13
14
  ReactWebComponent.create(<Annuaire />, "smartweb-annuaire", false);
15
+ ReactWebComponent.create(<Campaign />, "smartweb-campaign", false);
14
16
  ReactWebComponent.create(<News />, "smartweb-news", false);
15
17
  ReactWebComponent.create(<Events />, "smartweb-events", false);
16
18
  ReactWebComponent.create(<Search />, "smartweb-search", false);
@@ -280,9 +280,9 @@
280
280
  height: 100%;
281
281
  top: 0;
282
282
  left: 0;
283
- background-size: cover;
283
+ background-size: 130%;
284
284
  background-position: center;
285
- opacity: 0.8;
285
+ opacity: 0.6;
286
286
  }
287
287
 
288
288
  &-img {
@@ -0,0 +1,177 @@
1
+ import React, { useState, useEffect } from "react";
2
+ import { MapContainer, TileLayer, Marker, Popup, useMap } from "react-leaflet";
3
+ import useFilterQuery from "../hooks/useFilterQuery";
4
+ import L from "leaflet";
5
+ import iconSvg from "../assets/pin-react.svg";
6
+ import iconSvgActivated from "../assets/pin-react-active.svg";
7
+ import { Link } from "react-router-dom";
8
+ import "./Map.scss";
9
+ import "leaflet/dist/leaflet.css";
10
+ import removeAccents from "remove-accents";
11
+ import queryString from "query-string";
12
+ import { el } from "date-fns/locale";
13
+
14
+ function ChangeMapView({ activeItem, arrayOfLatLngs }) {
15
+ const map = useMap();
16
+ if (activeItem) {
17
+ const activeCoord = [];
18
+ activeCoord.push(activeItem.fields.geolocalisation.lat);
19
+ activeCoord.push(activeItem.fields.geolocalisation.lon);
20
+ map.setView(activeCoord, 15);
21
+ } else {
22
+ let bounds = new L.LatLngBounds(arrayOfLatLngs);
23
+ map.fitBounds(bounds);
24
+ }
25
+ return null;
26
+ }
27
+
28
+ function Map(props) {
29
+ const [activeItem, setActiveItem] = useState(null);
30
+ const [filterGeoArray, setFilterGeoArray] = useState([]);
31
+ const [allPosition, setAllPosition] = useState(null);
32
+ const { u, ...parsed } = Object.assign({
33
+ id: queryString.parse(useFilterQuery().toString())["u"],
34
+ });
35
+ // Delete Imio positions
36
+ useEffect(() => {
37
+ if (!props.items) {
38
+ return;
39
+ }
40
+ const filterArray = props.items.filter((isgeo) => {
41
+ if (isgeo.fields) {
42
+ return (
43
+ isgeo.fields.geolocalisation.lat &&
44
+ isgeo.fields.geolocalisation.lat !== 50.4989185 &&
45
+ isgeo.fields.geolocalisation.lon !== 4.7184485
46
+ );
47
+ } else {
48
+ return (
49
+ isgeo.geolocation.latitude &&
50
+ isgeo.geolocation.latitude !== 50.4989185 &&
51
+ isgeo.geolocation.longitude !== 4.7184485
52
+ );
53
+ }
54
+ });
55
+ setFilterGeoArray(filterArray);
56
+ }, [props.items]);
57
+
58
+ // Setup Maker Icon
59
+ const mapIcon = (url) => {
60
+ return new L.Icon({
61
+ iconUrl: url,
62
+ iconSize: [29, 37],
63
+ });
64
+ };
65
+ // Get Marker Icon and Z-index
66
+ const getMarkerIcon = (index) => {
67
+ if (index === parsed.id) {
68
+ return mapIcon(iconSvgActivated);
69
+ }
70
+ if (index === props.hoverId) {
71
+ return mapIcon(iconSvgActivated);
72
+ }
73
+ return mapIcon(iconSvg);
74
+ };
75
+ const getMarkerZindex = (index) => {
76
+ if (index === props.clickId) {
77
+ return 999;
78
+ }
79
+ if (index === props.hoverId) {
80
+ return 999;
81
+ }
82
+ return 1;
83
+ };
84
+
85
+ useEffect(() => {
86
+ var result =
87
+ filterGeoArray &&
88
+ filterGeoArray.filter((obj) => {
89
+ return obj.id === parsed.id;
90
+ });
91
+ setActiveItem(result[0]);
92
+ }, [filterGeoArray]);
93
+
94
+ useEffect(() => {
95
+ if (filterGeoArray.length > 0) {
96
+ let posArray = [];
97
+ filterGeoArray.map((pos, i) => {
98
+ let lat = pos.fields.geolocalisation.lat;
99
+ let long = pos.fields.geolocalisation.lon;
100
+ posArray.push([lat, long]);
101
+ });
102
+ setAllPosition(posArray);
103
+ }
104
+ }, [filterGeoArray]);
105
+ const position = [50.85034, 4.35171];
106
+
107
+ const markers = filterGeoArray.map((mark, i) => (
108
+ <Marker
109
+ key={i}
110
+ icon={getMarkerIcon(mark.id)}
111
+ zIndexOffset={getMarkerZindex(mark.id)}
112
+ position={[
113
+ mark.fields.geolocalisation ? mark.fields.geolocalisation.lat : "",
114
+ mark.fields.geolocalisation ? mark.fields.geolocalisation.lon : "",
115
+ ]}
116
+ eventHandlers={{
117
+ mouseover: (e) => {
118
+ // Gérer les événements ici
119
+ },
120
+ }}
121
+ >
122
+ <Popup closeButton={false}>
123
+ <Link
124
+ className="r-map-popup"
125
+ style={{ textDecoration: "none" }}
126
+ to={{
127
+ pathname:
128
+ "/" +
129
+ removeAccents(mark.text)
130
+ .replace(/[^a-zA-Z ]/g, "")
131
+ .replace(/\s/g, "-")
132
+ .toLowerCase(),
133
+ search: `?u=${mark.id}`,
134
+ state: {
135
+ idItem: mark.id,
136
+ },
137
+ }}
138
+ >
139
+ <span className="r-map-popup-title">{mark.text}</span>
140
+ </Link>
141
+ <a
142
+ href={`https://www.google.com/maps/dir/?api=1&destination=${mark.fields.rue ? mark.fields.rue + " " + mark.fields.numero : ""}`}
143
+ className="r-map-popup-adress"
144
+ >
145
+ {mark.fields.rue && mark.fields.rue + " " + mark.fields.numero}
146
+ </a>
147
+ </Popup>
148
+ </Marker>
149
+ ));
150
+
151
+ return (
152
+ <div>
153
+ <MapContainer
154
+ style={{ height: `calc(100vh - ${props.headerHeight}px)`, minHeight: "600px" }}
155
+ center={position}
156
+ zoom={35}
157
+ >
158
+ <TileLayer
159
+ attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
160
+ url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
161
+ />
162
+ {allPosition != null ? (
163
+ <ChangeMapView
164
+ activeItem={activeItem}
165
+ activeItemUID={parsed.id}
166
+ arrayOfLatLngs={allPosition && allPosition}
167
+ />
168
+ ) : (
169
+ ""
170
+ )}
171
+ {filterGeoArray && markers}
172
+ </MapContainer>
173
+ </div>
174
+ );
175
+ }
176
+
177
+ export default Map;
@@ -91,7 +91,7 @@ function Map(props) {
91
91
  }, [filterGeoArray]);
92
92
  const position = [50.85034, 4.35171];
93
93
 
94
- const markers = filterGeoArray.map((mark,i) => (
94
+ const markers = filterGeoArray.map((mark, i) => (
95
95
  <Marker
96
96
  key={i}
97
97
  icon={getMarkerIcon(mark.UID)}
@@ -4,4 +4,18 @@
4
4
 
5
5
  .leaflet-popup {
6
6
  padding: 0;
7
- }
7
+ }
8
+ .r-map-popup-title {
9
+ font-weight: bold;
10
+ text-decoration: none !important;
11
+ }
12
+
13
+ .r-map-popup-adress {
14
+ font-size: 1em;
15
+ text-decoration: underline;
16
+ display: block;
17
+ margin-top: 0.5rem;
18
+ color: #202228;
19
+ position: relative;
20
+ z-index: 1;
21
+ }