Просмотр исходного кода

Fixes #2619 - KB header and footer link-color not changeable

Mantas 3 лет назад
Родитель
Сommit
1404f7b2fc

+ 4 - 2
app/assets/javascripts/app/controllers/knowledge_base/public_menu_manager.coffee

@@ -27,11 +27,13 @@ class App.KnowledgeBasePublicMenuManager extends App.Controller
       {
         headline: 'Header menu',
         identifier: 'header',
-        color:      kb.color_header
+        color:      kb.color_header,
+        color_link: kb.color_header_link
       },
       {
         headline: 'Footer menu',
-        identifier: 'footer'
+        identifier: 'footer',
+        color_link: 'hsl(207,12%,50%)'
       }
     ]
 

+ 12 - 1
app/assets/javascripts/app/models/knowledge_base.coffee

@@ -1,5 +1,5 @@
 class App.KnowledgeBase extends App.Model
-  @configure 'KnowledgeBase', 'iconset', 'color_highlight', 'color_header', 'translation_ids', 'locale_ids', 'homepage_layout', 'category_layout', 'custom_address'
+  @configure 'KnowledgeBase', 'iconset', 'color_highlight', 'color_header', 'color_header_link', 'translation_ids', 'locale_ids', 'homepage_layout', 'category_layout', 'custom_address'
   @extend Spine.Model.Ajax
   @extend App.KnowledgeBaseActions
   @url: @apiPath + '/knowledge_bases'
@@ -148,6 +148,17 @@ class App.KnowledgeBase extends App.Model
           display:    false
           horizontal: true
           shown:      true
+    }, {
+      name: 'color_header_link'
+      display: 'Header Link Color'
+      tag: 'color'
+      style: 'block'
+      null: false
+      screen:
+        admin_style_color_header_link:
+          display:    false
+          horizontal: true
+          shown:      true
     # Layout picker is disabled in V1
     #}, {
     #  name:     'homepage_layout'

+ 6 - 5
app/assets/javascripts/app/views/knowledge_base/new_modal.coffee

@@ -26,11 +26,12 @@ class App.KnowledgeBaseNewModal extends App.ControllerModal
       App.UiElement[attribute.tag].prepareParams?(attribute, dom, params)
 
   applyDefaults: (params) ->
-    params['iconset']         = 'FontAwesome'
-    params['color_highlight'] = '#38ae6a'
-    params['color_header']    = '#f9fafb'
-    params['homepage_layout'] = 'grid'
-    params['category_layout'] = 'grid'
+    params['iconset']           = 'FontAwesome'
+    params['color_highlight']   = '#38ae6a'
+    params['color_header']      = '#f9fafb'
+    params['color_header_link'] = 'hsl(206,8%,50%)'
+    params['homepage_layout']   = 'grid'
+    params['category_layout']   = 'grid'
 
   onSubmit: (e) ->
     params = @formParams(@el)

+ 1 - 1
app/assets/javascripts/app/views/knowledge_base/public_menu_manager.jst.eco

@@ -14,7 +14,7 @@
       <div class="kb-menu-preview">
         <div class="label"><%= kb_locale.systemLocale().name %></div>
 
-        <div class="kb-menu-preview-container kb-menu-preview-container--<%= location.identifier %>" style="background-color: <%= location.color %>">
+        <div class="kb-menu-preview-container kb-menu-preview-container--<%= location.identifier %>" style="background-color: <%= location.color %>; color: <%= location.color_link %>;">
           <% menu_items = App.KnowledgeBaseMenuItem.using_kb_locale_location(kb_locale, location.identifier) %>
 
           <% if menu_items.length == 0: %>

+ 1 - 1
app/assets/stylesheets/zammad.scss

@@ -2661,7 +2661,7 @@ input.has-error {
   }
 
   a {
-    color: hsl(206,8%,50%);
+    color: inherit;
   }
 
   .label {

+ 3 - 2
app/models/knowledge_base.rb

@@ -27,8 +27,9 @@ class KnowledgeBase < ApplicationModel
   validates :category_layout, inclusion: { in: KnowledgeBase::LAYOUTS }
   validates :homepage_layout, inclusion: { in: KnowledgeBase::LAYOUTS }
 
-  validates :color_highlight, presence: true, color: true
-  validates :color_header,    presence: true, color: true
+  validates :color_highlight,   presence: true, color: true
+  validates :color_header,      presence: true, color: true
+  validates :color_header_link, presence: true, color: true
 
   validates :iconset, inclusion: { in: KnowledgeBase::ICONSETS }
 

+ 4 - 0
app/views/knowledge_base/public/_inline_stylesheet.html.erb

@@ -28,4 +28,8 @@
 	.header {
     background-color: <%= knowledge_base.color_header %>;
 	}
+
+  .header .menu-item {
+    color: <%= knowledge_base.color_header_link %>;
+  }
 </style>

+ 3 - 2
db/migrate/20190531180304_initialize_knowledge_base.rb

@@ -8,8 +8,9 @@ class InitializeKnowledgeBase < ActiveRecord::Migration[5.0]
     create_table :knowledge_bases do |t|
       t.string :iconset, limit: 30, null: false
 
-      t.string :color_highlight, limit: 25, null: false
-      t.string :color_header,    limit: 25, null: false
+      t.string :color_highlight,   limit: 25, null: false
+      t.string :color_header,      limit: 25, null: false
+      t.string :color_header_link, limit: 25, null: false
 
       t.string :homepage_layout, null: false
       t.string :category_layout, null: false

+ 11 - 0
db/migrate/20210923172256_issue_2619_kb_header_link_color.rb

@@ -0,0 +1,11 @@
+# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
+
+class Issue2619KbHeaderLinkColor < ActiveRecord::Migration[6.0]
+  def up
+    return if !Setting.exists?(name: 'system_init_done')
+
+    add_column :knowledge_bases, :color_header_link, :string, limit: 25, null: false, default: 'hsl(206,8%,50%)'
+    change_column_default :knowledge_bases, :color_header_link, nil
+    KnowledgeBasis.reset_column_information
+  end
+end

+ 1 - 0
spec/factories/knowledge_base.rb

@@ -8,6 +8,7 @@ FactoryBot.define do
     iconset         { 'FontAwesome' }
     color_highlight { '#AAA' }
     color_header    { '#EEE' }
+    color_header_link { '#FFF000' }
     homepage_layout { 'grid' }
     category_layout { 'list' }
 

Некоторые файлы не были показаны из-за большого количества измененных файлов