mirror of
https://github.com/ash-project/ash_phoenix.git
synced 2024-09-08 09:30:49 +12:00
improvement: setup project
This commit is contained in:
parent
b6b87b95e9
commit
6273bd08b0
15 changed files with 753 additions and 16 deletions
76
.github/CODE_OF_CONDUCT.md
vendored
Normal file
76
.github/CODE_OF_CONDUCT.md
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at zach@zachdaniel.dev. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
2
.github/CONTRIBUTING.md
vendored
Normal file
2
.github/CONTRIBUTING.md
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Contributing Guidelines
|
||||
Contributing guidelines can be found in the core project, [ash](https://github.com/ash-project/ash/blob/master/.github/CONTRIBUTING.md)
|
27
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
27
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug, needs review
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is. If you are not sure if the bug is related to `ash` or an extension, log it with [ash](https://github.com/ash-project/ash/issues/new) and we will move it.
|
||||
|
||||
**To Reproduce**
|
||||
A minimal set of resource definitions and calls that can reproduce the bug.
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
** Runtime
|
||||
- Elixir version
|
||||
- Erlang version
|
||||
- OS
|
||||
- Ash version
|
||||
- any related extension versions
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
36
.github/ISSUE_TEMPLATE/proposal.md
vendored
Normal file
36
.github/ISSUE_TEMPLATE/proposal.md
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
name: Proposal
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement, needs review
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Express the feature either with a change to resource syntax, or with a change to the resource interface**
|
||||
|
||||
For example
|
||||
|
||||
```elixir
|
||||
attributes do
|
||||
attribute :foo, :integer, bar: 10 # <- Adding `bar` here would cause <x>
|
||||
end
|
||||
```
|
||||
|
||||
Or
|
||||
|
||||
```elixir
|
||||
Api.read(:resource, bar: 10) # <- Adding `bar` here would cause <x>
|
||||
```
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
### Contributor checklist
|
||||
|
||||
- [ ] Bug fixes include regression tests
|
||||
- [ ] Features include unit/acceptance tests
|
119
.github/workflows/elixir.yml
vendored
Normal file
119
.github/workflows/elixir.yml
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
name: Elixir CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
tags-ignore: ["v*"]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
create:
|
||||
branches: master
|
||||
tags: ["v*"]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} / Ash ${{matrix.ash}}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
otp: ["23", "22"]
|
||||
elixir: ["1.10.3"]
|
||||
ash: ["master", "1.17.1"]
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
ASH_VERSION: ${{matrix.ash}}
|
||||
steps:
|
||||
- run: sudo apt-get install --yes erlang-dev
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-elixir@v1
|
||||
with:
|
||||
otp-version: ${{matrix.otp}}
|
||||
elixir-version: ${{matrix.elixir}}
|
||||
- uses: actions/cache@v1
|
||||
id: cache-deps
|
||||
with:
|
||||
path: deps
|
||||
key: otp-${{matrix.otp}}-elixir-${{matrix.elixir}}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
|
||||
restore-keys: otp-${{matrix.otp}}-elixir-${{matrix.elixir}}-deps-
|
||||
- uses: actions/cache@v1
|
||||
id: cache-build
|
||||
with:
|
||||
path: _build
|
||||
key: otp-${{matrix.otp}}-elixir-${{matrix.elixir}}-build-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
|
||||
restore-keys: otp-${{matrix.otp}}-elixir-${{matrix.elixir}}-build-
|
||||
- run: mix deps.get
|
||||
- run: mix check --except dialyzer
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
- run: mix check
|
||||
if: "!startsWith(github.ref, 'refs/tags/v')"
|
||||
coverage:
|
||||
needs: [build]
|
||||
runs-on: ubuntu-latest
|
||||
name: Report Test Coverage
|
||||
strategy:
|
||||
matrix:
|
||||
otp: ["23"]
|
||||
elixir: ["1.10.0"]
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- run: sudo apt-get install --yes erlang-dev
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-elixir@v1
|
||||
with:
|
||||
otp-version: ${{matrix.otp}}
|
||||
elixir-version: ${{matrix.elixir}}
|
||||
- uses: actions/cache@v1
|
||||
id: cache-deps
|
||||
with:
|
||||
path: deps
|
||||
key: otp-${{matrix.otp}}-elixir-${{matrix.elixir}}-deps-2-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
|
||||
restore-keys: otp-${{matrix.otp}}-elixir-${{matrix.elixir}}-deps-2-
|
||||
- run: mix deps.get
|
||||
- run: mix coveralls.github
|
||||
release:
|
||||
needs: [build]
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
runs-on: ubuntu-latest
|
||||
name: Release
|
||||
strategy:
|
||||
matrix:
|
||||
otp: ["23"]
|
||||
elixir: ["1.10.0"]
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- run: sudo apt-get install --yes erlang-dev
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-elixir@v1
|
||||
with:
|
||||
otp-version: ${{matrix.otp}}
|
||||
elixir-version: ${{matrix.elixir}}
|
||||
- uses: actions/cache@v1
|
||||
id: cache-deps
|
||||
with:
|
||||
path: deps
|
||||
key: otp-${{matrix.otp}}-elixir-${{matrix.elixir}}-deps-2-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
|
||||
restore-keys: otp-${{matrix.otp}}-elixir-${{matrix.elixir}}-deps-2-
|
||||
- run: mix deps.get
|
||||
- run: mix compile
|
||||
- run: mix hex.publish --yes
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
env:
|
||||
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
|
||||
- uses: olegtarasov/get-tag@v2
|
||||
id: tagName
|
||||
- uses: ethomson/send-tweet-action@v1
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
with:
|
||||
status: |
|
||||
Alpha version "${{ steps.tagName.outputs.tag }}" of AshPhoenix released!
|
||||
|
||||
#myelixirstatus
|
||||
|
||||
See the changelog for more info:
|
||||
https://github.com/ash-project/ash_phoenix/blob/master/CHANGELOG.md
|
||||
consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
|
||||
consumer-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
|
||||
access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
|
||||
access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
|
289
CHANGELOG.md
Normal file
289
CHANGELOG.md
Normal file
|
@ -0,0 +1,289 @@
|
|||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](Https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
<!-- changelog -->
|
||||
|
||||
## [v0.21.0](https://github.com/ash-project/ash_json_api/compare/v0.20.0...v0.21.0) (2020-10-12)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* support latest ash pagination features
|
||||
|
||||
## [v0.20.0](https://github.com/ash-project/ash_json_api/compare/v0.19.0...v0.20.0) (2020-10-10)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* support the `accept` configuration on actions
|
||||
|
||||
* move to latest ash
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* support the latest ash version
|
||||
|
||||
* don't be so strict about ash dependency
|
||||
|
||||
## [v0.19.0](https://github.com/ash-project/ash_json_api/compare/v0.18.0...v0.19.0) (2020-09-02)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* ash v1.11 (#32)
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* load properly on nested routes (#36)
|
||||
|
||||
* support routes w/o route params
|
||||
|
||||
* actually forward to the configured path
|
||||
|
||||
* only render links at appropriate times
|
||||
|
||||
* error while fetching record from path
|
||||
|
||||
## [v0.18.0](https://github.com/ash-project/ash_json_api/compare/v0.17.0...v0.18.0) (2020-08-18)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* update to latest ash
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* array type support in json_schema
|
||||
|
||||
* modernize side_load calls
|
||||
|
||||
## [v0.17.0](https://github.com/ash-project/ash_json_api/compare/v0.16.0...v0.17.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* support aggregates
|
||||
|
||||
* support array types
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* make primary key id requirement explicit
|
||||
|
||||
## [v0.16.0](https://github.com/ash-project/ash_json_api/compare/v0.15.0...v0.16.0) (2020-08-10)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* update to latest ash
|
||||
|
||||
## [v0.15.0](https://github.com/ash-project/ash_json_api/compare/0.14.0...v0.15.0) (2020-07-24)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* update to latest ash
|
||||
|
||||
## [v0.14.0](https://github.com/ash-project/ash_json_api/compare/0.13.0...v0.14.0) (2020-07-23)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* update to latest ash
|
||||
|
||||
## [v0.13.0](https://github.com/ash-project/ash_json_api/compare/0.12.0...v0.13.0) (2020-07-20)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* update to the latest ash
|
||||
|
||||
## [v0.12.0](https://github.com/ash-project/ash_json_api/compare/0.11.1...v0.12.0) (2020-07-16)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* update to latest ash
|
||||
|
||||
## [v0.11.1](https://github.com/ash-project/ash_json_api/compare/0.11.0...v0.11.1) (2020-07-15)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* *actually* upgrade to latest ash
|
||||
|
||||
## [v0.11.0](https://github.com/ash-project/ash_json_api/compare/0.10.0...v0.11.0) (2020-07-15)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* update to latest ash
|
||||
|
||||
## [v0.10.0](https://github.com/ash-project/ash_json_api/compare/0.9.0...v0.10.0) (2020-07-13)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* upgrade to latest ash
|
||||
|
||||
## [v0.9.0](https://github.com/ash-project/ash_json_api/compare/0.8.0...v0.9.0) (2020-07-09)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* update to latest ash
|
||||
|
||||
## [v0.8.0](https://github.com/ash-project/ash_json_api/compare/0.7.0...v0.8.0) (2020-07-08)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* update to latest ash
|
||||
|
||||
## [v0.7.0](https://github.com/ash-project/ash_json_api/compare/0.6.0...v0.7.0) (2020-07-08)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* update to latest ash
|
||||
|
||||
## [v0.6.0](https://github.com/ash-project/ash_json_api/compare/0.5.0...v0.6.0) (2020-06-29)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* update to latest ash
|
||||
|
||||
* update to latest ash
|
||||
|
||||
## [v0.5.0](https://github.com/ash-project/ash_json_api/compare/0.4.0...v0.5.0) (2020-06-29)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* upgrade to latest ash
|
||||
|
||||
## [v0.4.0](https://github.com/ash-project/ash_json_api/compare/0.3.0...v0.4.0) (2020-06-27)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* update to latest ash
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* json_schema issues
|
||||
|
||||
## [v0.3.0](https://github.com/ash-project/ash_json_api/compare/0.2.4...v0.3.0) (2020-06-19)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* upgrade to ash 0.6.0
|
||||
|
||||
## [v0.2.4](https://github.com/ash-project/ash_json_api/compare/0.2.3...v0.2.4) (2020-06-16)
|
||||
|
||||
|
||||
|
||||
|
||||
## [v0.2.3](https://github.com/ash-project/ash_json_api/compare/0.2.2...v0.2.3) (2020-06-16)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* router calls in tests
|
||||
|
||||
## [v0.2.2](https://github.com/ash-project/ash_json_api/compare/0.2.1...v0.2.2) (2020-06-16)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* router/module name issues
|
||||
|
||||
## [v0.2.1](https://github.com/ash-project/ash_json_api/compare/0.2.0...v0.2.1) (2020-06-15)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* update .formatter.exs
|
||||
|
||||
## [v0.2.0](https://github.com/ash-project/ash_json_api/compare/0.1.5...v0.2.0) (2020-06-14)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* use new dsl builder (#29)
|
||||
|
||||
## [v0.1.5](https://github.com/ash-project/ash_json_api/compare/0.1.4...v0.1.5) (2020-06-11)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* put test schema in `lib/` directory
|
||||
|
||||
## [v0.1.4](https://github.com/ash-project/ash_json_api/compare/0.1.3...v0.1.4) (2020-06-05)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* adjust tests/code for name/type removal
|
||||
|
||||
* account for name/type removal
|
||||
|
||||
## [v0.1.3](https://github.com/ash-project/ash_json_api/compare/0.1.2...v0.1.3) (2020-06-03)
|
||||
|
||||
This release is a test of the automated hex release package
|
1
FUNDING.yml
Normal file
1
FUNDING.yml
Normal file
|
@ -0,0 +1 @@
|
|||
github: zachdaniel
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Zachary Scott Daniel
|
||||
|
||||
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.
|
20
README.md
20
README.md
|
@ -1,11 +1,18 @@
|
|||
# AshPhoenix
|
||||
|
||||
**TODO: Add description**
|
||||
![Elixir CI](https://github.com/ash-project/ash_phoenix/workflows/Ash%20CI/badge.svg)
|
||||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
||||
[![Coverage Status](https://coveralls.io/repos/github/ash-project/ash_phoenix/badge.svg?branch=master)](https://coveralls.io/github/ash-project/ash_phoenix?branch=master)
|
||||
[![Hex version badge](https://img.shields.io/hexpm/v/ash_phoenix.svg)](https://hex.pm/packages/ash_phoenix)
|
||||
|
||||
## Installation
|
||||
See the online documentation for `AshPhoenix.LiveView` for the current set of utilities. This is a new integration, and doesn't do much. Currently, the only
|
||||
thing that is offered are a few helpers for keeping query data live ins ide of live views. There is some experimental code here as well for passing an `Ash.Changeset` to `Phoenix.HTML.form_for/4`.
|
||||
|
||||
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
|
||||
by adding `ash_phoenix` to your list of dependencies in `mix.exs`:
|
||||
Roadmap:
|
||||
|
||||
- UI authorization utilities e.g `<%= if authorized_to_do?(resource, action, actor) do %>`
|
||||
- Potentially helpers for easily connecting buttons to resource actions
|
||||
- Form helpers for using `Ash.Changeset`s with `form_for`
|
||||
|
||||
```elixir
|
||||
def deps do
|
||||
|
@ -14,8 +21,3 @@ def deps do
|
|||
]
|
||||
end
|
||||
```
|
||||
|
||||
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
|
||||
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
|
||||
be found at [https://hexdocs.pm/ash_phoenix](https://hexdocs.pm/ash_phoenix).
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
defmodule AshPhoenix do
|
||||
@moduledoc """
|
||||
Documentation for `AshPhoenix`.
|
||||
See the readme for the current state of the project
|
||||
"""
|
||||
end
|
||||
|
|
100
lib/changeset/form_data.ex
Normal file
100
lib/changeset/form_data.ex
Normal file
|
@ -0,0 +1,100 @@
|
|||
defimpl Phoenix.HTML.FormData, for: Ash.Changeset do
|
||||
# Most of this logic was simply copied from ecto
|
||||
# The goal here is to eventually lift complex validations
|
||||
# up into the form. While implementing this, it has become
|
||||
# very clear that ecto's changeset's implementations of errors
|
||||
# is much better than ours. Unsurprising, the current system
|
||||
# was simply tacked on based on the API error system.
|
||||
|
||||
def input_type(%{resource: resource}, _, field) do
|
||||
type = Ash.Resource.attribute(resource, field)
|
||||
|
||||
case Ash.Type.ecto_type(type) do
|
||||
:integer -> :number_input
|
||||
:boolean -> :checkbox
|
||||
:date -> :date_select
|
||||
:time -> :time_select
|
||||
:utc_datetime -> :datetime_select
|
||||
:naive_datetime -> :datetime_select
|
||||
_ -> :text_input
|
||||
end
|
||||
end
|
||||
|
||||
def input_validations(changeset, form, field) do
|
||||
# Ash.Changeset.
|
||||
# [required: ]
|
||||
[]
|
||||
end
|
||||
|
||||
# # Returns the HTML5 validations that would apply to the given field.
|
||||
|
||||
def input_value(changeset, _form, field) do
|
||||
Map.get(changeset.attributes, field)
|
||||
end
|
||||
|
||||
# # Returns the value for the given field.
|
||||
|
||||
def to_form(changeset, opts) do
|
||||
{name, opts} = Keyword.pop(opts, :as)
|
||||
|
||||
name = to_string(name || form_for_name(changeset.resource))
|
||||
id = Keyword.get(opts, :id) || name
|
||||
|
||||
%Phoenix.HTML.Form{
|
||||
source: changeset,
|
||||
impl: __MODULE__,
|
||||
id: id,
|
||||
name: name,
|
||||
errors: form_for_errors(changeset),
|
||||
data: changeset.data,
|
||||
params: %{},
|
||||
hidden: Map.take(changeset.data, Ash.Resource.primary_key(changeset.resource)),
|
||||
options: Keyword.put_new(opts, :method, form_for_method(changeset))
|
||||
}
|
||||
end
|
||||
|
||||
defp form_for_errors(%{action: nil}), do: []
|
||||
|
||||
defp form_for_errors(changeset) do
|
||||
for %{field: field} = error <- changeset.errors do
|
||||
case error do
|
||||
%{message: {message, opts}} ->
|
||||
{field, {message, opts}}
|
||||
|
||||
%{message: message} ->
|
||||
{field, {message, []}}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def to_form(changeset, form, field, opts) d
|
||||
# # %{params: params, data: data} = changeset
|
||||
# {name, opts} = Keyword.pop(opts, :as)
|
||||
|
||||
# name = to_string(name || form_for_name(changeset.resource))
|
||||
# id = Keyword.get(opts, :id) || name
|
||||
|
||||
# %Phoenix.HTML.Form{
|
||||
# source: changeset,
|
||||
# impl: __MODULE__,
|
||||
# id: id,
|
||||
# name: name,
|
||||
# # errors: form_for_errors(changeset),
|
||||
# data: changeset.data,
|
||||
# params: %{},
|
||||
# # hidden: form_for_hidden(data),
|
||||
# options: Keyword.put_new(opts, :method, form_for_method(changeset))
|
||||
# }
|
||||
nil
|
||||
end
|
||||
|
||||
defp form_for_method(%{action_type: :create}), do: "post"
|
||||
defp form_for_method(_), do: "put"
|
||||
|
||||
defp form_for_name(resource) do
|
||||
resource
|
||||
|> Module.split()
|
||||
|> List.last()
|
||||
|> Macro.underscore()
|
||||
end
|
||||
end
|
|
@ -72,6 +72,8 @@ defmodule Ash.Notifier.LiveView do
|
|||
page by number, you'll want to use `offset` pagination, but keep in mind that it performs worse on large
|
||||
tables.
|
||||
|
||||
To support this, accept a second parameter to your callback function, which will be the options to use in `page_opts
|
||||
|
||||
## Options:
|
||||
#{NimbleOptions.docs(@opts)}
|
||||
|
||||
|
@ -394,7 +396,7 @@ defmodule Ash.Notifier.LiveView do
|
|||
refetch_list(socket, config.callback, list, config.opts)
|
||||
|
||||
other ->
|
||||
run_callback(config.callback, socket, [])
|
||||
run_callback(config.callback, socket, nil)
|
||||
end
|
||||
|
||||
new_config =
|
||||
|
|
BIN
logos/small-logo.png
Normal file
BIN
logos/small-logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
68
mix.exs
68
mix.exs
|
@ -1,17 +1,66 @@
|
|||
defmodule AshPhoenix.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
@description """
|
||||
Utilities for integrating Ash with Phoenix
|
||||
"""
|
||||
|
||||
@version "0.1.0"
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :ash_phoenix,
|
||||
version: "0.1.0",
|
||||
elixir: "~> 1.11",
|
||||
{:ash, ash_version("~> 1.19")},
|
||||
version: @version,
|
||||
elixir: "~> 1.9",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps()
|
||||
deps: deps(),
|
||||
elixirc_paths: elixirc_paths(Mix.env()),
|
||||
start_permanent: Mix.env() == :prod,
|
||||
test_coverage: [tool: ExCoveralls],
|
||||
docs: docs(),
|
||||
preferred_cli_env: [
|
||||
coveralls: :test,
|
||||
"coveralls.github": :test
|
||||
],
|
||||
dialyzer: [
|
||||
plt_add_apps: [:ex_unit]
|
||||
],
|
||||
docs: docs(),
|
||||
package: package(),
|
||||
source_url: "https://github.com/ash-project/ash_phoenix",
|
||||
homepage_url: "https://github.com/ash-project/ash_phoenix"
|
||||
]
|
||||
end
|
||||
|
||||
defp elixirc_paths(:test) do
|
||||
["test/support/", "lib/"]
|
||||
end
|
||||
|
||||
defp elixirc_paths(_env) do
|
||||
["lib/"]
|
||||
end
|
||||
|
||||
defp package do
|
||||
[
|
||||
name: :ash_phoenix,
|
||||
licenses: ["MIT"],
|
||||
links: %{
|
||||
GitHub: "https://github.com/ash-project/ash_phoenix"
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
defp docs do
|
||||
[
|
||||
main: "readme",
|
||||
source_ref: "v#{@version}",
|
||||
logo: "logos/small-logo.png",
|
||||
extras: [
|
||||
"README.md"
|
||||
]
|
||||
]
|
||||
end
|
||||
|
||||
# Run "mix help compile.app" to learn about applications.
|
||||
def application do
|
||||
[
|
||||
extra_applications: [:logger]
|
||||
|
@ -27,4 +76,13 @@ defmodule AshPhoenix.MixProject do
|
|||
{:phoenix_live_view, "~> 0.14.7"}
|
||||
]
|
||||
end
|
||||
|
||||
defp ash_version(default_version) do
|
||||
case System.get_env("ASH_VERSION") do
|
||||
nil -> default_version
|
||||
"local" -> [path: "../ash"]
|
||||
"master" -> [git: "https://github.com/ash-project/ash.git"]
|
||||
version -> "~> #{version}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue