From 832adab4342c407db2b17e93eda60dcaaf4a97dd Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Wed, 27 Jul 2016 23:33:45 -0400 Subject: refactor post types so icons and names aren't in 3 places --- data/assets/js/admin/tabs/posts.js | 9 +---- src/guff/views/admin-page.cr | 79 +++++++++++++++++++++----------------- src/views/admin-page.ecr | 31 ++++++++------- 3 files changed, 60 insertions(+), 59 deletions(-) diff --git a/data/assets/js/admin/tabs/posts.js b/data/assets/js/admin/tabs/posts.js index 1cabc31..96d3a3c 100644 --- a/data/assets/js/admin/tabs/posts.js +++ b/data/assets/js/admin/tabs/posts.js @@ -85,12 +85,7 @@ jQuery(function($) { ], }); - var POST_TYPE_ICONS = { - blog: 'fa-sticky-note-o', - page: 'fa-bookmark-o', - project: 'fa-cube', - }; - + // FIXME: move this to DATA as well? var POST_STATES = { draft: { css: 'bg-warning', @@ -154,7 +149,7 @@ jQuery(function($) { return TEMPLATES.run('post', $.extend(row, { css: css, label: label, - icon: POST_TYPE_ICONS[row.post_type], + icon: DATA.post_types[row.post_type].icon, post_url: post_url, })); }).join('')); diff --git a/src/guff/views/admin-page.cr b/src/guff/views/admin-page.cr index 7761994..b9dc6f2 100644 --- a/src/guff/views/admin-page.cr +++ b/src/guff/views/admin-page.cr @@ -3,6 +3,26 @@ require "./html" class Guff::Views::AdminPageView < Guff::Views::HTMLView TITLE = "Guff Admin" + POST_TYPES = { + blog: { + id: "blog", + name: "Blog Post", + icon: "fa-sticky-note-o", + }, + + page: { + id: "page", + name: "Page", + icon: "fa-file-text-o", + }, + + project: { + id: "project", + name: "Project", + icon: "fa-cube", + }, + } + TABS = { "admin" => [{ :id => "home", @@ -69,6 +89,20 @@ class Guff::Views::AdminPageView < Guff::Views::HTMLView }], } + NEW_POST_MENU_ITEM = " +
  • + + + %s + +
  • + " + TEMPLATES = { :option => " @@ -86,42 +120,11 @@ class Guff::Views::AdminPageView < Guff::Views::HTMLView -