From e765b136e4cf7d80bf44ffaac2b626ba06c4469d Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 28 Jul 2016 00:46:28 -0400 Subject: refactor dialogs --- src/guff/views/admin/dialogs/blog-edit.cr | 5 + src/guff/views/admin/dialogs/page-edit.cr | 24 ++ src/guff/views/admin/dialogs/post-edit.cr | 16 + src/guff/views/admin/dialogs/project-edit.cr | 5 + src/guff/views/admin/dialogs/user-add.cr | 2 +- src/guff/views/admin/dialogs/user-edit.cr | 4 +- src/guff/views/admin/dialogs/user.cr | 2 +- src/guff/views/admin/page.cr | 37 +- src/views/admin/dialogs/blog-edit.ecr | 166 +++++++++ src/views/admin/dialogs/page-edit.ecr | 175 +++++++++ src/views/admin/dialogs/project-edit.ecr | 179 +++++++++ src/views/admin/page.ecr | 522 --------------------------- 12 files changed, 580 insertions(+), 557 deletions(-) create mode 100644 src/guff/views/admin/dialogs/blog-edit.cr create mode 100644 src/guff/views/admin/dialogs/page-edit.cr create mode 100644 src/guff/views/admin/dialogs/post-edit.cr create mode 100644 src/guff/views/admin/dialogs/project-edit.cr create mode 100644 src/views/admin/dialogs/blog-edit.ecr create mode 100644 src/views/admin/dialogs/page-edit.ecr create mode 100644 src/views/admin/dialogs/project-edit.ecr (limited to 'src') diff --git a/src/guff/views/admin/dialogs/blog-edit.cr b/src/guff/views/admin/dialogs/blog-edit.cr new file mode 100644 index 0000000..409b8d3 --- /dev/null +++ b/src/guff/views/admin/dialogs/blog-edit.cr @@ -0,0 +1,5 @@ +require "./post-edit" + +class Guff::Views::Admin::Dialogs::BlogEdit < Guff::Views::Admin::Dialogs::PostEdit + ECR.def_to_s("src/views/admin/dialogs/blog-edit.ecr") +end diff --git a/src/guff/views/admin/dialogs/page-edit.cr b/src/guff/views/admin/dialogs/page-edit.cr new file mode 100644 index 0000000..138691d --- /dev/null +++ b/src/guff/views/admin/dialogs/page-edit.cr @@ -0,0 +1,24 @@ +require "./post-edit" + +class Guff::Views::Admin::Dialogs::PageEdit < Guff::Views::Admin::Dialogs::PostEdit + private def theme_options + tmpl = Guff::Views::Admin::PageView::TEMPLATES[:option] + + [{ + "id" => "site-default", + "name" => "Site Default", + }].concat(@context.models.theme.all.map { |row| + { + "id" => row["theme_id"], + "name" => "%s (%s)" % %w{ + name + version + }.map { |k| row["theme_#{k}"] }, + } + }).map { |row| + tmpl % %w{id name}.map { |k| row[k] } + }.join("") + end + + ECR.def_to_s("src/views/admin/dialogs/page-edit.ecr") +end diff --git a/src/guff/views/admin/dialogs/post-edit.cr b/src/guff/views/admin/dialogs/post-edit.cr new file mode 100644 index 0000000..f817d5c --- /dev/null +++ b/src/guff/views/admin/dialogs/post-edit.cr @@ -0,0 +1,16 @@ +class Guff::Views::Admin::Dialogs::PostEdit < Guff::Views::HTMLView + protected def state_buttons + tmpl = Guff::Views::Admin::PageView::TEMPLATES[:state_button] + + @state_buttons ||= String.build do |io| + @context.models.state.get_states.each do |row| + io << tmpl % [ + h(row["name"]), + h(row["state"]), + h(row["icon"]), + h(row["name"]) + ] + end + end + end +end diff --git a/src/guff/views/admin/dialogs/project-edit.cr b/src/guff/views/admin/dialogs/project-edit.cr new file mode 100644 index 0000000..0db1f11 --- /dev/null +++ b/src/guff/views/admin/dialogs/project-edit.cr @@ -0,0 +1,5 @@ +require "./post-edit" + +class Guff::Views::Admin::Dialogs::ProjectEdit < Guff::Views::Admin::Dialogs::PostEdit + ECR.def_to_s("src/views/admin/dialogs/project-edit.ecr") +end diff --git a/src/guff/views/admin/dialogs/user-add.cr b/src/guff/views/admin/dialogs/user-add.cr index e347225..1a404fe 100644 --- a/src/guff/views/admin/dialogs/user-add.cr +++ b/src/guff/views/admin/dialogs/user-add.cr @@ -1,5 +1,5 @@ require "./user" -class Guff::Views::Admin::Dialogs::UserAddDialog < Guff::Views::Admin::Dialogs::UserDialog +class Guff::Views::Admin::Dialogs::UserAdd < Guff::Views::Admin::Dialogs::User ECR.def_to_s("src/views/admin/dialogs/user-add.ecr") end diff --git a/src/guff/views/admin/dialogs/user-edit.cr b/src/guff/views/admin/dialogs/user-edit.cr index e14211a..27789b7 100644 --- a/src/guff/views/admin/dialogs/user-edit.cr +++ b/src/guff/views/admin/dialogs/user-edit.cr @@ -1,3 +1,5 @@ -class Guff::Views::Admin::Dialogs::UserEditDialog < Guff::Views::Admin::Dialogs::UserDialog +require "./user" + +class Guff::Views::Admin::Dialogs::UserEdit < Guff::Views::Admin::Dialogs::User ECR.def_to_s("src/views/admin/dialogs/user-edit.ecr") end diff --git a/src/guff/views/admin/dialogs/user.cr b/src/guff/views/admin/dialogs/user.cr index 98a632e..4dea3cf 100644 --- a/src/guff/views/admin/dialogs/user.cr +++ b/src/guff/views/admin/dialogs/user.cr @@ -1,4 +1,4 @@ -class Guff::Views::Admin::Dialogs::UserDialog < Guff::Views::HTMLView +class Guff::Views::Admin::Dialogs::User < Guff::Views::HTMLView protected def role_options tmpl = Guff::Views::Admin::PageView::TEMPLATES[:option] diff --git a/src/guff/views/admin/page.cr b/src/guff/views/admin/page.cr index a61f52a..fe37ce5 100644 --- a/src/guff/views/admin/page.cr +++ b/src/guff/views/admin/page.cr @@ -150,19 +150,6 @@ class Guff::Views::Admin::PageView < Guff::Views::HTMLView TEMPLATES[:new_post_button] end - private def state_buttons - @state_buttons ||= String.build do |io| - @context.models.state.get_states.each do |row| - io << TEMPLATES[:state_button] % [ - h(row["name"]), - h(row["state"]), - h(row["icon"]), - h(row["name"]) - ] - end - end - end - private def authors_menu_items @context.models.user.get_users.map do |row| { @@ -194,31 +181,17 @@ class Guff::Views::Admin::PageView < Guff::Views::HTMLView end end - private def theme_options - [{ - "id" => "site-default", - "name" => "Site Default", - }].concat(@context.models.theme.all.map { |row| - { - "id" => row["theme_id"], - "name" => "%s (%s)" % %w{ - name - version - }.map { |k| row["theme_#{k}"] }, - } - }).map { |row| - TEMPLATES[:option] % %w{id name}.map { |k| row[k] } - }.join("") - end - private def page_data { post_types: POST_TYPES}.to_json end private def dialogs String.build do |io| - io << Dialogs::UserAddDialog.new(@context) - io << Dialogs::UserEditDialog.new(@context) + io << Dialogs::UserAdd.new(@context) + io << Dialogs::UserEdit.new(@context) + io << Dialogs::BlogEdit.new(@context) + io << Dialogs::PageEdit.new(@context) + io << Dialogs::ProjectEdit.new(@context) end end diff --git a/src/views/admin/dialogs/blog-edit.ecr b/src/views/admin/dialogs/blog-edit.ecr new file mode 100644 index 0000000..bbe946f --- /dev/null +++ b/src/views/admin/dialogs/blog-edit.ecr @@ -0,0 +1,166 @@ + diff --git a/src/views/admin/dialogs/page-edit.ecr b/src/views/admin/dialogs/page-edit.ecr new file mode 100644 index 0000000..c0b30e8 --- /dev/null +++ b/src/views/admin/dialogs/page-edit.ecr @@ -0,0 +1,175 @@ + diff --git a/src/views/admin/dialogs/project-edit.ecr b/src/views/admin/dialogs/project-edit.ecr new file mode 100644 index 0000000..59c89d4 --- /dev/null +++ b/src/views/admin/dialogs/project-edit.ecr @@ -0,0 +1,179 @@ + diff --git a/src/views/admin/page.ecr b/src/views/admin/page.ecr index c06b5f0..231b956 100644 --- a/src/views/admin/page.ecr +++ b/src/views/admin/page.ecr @@ -559,528 +559,6 @@ <%= dialogs %> - - - - - -- cgit v1.2.3