diff --git a/Gemfile b/Gemfile index 28b7e61..87cca0a 100644 --- a/Gemfile +++ b/Gemfile @@ -34,9 +34,6 @@ gem "mini_magick", github: 'minimagick/minimagick' gem 'carrierwave' gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid' -# Form helper -gem 'dynamic_form' - gem 'kaminari' gem "impressionist" gem "chartkick" diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb index df7aa3d..09ff234 100644 --- a/app/controllers/admin/categories_controller.rb +++ b/app/controllers/admin/categories_controller.rb @@ -2,6 +2,7 @@ class Admin::CategoriesController < OrbitAdminController before_action :setup_vars def index + @category = Category.new unless @module_app.nil? @categories = @module_app.categories end diff --git a/app/models/category.rb b/app/models/category.rb index 86211bb..3369de7 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -10,6 +10,8 @@ class Category scope :enabled, ->{ where(:disable.in => [false, nil, ''])} + validates :title, presence: true + def category_sub_managers Authorization.category_authorized_users(self).pluck(:user_id) end diff --git a/app/models/tag.rb b/app/models/tag.rb index cc19bcf..802ef7f 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -8,6 +8,8 @@ class Tag has_many :taggings, dependent: :destroy has_and_belongs_to_many :module_app + validates :name, presence: true + def show_names_slash span_names = [] Site.first.in_use_locales.each do |locale| diff --git a/app/views/admin/categories/index.html.erb b/app/views/admin/categories/index.html.erb index 6033517..d583e88 100644 --- a/app/views/admin/categories/index.html.erb +++ b/app/views/admin/categories/index.html.erb @@ -16,8 +16,13 @@
<%= f.fields_for :title_translations do |f| %> <% @site_in_use_locales.each do |locale| %> - <%= label_tag "name-#{locale}", "#{t(:name)} (#{t(locale)})" %> - <%= f.text_field locale, :class => 'input-large', :value => (@category.title_translations[locale] rescue ''), placeholder: t(:name), id: locale %> +
+ +
+ + <%= t('front_page.name_field_helper') %> +
+
<% end %> <% end %> <%= label_tag "disable" do %> @@ -26,11 +31,44 @@ <% end %>
<%= t(:cancel) %> - <%= f.submit t(:submit), class: 'btn btn-primary btn-small' %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "category_submit" %>
<% end %> - \ No newline at end of file + + \ No newline at end of file diff --git a/app/views/admin/tags/_form.html.erb b/app/views/admin/tags/_form.html.erb index 0e18fec..20654e3 100644 --- a/app/views/admin/tags/_form.html.erb +++ b/app/views/admin/tags/_form.html.erb @@ -3,7 +3,12 @@ <%= f.fields_for :name_translations do |f| %> <% @site_in_use_locales.each do |locale| %> - <%= f.label :locale, "#{t(:name)} #{t(locale)}" %> - <%= f.text_field locale, class: 'input-large', placeholder: "#{t(:name)} #{t(locale)}", value: (@tag.name_translations[locale] rescue nil), id: locale %> +
+ +
+ + <%= t('front_page.name_field_helper') %> +
+
<% end %> <% end %> diff --git a/app/views/admin/tags/index.html.erb b/app/views/admin/tags/index.html.erb index 8064504..d0c2e66 100644 --- a/app/views/admin/tags/index.html.erb +++ b/app/views/admin/tags/index.html.erb @@ -38,7 +38,7 @@ <%= render :partial => "form", :locals => { :f => f } %>
<%= t(:cancel) %> - <%= f.submit t(:submit), class: 'btn btn-primary btn-small' %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %>
<% end %> @@ -78,4 +78,38 @@ + + \ No newline at end of file diff --git a/app/views/shared/_filter.html.erb b/app/views/shared/_filter.html.erb index 49ae812..1c24faf 100644 --- a/app/views/shared/_filter.html.erb +++ b/app/views/shared/_filter.html.erb @@ -13,7 +13,7 @@
<% fields[field].each do |val| %> - <%= link_to t(val[:title]), "#", :onclick => "filter.addFilter('filters[#{field}][]=#{val[:id]}')", :class => "btn btn-small #{is_filter_active?(field, val[:id])}" %> + <%= link_to (val[:title].blank? ? "" : t(val[:title])), "#", :onclick => "filter.addFilter('filters[#{field}][]=#{val[:id]}')", :class => "btn btn-small #{is_filter_active?(field, val[:id])}" %> <% end %>