Different colors for new tracks, types and levels

Every time a new track, event type or difficulty level is created, the color picker has a different color by default.

Closes https://github.com/openSUSE/osem/issues/1077
This commit is contained in:
Ana 2016-07-02 21:37:16 +02:00
parent 798998b73f
commit 0deaf1abc7
8 changed files with 21 additions and 3 deletions

View file

@ -595,6 +595,20 @@ class Conference < ActiveRecord::Base
registration_limit > 0 && registrations.count >= registration_limit
end
# Returns an hexadecimal color given a collection. The returned color changed
# when the number of element in the collection changes and for consecutive
# number of elements it returns highly different colors.
def next_color_for_collection(collection)
# we have different start indices for every collection to generate a
# different color for every of them.
start_index = {
tracks: (program.tracks.count + 1),
levels: (program.difficulty_levels.count + 51),
types: (program.event_types.count + 101)
}
next_color(start_index[collection])
end
private
# Returns a different html colour for every i and consecutive colors are