Skip to content

Commit

Permalink
wip: proposal status
Browse files Browse the repository at this point in the history
  • Loading branch information
Hadrien Froger committed Oct 16, 2024
1 parent eb17542 commit 0d05ffe
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/cells/decidim/geo/content_blocks/geo_maps_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions app/packs/src/decidim/geo/ui/DrawerListItem/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as meetings } from "./meetings";
export { default as proposals } from "./proposals";
export { default as fallback } from "./fallback";
8 changes: 6 additions & 2 deletions app/packs/src/decidim/geo/ui/DrawerListItem/item.js
Original file line number Diff line number Diff line change
@@ -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);
}
};
Expand Down
51 changes: 51 additions & 0 deletions app/packs/src/decidim/geo/ui/DrawerListItem/proposals.js
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions lib/decidim/geo/proposal/proposal_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0d05ffe

Please sign in to comment.