|
137 | 137 |
|
138 | 138 | <% unless @name.children.empty? %> |
139 | 139 | <dt><%= fa_icon('sort-amount-down-alt') %> Children |
140 | | - <span class="text-muted">(<%= @name.children.count %>)</span><dt> |
| 140 | + <span class="text-muted" id="name-<%= @name.id %>-children-count">(<%= |
| 141 | + @name.children.count %>)</span><dt> |
141 | 142 | <dd> |
142 | 143 | <% if @name.children.length >= 12 %> |
143 | 144 | <div id="name-<%= @name.id %>-children-filter"> |
144 | | - <% { validated: 'non-validly published', correct: 'incorrect' |
145 | | - }.each do |feat, txt| %> |
| 145 | + <% { |
| 146 | + validated: 'non-validly published', |
| 147 | + correct: 'validly published but incorrect' |
| 148 | + }.each do |feat, txt| %> |
146 | 149 | <%= link_to('#', |
147 | | - class: 'badge badge-pill badge-primary mr-2', |
| 150 | + class: 'badge badge-pill badge-primary mr-1', |
148 | 151 | data: { feat: feat, visible: true, name: @name.id } |
149 | 152 | ) do %> |
150 | | - <%= fa_icon('eye-slash') %> <span>Hide</span> <%= txt %> names |
| 153 | + <%= fa_icon('eye-slash', class: 'mr-2') %> |
| 154 | + <span>Hide</span> <%= txt %> names |
151 | 155 | <% end %> |
152 | 156 | <% end %> |
153 | 157 | </div> |
|
163 | 167 | ); |
164 | 168 | if (btn.data("visible")) { |
165 | 169 | children.hide(400); |
| 170 | + children.data("visible", false); |
166 | 171 | btn.data("visible", false); |
167 | 172 | btn.find("span").html("Show"); |
168 | 173 | btn.find("i").removeClass("fa-eye-slash"); |
169 | 174 | btn.find("i").addClass("fa-eye"); |
170 | 175 | } else { |
171 | 176 | children.show(400); |
| 177 | + children.data("visible", true); |
172 | 178 | btn.data("visible", true); |
173 | 179 | btn.find("span").html("Hide"); |
174 | 180 | btn.find("i").removeClass("fa-eye"); |
175 | 181 | btn.find("i").addClass("fa-eye-slash"); |
176 | 182 | } |
| 183 | + visible = $(`ul#name-${name_id}-children li[data-visible=true]`); |
| 184 | + $(`#name-${name_id}-children-count`).html(`(${visible.length})`); |
177 | 185 | return false; |
178 | 186 | }); |
179 | 187 | }); |
|
0 commit comments