improving event

This commit is contained in:
Torsten 2023-01-16 18:59:07 +02:00
parent cb54951037
commit 37164b534d
8 changed files with 60 additions and 81 deletions

View File

@ -1,6 +1,7 @@
class Profile < ApplicationRecord
belongs_to :member
has_many :events
validates :name , presence: true
validates :kind , presence: true
validates :bio , presence: true

View File

@ -0,0 +1,11 @@
%section.overflow-hidden.grid.grid-cols-1.m-5.md:m-12.lg:m-20.md:grid-cols-2
%div
= image_for( event , "h-56 w-full object-cover sm:h-full")
.p-8.md:p-12.lg:px-16.lg:py-24
.mx-auto.max-w-xl.text-center
%h2.text-2xl.font-bold.md:text-4xl
= event.name
%h4.text-xl.mt-10.md:text-2xl
= event.start_date
.mt-8{ prose_classes }
= markdown(event.text)

View File

@ -8,7 +8,9 @@
= f.input :end_date
= f.input :profile_id , as: :hidden
= f.input :picture , as: :file
%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
= link_to 'Back', @story
.flex.justify-between
%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'
= link_to member_path(current_member) do
.mt-6.ml-20.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
Back

View File

@ -1,31 +1,12 @@
%h1 Listing events
%table
%thead
%tr
%th Name
%th Text
%th Start date
%th End date
%th Profile
%th Picture
%th
%th
%th
%tbody
.flex.justify-center
.grid.grid-cols-4
- @events.each do |event|
%tr
%td= event.name
%td= event.text
%td= event.start_date
%td= event.end_date
%td= event.profile
%td= event.picture
%td= link_to 'Show', event
%td= link_to 'Edit', edit_event_path(event)
%td= link_to 'Destroy', event, method: :delete, data: { confirm: 'Are you sure?' }
%br
= link_to 'New Event', new_event_path
.fex.flex-col.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm.m-10
=link_to event do
= image_for( event , class: "h-60 w-full object-cover")
%h3.py-5.text-2xl.bg-gray-100.text-black.font-bold.text-center
= event.name
%div.h-full
.p-5.text-center
.m-2.text-sm.leading-relaxed.line-clamp-3{ prose_classes }
= shorten markdown(event.text)

View File

@ -1,24 +1,3 @@
%p#notice= notice
= render "event" , event: @event
%p
%b Name:
= @event.name
%p
%b Text:
= @event.text
%p
%b Start date:
= @event.start_date
%p
%b End date:
= @event.end_date
%p
%b Profile:
= @event.profile
%p
%b Picture:
= @event.picture
= link_to 'Edit', edit_event_path(@event)
\|
= link_to 'Back', events_path
= render "profiles/profile" , profile: @event.profile , header: "About the teacher"

View File

@ -13,28 +13,33 @@
.grid.grid-cols-2.mx-20
.first
- Profile.types.each do |kind|
.grid.grid-cols-3
.grid.grid-cols-4
- if profile = @member.profile(kind)
%div
=profile.Kind
exists with name
=link_to profile.name , profile_path(profile) , class: "underline"
exists
= link_to edit_profile_path(profile) do
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
Edit
=profile.Kind
= link_to new_event_path(profile: profile.kind) do
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
New #{profile.Kind} Event
-if event = profile.events.length >0
%div
=link_to profile.events.first.name , event_path(profile.events.first) , class: "underline"
= link_to edit_event_path(profile.events.first) do
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
Edit
-else
No events
-else
%div Create new #{kind.capitalize} profile as
%div Create new profile as
= link_to new_profile_path(kind: kind) do
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
New
= kind.capitalize
%div Create profile first, then events
%div Create profile first
%div No events, create profile first
.grid.grid-cols-6.gap-4.mt-10.mx-10
-@member.entities.each do |entity|

View File

@ -0,0 +1,14 @@
.px-4.py-16.mx-auto.sm:max-w-xl.md:max-w-full.lg:max-w-screen-xl.md:px-24.lg:px-8.lg:py-20
.flex.justify-center
.px-4.py-4.text-center
%h1.text-2xl.font-bold.tracking-tight.sm:text-4xl
= header
.flex.mt-6.py-4.flex-col.max-w-screen-lg.overflow-hidden.bg-white.border.rounded.shadow-sm.lg:flex-row.sm:mx-auto
.relative{:class => "lg:w-1/2"}
-if profile.picture_url
= image_tag profile.picture_url, class: "object-cover w-full lg:absolute h-80 lg:h-full"
.flex.flex-col.justify-center.p-8.lg:p-16.lg:pl-10{:class => "lg:w-1/2"}
%h5.mb-3.text-3xl.font-extrabold.leading-none.sm:text-4xl
= profile.name
.mb-8.text-gray-800
.prose= markdown(profile.bio)

View File

@ -1,15 +1 @@
.px-4.py-16.mx-auto.sm:max-w-xl.md:max-w-full.lg:max-w-screen-xl.md:px-24.lg:px-8.lg:py-20
.flex.justify-center
.px-4.py-4.text-center
%h1text-2xl.font-bold.tracking-tight.sm:text-4xl
= @profile.Kind
profile
.flex.py-4.flex-col.max-w-screen-lg.overflow-hidden.bg-white.border.rounded.shadow-sm.lg:flex-row.sm:mx-auto
.relative{:class => "lg:w-1/2"}
-if @profile.picture_url
= image_tag @profile.picture_url, class: "object-cover w-full lg:absolute h-80 lg:h-full"
.flex.flex-col.justify-center.p-8.lg:p-16.lg:pl-10{:class => "lg:w-1/2"}
%h5.mb-3.text-3xl.font-extrabold.leading-none.sm:text-4xl
= @profile.name
.mb-8.text-gray-800
.prose= markdown(@profile.bio)
= render "profile" , profile: @profile , header: "#{@profile.Kind} profile"