finishing new page/blog
This commit is contained in:
parent
57fdada4fa
commit
d6b238ba94
@ -25,13 +25,19 @@ module Merged
|
|||||||
def create
|
def create
|
||||||
name = params[:name]
|
name = params[:name]
|
||||||
if( name.blank? )
|
if( name.blank? )
|
||||||
@pages = Page.all
|
flash.alert = "Must enter name"
|
||||||
flash.now.alert = "Must enter name"
|
redirect_to pages_url
|
||||||
render :index
|
|
||||||
else
|
else
|
||||||
@page = Page.new_page(name , params[:type])
|
@page = Page.new_page(name , params[:type])
|
||||||
@page.add_save(current_member.email)
|
@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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,8 +63,8 @@ module Merged
|
|||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.new_page(name )
|
def self.new_page(name , type)
|
||||||
data = { name: name.dup , updated_at: Time.now }
|
data = { name: name.dup , updated_at: Time.now , type: type}
|
||||||
Page.new(data)
|
Page.new(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,20 +27,19 @@
|
|||||||
=page.updated_by
|
=page.updated_by
|
||||||
- s = page.sections_update
|
- s = page.sections_update
|
||||||
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
%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
|
%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
|
%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"}
|
%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)
|
= 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"}
|
%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)
|
= link_to 'Edit', merged.page_path(page.id)
|
||||||
|
|
||||||
.grid.grid-cols-3.gap-2.m-8.new_page
|
.flex.mx-20.new_page
|
||||||
.relative.block.border.border-gray-100
|
= form_tag( merged.pages_path , {method: :post } ) do
|
||||||
= form_tag( merged.pages_path , {method: :post } ) do
|
%label.block
|
||||||
%label.block
|
%h4.text-lg.font-bold Name
|
||||||
%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")
|
||||||
= 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|
|
||||||
- @page_styles.each do |page|
|
%button.mt-3.bg-cyan-200{class: button_classes , name: :type , value: page.type}= "New #{page.type.capitalize}"
|
||||||
%button.mt-3.bg-cyan-200{class: button_classes , name: :type , value: page.type}= "New #{page.type.capitalize}"
|
|
||||||
|
@ -31,14 +31,14 @@ class PagesWrite < ActionDispatch::IntegrationTest
|
|||||||
click_on ("Update")
|
click_on ("Update")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def test_new_works_without
|
def test_new_handles_noinput
|
||||||
visit "/merged/pages"
|
visit "/merged/pages"
|
||||||
within(".new_page") do
|
within(".new_page") do
|
||||||
click_on ("New Page")
|
click_on ("New Page")
|
||||||
end
|
end
|
||||||
assert_equal "/merged/pages" , current_path
|
assert_equal "/merged/pages" , current_path
|
||||||
end
|
end
|
||||||
def test_new_works_with_name
|
def test_new_page_works_with_name
|
||||||
visit "/merged/pages"
|
visit "/merged/pages"
|
||||||
within(".new_page") do
|
within(".new_page") do
|
||||||
fill_in 'Name', with: 'New Page'
|
fill_in 'Name', with: 'New Page'
|
||||||
@ -47,6 +47,15 @@ class PagesWrite < ActionDispatch::IntegrationTest
|
|||||||
assert_equal "/merged/sections/41/select_template" , current_path
|
assert_equal "/merged/sections/41/select_template" , current_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_new_blog_works_with_name
|
||||||
|
visit "/merged/pages"
|
||||||
|
within(".new_page") do
|
||||||
|
fill_in 'Name', with: 'New Page'
|
||||||
|
click_on ("New Blog")
|
||||||
|
end
|
||||||
|
assert_equal "/merged/sections/41" , current_path
|
||||||
|
end
|
||||||
|
|
||||||
def test_delete_works
|
def test_delete_works
|
||||||
id = Merged::Page.first.id
|
id = Merged::Page.first.id
|
||||||
visit merged.page_sections_path(id)
|
visit merged.page_sections_path(id)
|
||||||
|
@ -49,7 +49,7 @@ module Merged
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_page_new
|
def test_page_new
|
||||||
studios = Page.new_page("new")
|
studios = Page.new_page("new" , :page)
|
||||||
studios.add_save("email")
|
studios.add_save("email")
|
||||||
assert_equal "new" , change.added("Page").first.last
|
assert_equal "new" , change.added("Page").first.last
|
||||||
assert_nil change.edited("Page").first
|
assert_nil change.edited("Page").first
|
||||||
|
@ -11,7 +11,7 @@ module Merged
|
|||||||
assert_equal OptionDefinition.first.class , OptionDefinition
|
assert_equal OptionDefinition.first.class , OptionDefinition
|
||||||
end
|
end
|
||||||
def test_there_options
|
def test_there_options
|
||||||
assert_equal OptionDefinition.all.length , 18
|
assert_equal OptionDefinition.all.length , 19
|
||||||
end
|
end
|
||||||
def test_has_option_objects
|
def test_has_option_objects
|
||||||
assert_equal first.class , OptionDefinition
|
assert_equal first.class , OptionDefinition
|
||||||
|
@ -10,11 +10,6 @@ module Merged
|
|||||||
def test_all
|
def test_all
|
||||||
assert_equal 2 , Page.all.length
|
assert_equal 2 , Page.all.length
|
||||||
end
|
end
|
||||||
def test_creates_page
|
|
||||||
name = "randomname"
|
|
||||||
page = Page.new_page( name)
|
|
||||||
assert_equal page.name , name
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_has_type
|
def test_has_type
|
||||||
assert_equal index.type , "page"
|
assert_equal index.type , "page"
|
||||||
|
@ -8,6 +8,24 @@ module Merged
|
|||||||
Page.find_by_name('index')
|
Page.find_by_name('index')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_creates_page
|
||||||
|
name = "randomname"
|
||||||
|
page = Page.new_page( name , "page")
|
||||||
|
assert_equal page.name , name
|
||||||
|
assert_equal page.sections.length , 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_creates_blog
|
||||||
|
name = "randomname"
|
||||||
|
page = Page.new_page( name , "blog")
|
||||||
|
assert_equal page.name , name
|
||||||
|
page.add_save("me")
|
||||||
|
template = PageStyle.find_by_type(page.type).section_template
|
||||||
|
section = page.new_section(template)
|
||||||
|
section.add_save("me")
|
||||||
|
assert_equal page.sections.length , 1
|
||||||
|
end
|
||||||
|
|
||||||
def test_deletes
|
def test_deletes
|
||||||
id = index.id
|
id = index.id
|
||||||
index.delete
|
index.delete
|
||||||
|
Loading…
Reference in New Issue
Block a user