Some fixes for tags: authorization, translation…

can_use now takes all the open_for into account
This commit is contained in:
chris 2013-10-18 11:38:30 +08:00
parent d2602a3a84
commit 68a379f8a4
9 changed files with 30 additions and 43 deletions

View File

@ -1,12 +1,6 @@
class Admin::CategoriesController < OrbitBackendController
# TODO = put back ========================
# before_filter :force_order_for_visitor, only: [:index]
# before_filter :force_order_for_user, except: [:index]
# before_filter :for_app_sub_manager, except: [:index]
# ========================================
before_filter :setup_vars
# ========================================
open_for_manager
def index
@categories = get_categories_for_index

View File

@ -2,12 +2,7 @@ class Admin::ItemsController < OrbitBackendController
layout "structure"
# TODO = put back ========================
# before_filter :authenticate_user!
# before_filter :find_parent_item
# before_filter :is_admin?
# before_filter :set_current_item
#=========================================
open_for_admin
def index
if params[:item_id]

View File

@ -1,13 +1,7 @@
class Admin::ModuleTagsController < OrbitBackendController
include OrbitTag::Merging
# TODO = put back ========================
# before_filter :force_order_for_visitor, only: [:index]
# before_filter :force_order_for_user, except: [:index]
# before_filter :for_app_sub_manager, except: [:index]
# ========================================
before_filter :setup_vars
# ========================================
open_for_manager
helper 'admin/tags'
@ -33,6 +27,7 @@ class Admin::ModuleTagsController < OrbitBackendController
redirect_to admin_module_tags_url(module_app_id: @module_app_id)
else
@tag = ModuleTag.new(params[:module_tag])
flash.now[:error] = t('create.error.tag')
render :action => "new"
end
end
@ -42,6 +37,7 @@ class Admin::ModuleTagsController < OrbitBackendController
if @tag.update_attributes(params[:module_tag])
redirect_to admin_module_tags_url(module_app_id: @module_app_id)
else
flash.now[:error] = t('update.error.tag')
render :action => "edit"
end
end

View File

@ -1,6 +1,8 @@
class Admin::TagsController < OrbitBackendController
include OrbitTag::Merging
open_for_manager
def index
@tags = @module_app.module_tags
@module_apps = ModuleApp.where(has_tag: true)

View File

@ -16,14 +16,14 @@
<div id="tags-list">
<p class="tag-lead lead muted"><i class="icons-tag"></i> <%= t(:default) %> <span class="badge pull-right"><%= @tags.count %></span></p>
<ul class="tags-groups checkbox-card default-tags">
<%= render partial: "module_tag", collection: @tags %>
<%= render partial: "tag", collection: @tags %>
</ul>
<% @module_apps.each do |module_app| %>
<% tags = module_app.module_tags %>
<% icon_name = get_module_app_icon(module_app) %>
<p class="tag-lead lead muted"><i class="<%= icon_name %>"></i> <%= module_app.title %> <span class="badge pull-right"><%= tags.count %></span></p>
<ul class="tags-groups checkbox-card module-tags">
<%= render partial: "module_tag", collection: tags, locals: {in_module: true} %>
<%= render partial: "tag", collection: tags, locals: {in_module: true} %>
</ul>
<% end %>
</div>

View File

@ -1,19 +0,0 @@
<li class="filter-item <%= module_tag.is_default ? 'default' : '' %>">
<% unless defined?(in_module) && module_tag.is_default %>
<p class="card pull-left">
<input type="checkbox">
</p>
<%= hidden_field_tag "ids[]", module_tag.id, class: "tag_id" %>
<% end %>
<% if defined?(in_module) && module_tag.is_default %>
<a>
<span class="amount"><%= get_tagging_count(module_tag) %></span>
<%= show_names_slash(module_tag) %>
</a>
<% else %>
<%= link_to edit_admin_tag_path(module_tag), class: "open-slide" do %>
<span class="amount"><%= get_tagging_count(module_tag) %></span>
<%= show_names_slash(module_tag) %>
<% end %>
<% end %>
</li>

View File

@ -0,0 +1,19 @@
<li class="filter-item <%= tag.is_default ? 'default' : '' %>">
<% unless defined?(in_module) && tag.is_default %>
<p class="card pull-left">
<input type="checkbox">
</p>
<%= hidden_field_tag "ids[]", tag.id, class: "tag_id" %>
<% end %>
<% if defined?(in_module) && tag.is_default %>
<a>
<span class="amount"><%= get_tagging_count(tag) %></span>
<%= show_names_slash(tag) %>
</a>
<% else %>
<%= link_to edit_admin_tag_path(tag), class: "open-slide", data: {title: t('editing.tag')} do %>
<span class="amount"><%= get_tagging_count(tag) %></span>
<%= show_names_slash(tag) %>
<% end %>
<% end %>
</li>

View File

@ -69,7 +69,7 @@ en:
remove_default: Are you sure you want to remove the default tags?
update:
error:
tag: Error when updating category
category: Error when updating category
tag: Error when updating tag
url_alt: Alternative text
use_default: Use Default

View File

@ -69,7 +69,7 @@ zh_tw:
remove_default: 您確定要移除此預設標籤嗎?
update:
error:
tag: 更新類別時發生錯誤
category: 更新類別時發生錯誤
tag: 更新標籤時發生錯誤
url_alt: 註解
use_default: Use Default