Skip to content

Commit

Permalink
Feature/component map (#9)
Browse files Browse the repository at this point in the history
* add first approach to component with a map

* fix in component routes and add map js logic

* make rubocop happy

* add query to graphql api to show meetings and proposals, still without templates as popup

* fix use of templates in awesome map

* update bundle && erblint

* rearrange map into a single component

* update gemfiles and appraisal

* fix gemfile

* fix gemfile

* fix gemfile

* fix dummy app bndle

* revert automatic gemfile version finder

* normalize yml

* add seeds to awesome

* refactor javascript

* add geolocation to proposals in assemblys when seeding

* add customizable height

* ask only if elements are geolocated

* fix dropdown zindex

* custom icon for meetings

* custom icons

* add pagination to api queries (#11)

* add colors based on categories to markers (#12)

* add colors based on categories to markers

* set fillColor to --primary in case the category has no color assigned

* use a Category class

* add category layers

* add category colors

* add amendments layer

* search for category names

* automatic choose best language

* intelligent label placement

* refactor category assignation

* style fixes

* add specs

* fix unpublished components

* fix empy nodes

* try to fix not found image from leaflet

* Add readme info

* remove custom asset

* override assets

* fix finall call on paginate

* erblint

* New Crowdin updates (#18)

* New translations en.yml (French)

* New translations en.yml (Spanish)

* New translations en.yml (Catalan)

* fix asset definition

* fix category filter management

* New Crowdin updates (#19)

* New translations en.yml (French)

* New translations en.yml (Spanish)

* New translations en.yml (Catalan)

* New translations en.yml (Catalan)

Co-authored-by: Ivan Vergés <[email protected]>

* do not hide parent categories

* add menu collapse option

* fix test

* disable codeclimate reporter

* New Crowdin updates (#21)

* New translations en.yml (French)

* New translations en.yml (Spanish)

* New translations en.yml (Catalan)

* New translations en.yml (Catalan)

* New translations en.yml (French)

* New translations en.yml (Spanish)

* New translations en.yml (Catalan)

* New translations en.yml (Catalan)

Co-authored-by: Ivan Vergés <[email protected]>

* New Crowdin updates (#23)

* New translations en.yml (French)

* New translations en.yml (Spanish)

* New translations en.yml (Catalan)

* New translations en.yml (Catalan)

* New translations en.yml (French)

* New translations en.yml (Spanish)

* New translations en.yml (Catalan)

* New translations en.yml (Catalan)

* New translations en.yml (Spanish)

* New translations en.yml (Spanish)

Co-authored-by: Ivan Vergés <[email protected]>

Co-authored-by: David Igón <[email protected]>
Co-authored-by: Platoniq Bot <[email protected]>
  • Loading branch information
3 people authored Sep 18, 2020
1 parent 6498360 commit 78dd8cf
Show file tree
Hide file tree
Showing 53 changed files with 1,783 additions and 109 deletions.
2 changes: 2 additions & 0 deletions .csslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--exclude-exts=.min.css
--ignore=adjoining-classes,box-model,ids,order-alphabetical,unqualified-attributes
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"globals": {
"$": false,
"jQuery": false,
"L": false,
"ApiFetcher": false,
"FormStorage": false,
"Quill": false,
"InscrybMDE": false,
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ jobs:
- name: Setup Database
run: bundle exec rake test_app

- name: Setup Code Climate test-reporter
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
# - name: Setup Code Climate test-reporter
# run: |
# curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
# chmod +x ./cc-test-reporter
# ./cc-test-reporter before-build

- name: Run RSpec
run: SIMPLECOV=1 CODECOV=1 bundle exec appraisal rake

- name: Publish code coverage
run: |
export GIT_BRANCH="${GITHUB_REF/refs\/heads\//}"
./cc-test-reporter after-build -r "$CC_TEST_REPORTER_ID"
env:
CC_TEST_REPORTER_ID: 094100f11a0b69b24e4deab7adc5532006239e0803a8b1964b3000766bca5de1
# - name: Publish code coverage
# run: |
# export GIT_BRANCH="${GITHUB_REF/refs\/heads\//}"
# ./cc-test-reporter after-build -r "$CC_TEST_REPORTER_ID"
# env:
# CC_TEST_REPORTER_ID: 094100f11a0b69b24e4deab7adc5532006239e0803a8b1964b3000766bca5de1
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source "https://rubygems.org"

ruby RUBY_VERSION
# DECIDIM_VERSION = { git: "https://github.com/decidim/decidim" }

DECIDIM_VERSION = "0.21"

gem "decidim", DECIDIM_VERSION
Expand Down
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
decidim-decidim_awesome (0.2)
decidim-decidim_awesome (0.3)
decidim-admin (>= 0.20.0)
decidim-core (>= 0.20.0)
redcarpet (~> 3.4)
Expand Down Expand Up @@ -75,7 +75,7 @@ GEM
babel-source (>= 4.0, < 6)
execjs (~> 2.0)
batch-loader (1.5.0)
bcrypt (3.1.15)
bcrypt (3.1.16)
better_html (1.0.15)
actionview (>= 4.0)
activesupport (>= 4.0)
Expand Down Expand Up @@ -115,7 +115,7 @@ GEM
cells (>= 4.1.6, < 5.0.0)
charlock_holmes (0.7.7)
childprocess (3.0.0)
codecov (0.2.9)
codecov (0.2.11)
json
simplecov
coercible (1.0.0)
Expand Down Expand Up @@ -484,7 +484,7 @@ GEM
mini_magick (4.10.1)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.1)
minitest (5.14.2)
mixlib-cli (1.7.0)
mixlib-config (2.2.18)
tomlrb
Expand All @@ -494,7 +494,7 @@ GEM
multipart-post (2.1.1)
mustache (1.1.1)
netrc (0.11.0)
nio4r (2.5.2)
nio4r (2.5.3)
nobspw (0.6.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
Expand Down Expand Up @@ -544,8 +544,8 @@ GEM
premailer-rails (1.11.1)
actionmailer (>= 3)
premailer (~> 1.7, >= 1.7.9)
public_suffix (4.0.5)
puma (4.3.5)
public_suffix (4.0.6)
puma (4.3.6)
nio4r (~> 2.0)
rack (2.2.3)
rack-attack (6.3.1)
Expand Down Expand Up @@ -602,7 +602,7 @@ GEM
virtus (~> 1.0.5)
wisper (>= 1.6.1)
redcarpet (3.5.0)
redis (4.2.1)
redis (4.2.2)
regexp_parser (1.7.1)
request_store (1.5.0)
rack (>= 1.4)
Expand Down
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,16 @@ Many scopes can be defined for every tweak.

![Admin tweaks for editors](examples/admin-editors.png)

#### 6. Awesome map component

#### 6. To be continued...
This is a component you can add in any participatory space. It retrieves all the geolocated content in that participatory space (meetings or proposals) and displays it in a big map.

It also provides a simple search by category, each category is assignated to a different color.

![Awesome map](examples/awesome-map.png)


#### To be continued...

Some things in the road-map:

Expand Down Expand Up @@ -184,7 +192,6 @@ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake test_
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal rspec
```


Note that the database user has to have rights to create and drop a database in
order to create the dummy test app database.

Expand All @@ -206,6 +213,23 @@ SIMPLECOV=1 bundle exec rspec
This will generate a folder named `coverage` in the project root which contains
the code coverage report.

### Appraisals commands

Appraisal uses custom gems for testing in the folder `gemfiles`, in order to update the Gemfile we normaly use:

```
bundle update
```

To update the Appraisal definitions do the following:

```
cd gemfiles
BUNDLE_GEMFILE=./decidim_0.XX.gemfile bundle update
```

Where 0.XX is the supported version that needs to be updated.

### Localization

If you would like to see this module in your own language, you can help with its
Expand Down
1 change: 1 addition & 0 deletions app/assets/config/decidim_decidim_awesome_manifest.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
*= link decidim/decidim_awesome/application.css
*= link decidim/decidim_awesome/awesome_map/map.css
*/
1 change: 1 addition & 0 deletions app/assets/config/decidim_decidim_awesome_manifest.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// = link decidim/decidim_awesome/application.js
// = link decidim/decidim_awesome/awesome_map/map.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// = require decidim/decidim_awesome/proposals/images
// = require decidim/decidim_awesome/editors/quill_editor
// = require decidim/decidim_awesome/editors/markdown_view
// = require decidim/decidim_awesome/forms/autosave
// = require decidim/decidim_awesome/forms/autosave
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* eslint-disable no-unused-vars */

class ApiFetcher {

constructor(query, variables) {
this.query = query;
this.variables = variables;
}

fetch(callback) {
$.ajax({
method: "POST",
url: "/api",
contentType: "application/json",
data: JSON.stringify({
query: this.query,
variables: this.variables
})
}).done(function(data) {
callback(data.data);
});
}

fetchAll (callback) {
this.fetch(callback);
}

static findTranslation(translations) {
let text, lang = document.querySelector('html').getAttribute('lang');

translations.forEach((t) => {
if(t.text) {
if(!text || t.locale == lang) {
text = t.text
}
}
});
return text;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
((exports) => {

const getCategory = (category) => {
let defaultCat = {
color: getComputedStyle(document.documentElement).getPropertyValue('--primary'),
children: () => {},
parent: null,
name: null
};
if(category) {
let id = category.id ? parseInt(category.id, 10) : parseInt(category, 10);
let cat = exports.AwesomeMap.categories.find((c) => c.id == id);
if(cat) {
cat.children = () => {
return exports.AwesomeMap.categories.filter((c) => c.parent === cat.id );
}
return cat;
}
}
return defaultCat;
};

exports.AwesomeMap = exports.AwesomeMap || {};
exports.AwesomeMap.getCategory = getCategory;
})(window);
Loading

0 comments on commit 78dd8cf

Please sign in to comment.