diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 0d34e25..04b1266 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -48,6 +48,6 @@ class MembersController < ApplicationController # Only allow a list of trusted parameters through. def member_params - params.require(:member).permit(:name, :public, :bio , :picture) + params.require(:member).permit(:name, :public, :bio , :picture, :arrived ,:left) end end diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb index d5ad192..765d2f2 100644 --- a/app/helpers/members_helper.rb +++ b/app/helpers/members_helper.rb @@ -9,4 +9,10 @@ module MembersHelper image_tag(image , alt: someone.name , class: classes ) end + def stayed(member) + return "Not arrived" if member.arrived.blank? + text = member.arrived.to_s + return text + " not left" if member.left.blank? + text + " " + distance_of_time_in_words( member.left , member.arrived) + end end diff --git a/app/views/members/edit.html.haml b/app/views/members/edit.html.haml index 99e021e..1c8062d 100644 --- a/app/views/members/edit.html.haml +++ b/app/views/members/edit.html.haml @@ -5,14 +5,17 @@ .flex.flex-col %h1.text-4xl Editing profile -= simple_form_for @member , builder: SimpleForm::Tailwind::FormBuilder do |f| += simple_form_for @member do |f| = f.error_notification .grid.grid-cols-4.mx-20 .info.mr-8 = f.input :name + .grid.grid-cols-2.gap-10 + = f.input :arrived + = f.input :left = f.input :public , label: "Public: (Click box below)" - = f.input :picture , as: :file + = f.input :picture , as: :file , label: (@member.picture.blank? ? "Add picture" : "Change picture") .flex.justify-center.actions.m-10 = f.button :button, "Update", class: button_classes + " bg-cyan-200" = link_to member_path(@member) do diff --git a/app/views/members/index.html.haml b/app/views/members/index.html.haml index 0995dd5..c1e9f7f 100644 --- a/app/views/members/index.html.haml +++ b/app/views/members/index.html.haml @@ -6,8 +6,10 @@ .fex.flex-col.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm.m-10 =link_to member do = image_for( member , class: "h-60 w-full object-cover") - %h3.p-5.text-2xl.bg-gray-100.text-black.font-bold.text-center + %h3.pt-5.text-2xl.bg-gray-100.text-black.font-bold.text-center = member.name + .p-2.text-xs.bg-gray-50.text-black.font-bold.text-center + = stayed member %div.h-full .p-5.text-center .m-2.text-sm.leading-relaxed.line-clamp-3{ prose_classes } diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 6ee5b77..8335db3 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -6,7 +6,7 @@ .flex.flex-col.justify-center.p-8.lg:p-16.lg:pl-10{:class => "lg:w-1/2"} %div %p.inline-block.px-3.py-px.mb-4.text-xs.font-semibold.tracking-wider.text-teal-900.uppercase.rounded-full.bg-teal-accent-400 - Arrived + = stayed(@member) %h5.mb-3.text-3xl.font-extrabold.leading-none.sm:text-4xl = @member.name .mb-8.text-gray-800 diff --git a/app/views/stories/edit.html.haml b/app/views/stories/edit.html.haml index f383346..b87efb4 100644 --- a/app/views/stories/edit.html.haml +++ b/app/views/stories/edit.html.haml @@ -13,7 +13,7 @@ = f.input :picture , as: :file , label: (@story.picture.blank? ? "Add picture" : "Change picture") = f.input :header = f.input :text , input_html: {rows: rows(@story.text)} - .mt-4= f.input :happened , class: "flex" + = f.input :happened , wrapper_class: "flex mt-4 align-center" %button.mt-6.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400 = f.submit 'Save' %button.ml-20.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400 diff --git a/db/migrate/20230112123705_add_arrived_to_memberss.rb b/db/migrate/20230112123705_add_arrived_to_memberss.rb new file mode 100644 index 0000000..9484852 --- /dev/null +++ b/db/migrate/20230112123705_add_arrived_to_memberss.rb @@ -0,0 +1,6 @@ +class AddArrivedToMemberss < ActiveRecord::Migration[7.0] + def change + add_column :members, :arrived, :date + add_column :members, :left, :date + end +end diff --git a/db/schema.rb b/db/schema.rb index 2f7101a..a62042e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_01_11_164425) do +ActiveRecord::Schema[7.0].define(version: 2023_01_12_123705) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -42,6 +42,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_11_164425) do t.datetime "confirmed_at" t.datetime "confirmation_sent_at" t.string "unconfirmed_email" + t.date "arrived" + t.date "left" t.index ["email"], name: "index_members_on_email", unique: true t.index ["reset_password_token"], name: "index_members_on_reset_password_token", unique: true end