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)
|
||||
end
|
||||
|
||||
def remove
|
||||
section = @card.section
|
||||
section.remove_card( @card )
|
||||
section.save
|
||||
redirect_to section_cards_url(section.id)
|
||||
def destroy
|
||||
@card.destroy
|
||||
@card.section.save
|
||||
redirect_to section_cards_url(@card.section.id) , notice: "Card #{@card.index + 1} removed"
|
||||
end
|
||||
|
||||
def update
|
||||
|
@ -1,24 +1,15 @@
|
||||
module Merged
|
||||
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
|
||||
@pages = Page.all.values
|
||||
end
|
||||
|
||||
# GET /merged/pages/1
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /merged/pages/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /merged/pages
|
||||
def create
|
||||
name = params[:name]
|
||||
message = Page.check_name(name)
|
||||
message = "Must enter name" if name.blank?
|
||||
if( message.nil?)
|
||||
@page = Page.build_new(name)
|
||||
redirect_to new_page_section_url(@page.name) , notice: "Page was successfully created."
|
||||
@ -29,30 +20,15 @@ module Merged
|
||||
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
|
||||
Page.destroy(@page)
|
||||
redirect_to pages_url, notice: "Page #{@page.name} was removed."
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_page
|
||||
@page = Page.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def page_params
|
||||
params.fetch(:page, {})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -29,11 +29,10 @@ module Merged
|
||||
end
|
||||
end
|
||||
|
||||
def remove
|
||||
page = @section.page
|
||||
page.remove_section( @section )
|
||||
page.save
|
||||
redirect_to page_sections_url(page.name)
|
||||
def destroy
|
||||
@section.destroy()
|
||||
@section.page.save
|
||||
redirect_to page_sections_url(@section.page.name) , notice: "Section #{@section.index + 1} removed"
|
||||
end
|
||||
|
||||
def set_image
|
||||
|
@ -24,6 +24,9 @@ module Merged
|
||||
@@all[self.id] = self
|
||||
end
|
||||
|
||||
def destroy
|
||||
@section.remove_card( self)
|
||||
end
|
||||
|
||||
def update(key , value)
|
||||
return if key == "id" #not updating that
|
||||
|
@ -103,9 +103,14 @@ module Merged
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@page.remove_section(self)
|
||||
end
|
||||
|
||||
def move_up
|
||||
@page.move_section_up(self)
|
||||
end
|
||||
|
||||
def move_down
|
||||
@page.move_section_down(self)
|
||||
end
|
||||
|
@ -6,7 +6,7 @@
|
||||
=flash.alert
|
||||
|
||||
-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
|
||||
%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"}
|
||||
|
@ -19,7 +19,8 @@
|
||||
%h3.mt-4.text-lg.font-bold Card #{index + 1}
|
||||
= blue_button( "Up" , card_move_url(card.id , dir: :up) )
|
||||
= 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
|
||||
%h3.mt-4.text-lg.font-bold Image
|
||||
= yellow_button("Change Image" , card_select_image_url(card.id) )
|
||||
|
@ -21,7 +21,7 @@
|
||||
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||
= merged_page.first_template
|
||||
%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
|
||||
%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)
|
||||
|
@ -13,7 +13,8 @@
|
||||
= blue_button( "Down" , section_move_url(section.id , dir: :down) )
|
||||
= yellow_button("Edit" , section_path(section.id) )
|
||||
= 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
|
||||
%h3.mt-4.text-lg.font-bold Template
|
||||
= link_to(section_select_template_url(section.id)) do
|
||||
@ -42,9 +43,11 @@
|
||||
%p
|
||||
= name
|
||||
= value
|
||||
.relative.block.border.border-gray-100
|
||||
.grid.grid-cols-2.gap-2.m-8
|
||||
.relative.block
|
||||
%p
|
||||
= green_button( "New Section" , new_page_section_url(@page.name) )
|
||||
.relative.block
|
||||
%p
|
||||
= 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 :set_card_template
|
||||
get :move
|
||||
get :remove
|
||||
resources :cards do
|
||||
get :select_image
|
||||
get :set_image
|
||||
get :move
|
||||
get :remove
|
||||
end
|
||||
end
|
||||
get :remove
|
||||
end
|
||||
resources :images do
|
||||
get :remove
|
||||
end
|
||||
resources :images
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user