Change feed form style.

This commit is contained in:
BoHung Chiu 2021-06-03 11:17:26 +08:00
parent f34be54da0
commit cf8e48bc1b
4 changed files with 35 additions and 26 deletions

View File

@ -470,7 +470,14 @@ class Admin::AnnouncementsController < OrbitAdminController
end end
def feed_params def feed_params
params.require(:bulletin_feed).permit! feed_params = params.require(:bulletin_feed).permit!
if feed_params[:tag_ids].nil?
feed_params[:tag_ids] = []
end
if feed_params[:category_ids].nil?
feed_params[:category_ids] = []
end
feed_params
end end
def settings_params def settings_params

View File

@ -14,45 +14,45 @@
<div class="tags"> <div class="tags">
<h4><%=t(:tags)%></h4> <h4><%=t(:tags)%></h4>
<div id="tags-list"> <div id="tags-list">
<ul class="tags-groups checkbox-card module-tags"> <div class="tags-groups checkbox-card module-tags">
<% @module_app.tags.each do |tag| %> <% @module_app.tags.each do |tag| %>
<li class="filter-item module"> <label class="filter-item module <%= @announcement_feed.tag_ids.include?(tag.id.to_s) ? "active" : "" %>">
<p class='card pull-left <%= @announcement_feed.tag_ids.include?(tag.id.to_s) ? "active" : "" %>'> <p class='card pull-left <%= @announcement_feed.tag_ids.include?(tag.id.to_s) ? "active" : "" %>'>
<input type="checkbox" <%= @announcement_feed.tag_ids.include?(tag.id.to_s) ? "checked=checked" : "" %> class="tag-checkbox" value="<%= tag.id.to_s %>" name="bulletin_feed[tag_ids][]"> <input type="checkbox" <%= @announcement_feed.tag_ids.include?(tag.id.to_s) ? "checked=checked" : "" %> class="tag-checkbox" value="<%= tag.id.to_s %>" name="bulletin_feed[tag_ids][]">
</p> </p>
<a href="#" onclick="return false;"> <div>
<% @site_in_use_locales.each_with_index do |locale,index| %> <% @site_in_use_locales.each_with_index do |locale,index| %>
<span class="tag"><%= tag.name_translations[locale] %></span> <span class="tag"><%= tag.name_translations[locale] %></span>
<% if index < (@site_in_use_locales.count - 1) %> <% if index < (@site_in_use_locales.count - 1) %>
/ /
<% end %> <% end %>
<% end %> <% end %>
</a> </div>
</li> </label>
<% end %> <% end %>
</ul> </div>
</div> </div>
</div> </div>
<div class="categories"> <div class="categories">
<h4><%=t(:category)%></h4> <h4><%=t(:category)%></h4>
<div id="categories-list"> <div id="categories-list">
<ul class="tags-groups checkbox-card module-categories"> <div class="tags-groups checkbox-card module-categories">
<% @module_app.categories.each do |category| %> <% @module_app.categories.each do |category| %>
<li class="filter-item module"> <label class="filter-item module <%= @announcement_feed.category_ids.include?(category.id.to_s) ? "active" : "" %>">
<p class="card pull-left <%= @announcement_feed.category_ids.include?(category.id.to_s) ? "active" : "" %>"> <p class="card pull-left <%= @announcement_feed.category_ids.include?(category.id.to_s) ? "active" : "" %>">
<input type="checkbox" class="tag-checkbox" <%= @announcement_feed.category_ids.include?(category.id.to_s) ? "checked=checked" : "" %> value="<%= category.id.to_s %>" name="bulletin_feed[category_ids][]"> <input type="checkbox" class="tag-checkbox" <%= @announcement_feed.category_ids.include?(category.id.to_s) ? "checked=checked" : "" %> value="<%= category.id.to_s %>" name="bulletin_feed[category_ids][]">
</p> </p>
<a href="#" onclick="return false;"> <div>
<% @site_in_use_locales.each_with_index do |locale,index| %> <% @site_in_use_locales.each_with_index do |locale,index| %>
<span class="tag"><%= category.title_translations[locale] %></span> <span class="tag"><%= category.title_translations[locale] %></span>
<% if index < (@site_in_use_locales.count - 1) %> <% if index < (@site_in_use_locales.count - 1) %>
/ /
<% end %> <% end %>
<% end %> <% end %>
</a> </div>
</li> </label>
<% end %> <% end %>
</ul> </div>
</div> </div>
</div> </div>
</fieldset> </fieldset>

