finishing new page/blog

This commit is contained in:
2022-12-27 16:47:57 +02:00
parent 57fdada4fa
commit d6b238ba94
8 changed files with 52 additions and 25 deletions

View File

@ -25,13 +25,19 @@ module Merged
def create
name = params[:name]
if( name.blank? )
@pages = Page.all
flash.now.alert = "Must enter name"
render :index
flash.alert = "Must enter name"
redirect_to pages_url
else
@page = Page.new_page(name , params[:type])
@page.add_save(current_member.email)
redirect_to new_page_section_url(@page.id) , notice: "Page was successfully created."
template = PageStyle.find_by_type(@page.type).section_template
if(template)
section = @page.new_section(template)
section.add_save(current_member.email)
redirect_to section_url(section.id) , notice: "Page was successfully created."
else
redirect_to new_page_section_url(@page.id) , notice: "Page was successfully created. Choose first section"
end
end
end

View File

@ -63,8 +63,8 @@ module Merged
super
end
def self.new_page(name )
data = { name: name.dup , updated_at: Time.now }
def self.new_page(name , type)
data = { name: name.dup , updated_at: Time.now , type: type}
Page.new(data)
end

View File

@ -27,20 +27,19 @@
=page.updated_by
- s = page.sections_update
%td.whitespace-nowrap.px-4.py-2.text-gray-700
=distance_of_time_in_words_to_now(s.updated_at)
=distance_of_time_in_words_to_now(s.updated_at) if s
%td.whitespace-nowrap.px-4.py-2.text-gray-700
=s.updated_by
=s.updated_by if s
%td.whitespace-nowrap.px-4.py-2
%strong.rounded.bg-green-100.px-3.text-xs.font-medium.text-green-700{:class => "py-1.5"}
= link_to 'Sections', merged.page_sections_path(page.id)
%strong.rounded.bg-amber-100.px-3.text-xs.font-medium.text-amber-700{:class => "py-1.5"}
= link_to 'Edit', merged.page_path(page.id)
.grid.grid-cols-3.gap-2.m-8.new_page
.relative.block.border.border-gray-100
= form_tag( merged.pages_path , {method: :post } ) do
%label.block
%h4.text-lg.font-bold Name
= text_field_tag( :name , params[:name], class: "block w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm")
- @page_styles.each do |page|
%button.mt-3.bg-cyan-200{class: button_classes , name: :type , value: page.type}= "New #{page.type.capitalize}"
.flex.mx-20.new_page
= form_tag( merged.pages_path , {method: :post } ) do
%label.block
%h4.text-lg.font-bold Name
= text_field_tag( :name , params[:name], class: "block w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm")
- @page_styles.each do |page|
%button.mt-3.bg-cyan-200{class: button_classes , name: :type , value: page.type}= "New #{page.type.capitalize}"