cleaning destroys and messages
This commit is contained in:
parent
d10361f13d
commit
6bb1a814ad
@ -32,11 +32,10 @@ module Merged
|
|||||||
redirect_to section_cards_url(@section.id)
|
redirect_to section_cards_url(@section.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove
|
def destroy
|
||||||
section = @card.section
|
@card.destroy
|
||||||
section.remove_card( @card )
|
@card.section.save
|
||||||
section.save
|
redirect_to section_cards_url(@card.section.id) , notice: "Card #{@card.index + 1} removed"
|
||||||
redirect_to section_cards_url(section.id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@ -1,24 +1,15 @@
|
|||||||
module Merged
|
module Merged
|
||||||
class PagesController < MergedController
|
class PagesController < MergedController
|
||||||
before_action :set_page, only: %i[ show edit update destroy ]
|
before_action :set_page, only: %i[ update destroy ]
|
||||||
|
|
||||||
# GET /merged/pages
|
|
||||||
def index
|
def index
|
||||||
@pages = Page.all.values
|
@pages = Page.all.values
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /merged/pages/1
|
|
||||||
def show
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /merged/pages/1/edit
|
|
||||||
def edit
|
|
||||||
end
|
|
||||||
|
|
||||||
# POST /merged/pages
|
|
||||||
def create
|
def create
|
||||||
name = params[:name]
|
name = params[:name]
|
||||||
message = Page.check_name(name)
|
message = Page.check_name(name)
|
||||||
|
message = "Must enter name" if name.blank?
|
||||||
if( message.nil?)
|
if( message.nil?)
|
||||||
@page = Page.build_new(name)
|
@page = Page.build_new(name)
|
||||||
redirect_to new_page_section_url(@page.name) , notice: "Page was successfully created."
|
redirect_to new_page_section_url(@page.name) , notice: "Page was successfully created."
|
||||||
@ -29,30 +20,15 @@ module Merged
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PATCH/PUT /merged/pages/1
|
|
||||||
def update
|
|
||||||
if @page.update(page_params)
|
|
||||||
redirect_to @page, notice: "Page was successfully updated."
|
|
||||||
else
|
|
||||||
render :edit, status: :unprocessable_entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# DELETE /merged/pages/1
|
|
||||||
def destroy
|
def destroy
|
||||||
Page.destroy(@page)
|
Page.destroy(@page)
|
||||||
redirect_to pages_url, notice: "Page #{@page.name} was removed."
|
redirect_to pages_url, notice: "Page #{@page.name} was removed."
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
|
||||||
def set_page
|
def set_page
|
||||||
@page = Page.find(params[:id])
|
@page = Page.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Only allow a list of trusted parameters through.
|
|
||||||
def page_params
|
|
||||||
params.fetch(:page, {})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -29,11 +29,10 @@ module Merged
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove
|
def destroy
|
||||||
page = @section.page
|
@section.destroy()
|
||||||
page.remove_section( @section )
|
@section.page.save
|
||||||
page.save
|
redirect_to page_sections_url(@section.page.name) , notice: "Section #{@section.index + 1} removed"
|
||||||
redirect_to page_sections_url(page.name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_image
|
def set_image
|
||||||
|
@ -24,6 +24,9 @@ module Merged
|
|||||||
@@all[self.id] = self
|
@@all[self.id] = self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@section.remove_card( self)
|
||||||
|
end
|
||||||
|
|
||||||
def update(key , value)
|
def update(key , value)
|
||||||
return if key == "id" #not updating that
|
return if key == "id" #not updating that
|
||||||
|
@ -103,9 +103,14 @@ module Merged
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@page.remove_section(self)
|
||||||
|
end
|
||||||
|
|
||||||
def move_up
|
def move_up
|
||||||
@page.move_section_up(self)
|
@page.move_section_up(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_down
|
def move_down
|
||||||
@page.move_section_down(self)
|
@page.move_section_down(self)
|
||||||
end
|
end
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
=flash.alert
|
=flash.alert
|
||||||
|
|
||||||
-if flash.notice
|
-if flash.notice
|
||||||
.rounded-xl.border.border-gray-100.p-4.shadow-xl{:role => "alert"}
|
.m-20.rounded-xl.border.border-gray-100.p-4.shadow-xl{:role => "alert"}
|
||||||
.flex.items-start.gap-4
|
.flex.items-start.gap-4
|
||||||
%span.text-green-600
|
%span.text-green-600
|
||||||
%svg.h-6.w-6{:fill => "none", :stroke => "currentColor", "stroke-width" => "1.5", :viewbox => "0 0 24 24", :xmlns => "http://www.w3.org/2000/svg"}
|
%svg.h-6.w-6{:fill => "none", :stroke => "currentColor", "stroke-width" => "1.5", :viewbox => "0 0 24 24", :xmlns => "http://www.w3.org/2000/svg"}
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
%h3.mt-4.text-lg.font-bold Card #{index + 1}
|
%h3.mt-4.text-lg.font-bold Card #{index + 1}
|
||||||
= blue_button( "Up" , card_move_url(card.id , dir: :up) )
|
= blue_button( "Up" , card_move_url(card.id , dir: :up) )
|
||||||
= blue_button( "Down" , card_move_url(card.id , dir: :down) )
|
= blue_button( "Down" , card_move_url(card.id , dir: :down) )
|
||||||
= red_button( "Delete" , card_remove_path(card.id) )
|
= form_tag( card_url(card.id) , {method: :delete } ) do
|
||||||
|
=submit_button( "Delete" , true)
|
||||||
.p-4
|
.p-4
|
||||||
%h3.mt-4.text-lg.font-bold Image
|
%h3.mt-4.text-lg.font-bold Image
|
||||||
= yellow_button("Change Image" , card_select_image_url(card.id) )
|
= yellow_button("Change Image" , card_select_image_url(card.id) )
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||||
= merged_page.first_template
|
= merged_page.first_template
|
||||||
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||||
= merged_page.content.length
|
= merged_page.sections.length
|
||||||
%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', page_sections_path(merged_page.name)
|
= link_to 'Sections', page_sections_path(merged_page.name)
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
= blue_button( "Down" , section_move_url(section.id , dir: :down) )
|
= blue_button( "Down" , section_move_url(section.id , dir: :down) )
|
||||||
= yellow_button("Edit" , section_path(section.id) )
|
= yellow_button("Edit" , section_path(section.id) )
|
||||||
= green_button( "Copy" , new_page_section_url(@page.name, template: section.template) )
|
= green_button( "Copy" , new_page_section_url(@page.name, template: section.template) )
|
||||||
= red_button( "Delete" , section_remove_path(section.id) )
|
= form_tag( section_url(section.id) , {method: :delete } ) do
|
||||||
|
=submit_button( "Delete" , true)
|
||||||
.relative.block.border.border-gray-100.p-4
|
.relative.block.border.border-gray-100.p-4
|
||||||
%h3.mt-4.text-lg.font-bold Template
|
%h3.mt-4.text-lg.font-bold Template
|
||||||
= link_to(section_select_template_url(section.id)) do
|
= link_to(section_select_template_url(section.id)) do
|
||||||
@ -42,9 +43,11 @@
|
|||||||
%p
|
%p
|
||||||
= name
|
= name
|
||||||
= value
|
= value
|
||||||
.relative.block.border.border-gray-100
|
.grid.grid-cols-2.gap-2.m-8
|
||||||
|
.relative.block
|
||||||
%p
|
%p
|
||||||
= green_button( "New Section" , new_page_section_url(@page.name) )
|
= green_button( "New Section" , new_page_section_url(@page.name) )
|
||||||
|
.relative.block
|
||||||
%p
|
%p
|
||||||
= form_tag( page_url(@page.name) , {method: :delete } ) do
|
= form_tag( page_url(@page.name) , {method: :delete } ) do
|
||||||
=submit_button( "Delete" , true)
|
=submit_button( "Delete Page" , true)
|
||||||
|
@ -13,17 +13,12 @@ Merged::Engine.routes.draw do
|
|||||||
get :select_card_template
|
get :select_card_template
|
||||||
get :set_card_template
|
get :set_card_template
|
||||||
get :move
|
get :move
|
||||||
get :remove
|
|
||||||
resources :cards do
|
resources :cards do
|
||||||
get :select_image
|
get :select_image
|
||||||
get :set_image
|
get :set_image
|
||||||
get :move
|
get :move
|
||||||
get :remove
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
get :remove
|
|
||||||
end
|
|
||||||
resources :images do
|
|
||||||
get :remove
|
|
||||||
end
|
end
|
||||||
|
resources :images
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user