Early bird field to db

This commit is contained in:
2024-01-16 20:00:40 +02:00
parent 57ae053855
commit 6afff866a2
10 changed files with 270 additions and 150 deletions

View File

@@ -8,89 +8,98 @@
phx-target={@myself}
phx-change="validate"
phx-submit="save">
<%= label f, :order_type, "Valitse tilausmuoto" %>
<%= select f,
:order_type,
<%= select f,
:order_type,
[
"Koko kausi": :full,
"Koko kausi": :full,
"Koko kausi (pikkuboksi)": :full_pikku,
"Joka toinen viikko": :everyother,
"Joka toinen viikko": :everyother,
"Joka toinen viikko (pikkuboksi)": :everyother_pikku,
"Elotilaus": :elo,
"Elotilaus": :elo,
"Elotilaus (pikkuboksi)": :elo_pikku,
"Viljely-yhteisö": :community,
"Viljely-yhteisö (pikkuboksi)": :community_pikku
],
prompt: "Ei valintaa"
],
prompt: "Ei valintaa"
%>
<%= if @action == :edit && @changeset.data.order_type == :everyother do %>
<%= error_tag f, :order_type %>
<%= if @action == :edit && (@changeset.data.order_type == :everyother || @changeset.data.order_type == :everyother_pikku) do %>
<div class="checkbox-container">
<%= checkbox f, :even_weeks, class: "checkbox" %>
<%= label f, :even_weeks, "Parilliset viikot" %>
<%= error_tag f, :even_weeks %>
</div>
<% end %>
<%= error_tag f, :order_type %>
<%= if @action == :edit do %>
<div class="checkbox-container">
<%= checkbox f, :early_bird, class: "checkbox" %>
<%= label f, :early_bird, "Early Bird" %>
<%= error_tag f, :early_bird %>
</div>
<% end %>
<%= label f, :location, "Valitse jakopaikka" %>
<%= select f,
:location,
<%= select f,
:location,
[
"Koroinen, Koroistentie 2": "koroinen",
"Ocean Spirit, Linnankatu 37": "ocean",
"Raisio, Timonkuja 8": "raisio",
"Naantali, Alitalontie 20": "naantali",
"Viherlassila, Alakyläntie 2": "viherlassila",
"Kirjakahvila, Vanha Suurtori 3": "kirjakahvila",
"Askainen, Askaistentie 986": "askainen",
"Koroinen, Koroistentie 2": "koroinen",
"Ocean Spirit, Linnankatu 37": "ocean",
"Raisio, Timonkuja 8": "raisio",
"Naantali, Alitalontie 20": "naantali",
"Viherlassila, Alakyläntie 2": "viherlassila",
"Kirjakahvila, Vanha Suurtori 3": "kirjakahvila",
"Askainen, Askaistentie 986": "askainen",
"Livonsaari, Pohjanpääntie 90": "livonsaari",
"C/o Naantalin hunaja, Paltteentie 2, Merimasku": "merimasku"
],
prompt: "Ei valintaa"
],
prompt: "Ei valintaa"
%>
<%= error_tag f, :location %>
<%= label f, :is_member, "Jäsenyytesi" %>
<%= select f,
:is_member,
<%= select f,
:is_member,
[
"Liity jäseneksi (kertamaksu 50€)": :false,
"Olen jo Livonsaaren Osuuspuutarhan jäsen": :true,
"Liity jäseneksi (kertamaksu 50€)": :false,
"Olen jo Livonsaaren Osuuspuutarhan jäsen": :true,
]
%>
<%= error_tag f, :is_member %>
<div class="checkbox-container">
<%= checkbox f, :split_invoice, class: "checkbox" %>
<%= label f, :split_invoice, "Haluan maksaa laskun kahdessa erässä (sis. laskutuslisä 2,50€)" %>
<%= error_tag f, :split_invoice %>
</div>
<%= label f, :fname, "Etunimi" %>
<%= text_input f, :fname %>
<%= error_tag f, :fname %>
<%= label f, :lname, "Sukunimi" %>
<%= text_input f, :lname %>
<%= error_tag f, :lname %>
<%= label f, :address, "Katuosoite" %>
<%= text_input f, :address %>
<%= error_tag f, :address %>
<%= label f, :pcode, "Postinumero" %>
<%= text_input f, :pcode %>
<%= error_tag f, :pcode %>
<%= label f, :city, "Postitoimipaikka" %>
<%= text_input f, :city %>
<%= error_tag f, :city %>
<%= label f, :phone, "Puhelinnumero" %>
<%= text_input f, :phone %>
<%= error_tag f, :phone %>
<%= label f, :email, "Sähköpostiosoite" %>
<%= text_input f, :email %>
<%= error_tag f, :email %>
@@ -105,7 +114,7 @@
</label>
</div>
<% end %>
<div>
<%= submit @submit_text, phx_disable_with: "Tallennetaan..." %>
</div>

