From e47e83cf6bded3d1924b4d500193e7876833ef83 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 2 Jul 2017 13:03:43 -0400 Subject: Created admin panel Currently allows you to create and edit blogs, including associated records. Uses a WYSIWYG editor that allows uploading images. Also included jQuery :( --- app/views/admin/blogs/_form.html.haml | 23 +++++++++++++++++++++++ app/views/admin/blogs/edit.html.haml | 2 ++ app/views/admin/blogs/index.html.haml | 10 ++++++++++ app/views/admin/blogs/new.html.haml | 2 ++ 4 files changed, 37 insertions(+) create mode 100644 app/views/admin/blogs/_form.html.haml create mode 100644 app/views/admin/blogs/edit.html.haml create mode 100644 app/views/admin/blogs/index.html.haml create mode 100644 app/views/admin/blogs/new.html.haml (limited to 'app/views/admin/blogs') diff --git a/app/views/admin/blogs/_form.html.haml b/app/views/admin/blogs/_form.html.haml new file mode 100644 index 0000000..55a297a --- /dev/null +++ b/app/views/admin/blogs/_form.html.haml @@ -0,0 +1,23 @@ +- if f.object.errors.any? + %ul#errors + - f.object.errors.full_messages.each do |error| + %li= error +%fieldset#content + .title-field + = f.label :title + = f.text_field :title, placeholder: "Title" + .slug-field + = f.label :slug, "https://feffernoo.se/says/" + = f.text_field :slug, placeholder: "insert-slug-here" + .body-field + = f.label :body + = f.cktext_area :body +%fieldset#details + .details-module + = f.fields_for :records, Record.new do |builder| + .should-create-record-field + = builder.check_box :_destroy, {checked: false}, "0", "1" + = builder.label :_destroy, "Create record?" + .record-description-field + = builder.text_area :description, placeholder: "record text" + .details-module= f.submit diff --git a/app/views/admin/blogs/edit.html.haml b/app/views/admin/blogs/edit.html.haml new file mode 100644 index 0000000..3f4d412 --- /dev/null +++ b/app/views/admin/blogs/edit.html.haml @@ -0,0 +1,2 @@ += form_for @blog, url: admin_blog_url(@blog), html: { id: "blog-form" } do |f| + = render partial: "form", locals: { f: f } diff --git a/app/views/admin/blogs/index.html.haml b/app/views/admin/blogs/index.html.haml new file mode 100644 index 0000000..448617a --- /dev/null +++ b/app/views/admin/blogs/index.html.haml @@ -0,0 +1,10 @@ +%table#entries + %tr + %th Title + %th Date created + %th + - @blogs.each do |blog| + %tr{ class: cycle("even", "odd") } + %td= blog.title + %td= blog.created_at.strftime("%B %d, %Y, %l:%M%P") + %td= link_to "Edit", edit_admin_blog_url(blog) diff --git a/app/views/admin/blogs/new.html.haml b/app/views/admin/blogs/new.html.haml new file mode 100644 index 0000000..914f27b --- /dev/null +++ b/app/views/admin/blogs/new.html.haml @@ -0,0 +1,2 @@ += form_for @blog, url: admin_blogs_url, html: { id: "blog-form" } do |f| + = render partial: "form", locals: { f: f } -- cgit 1.4.1