show page for pages (a start)
This commit is contained in:
@ -1,11 +1,15 @@
|
||||
module Merged
|
||||
class PagesController < MergedController
|
||||
before_action :set_page, only: %i[ update destroy ]
|
||||
before_action :set_page, only: %i[ update destroy show ]
|
||||
|
||||
def index
|
||||
@pages = Page.all
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
name = params[:name]
|
||||
message = Page.check_name(name)
|
||||
|
@ -1,13 +1,18 @@
|
||||
module Merged
|
||||
class Page < ViewBase
|
||||
|
||||
fields :name , :type , :options
|
||||
|
||||
fields :name , :tempate
|
||||
alias :template :type
|
||||
|
||||
def sections
|
||||
Section.where(page_id: id).order(index: :asc)
|
||||
end
|
||||
|
||||
def template_style
|
||||
PageStyle.find_by_type( type )
|
||||
end
|
||||
|
||||
def new_section(section_template)
|
||||
section_template = "section_spacer" if section_template.blank?
|
||||
section = Section.new_section(section_template, self.id , sections.length + 1)
|
||||
|
@ -11,6 +11,10 @@ module Merged
|
||||
Card.where(section_id: id).order(index: :asc)
|
||||
end
|
||||
|
||||
def template_style
|
||||
SectionStyle.find_by_template( template )
|
||||
end
|
||||
|
||||
def set_template(new_template)
|
||||
self.template = new_template
|
||||
new_style = template_style
|
||||
|
@ -10,10 +10,6 @@ module Merged
|
||||
|
||||
fields :options , :updated_at , :updated_by
|
||||
|
||||
def template_style
|
||||
SectionStyle.find_by_template( template )
|
||||
end
|
||||
|
||||
def has_option?(option)
|
||||
options.has_key?(option) and !options[option].blank?
|
||||
end
|
||||
|
@ -24,7 +24,7 @@
|
||||
Actions
|
||||
%tbody.divide-y.divide-gray-200
|
||||
- @pages.each do |merged_page|
|
||||
%tr
|
||||
%tr{id: merged_page.name}
|
||||
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||
= link_to merged_page.name , page_sections_path(merged_page.id)
|
||||
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||
@ -37,7 +37,7 @@
|
||||
%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.id)
|
||||
%strong.rounded.bg-amber-100.px-3.text-xs.font-medium.text-amber-700{:class => "py-1.5"}
|
||||
= link_to 'Edit', edit_page_path(merged_page.id)
|
||||
= link_to 'Edit', page_path(merged_page.id)
|
||||
|
||||
.grid.grid-cols-3.gap-2.m-8
|
||||
.relative.block.border.border-gray-100
|
||||
|
36
app/views/merged/pages/show.haml
Normal file
36
app/views/merged/pages/show.haml
Normal file
@ -0,0 +1,36 @@
|
||||
- content_for( :merged_menu ) do
|
||||
.text-xl.font-bold.text-gray-900
|
||||
Page
|
||||
.text-xl.font-bold.text-gray-900
|
||||
=@page.name
|
||||
%strong.rounded.bg-green-100.px-3.text-xs.font-medium.text-green-700{:class => "py-1.5"}
|
||||
= link_to 'Sections', page_sections_path(@page.id)
|
||||
|
||||
.text-xl= distance_of_time_in_words_to_now(@page.updated_at)
|
||||
= render "layouts/merged_header"
|
||||
|
||||
.flex.gap-4.justify-center.m-20
|
||||
.flex.flex-col
|
||||
-@page.sections.each do |section |
|
||||
.flex.pb-2.px-2{class: (section.index%2)==1 ? 'bg-cyan-50' : 'bg-red-50'}
|
||||
=link_to( section_path(section.id)) do
|
||||
.mt-4.text-lg.font-bold Section #{section.index} : #{section.header}
|
||||
- if section.has_cards?
|
||||
%h3.mt-4.text-lg.font-bold #{section.cards.length} Cards
|
||||
.basis-80
|
||||
= form_tag( page_url(@page.id) , {method: :patch , class: "mx-auto mt-8 mb-0 max-w space-y-4" } ) do
|
||||
%label.block
|
||||
%h4.text-lg.font-bold Name
|
||||
= text_field_tag( :name , @page.name, class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm")
|
||||
.mt-4= submit_button("Update")
|
||||
(renaming not implemented)
|
||||
|
||||
.basis-80.grow
|
||||
%h3.mt-4.text-lg.font-bold Options
|
||||
= form_tag( page_url(@page.id) , {method: :patch , class: "mx-auto mt-8 mb-0 max-w space-y-4" } ) do
|
||||
- @page.option_definitions.each do |option|
|
||||
=render "option_form_#{option.type}" , section: @page , option: option
|
||||
-if @page.option_definitions.empty?
|
||||
%p No options
|
||||
-else
|
||||
.mt-4= submit_button("Update")
|
Reference in New Issue
Block a user