From 6d788dc97d0361aac7a22a67ab065a4befe72cf6 Mon Sep 17 00:00:00 2001 From: Craig P Jolicoeur Date: Mon, 6 Jan 2020 08:50:22 -0500 Subject: [PATCH 1/6] Update changelog for version 2.1.0 --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++-- bin/release | 1 + 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bdb23b2..5cad7175 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,22 @@ -# Change Log +# Changelog + +## [v2.1.0](https://github.com/mojotech/torch/tree/v2.1.0) (2020-01-06) + +[Full Changelog](https://github.com/mojotech/torch/compare/v2.0.0...v2.1.0) + +**Merged pull requests:** + +- Properly backup and restore project templates for torch.gen.html task [\#126](https://github.com/mojotech/torch/pull/126) ([cpjolicoeur](https://github.com/cpjolicoeur)) +- Bump excoveralls from 0.11.2 to 0.12.1 [\#124](https://github.com/mojotech/torch/pull/124) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump gettext from 0.17.0 to 0.17.1 [\#123](https://github.com/mojotech/torch/pull/123) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump credo from 0.10.2 to 1.1.5 [\#121](https://github.com/mojotech/torch/pull/121) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump phoenix\_html from 2.13.1 to 2.13.3 [\#120](https://github.com/mojotech/torch/pull/120) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump gettext from 0.16.1 to 0.17.0 [\#117](https://github.com/mojotech/torch/pull/117) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump ex\_doc from 0.19.3 to 0.21.2 [\#116](https://github.com/mojotech/torch/pull/116) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump excoveralls from 0.10.4 to 0.11.2 [\#114](https://github.com/mojotech/torch/pull/114) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) ## [v2.0.0](https://github.com/mojotech/torch/tree/v2.0.0) (2019-09-19) + [Full Changelog](https://github.com/mojotech/torch/compare/v2.0.0-rc.3...v2.0.0) **Closed issues:** @@ -13,6 +29,7 @@ - Update NPM assets for security warnings [\#110](https://github.com/mojotech/torch/pull/110) ([cpjolicoeur](https://github.com/cpjolicoeur)) ## [v2.0.0-rc.3](https://github.com/mojotech/torch/tree/v2.0.0-rc.3) (2019-09-16) + [Full Changelog](https://github.com/mojotech/torch/compare/v2.0.0-rc.2...v2.0.0-rc.3) **Implemented enhancements:** @@ -35,6 +52,7 @@ - \[test\] Configure coveralls for TravisCI [\#109](https://github.com/mojotech/torch/pull/109) ([cpjolicoeur](https://github.com/cpjolicoeur)) ## [v2.0.0-rc.2](https://github.com/mojotech/torch/tree/v2.0.0-rc.2) (2019-09-12) + [Full Changelog](https://github.com/mojotech/torch/compare/v2.0.0-rc.1...v2.0.0-rc.2) **Closed issues:** @@ -69,6 +87,7 @@ - \[\#85\] Improve tests [\#87](https://github.com/mojotech/torch/pull/87) ([danielberkompas](https://github.com/danielberkompas)) ## [v2.0.0-rc.1](https://github.com/mojotech/torch/tree/v2.0.0-rc.1) (2018-04-13) + [Full Changelog](https://github.com/mojotech/torch/compare/v1.0.0-rc.6...v2.0.0-rc.1) **Implemented enhancements:** @@ -101,6 +120,7 @@ - Add ability to set default sort order [\#55](https://github.com/mojotech/torch/pull/55) ([mlaco](https://github.com/mlaco)) ## [v1.0.0-rc.6](https://github.com/mojotech/torch/tree/v1.0.0-rc.6) (2017-05-03) + [Full Changelog](https://github.com/mojotech/torch/compare/v1.0.0-rc.5...v1.0.0-rc.6) **Fixed bugs:** @@ -137,6 +157,7 @@ - Reorganize repo as a lib with example, rather than an umbrella app [\#33](https://github.com/mojotech/torch/pull/33) ([darinwilson](https://github.com/darinwilson)) ## [v1.0.0-rc.5](https://github.com/mojotech/torch/tree/v1.0.0-rc.5) (2016-10-28) + [Full Changelog](https://github.com/mojotech/torch/compare/v1.0.0-rc.4...v1.0.0-rc.5) **Merged pull requests:** @@ -144,6 +165,7 @@ - Upgrade to latest version of Credo [\#30](https://github.com/mojotech/torch/pull/30) ([darinwilson](https://github.com/darinwilson)) ## [v1.0.0-rc.4](https://github.com/mojotech/torch/tree/v1.0.0-rc.4) (2016-09-27) + [Full Changelog](https://github.com/mojotech/torch/compare/v1.0.0-rc.3...v1.0.0-rc.4) **Fixed bugs:** @@ -157,6 +179,7 @@ - Fix `end\_page/3` math issue [\#27](https://github.com/mojotech/torch/pull/27) ([codeithuman](https://github.com/codeithuman)) ## [v1.0.0-rc.3](https://github.com/mojotech/torch/tree/v1.0.0-rc.3) (2016-09-19) + [Full Changelog](https://github.com/mojotech/torch/compare/v1.0.0-rc.2...v1.0.0-rc.3) **Closed issues:** @@ -168,6 +191,7 @@ - Restrict pagination links to groups of 10 [\#23](https://github.com/mojotech/torch/pull/23) ([darinwilson](https://github.com/darinwilson)) ## [v1.0.0-rc.2](https://github.com/mojotech/torch/tree/v1.0.0-rc.2) (2016-08-15) + [Full Changelog](https://github.com/mojotech/torch/compare/v1.0.0-rc.1...v1.0.0-rc.2) **Closed issues:** @@ -187,6 +211,7 @@ - Add Credo for linting [\#7](https://github.com/mojotech/torch/pull/7) ([danielberkompas](https://github.com/danielberkompas)) ## [v1.0.0-rc.1](https://github.com/mojotech/torch/tree/v1.0.0-rc.1) (2016-07-15) + [Full Changelog](https://github.com/mojotech/torch/compare/v0.2.0-rc.5...v1.0.0-rc.1) **Merged pull requests:** @@ -199,21 +224,29 @@ - Add CSS structure and header styles [\#1](https://github.com/mojotech/torch/pull/1) ([codeithuman](https://github.com/codeithuman)) ## [v0.2.0-rc.5](https://github.com/mojotech/torch/tree/v0.2.0-rc.5) (2016-06-28) + [Full Changelog](https://github.com/mojotech/torch/compare/v0.2.0-rc.4...v0.2.0-rc.5) ## [v0.2.0-rc.4](https://github.com/mojotech/torch/tree/v0.2.0-rc.4) (2016-06-28) + [Full Changelog](https://github.com/mojotech/torch/compare/v0.2.0-rc.3...v0.2.0-rc.4) ## [v0.2.0-rc.3](https://github.com/mojotech/torch/tree/v0.2.0-rc.3) (2016-06-28) + [Full Changelog](https://github.com/mojotech/torch/compare/0.2.0-rc.2...v0.2.0-rc.3) ## [0.2.0-rc.2](https://github.com/mojotech/torch/tree/0.2.0-rc.2) (2016-06-28) + [Full Changelog](https://github.com/mojotech/torch/compare/0.2.0-rc.1...0.2.0-rc.2) ## [0.2.0-rc.1](https://github.com/mojotech/torch/tree/0.2.0-rc.1) (2016-06-28) + [Full Changelog](https://github.com/mojotech/torch/compare/v0.1.0...0.2.0-rc.1) ## [v0.1.0](https://github.com/mojotech/torch/tree/v0.1.0) (2016-06-27) +[Full Changelog](https://github.com/mojotech/torch/compare/0dbb20ebe44ecfe2796af1d54659c2424803790e...v0.1.0) + + -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/bin/release b/bin/release index db61765b..730788d9 100755 --- a/bin/release +++ b/bin/release @@ -8,6 +8,7 @@ continue = system "git commit -am \"Release version #{version}\"" continue = system "git tag v#{version}" if continue continue = system "git push" if continue continue = system "git push -f origin v#{version}" if continue +continue = system "mix deps.get" if continue continue = system "mix hex.publish" if continue continue = system "mix hex.publish docs" if continue continue = system "github_changelog_generator" if continue From 925eae7b6507bb0e0d8b6ec957d7bba7a83c397a Mon Sep 17 00:00:00 2001 From: Craig P Jolicoeur Date: Fri, 7 Feb 2020 13:28:10 -0500 Subject: [PATCH 2/6] [mix] Version bump --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 34314982..73285eab 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Torch.MixProject do def project do [ app: :torch, - version: "2.1.0", + version: "3.0.0", elixir: "~> 1.5", start_permanent: Mix.env() == :prod, compilers: [:phoenix, :gettext] ++ Mix.compilers(), From 808fb78011b65b6f19f3f406a57daae4f023b588 Mon Sep 17 00:00:00 2001 From: Craig P Jolicoeur Date: Fri, 7 Feb 2020 14:20:19 -0500 Subject: [PATCH 3/6] [mix] Require Elixir 1.8 or newer >= 1.8.0 and < 2.0 --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 73285eab..e49201f8 100644 --- a/mix.exs +++ b/mix.exs @@ -5,7 +5,7 @@ defmodule Torch.MixProject do [ app: :torch, version: "3.0.0", - elixir: "~> 1.5", + elixir: "~> 1.8", start_permanent: Mix.env() == :prod, compilers: [:phoenix, :gettext] ++ Mix.compilers(), name: "Torch", From 74cc67c40ba8d40db9e43b88e97f3b356140206d Mon Sep 17 00:00:00 2001 From: Craig P Jolicoeur Date: Fri, 7 Feb 2020 14:20:49 -0500 Subject: [PATCH 4/6] [CI] Build on Elixir 1.10 and latest OTP 22 --- .travis.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4c42ef0a..a0c630fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,16 @@ cache: elixir: - 1.8.1 - 1.9.1 + - 1.10.0 otp_release: - - 20.3 - 21.3 - - 22.0 + - 22.2 +jobs: + include: + - elixir: '1.8.1' + otp_release: '20.3' + - elixir: '1.9.1' + otp_release: '20.3' script: - bin/setup before_script: From 5ce1b179d35991a97357c4fd9e88b9079dedf63b Mon Sep 17 00:00:00 2001 From: Craig P Jolicoeur Date: Fri, 7 Feb 2020 12:35:59 -0500 Subject: [PATCH 5/6] Add filter_date_select/3 This will generate an HTML select with Before/After options for filtering dates --- lib/torch/views/filter_view.ex | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/torch/views/filter_view.ex b/lib/torch/views/filter_view.ex index 880868a5..37ae9843 100644 --- a/lib/torch/views/filter_view.ex +++ b/lib/torch/views/filter_view.ex @@ -53,6 +53,29 @@ defmodule Torch.FilterView do select(:filters, "", opts, class: "filter-type", value: "#{prefix}[#{selected}]") end + @doc """ + Generates a "before/after" filter type select box for a given `date` or + `datetime` field. + + ## Example + + iex> params = %{"post" => %{"updated_at_after" => "01/01/2019"}} + ...> filter_date_select(:post, :updated_at, params) |> safe_to_string() + "" + """ + @spec filter_date_select(prefix, field, map) :: Phoenix.HTML.safe() + def filter_date_select(prefix, field, params) do + prefix_str = to_string(prefix) + {selected, _value} = find_param(params[prefix_str], field) + + opts = [ + {dgettext("default", "Before"), "#{prefix}[#{field}_before]"}, + {dgettext("default", "After"), "#{prefix}[#{field}_after]"} + ] + + select(:filters, "", opts, class: "filter-type", value: "#{prefix}[#{selected}]") + end + @doc """ Generates a number filter type select box for a given `number` field. From 5df834e233028dd34dd12765cf70582cf04a4fc2 Mon Sep 17 00:00:00 2001 From: Craig P Jolicoeur Date: Fri, 7 Feb 2020 13:26:04 -0500 Subject: [PATCH 6/6] Modify filter_date_input/3 to filter_date_input/4 Now accepts a spefic `input_type` argument which defaults to `:range` for backwards compatibility with existing usage of `filter_date_input/3`. The alternate, non-default `input_type` option of `:select` will output a single datepicker input field meant to be used in conjunction with the recently added `filter_date_select/3` function. --- lib/torch/views/filter_view.ex | 44 ++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/torch/views/filter_view.ex b/lib/torch/views/filter_view.ex index 37ae9843..54c7fe63 100644 --- a/lib/torch/views/filter_view.ex +++ b/lib/torch/views/filter_view.ex @@ -9,6 +9,7 @@ defmodule Torch.FilterView do @type prefix :: atom | String.t() @type field :: atom | String.t() + @type input_type :: atom | String.t() @doc """ Generates a select box for a `belongs_to` association. @@ -149,9 +150,23 @@ defmodule Torch.FilterView do iex> params = %{"post" => %{"inserted_at_between" => %{"start" => "01/01/2018", "end" => "01/31/2018"}}} ...> filter_date_input(:post, :inserted_at, params) |> safe_to_string() "" + + iex> params = %{"post" => %{"inserted_at_between" => %{"start" => "01/01/2018", "end" => "01/31/2018"}}} + ...> filter_date_input(:post, :inserted_at, params, :range) |> safe_to_string() + "" + + iex> params = %{"post" => %{"inserted_at_before" => "01/01/2018"}} + ...> filter_date_input(:post, :inserted_at, params, :select) |> safe_to_string() + "" + + iex> params = %{"post" => %{"inserted_at_after" => "01/01/2018"}} + ...> filter_date_input(:post, :inserted_at, params, :select) |> safe_to_string() + "" """ - @spec filter_date_input(prefix, field, map) :: Phoenix.HTML.safe() - def filter_date_input(prefix, field, params) do + @spec filter_date_input(prefix, field, map, input_type) :: Phoenix.HTML.safe() + def filter_date_input(prefix, field, params, input_type \\ :range) + + def filter_date_input(prefix, field, params, :range) do prefix = to_string(prefix) field = to_string(field) @@ -172,6 +187,19 @@ defmodule Torch.FilterView do raw(start ++ ending) end + def filter_date_input(prefix, field, params, :select) do + prefix_str = to_string(prefix) + {name, value} = find_param(params[prefix_str], field, :date) + + {:safe, date_input} = + torch_date_input( + "#{prefix}[#{name}]", + value + ) + + raw(date_input) + end + @doc """ Generates a filter select box for a boolean field. @@ -192,6 +220,17 @@ defmodule Torch.FilterView do checkbox(prefix, :"#{field}_equals", value: value) end + defp torch_date_input(name, value) do + tag( + :input, + type: "text", + class: "datepicker", + name: name, + value: value, + placeholder: dgettext("default", "Select Date") + ) + end + defp torch_date_input(name, value, "start") do tag( :input, @@ -229,6 +268,7 @@ defmodule Torch.FilterView do cond do result == nil && type == :string -> {"#{pattern}_contains", nil} result == nil && type == :number -> {"#{pattern}_equals", nil} + result == nil && type == :date -> {"#{pattern}_before", nil} result != nil -> result end end