• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
Add toggle element and classes in output for day filter functionality.
Line 62: Line 62:  
_consumed_equip_category_template = "Category:Equipment that consume ${equip_name} during improvement",
 
_consumed_equip_category_template = "Category:Equipment that consume ${equip_name} during improvement",
 
_single_screw_improvement_category = "Category:Equipment that can be improved using only one improvement material",
 
_single_screw_improvement_category = "Category:Equipment that can be improved using only one improvement material",
 +
_detail_toggle = [[<div class="hidden multi-toggle" data-target="improvementtablekai-day" data-states='["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]' style="display: none;">]]
 +
.. '<span class="multi-toggle-button" data-state="false"><span class="multi-toggle-active">Filter by day:</span><span class="multi-toggle-inactive" style="cursor: pointer; color: #006cb0;">Show all</span></span>'
 +
.. ' <span class="multi-toggle-button" data-state="Sunday"><span class="multi-toggle-active" style="cursor: pointer; color: #006cb0; text-decoration: underline;">Sunday</span><span class="multi-toggle-inactive" style="cursor: pointer; color: #006cb0;">Sunday</span></span>'
 +
.. ' <span class="multi-toggle-button" data-state="Monday"><span class="multi-toggle-active" style="cursor: pointer; color: #006cb0; text-decoration: underline;">Monday</span><span class="multi-toggle-inactive" style="cursor: pointer; color: #006cb0;">Monday</span></span>'
 +
.. ' <span class="multi-toggle-button" data-state="Tuesday"><span class="multi-toggle-active" style="cursor: pointer; color: #006cb0; text-decoration: underline;">Tuesday</span><span class="multi-toggle-inactive" style="cursor: pointer; color: #006cb0;">Tuesday</span></span>'
 +
.. ' <span class="multi-toggle-button" data-state="Wednesday"><span class="multi-toggle-active" style="cursor: pointer; color: #006cb0; text-decoration: underline;">Wednesday</span><span class="multi-toggle-inactive" style="cursor: pointer; color: #006cb0;">Wednesday</span></span>'
 +
.. ' <span class="multi-toggle-button" data-state="Thursday"><span class="multi-toggle-active" style="cursor: pointer; color: #006cb0; text-decoration: underline;">Thursday</span><span class="multi-toggle-inactive" style="cursor: pointer; color: #006cb0;">Thursday</span></span>'
 +
.. ' <span class="multi-toggle-button" data-state="Friday"><span class="multi-toggle-active" style="cursor: pointer; color: #006cb0; text-decoration: underline;">Friday</span><span class="multi-toggle-inactive" style="cursor: pointer; color: #006cb0;">Friday</span></span>'
 +
.. ' <span class="multi-toggle-button" data-state="Saturday"><span class="multi-toggle-active" style="cursor: pointer; color: #006cb0; text-decoration: underline;">Saturday</span><span class="multi-toggle-inactive" style="cursor: pointer; color: #006cb0;">Saturday</span></span>'
 +
.. '</div>',
 +
_day_of_week_class_prefix = "multi-toggle-target-improvementtablekai-day-",
 
}
 
}
   Line 81: Line 92:  
}
 
}
 
else
 
else
self._custom_rows[item:name()] = format{self._name_custom_row_template,  
+
self._custom_rows[item:name()] = {content = format{self._name_custom_row_template,  
 
icon = Formatting:format_image{Formatting:format_equipment_icon(item:icon())},  
 
icon = Formatting:format_image{Formatting:format_equipment_icon(item:icon())},  
 
name = Formatting:format_link(item:link()),  
 
name = Formatting:format_link(item:link()),  
 
resources = Formatting:format_resources(item:improvement_resources() or {devmat = false, screw = false}),  
 
resources = Formatting:format_resources(item:improvement_resources() or {devmat = false, screw = false}),  
 
edit_link = edit_link,
 
edit_link = edit_link,
}
+
}, row = {}}
 
table.insert(result, item:name())
 
table.insert(result, item:name())
 
end
 
end
Line 168: Line 179:     
for _, stars in ipairs(item:improvement_brackets(product)) do
 
for _, stars in ipairs(item:improvement_brackets(product)) do
table.insert(result, {item = item, product = product, stars = stars, ships = ships, ship_data = ship_data, ship_names = ship_names, initials = initials, availability = availability, resources = item:improvement_resources(false, product, stars), resources_x = item:improvement_resources(true, product, stars)})
+
table.insert(result, {item = item, classes = {}, product = product, stars = stars, ships = ships, ship_data = ship_data, ship_names = ship_names, initials = initials, availability = availability, resources = item:improvement_resources(false, product, stars), resources_x = item:improvement_resources(true, product, stars)})
 
end
 
end
 
end
 
end
 
else
 
else
table.insert(result, {item = item, stars = nil})
+
table.insert(result, {item = item, classes = {}})
 
end
 
end
 
else
 
else
Line 362: Line 373:  
end
 
end
 
end
 
end
 +
local day_of_week_class = self._day_of_week_class_prefix .. day
 
if not available then
 
if not available then
 
bg_color = self._unavailable_color
 
bg_color = self._unavailable_color
 +
else
 +
table.insert(row_data.classes, day_of_week_class)
 
end
 
end
return {values = {value = available and table.concat(availability, "<br />") or "✗"}, bg_color = bg_color, text_align = self._center_align}
+
--values.ships is not displayed in the table (cell template string doesn't ask for ships).
 +
--It is included in order to keep availability cells from merging when helper ships cells were split.
 +
--This was only observed to occur when no ship had availability for a certain day across multiple improvement paths.
 +
return {values = {value = available and table.concat(availability, "<br />") or "✗", ships = row_data.ships}, classes = day_of_week_class, bg_color = bg_color, text_align = self._center_align}
 
end
 
end
   Line 386: Line 403:  
end
 
end
 
return {values = {value = table.concat(ships, "<br />")}, bg_color = self._transparent, text_align = self._center_align}
 
return {values = {value = table.concat(ships, "<br />")}, bg_color = self._transparent, text_align = self._center_align}
 +
end
 +
 +
function ImprovementTableKai:row(row_data)
 +
return {classes = table.concat(row_data.classes, " ")}
 
end
 
end
   Line 392: Line 413:  
self._rows = {self._table_start, self._title_row, self._header}
 
self._rows = {self._table_start, self._title_row, self._header}
 
elseif #self._data_rows > 0 and type(self._data_rows[1]) ~= "table" then
 
elseif #self._data_rows > 0 and type(self._data_rows[1]) ~= "table" then
self._rows = {self._table_start}
+
self._rows = {self._detail_toggle, self._table_start}
 
else
 
else
 
self._rows = {self._table_start, self._header}
 
self._rows = {self._table_start, self._header}
Anonymous user

Navigation menu