Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add places controller #1

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5c229f2
Add places controller
EvertSalinas Nov 2, 2021
2c6daf3
test
EvertSalinas Nov 2, 2021
f1fb3bf
help
EvertSalinas Nov 2, 2021
98db8a8
add more details
EvertSalinas Nov 2, 2021
8eb8d56
Changes
EvertSalinas Nov 2, 2021
c6aee4e
Remove unnecessary code
EvertSalinas Nov 2, 2021
c5a6179
Fix stim controller
EvertSalinas Nov 2, 2021
fd515fc
Setup places controller only if attribute is location
EvertSalinas Nov 4, 2021
8782f14
Include? method fix
EvertSalinas Nov 4, 2021
e7c2615
fix conditional
EvertSalinas Nov 4, 2021
4556fb2
test
EvertSalinas Nov 4, 2021
e240ab5
minor change
EvertSalinas Nov 4, 2021
94500b6
Add German locale (#53)
thedarkside Feb 8, 2022
16bd946
Pin Administrate below 0.20.0 (#68)
nickcharlton Jan 25, 2024
6b38711
Refresh Appraisals (#69)
nickcharlton Jan 25, 2024
bdb533c
Refresh Appraisals (properly) (#71)
nickcharlton Jan 25, 2024
4259dd8
Drop SQLite development dependency (#70)
nickcharlton Jan 25, 2024
85c33f0
Upgrade Ruby to v3.3.0 (#67)
nickcharlton Jan 25, 2024
fed29c8
Drop Administrate support below v0.19.0 (#72)
nickcharlton Jan 25, 2024
d7cb720
Add a bin/setup script (#73)
nickcharlton Jan 25, 2024
6625781
Add a script to build the changelog (#74)
nickcharlton Jan 25, 2024
e8a3254
Add LICENSE (#75)
nickcharlton Jan 25, 2024
39a5fe3
Add SECURITY (#77)
nickcharlton Jan 25, 2024
bcf4c74
Add the thoughtbot CoC (#76)
nickcharlton Jan 25, 2024
194e887
Add CONTRIBUTING (#78)
nickcharlton Jan 25, 2024
2baa53f
Release 2.0.0
nickcharlton Jan 25, 2024
526b7c7
Add Selectize support for the select boxes (#64)
jubilee2 Jan 25, 2024
e2ee130
Add support for attribute grouping (#79)
trevorrjohn Feb 14, 2024
cccd786
Release 2.1.0
nickcharlton Mar 15, 2024
5205832
Merge pull request #2 from nickcharlton/main
aliciapaz Jan 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
working_directory: ~/administrate-field-nested_has_many
docker:
- image: circleci/ruby:2.7.0-node-browsers
- image: cimg/ruby:3.3-browsers
environment:
PGHOST: localhost
PGUSER: administrate-field-nested_has_many
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.7.0
ruby-3.3.0
12 changes: 8 additions & 4 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env ruby

appraise "administrate-0.15" do
gem "administrate", "0.15.0"
appraise "administrate-0.19" do
gem "administrate", "0.19.0"
end

appraise "administrate-master" do
gem "administrate", git: "https://github.com/thoughtbot/administrate", branch: "master"
appraise "administrate-0.20" do
gem "administrate", "0.20.0"
end

appraise "administrate-main" do
gem "administrate", git: "https://github.com/thoughtbot/administrate", branch: "main"
end
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# CHANGELOG

## 2.1.0

* Add support for attribute grouping ([#79][])
* Add Selectize support for the select boxes ([#64][])

[#79]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/79
[#64]: https://github.com/nickcharlton/administrate-field-nested_has_many/pull/64

## 2.0.0

* Add CONTRIBUTING (#78)
* Add the thoughtbot CoC (#76)
* Add SECURITY (#77)
* Add LICENSE (#75)
* Add a script to build the changelog (#74)
* Add a bin/setup script (#73)
* Drop Administrate support below v0.19.0 (#72)
* Upgrade Ruby to v3.3.0 (#67)
* Drop SQLite development dependency (#70)
* Refresh Appraisals (properly) (#71)
* Refresh Appraisals (#69)
* Pin Administrate below 0.20.0 (#68)
* Add German locale (#53)
* Align #show pagination with 0.16.0 (#52)
* Let Administrate figure out the associations (#44)
* Avoid having to add assets to the host manifest (#45)
* Add French locale (#51)
* Fix build to work with Rails 6.1 (#47)
* Remove old compatibility (#46)
* Remind users to declare accepts_nested_attributes_for (#48)

## 1.3.0

* Cover more test cases ([#43][])
Expand Down
6 changes: 6 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Code of conduct

By participating in this project, you agree to abide by the
[thoughtbot code of conduct][1].

[1]: https://thoughtbot.com/open-source-code-of-conduct
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Contributing Guide

## Code of Conduct

We welcome pull requests from everyone. By participating in this project, you
agree to abide by the thoughtbot [code of conduct].

We expect everyone to follow the code of conduct anywhere in thoughtbot's
project codebases, issue trackers, chat-rooms, and mailing lists.

[code of conduct]: https://thoughtbot.com/open-source-code-of-conduct

## Getting Started

`administrate-field-nested_has_many` is a field plugin for [Administrate][],
that allows for nested `has_many` forms.

To maintain compatibility with different dependency versions, we use
[Appraisal][].

[Administrate]: https://github.com/thoughtbot/administrate
[Appraisal]: https://github.com/thoughtbot/appraisal

### Opening a PR

1. Fork the repo,
2. Run `./bin/setup` to install the base dependencies and setup a local
database,
3. Run the test suite: `bundle exec rspec && bundle exec appraisal rspec`,
4. Make your changes,
5. Push your fork and open a pull request.

A good PR will solve the smallest problem it possibly can, have good test
coverage and (where necessary) have internationalisation support.

## Security

See the [security policy](./SECURITY.md).
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015-2024 thoughtbot, inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ some versions of this gem will be compatible only with some versions of Administ
This is a table of known compatibilities. It is accurate to the best of our knowledge.
Please let us know if you detect other incompatibilities:

| Versions of this gem | should work with these versions of Administrate |
|----------------------|-------------------------------------------------|
| prior to v1.3.0 | unknown |
| v1.3.0 | up to master (last known: v0.15) |
| master | from v0.15 |
| `nested_has_many` | Administrate |
|-------------------|---------------|
| v2.1.0 | v0.20.0 |
| v2.0.0 | up to v0.19 |
| v1.3.0 | up to v0.15 |
| `#726d8gc` | from v0.16 |
| `master` | up to v0.19.0 |

## Usage

Expand Down
16 changes: 16 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Security Policy

## Supported Versions

We only expect to support the latest version of Administrate (and it's related
projects) as a given time. If you find a security issue with an older version,
please try updating to the latest version first.

If for some reason you can't update to the latest version, please let us know
your reasons so that we can have a better understanding of your situation.

## Reporting a Vulnerability

For security inquiries or vulnerability reports, please email
<[email protected]>.
If you'd like, you can use our PGP key when reporting vulnerabilities.
5 changes: 2 additions & 3 deletions administrate-field-nested_has_many.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)

Gem::Specification.new do |gem|
gem.name = "administrate-field-nested_has_many"
gem.version = "1.3.0"
gem.version = "2.1.0"
gem.authors = ["Nick Charlton", "Grayson Wright"]
gem.email = ["[email protected]", "[email protected]"]
gem.homepage = "https://github.com/nickcharlton/" \
Expand All @@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")

gem.add_dependency "administrate", ">= 0.15", "< 1"
gem.add_dependency "administrate", ">= 0.19", "< 1"
gem.add_dependency "cocoon", "~> 1.2", ">= 1.2.11"

gem.add_development_dependency "appraisal"
Expand All @@ -25,5 +25,4 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "i18n-tasks"
gem.add_development_dependency "rake"
gem.add_development_dependency "rspec-rails"
gem.add_development_dependency "sqlite3"
end
Binary file added app/assets/images/markergc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
//= require cocoon
$(document).on('ready page:load turbolinks:load turbo:load cocoon:after-insert', function() {
$('.field-unit--select select').selectize({});
$('.field-unit--belongs-to select').selectize({});
$(".field-unit--has-many select").selectize({});
$('.field-unit--polymorphic select').selectize({});
});
28 changes: 20 additions & 8 deletions app/views/fields/nested_has_many/_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
<div class="nested-fields">
<% field.nested_fields_for_builder(f).each do |attribute| -%>
<div class="field-unit field-unit--<%= attribute.html_class %>">
<%= render_field attribute, f: f %>
</div>
<% end -%>
<% if field.associated_class_name.downcase.include?("location") %>
<div class="nested-fields" data-controller="places" data-action="google-maps-callback@window->places#initMap" data-places-imageurl-value="<%= asset_path 'markergc.png' %>">
<% field.nested_fields_for_builder(f).each do |attribute| -%>
<div class="field-unit field-unit--<%= attribute.html_class %>">
<%= render_field attribute, f: f %>
</div>
<% end -%>

<%= link_to_remove_association I18n.t("administrate.fields.nested_has_many.remove", resource: field.associated_class_name.titleize), f %>
</div>
<%= link_to_remove_association I18n.t("administrate.fields.nested_has_many.remove", resource: field.associated_class_name.titleize), f %>
</div>
<% else %>
<div class="nested-fields">
<% field.nested_fields_for_builder(f).each do |attribute| -%>
<div class="field-unit field-unit--<%= attribute.html_class %>">
<%= render_field attribute, f: f %>
</div>
<% end -%>

<%= link_to_remove_association I18n.t("administrate.fields.nested_has_many.remove", resource: field.associated_class_name.titleize), f %>
</div>
<% end %>
24 changes: 24 additions & 0 deletions bin/build-changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

set -e

if ! command -v gh > /dev/null; then
echo "Please install the GitHub CLI: https://cli.github.com/"
exit 1
fi

last_release=$(git describe --tag --abbrev=0)

revision_range="${last_release}..origin/main"
commit_format="--pretty=tformat:%h %s"
commits_since=$(git log --author="^(?!dependabot).*$" --perl-regexp "${revision_range}" "${commit_format}")

echo "$commits_since" | while read -r line; do
sha=$(echo "${line}" | awk '{print $1}')
commit_message=$(echo "${line}" | awk '{print substr($0, index($0, " ")+1)}')

pr_number=$(gh pr list --search "$sha" --state merged --json number --jq '.[].number')
trimmed_commit=$(echo "${commit_message}"| sed "s/ (\#$pr_number)//g")

echo "* ${trimmed_commit} (#${pr_number})"
done
13 changes: 13 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

set -e

gem install bundler --conservative
bundle check || bundle install

bundle exec appraisal install

bundle exec rake db:setup

# Add binstubs to PATH via export PATH=".git/safe/../../bin:$PATH" in ~/.zshenv
mkdir -p .git/safe
7 changes: 7 additions & 0 deletions config/locales/administrate-field-nested_has_many.de.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
de:
administrate:
fields:
nested_has_many:
add: "%{resource} hinzufügen"
remove: "%{resource} entfernen"
Loading