diff --git a/app/cells/decidim/geo/content_blocks/geo_maps_cell.rb b/app/cells/decidim/geo/content_blocks/geo_maps_cell.rb index 002e617..2662a67 100644 --- a/app/cells/decidim/geo/content_blocks/geo_maps_cell.rb +++ b/app/cells/decidim/geo/content_blocks/geo_maps_cell.rb @@ -82,6 +82,7 @@ def geo_i18n geo_i18n = supported_models.to_h { **geo_i18n, + "decidim.geo.proposals.states": t("decidim.admin.filters.proposals.state_eq.values"), "decidim.geo.mobile.open_fullscreen": t("decidim.geo.mobile.open_fullscreen"), "decidim.geo.mobile.close_fullscreen": t("decidim.geo.mobile.close_fullscreen"), "decidim_geo.scopes.all": t("decidim.geo.scopes.all"), diff --git a/app/packs/src/decidim/geo/ui/DrawerListItem/index.js b/app/packs/src/decidim/geo/ui/DrawerListItem/index.js index 94c4a09..67a5225 100644 --- a/app/packs/src/decidim/geo/ui/DrawerListItem/index.js +++ b/app/packs/src/decidim/geo/ui/DrawerListItem/index.js @@ -1,2 +1,3 @@ export { default as meetings } from "./meetings"; +export { default as proposals } from "./proposals"; export { default as fallback } from "./fallback"; diff --git a/app/packs/src/decidim/geo/ui/DrawerListItem/item.js b/app/packs/src/decidim/geo/ui/DrawerListItem/item.js index 31873ce..514009b 100644 --- a/app/packs/src/decidim/geo/ui/DrawerListItem/item.js +++ b/app/packs/src/decidim/geo/ui/DrawerListItem/item.js @@ -1,11 +1,15 @@ import _ from "lodash"; -import { fallback, meetings } from "."; +import { fallback, meetings, proposals } from "."; const item = (node) => { switch (node.resourceType) { case "meetings": return meetings(node); - default: + case "proposals": + return proposals(node); + case "reporting_proposals": + return reporting_proposals(node); + default: return fallback(node); } }; diff --git a/app/packs/src/decidim/geo/ui/DrawerListItem/proposals.js b/app/packs/src/decidim/geo/ui/DrawerListItem/proposals.js new file mode 100644 index 0000000..15ab6d2 --- /dev/null +++ b/app/packs/src/decidim/geo/ui/DrawerListItem/proposals.js @@ -0,0 +1,51 @@ +import configStore from "../../stores/configStore"; +import createClasses from "../createClasses"; +import _ from "lodash"; + +const proposals = (node) => { + const { i18n, images, locale, defaultLocale } = configStore.getState(); + const states = i18n["decidim.geo.proposals.states"] + const listCard = L.DomUtil.create("li", "decidimGeo__drawer__listCard"); + const info = L.DomUtil.create( + "div", + "decidimGeo__drawer__listCardInfo decidimGeo__drawer__listCardInfo--large", + listCard + ); + const metadatas = L.DomUtil.create("div", "decidimGeo__drawer__metas", info); + + const infoType = L.DomUtil.create("div", "decidimGeo__drawer__listCardType", metadatas); + infoType.textContent = i18n[node.resourceType]; + + const notGeoEncodedIcon = L.DomUtil.create( + "img", + createClasses("decidimGeo__drawer__listCardIcon", [node.lonlat && "hidden"]), + infoType + ); + notGeoEncodedIcon.src = images?.not_geolocated; + + const infoTitle = L.DomUtil.create("div", "decidimGeo__drawer__listCardTitle", info); + infoTitle.textContent = node.title[locale] || node.title[defaultLocale]; + const status = node.resourceStatus || "published" + if(status){ + const infoStatus = L.DomUtil.create( + "div", + createClasses("decidimGeo__drawer__listCardStatus", [status]), + metadatas + ); + infoStatus.textContent = states[status] + } + + if (node.shortDescription) { + const infoDescription = L.DomUtil.create( + "div", + "decidimGeo__drawer__listCardDescription", + info + ); + infoDescription.textContent = + node.shortDescription[locale] || node.shortDescription[defaultLocale]; + } + + return listCard; +}; + +export default proposals; diff --git a/app/packs/stylesheets/decidim/geo/geo/_decidim_geo_drawer_list.scss b/app/packs/stylesheets/decidim/geo/geo/_decidim_geo_drawer_list.scss index 7856e93..51aecad 100644 --- a/app/packs/stylesheets/decidim/geo/geo/_decidim_geo_drawer_list.scss +++ b/app/packs/stylesheets/decidim/geo/geo/_decidim_geo_drawer_list.scss @@ -123,6 +123,32 @@ min-height: 16px; } + .decidimGeo__drawer__metas { + display: inline-flex; + gap: 0; + flex-direction: column; + margin-bottom: 4px; + } + + .decidimGeo__drawer__listCardStatus { + flex: 0; + padding: 1px 8px; + background: white; + border: 1px solid #808080; + border-radius: 18px; + font-size: 11px; + line-height: 1em; + text-align: center; + text-transform: uppercase; + &--withdrawn { + border-color: var(--alert); + color: var(--alert); + } + &--accepted { + border-color: var(--success); + color: var(--success); + } + } .decidimGeo__drawer__listCardTitle { color: var(--primary); font-size: 17px; diff --git a/lib/decidim/geo/proposal/proposal_filter.rb b/lib/decidim/geo/proposal/proposal_filter.rb index dcca5ea..917d9a0 100644 --- a/lib/decidim/geo/proposal/proposal_filter.rb +++ b/lib/decidim/geo/proposal/proposal_filter.rb @@ -5,23 +5,19 @@ module Geo module Api class ProposalFilter < DefaultFilter def filter_past(query) - query.where(resource_type: manifest_name, resource_status: %w(rejected accepted)).or( + query.where(resource_type: manifest_name, resource_status: %w(rejected)).or( super(query) ) end def filter_active(query) - query.where(resource_type: manifest_name, resource_status: %w(not_answered evaluating)).or( - query.where(resource_type: manifest_name, resource_status: nil) - ).or( + query.where(resource_type: manifest_name, resource_status: %w(not_answered evaluating)).where( super(query) ) end def filter_future(query) query.where(resource_type: manifest_name, resource_status: %w(not_answered evaluating)).or( - query.where(resource_type: manifest_name, resource_status: nil) - ).or( super(query) ) end