Clean up & expand button color choices

This commit is contained in:
jeremystretch 2021-12-29 20:28:12 -05:00
parent ae3c871438
commit 9f53497e39
3 changed files with 30 additions and 40 deletions

View File

@ -1,4 +1,4 @@
from utilities.choices import ChoiceSet
from utilities.choices import ButtonColorChoices, ChoiceSet
#
@ -47,36 +47,13 @@ class CustomFieldFilterLogicChoices(ChoiceSet):
# CustomLinks
#
class CustomLinkButtonClassChoices(ChoiceSet):
class CustomLinkButtonClassChoices(ButtonColorChoices):
CLASS_DEFAULT = 'outline-dark'
CLASS_LINK = 'ghost-dark'
CLASS_BLUE = 'blue'
CLASS_INDIGO = 'indigo'
CLASS_PURPLE = 'purple'
CLASS_PINK = 'pink'
CLASS_RED = 'red'
CLASS_ORANGE = 'orange'
CLASS_YELLOW = 'yellow'
CLASS_GREEN = 'green'
CLASS_TEAL = 'teal'
CLASS_CYAN = 'cyan'
CLASS_GRAY = 'secondary'
LINK = 'ghost-dark'
CHOICES = (
(CLASS_DEFAULT, 'Default'),
(CLASS_LINK, 'Link'),
(CLASS_BLUE, 'Blue'),
(CLASS_INDIGO, 'Indigo'),
(CLASS_PURPLE, 'Purple'),
(CLASS_PINK, 'Pink'),
(CLASS_RED, 'Red'),
(CLASS_ORANGE, 'Orange'),
(CLASS_YELLOW, 'Yellow'),
(CLASS_GREEN, 'Green'),
(CLASS_TEAL, 'Teal'),
(CLASS_CYAN, 'Cyan'),
(CLASS_GRAY, 'Gray'),
*ButtonColorChoices.CHOICES,
(LINK, 'Link'),
)
#

View File

@ -212,7 +212,7 @@ class CustomLink(ChangeLoggedModel):
button_class = models.CharField(
max_length=30,
choices=CustomLinkButtonClassChoices,
default=CustomLinkButtonClassChoices.CLASS_DEFAULT,
default=CustomLinkButtonClassChoices.DEFAULT,
help_text="The class of the first link in a group will be used for the dropdown button"
)
new_window = models.BooleanField(

View File

@ -161,21 +161,34 @@ class ButtonColorChoices(ChoiceSet):
Map standard button color choices to Bootstrap 3 button classes
"""
DEFAULT = 'outline-dark'
BLUE = 'primary'
CYAN = 'info'
GREEN = 'success'
RED = 'danger'
YELLOW = 'warning'
GREY = 'secondary'
BLACK = 'dark'
BLUE = 'blue'
INDIGO = 'indigo'
PURPLE = 'purple'
PINK = 'pink'
RED = 'red'
ORANGE = 'orange'
YELLOW = 'yellow'
GREEN = 'green'
TEAL = 'teal'
CYAN = 'cyan'
GRAY = 'gray'
GREY = 'gray' # Backward compatability for <3.2
BLACK = 'black'
WHITE = 'white'
CHOICES = (
(DEFAULT, 'Default'),
(BLUE, 'Blue'),
(CYAN, 'Cyan'),
(GREEN, 'Green'),
(INDIGO, 'Indigo'),
(PURPLE, 'Purple'),
(PINK, 'Pink'),
(RED, 'Red'),
(ORANGE, 'Orange'),
(YELLOW, 'Yellow'),
(GREY, 'Grey'),
(BLACK, 'Black')
(GREEN, 'Green'),
(TEAL, 'Teal'),
(CYAN, 'Cyan'),
(GRAY, 'Gray'),
(BLACK, 'Black'),
(WHITE, 'White'),
)