View File

@@ -6,7 +6,7 @@ defmodule OsuuspuutarhaWeb.OrderLive.Index do
@impl true
def mount(_params, _session, socket) do
{:ok, assign(socket, :orders, Orders.list_orders())}
{:ok, assign(socket, :orders, Orders.get_sorted_by(:desc, :inserted_at))}
end
@impl true

View File

@@ -21,80 +21,87 @@
<thead>
<tr>
<th class="table_header">
<%= cond do %>
<% @live_action == :sorted_desc && @column == :order_type -> %> <%= link "Tyyppi ↓", to: Routes.order_index_path(@socket, :sorted_asc, :order_type) %>
<%= cond do %>
<% @live_action == :sorted_desc && @column == :order_type -> %> <%= link "Tyyppi ↓", to: Routes.order_index_path(@socket, :sorted_asc, :order_type) %>
<% @live_action == :sorted_asc && @column == :order_type -> %> <%= link "Tyyppi ↑", to: Routes.order_index_path(@socket, :sorted_desc, :order_type) %>
<% true -> %> <%= link "Tyyppi", to: Routes.order_index_path(@socket, :sorted_asc, :order_type) %>
<% true -> %> <%= link "Tyyppi", to: Routes.order_index_path(@socket, :sorted_asc, :order_type) %>
<% end %>
</th>
<th class="table_header">
<%= cond do %>
<% @live_action == :sorted_desc && @column == :location -> %> <%= link "Paikka ↓", to: Routes.order_index_path(@socket, :sorted_asc, :location) %>
<%= cond do %>
<% @live_action == :sorted_desc && @column == :location -> %> <%= link "Paikka ↓", to: Routes.order_index_path(@socket, :sorted_asc, :location) %>
<% @live_action == :sorted_asc && @column == :location -> %> <%= link "Paikka ↑", to: Routes.order_index_path(@socket, :sorted_desc, :location) %>
<% true -> %> <%= link "Paikka", to: Routes.order_index_path(@socket, :sorted_asc, :location) %>
<% true -> %> <%= link "Paikka", to: Routes.order_index_path(@socket, :sorted_asc, :location) %>
<% end %>
</th>
<th class="table_header">
<%= cond do %>
<% @live_action == :sorted_desc && @column == :lname -> %> <%= link "Tilaaja ↓", to: Routes.order_index_path(@socket, :sorted_asc, :lname) %>
<%= cond do %>
<% @live_action == :sorted_desc && @column == :lname -> %> <%= link "Tilaaja ↓", to: Routes.order_index_path(@socket, :sorted_asc, :lname) %>
<% @live_action == :sorted_asc && @column == :lname -> %> <%= link "Tilaaja ↑", to: Routes.order_index_path(@socket, :sorted_desc, :lname) %>
<% true -> %> <%= link "Tilaaja", to: Routes.order_index_path(@socket, :sorted_asc, :lname) %>
<% true -> %> <%= link "Tilaaja", to: Routes.order_index_path(@socket, :sorted_asc, :lname) %>
<% end %>
</th>
<th class="table_header">
<%= cond do %>
<% @live_action == :sorted_desc && @column == :city -> %> <%= link "Osoite ↓", to: Routes.order_index_path(@socket, :sorted_asc, :city) %>
<%= cond do %>
<% @live_action == :sorted_desc && @column == :city -> %> <%= link "Osoite ↓", to: Routes.order_index_path(@socket, :sorted_asc, :city) %>
<% @live_action == :sorted_asc && @column == :city -> %> <%= link "Osoite ↑", to: Routes.order_index_path(@socket, :sorted_desc, :city) %>
<% true -> %> <%= link "Osoite", to: Routes.order_index_path(@socket, :sorted_asc, :city) %>
<% true -> %> <%= link "Osoite", to: Routes.order_index_path(@socket, :sorted_asc, :city) %>
<% end %>
</th>
<th class="table_header">
<%= cond do %>
<% @live_action == :sorted_desc && @column == :phone -> %> <%= link "Puh. ↓", to: Routes.order_index_path(@socket, :sorted_asc, :phone) %>
<%= cond do %>
<% @live_action == :sorted_desc && @column == :phone -> %> <%= link "Puh. ↓", to: Routes.order_index_path(@socket, :sorted_asc, :phone) %>
<% @live_action == :sorted_asc && @column == :phone -> %> <%= link "Puh. ↑", to: Routes.order_index_path(@socket, :sorted_desc, :phone) %>
<% true -> %> <%= link "Puh.", to: Routes.order_index_path(@socket, :sorted_asc, :phone) %>
<% true -> %> <%= link "Puh.", to: Routes.order_index_path(@socket, :sorted_asc, :phone) %>
<% end %>
</th>
<th class="table_header">
<%= cond do %>
<% @live_action == :sorted_desc && @column == :email -> %> <%= link "Säpö ↓", to: Routes.order_index_path(@socket, :sorted_asc, :email) %>
<%= cond do %>
<% @live_action == :sorted_desc && @column == :email -> %> <%= link "Säpö ↓", to: Routes.order_index_path(@socket, :sorted_asc, :email) %>
<% @live_action == :sorted_asc && @column == :email -> %> <%= link "Säpö ↑", to: Routes.order_index_path(@socket, :sorted_desc, :email) %>
<% true -> %> <%= link "Säpö", to: Routes.order_index_path(@socket, :sorted_asc, :email) %>
<% true -> %> <%= link "Säpö", to: Routes.order_index_path(@socket, :sorted_asc, :email) %>
<% end %>
</th>
<th class="table_header">
<%= cond do %>
<% @live_action == :sorted_desc && @column == :is_member -> %> <%= link "Jäsen? ↓", to: Routes.order_index_path(@socket, :sorted_asc, :is_member) %>
<%= cond do %>
<% @live_action == :sorted_desc && @column == :is_member -> %> <%= link "Jäsen? ↓", to: Routes.order_index_path(@socket, :sorted_asc, :is_member) %>
<% @live_action == :sorted_asc && @column == :is_member -> %> <%= link "Jäsen? ↑", to: Routes.order_index_path(@socket, :sorted_desc, :is_member) %>
<% true -> %> <%= link "Jäsen?", to: Routes.order_index_path(@socket, :sorted_asc, :is_member) %>
<% true -> %> <%= link "Jäsen?", to: Routes.order_index_path(@socket, :sorted_asc, :is_member) %>
<% end %>
</th>
<th class="table_header">
<%= cond do %>
<% @live_action == :sorted_desc && @column == :split_invoice -> %> <%= link "Kaksi laskua? ↓", to: Routes.order_index_path(@socket, :sorted_asc, :split_invoice) %>
<%= cond do %>
<% @live_action == :sorted_desc && @column == :split_invoice -> %> <%= link "Kaksi laskua? ↓", to: Routes.order_index_path(@socket, :sorted_asc, :split_invoice) %>
<% @live_action == :sorted_asc && @column == :split_invoice -> %> <%= link "Kaksi laskua? ↑", to: Routes.order_index_path(@socket, :sorted_desc, :split_invoice) %>
<% true -> %> <%= link "Kaksi laskua?", to: Routes.order_index_path(@socket, :sorted_asc, :split_invoice) %>
<% true -> %> <%= link "Kaksi laskua?", to: Routes.order_index_path(@socket, :sorted_asc, :split_invoice) %>
<% end %>
</th>
<th class="table_header">
<%= cond do %>
<% @live_action == :sorted_desc && @column == :even_weeks -> %> <%= link "Parilliset viikot ↓", to: Routes.order_index_path(@socket, :sorted_asc, :even_weeks) %>
<%= cond do %>
<% @live_action == :sorted_desc && @column == :even_weeks -> %> <%= link "Parilliset viikot ↓", to: Routes.order_index_path(@socket, :sorted_asc, :even_weeks) %>
<% @live_action == :sorted_asc && @column == :even_weeks -> %> <%= link "Parilliset viikot ↑", to: Routes.order_index_path(@socket, :sorted_desc, :even_weeks) %>
<% true -> %> <%= link "Parilliset viikot", to: Routes.order_index_path(@socket, :sorted_asc, :even_weeks) %>
<% true -> %> <%= link "Parilliset viikot", to: Routes.order_index_path(@socket, :sorted_asc, :even_weeks) %>
<% end %>
</th>
<th class="table_header">
<%= cond do %>
<% @live_action == :sorted_desc && @column == :inserted_at -> %> <%= link "Lisätty ↓", to: Routes.order_index_path(@socket, :sorted_asc, :inserted_at) %>
<%= cond do %>
<% @live_action==:sorted_desc && @column==:early_bird -> %> <%= link "Early Bird? ↓" , to: Routes.order_index_path(@socket, :sorted_asc, :early_bird) %>
<% @live_action==:sorted_asc && @column==:early_bird -> %> <%= link "Early Bird? ↑" , to: Routes.order_index_path(@socket, :sorted_desc, :early_bird) %>
<% true -> %> <%= link "Early Bird?" , to: Routes.order_index_path(@socket, :sorted_asc, :early_bird) %>
<% end %>
</th>
<th class="table_header">
<%= cond do %>
<% @live_action == :sorted_desc && @column == :inserted_at -> %> <%= link "Lisätty ↓", to: Routes.order_index_path(@socket, :sorted_asc, :inserted_at) %>
<% @live_action == :sorted_asc && @column == :inserted_at -> %> <%= link "Lisätty ↑", to: Routes.order_index_path(@socket, :sorted_desc, :inserted_at) %>
<% true -> %> <%= link "Lisätty", to: Routes.order_index_path(@socket, :sorted_asc, :inserted_at) %>
<% true -> %> <%= link "Lisätty", to: Routes.order_index_path(@socket, :sorted_asc, :inserted_at) %>
<% end %>
</th>
<th class="table_header">
<%= cond do %>
<% @live_action == :sorted_desc && @column == :updated_at -> %> <%= link "Viimeisin muutos ↓", to: Routes.order_index_path(@socket, :sorted_asc, :updated_at) %>
<%= cond do %>
<% @live_action == :sorted_desc && @column == :updated_at -> %> <%= link "Viimeisin muutos ↓", to: Routes.order_index_path(@socket, :sorted_asc, :updated_at) %>
<% @live_action == :sorted_asc && @column == :updated_at -> %> <%= link "Viimeisin muutos ↑", to: Routes.order_index_path(@socket, :sorted_desc, :updated_at) %>
<% true -> %> <%= link "Viimeisin muutos", to: Routes.order_index_path(@socket, :sorted_asc, :updated_at) %>
<% true -> %> <%= link "Viimeisin muutos", to: Routes.order_index_path(@socket, :sorted_asc, :updated_at) %>
<% end %>
</th>
@@ -113,6 +120,7 @@
<td><%= Osuuspuutarha.Orders.Parser.parse_boolean(order.is_member) %></td>
<td><%= Osuuspuutarha.Orders.Parser.parse_boolean(order.split_invoice) %></td>
<td><%= Osuuspuutarha.Orders.Parser.parse_boolean(order.even_weeks) %></td>
<td><%= Osuuspuutarha.Orders.Parser.parse_boolean(order.early_bird) %></td>
<td><%= Osuuspuutarha.Orders.Parser.parse_date(order.inserted_at) %></td>
<td><%= Osuuspuutarha.Orders.Parser.parse_date(order.updated_at) %></td>

