picture cache for forms
This commit is contained in:
parent
0a9b32f06b
commit
e4364fc677
@ -1,6 +1,6 @@
|
||||
GIT
|
||||
remote: https://github.com/HubFeenixMakers/merged
|
||||
revision: accb6682675f92eed6e1c306995017b1c8da1289
|
||||
revision: a452bd5d8daf83387172fe635ba3ccbb4bdd9ace
|
||||
specs:
|
||||
merged (0.1.0)
|
||||
active_hash
|
||||
@ -303,7 +303,7 @@ GEM
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.4.4)
|
||||
rails-html-sanitizer (1.5.0)
|
||||
loofah (~> 2.19, >= 2.19.1)
|
||||
rails_gravatar (1.0.4)
|
||||
actionview
|
||||
|
@ -1,16 +1,13 @@
|
||||
class EventsController < ApplicationController
|
||||
before_action :set_event, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /events
|
||||
def index
|
||||
@events = Event.all
|
||||
end
|
||||
|
||||
# GET /events/1
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /events/new
|
||||
def new
|
||||
kind = params[:profile]
|
||||
kind = Profile.kinds.first unless Profile.kinds.include?(kind)
|
||||
@ -22,11 +19,9 @@ class EventsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
# GET /events/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /events
|
||||
def create
|
||||
@event = Event.new(event_params)
|
||||
|
||||
@ -37,7 +32,6 @@ class EventsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /events/1
|
||||
def update
|
||||
if @event.update(event_params)
|
||||
redirect_to @event, notice: "Event was successfully updated."
|
||||
@ -60,6 +54,7 @@ class EventsController < ApplicationController
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def event_params
|
||||
params.require(:event).permit(:name, :text, :start_date, :end_date, :profile_id, :picture)
|
||||
params.require(:event).permit(:name, :text, :start_date, :end_date,
|
||||
:profile_id, :picture, :picture_cache)
|
||||
end
|
||||
end
|
||||
|
@ -1,28 +1,23 @@
|
||||
class ProfilesController < ApplicationController
|
||||
before_action :set_profile, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /profiles
|
||||
def index
|
||||
@profiles = Profile.page params[:page]
|
||||
end
|
||||
|
||||
# GET /profiles/1
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /profiles/new
|
||||
def new
|
||||
kind = params[:kind]
|
||||
kind = Profile.kinds.first unless Profile.kinds.include?(kind)
|
||||
@profile = Profile.new kind: kind
|
||||
end
|
||||
|
||||
# GET /profiles/1/edit
|
||||
def edit
|
||||
authorize @profile
|
||||
end
|
||||
|
||||
# POST /profiles
|
||||
def create
|
||||
@profile = Profile.new(profile_params)
|
||||
@profile.member = current_member
|
||||
@ -34,7 +29,6 @@ class ProfilesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /profiles/1
|
||||
def update
|
||||
authorize @profile
|
||||
if @profile.update(profile_params)
|
||||
@ -44,7 +38,6 @@ class ProfilesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /profiles/1
|
||||
def destroy
|
||||
authorize @profile
|
||||
@profile.destroy
|
||||
@ -59,6 +52,6 @@ class ProfilesController < ApplicationController
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def profile_params
|
||||
params.require(:profile).permit(:name, :bio, :picture, :kind)
|
||||
params.require(:profile).permit(:name, :bio, :picture,:picture_cache, :kind)
|
||||
end
|
||||
end
|
||||
|
@ -7,7 +7,12 @@
|
||||
= f.input :start_date
|
||||
= f.input :end_date
|
||||
= f.input :profile_id , as: :hidden
|
||||
= f.input :picture , as: :file
|
||||
.flex.h-16.mt-2
|
||||
= image_tag(@event.picture_url , class: "align-middle mr-2") if @event.picture?
|
||||
= f.input :picture , as: :file , input_html: {wrapper_class: "w-full"},
|
||||
label: (@event.picture.blank? ? "Add picture" : "Change picture")
|
||||
= f.hidden_field :picture_cache
|
||||
|
||||
.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'
|
||||
|
@ -1,23 +0,0 @@
|
||||
= simple_form_for @member do |f|
|
||||
= f.error_notification
|
||||
|
||||
.grid.grid-cols-2.m-20.gap-10
|
||||
.field
|
||||
= f.label :name
|
||||
= f.text_field :name
|
||||
.field
|
||||
= f.label :public
|
||||
= f.check_box :public
|
||||
.field
|
||||
= f.label :picture
|
||||
= f.file_field :picture
|
||||
-if @member.picture
|
||||
%div.overflow-hidden
|
||||
.my-5 Currently
|
||||
= image_tag @member.picture, class: "object-contain h-40"
|
||||
|
||||
.field
|
||||
= f.label :Bio
|
||||
= f.rich_text_area :bio
|
||||
.flex.justify-center.actions
|
||||
= f.submit 'Save'
|
@ -1,41 +0,0 @@
|
||||
= javascript_include_tag "merged/vue.min.js"
|
||||
= javascript_include_tag "marked.min.js"
|
||||
|
||||
.flex.justify-center.m-20
|
||||
.flex.flex-col
|
||||
%h1.text-4xl Editing profile
|
||||
|
||||
= simple_form_for @member , builder: SimpleForm::Tailwind::FormBuilder do |f|
|
||||
= f.error_notification
|
||||
|
||||
.grid.grid-cols-4.mx-20
|
||||
.info.mr-8
|
||||
= f.input :name
|
||||
= f.input :public , label: "Public: (Click box below)"
|
||||
= f.input :picture , as: :file
|
||||
.flex.justify-center.actions.m-10
|
||||
= f.button :button, "Update", class: button_classes + " bg-cyan-200"
|
||||
= link_to member_path(@member) do
|
||||
%button.ml-10{type: :submit, class: button_classes}
|
||||
Back
|
||||
.field.flex.flex-col.pr-2.border-r-8.border-slate-600
|
||||
= f.text_area :bio ,rows: 18 , "v-model" => "markdown" , class: "appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
|
||||
%div.h-90
|
||||
-if @member.picture_url
|
||||
%div.overflow-hidden.ml-2.mr-8
|
||||
= image_tag @member.picture_url, class: "object-contain w-full"
|
||||
-else
|
||||
No Picture
|
||||
.preview.prose
|
||||
%b.text-2xl Preview
|
||||
%div{"v-html" => "compiledMarkdown"}
|
||||
:ruby2js
|
||||
class Mark < Vue
|
||||
options el: '.grid'
|
||||
def initialize
|
||||
@markdown = "#{@member.bio.to_s.html_safe}"
|
||||
end
|
||||
def compiledMarkdown
|
||||
marked.parse(@markdown)
|
||||
end
|
||||
end
|
@ -4,7 +4,11 @@
|
||||
= f.input :name
|
||||
= f.input :bio
|
||||
= f.input :kind, :as => :hidden
|
||||
= f.input :picture , as: :file , label: (@profile.picture.blank? ? "Add picture" : "Change picture (optional)")
|
||||
.flex.h-16.mt-2
|
||||
= image_tag(@profile.picture_url , class: "align-middle mr-2") if @profile.picture?
|
||||
= f.input :picture , as: :file , input_html: {wrapper_class: "w-full"},
|
||||
label: (@profile.picture.blank? ? "Add picture" : "Change picture")
|
||||
= f.hidden_field :picture_cache
|
||||
|
||||
.flex.justify-between.mt-4
|
||||
%button.bg-cyan-200{class: button_classes}
|
||||
|
Loading…
Reference in New Issue
Block a user