From 6aaa8ee7916e82069755c4ceb16d08ae48aa84de Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 31 Jul 2016 02:56:44 -0400 Subject: refactor mock panels, enable panel add and remove --- src/guff/views/pages/admin.cr | 3 + src/guff/views/panes/admin/home.cr | 119 ++++++++++++++++--------------------- src/views/panes/admin/home.ecr | 57 ++++-------------- 3 files changed, 64 insertions(+), 115 deletions(-) (limited to 'src') diff --git a/src/guff/views/pages/admin.cr b/src/guff/views/pages/admin.cr index 7113fbc..0a1e62d 100644 --- a/src/guff/views/pages/admin.cr +++ b/src/guff/views/pages/admin.cr @@ -120,6 +120,9 @@ class Guff::Views::Pages::Admin < Guff::Views::HTMLView default_lang: default_lang, default_theme_id: default_theme_id, + # home panel template + panel_template: Guff::Views::Panel::TEMPLATE.string, + site_dialogs: { paths: { add: "site/add", diff --git a/src/guff/views/panes/admin/home.cr b/src/guff/views/panes/admin/home.cr index d7d1596..6010fd4 100644 --- a/src/guff/views/panes/admin/home.cr +++ b/src/guff/views/panes/admin/home.cr @@ -2,91 +2,50 @@ require "./pane" class Guff::Views::Panes::Admin::Home < Guff::Views::Panes::Admin::Pane TEMPLATES = Template::Cache.new({ - "col" => %{ + "cols-menu-item" => %{ }.strip, - "old-panel-edit" => %{ - - }.strip, - - "panel-edit" => %{ - - - + "add-menu-item" => %{ +
  • + + %{name|h} + +
  • }.strip, }) + ADD_MENU_ITEMS = [{ + "id" => "test-1", + "name" => "Test 1", + }, { + "id" => "test-2", + "name" => "Test 2", + }].map { |row| + TEMPLATES["add-menu-item"].run(row) + }.join + private def add_menu - # TODO - "" + ADD_MENU_ITEMS end private def cols_menu - t = TEMPLATES["col"] + t = TEMPLATES["cols-menu-item"] num_cols = 3 (1..4).map { |i| @@ -94,14 +53,36 @@ class Guff::Views::Panes::Admin::Home < Guff::Views::Panes::Admin::Pane "i" => i.to_s, "s" => (i == 1) ? "" : "s", "css" => (i == num_cols) ? "active" : "", + "col" => "col-md-%d" % [12 / i], }) }.join end - PANEL_EDIT = TEMPLATES["panel-edit"].run({} of String => String) + MOCK_PANELS = { + p1: { + id: "1", + type: "test", + name: "Some Panel", + body: "

    Some panel.

    ", + }, + + p2: { + id: "2", + type: "test", + name: "Another Panel", + body: "

    Another panel.

    ", + }, + + p3: { + id: "3", + type: "test", + name: "Third Panel", + body: "

    Third panel.

    ", + }, + } - private def panel_edit : String - PANEL_EDIT + private def mock_panel(id) + Guff::Views::Panel.make(**MOCK_PANELS[id]) end ECR.def_to_s("src/views/panes/admin/home.ecr") diff --git a/src/views/panes/admin/home.ecr b/src/views/panes/admin/home.ecr index df0c7ec..90b7feb 100644 --- a/src/views/panes/admin/home.ecr +++ b/src/views/panes/admin/home.ecr @@ -27,6 +27,8 @@ %> + <%= divider %> + -- cgit v1.2.3