View File

@@ -2,92 +2,94 @@
<%= if @live_action in [:edit] do %>
<.modal return_to={Routes.order_show_path(@socket, :show, @order)}>
<.live_component
module={OsuuspuutarhaWeb.OrderLive.FormComponent}
id={@order.id}
title={@page_title}
action={@live_action}
submit_text="Tallenna"
has_privacy_consent={false}
order={@order}
return_to={Routes.order_show_path(@socket, :show, @order)}
/>
<.live_component module={OsuuspuutarhaWeb.OrderLive.FormComponent} id={@order.id} title={@page_title}
action={@live_action} submit_text="Tallenna" has_privacy_consent={false} order={@order}
return_to={Routes.order_show_path(@socket, :show, @order)} />
</.modal>
<% end %>
<% end %>
<ul>
<ul>
<li>
<strong>Tilausmuoto:</strong>
<%= @order.order_type %>
</li>
<li>
<strong>Tilausmuoto:</strong>
<%= @order.order_type %>
</li>
<li>
<strong>Jakopaikka:</strong>
<%= @order.location %>
</li>
<li>
<strong>Jakopaikka:</strong>
<%= @order.location %>
</li>
<li>
<strong>Etunimi:</strong>
<%= @order.fname %>
</li>
<li>
<strong>Etunimi:</strong>
<%= @order.fname %>
</li>
<li>
<strong>Sukunimi:</strong>
<%= @order.lname %>
</li>
<li>
<strong>Sukunimi:</strong>
<%= @order.lname %>
</li>
<li>
<strong>Osoite:</strong>
<%= @order.address %>
</li>
<li>
<strong>Osoite:</strong>
<%= @order.address %>
</li>
<li>
<strong>Postinumero:</strong>
<%= @order.pcode %>
</li>
<li>
<strong>Postinumero:</strong>
<%= @order.pcode %>
</li>
<li>
<strong>Postitoimipaikka:</strong>
<%= @order.city %>
</li>
<li>
<strong>Postitoimipaikka:</strong>
<%= @order.city %>
</li>
<li>
<strong>Puhelinnumero:</strong>
<%= @order.phone %>
</li>
<li>
<strong>Puhelinnumero:</strong>
<%= @order.phone %>
</li>
<li>
<strong>Sähköpostiosoite:</strong>
<%= @order.email %>
</li>
<li>
<strong>Sähköpostiosoite:</strong>
<%= @order.email %>
</li>
<li>
<strong>Jäsen?</strong>
<%= @order.is_member %>
</li>
<li>
<strong>Jäsen?</strong>
<%= @order.is_member %>
</li>
<li>
<strong>Kahdella laskulla:</strong>
<%= @order.split_invoice %>
</li>
<li>
<strong>Kahdella laskulla:</strong>
<%= @order.split_invoice %>
</li>
<li>
<strong>Parilliset viikot:</strong>
<%= @order.even_weeks %>
</li>
<li>
<strong>Parilliset viikot:</strong>
<%= @order.even_weeks %>
</li>
<li>
<strong>Lisätty:</strong>
<%= @order.inserted_at.day %>.<%= @order.inserted_at.month %>.<%= @order.inserted_at.year %>
</li>
<li>
<strong>Early bird:</strong>
<%= @order.early_bird %>
</li>
<li>
<strong>Viimeisin muutos:</strong>
<%= @order.updated_at.day %>.<%= @order.updated_at.month %>.<%= @order.updated_at.year %>
</li>
<li>
<strong>Lisätty:</strong>
<%= @order.inserted_at.day %>.<%= @order.inserted_at.month %>.<%= @order.inserted_at.year %>
</li>
</ul>
<li>
<strong>Viimeisin muutos:</strong>
<%= @order.updated_at.day %>.<%= @order.updated_at.month %>.<%= @order.updated_at.year %>
</li>
<span><%= live_patch "Muokkaa", to: Routes.order_show_path(@socket, :edit, @order), class: "button" %></span> |
<span><%= live_redirect "Takaisin", to: Routes.order_index_path(@socket, :index) %></span>
</ul>
<span>
<%= live_patch "Muokkaa" , to: Routes.order_show_path(@socket, :edit, @order), class: "button" %>
</span> |
<span>
<%= live_redirect "Takaisin" , to: Routes.order_index_path(@socket, :index) %>
</span>