Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
f565c439
Commit
f565c439
authored
May 24, 2017
by
winh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide default for calculating label text color (!11681)
parent
e63d27d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+2
-3
app/models/label.rb
app/models/label.rb
+4
-0
No files found.
app/helpers/labels_helper.rb
View file @
f565c439
...
@@ -69,13 +69,12 @@ module LabelsHelper
...
@@ -69,13 +69,12 @@ module LabelsHelper
end
end
def
render_colored_label
(
label
,
label_suffix
=
''
,
tooltip:
true
)
def
render_colored_label
(
label
,
label_suffix
=
''
,
tooltip:
true
)
label_color
=
label
.
color
||
Label
::
DEFAULT_COLOR
text_color
=
text_color_for_bg
(
label
.
color
)
text_color
=
text_color_for_bg
(
label_color
)
# Intentionally not using content_tag here so that this method can be called
# Intentionally not using content_tag here so that this method can be called
# by LabelReferenceFilter
# by LabelReferenceFilter
span
=
%(<span class="label color-label #{"has-tooltip" if tooltip}" )
+
span
=
%(<span class="label color-label #{"has-tooltip" if tooltip}" )
+
%(style="background-color: #{label
_
color}; color: #{text_color}" )
+
%(style="background-color: #{label
.
color}; color: #{text_color}" )
+
%(title="#{escape_once(label.description)}" data-container="body">)
+
%(title="#{escape_once(label.description)}" data-container="body">)
+
%(#{escape_once(label.name)}#{label_suffix}</span>)
%(#{escape_once(label.name)}#{label_suffix}</span>)
...
...
app/models/label.rb
View file @
f565c439
...
@@ -133,6 +133,10 @@ class Label < ActiveRecord::Base
...
@@ -133,6 +133,10 @@ class Label < ActiveRecord::Base
template
template
end
end
def
color
super
||
DEFAULT_COLOR
end
def
text_color
def
text_color
LabelsHelper
.
text_color_for_bg
(
self
.
color
)
LabelsHelper
.
text_color_for_bg
(
self
.
color
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment