page index ok
This commit is contained in:
parent
beaae6cb32
commit
a2d79d397d
@ -1,11 +1,12 @@
|
|||||||
module Cms
|
module Cms
|
||||||
class Page
|
class Page
|
||||||
include ActiveModel::API
|
include ActiveModel::Model
|
||||||
include ActiveModel::Conversion
|
include ActiveModel::Conversion
|
||||||
|
include ActiveModel::Dirty
|
||||||
|
|
||||||
@@files = Set.new Dir.new(Rails.root.join("cms")).children
|
@@files = Set.new Dir.new(Rails.root.join("cms")).children
|
||||||
|
|
||||||
attr_reader :name
|
attr_reader :name , :content
|
||||||
|
|
||||||
def id
|
def id
|
||||||
@name
|
@name
|
||||||
@ -20,8 +21,17 @@ module Cms
|
|||||||
@content = YAML.load_file(Rails.root.join("cms" , file_name))
|
@content = YAML.load_file(Rails.root.join("cms" , file_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def template
|
||||||
|
@content[0]["template"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def save
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def self.all
|
def self.all
|
||||||
@@files.collect{ |file| Page.new(file) }
|
@@files.collect{ |file| Page.new(file) }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,21 +1,31 @@
|
|||||||
%h1 Listing cms_pages
|
.overflow-hidden.overflow-x-auto.rounded-lg.border.border-gray-200.m-20
|
||||||
|
%table.min-w-full.divide-y.divide-gray-200.text-sm
|
||||||
%table
|
%thead.bg-gray-100
|
||||||
%thead
|
|
||||||
%tr
|
%tr
|
||||||
%th
|
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
|
||||||
%th
|
.flex.items-center.gap-2
|
||||||
%th
|
Name
|
||||||
|
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
|
||||||
%tbody
|
.flex.items-center.gap-2
|
||||||
|
First Template
|
||||||
|
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
|
||||||
|
.flex.items-center.gap-2
|
||||||
|
Size (Sections)
|
||||||
|
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
|
||||||
|
Status
|
||||||
|
%tbody.divide-y.divide-gray-200
|
||||||
- @cms_pages.each do |cms_page|
|
- @cms_pages.each do |cms_page|
|
||||||
%tr
|
%tr
|
||||||
=cms_page.id
|
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||||
%tr
|
= link_to cms_page.name , cms_page.name
|
||||||
%td= link_to 'Show', cms_page
|
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||||
%td= #link_to 'Edit', edit_cms_page_path(cms_page)
|
= cms_page.template
|
||||||
%td= link_to 'Destroy', cms_page, method: :delete, data: { confirm: 'Are you sure?' }
|
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||||
|
= cms_page.content.length
|
||||||
%br
|
%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 'Show', cms_page_path(cms_page , id: cms_page.name)
|
||||||
|
%strong.rounded.bg-amber-100.px-3.text-xs.font-medium.text-amber-700{:class => "py-1.5"}
|
||||||
|
= link_to 'Edit', edit_cms_page_path(cms_page , id: cms_page.name)
|
||||||
|
|
||||||
= link_to 'New Page', new_cms_page_path
|
= link_to 'New Page', new_cms_page_path
|
||||||
|
Loading…
Reference in New Issue
Block a user