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 class Admin::CategoriesController < OrbitBackendController
# TODO = put back ======================== open_for_manager
# 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
# ========================================
def index def index
@categories = get_categories_for_index @categories = get_categories_for_index

View File

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

View File

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

View File

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

View File

@ -16,14 +16,14 @@
<div id="tags-list"> <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> <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"> <ul class="tags-groups checkbox-card default-tags">
<%= render partial: "module_tag", collection: @tags %> <%= render partial: "tag", collection: @tags %>
</ul> </ul>
<% @module_apps.each do |module_app| %> <% @module_apps.each do |module_app| %>
<% tags = module_app.module_tags %> <% tags = module_app.module_tags %>
<% icon_name = get_module_app_icon(module_app) %> <% 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> <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"> <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> </ul>
<% end %> <% end %>
</div> </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? remove_default: Are you sure you want to remove the default tags?
update: update:
error: error:
tag: Error when updating category category: Error when updating category
tag: Error when updating tag tag: Error when updating tag
url_alt: Alternative text url_alt: Alternative text
use_default: Use Default use_default: Use Default

View File

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