View File

@ -14,45 +14,45 @@
<div class="tags"> <div class="tags">
<h4><%=t(:tags)%></h4> <h4><%=t(:tags)%></h4>
<div id="tags-list"> <div id="tags-list">
<ul class="tags-groups checkbox-card module-tags"> <div class="tags-groups checkbox-card module-tags">
<% @module_app.tags.each do |tag| %> <% @module_app.tags.each do |tag| %>
<li class="filter-item module"> <label class="filter-item module">
<p class="card pull-left"> <p class="card pull-left">
<input type="checkbox" class="tag-checkbox" value="<%= tag.id.to_s %>" name="bulletin_feed[tag_ids][]"> <input type="checkbox" class="tag-checkbox" value="<%= tag.id.to_s %>" name="bulletin_feed[tag_ids][]">
</p> </p>
<a href="#" onclick="return false;"> <div>
<% @site_in_use_locales.each_with_index do |locale,index| %> <% @site_in_use_locales.each_with_index do |locale,index| %>
<span class="tag"><%= tag.name_translations[locale] %></span> <span class="tag"><%= tag.name_translations[locale] %></span>
<% if index < (@site_in_use_locales.count - 1) %> <% if index < (@site_in_use_locales.count - 1) %>
/ /
<% end %> <% end %>
<% end %> <% end %>
</a> </div>
</li> </label>
<% end %> <% end %>
</ul> </div>
</div> </div>
</div> </div>
<div class="categories"> <div class="categories">
<h4><%=t(:category)%></h4> <h4><%=t(:category)%></h4>
<div id="categories-list"> <div id="categories-list">
<ul class="tags-groups checkbox-card module-categories"> <div class="tags-groups checkbox-card module-categories">
<% @module_app.categories.each do |category| %> <% @module_app.categories.each do |category| %>
<li class="filter-item module"> <label class="filter-item module">
<p class="card pull-left"> <p class="card pull-left">
<input type="checkbox" class="tag-checkbox" value="<%= category.id.to_s %>" name="bulletin_feed[category_ids][]"> <input type="checkbox" class="tag-checkbox" value="<%= category.id.to_s %>" name="bulletin_feed[category_ids][]">
</p> </p>
<a href="#" onclick="return false;"> <div>
<% @site_in_use_locales.each_with_index do |locale,index| %> <% @site_in_use_locales.each_with_index do |locale,index| %>
<span class="tag"><%= category.title_translations[locale] %></span> <span class="tag"><%= category.title_translations[locale] %></span>
<% if index < (@site_in_use_locales.count - 1) %> <% if index < (@site_in_use_locales.count - 1) %>
/ /
<% end %> <% end %>
<% end %> <% end %>
</a> </div>
</li> </label>
<% end %> <% end %>
</ul> </div>
</div> </div>
</div> </div>
</fieldset> </fieldset>

View File

@ -91,8 +91,10 @@
$(".tag-checkbox").on("click",function(){ $(".tag-checkbox").on("click",function(){
if($(this).is(":checked")){ if($(this).is(":checked")){
$(this).parent().addClass("active"); $(this).parent().addClass("active");
$(this).parent().parent().addClass("active");
}else{ }else{
$(this).parent().removeClass("active"); $(this).parent().removeClass("active");
$(this).parent().parent().removeClass("active");
} }
}) })