Allow addding to Category
This commit is contained in:
parent
b51e10eb9d
commit
3f87914e46
|
@ -9,7 +9,6 @@ class Panel::Dictionary::BackEnd::DictionaryVocabCategorysController < OrbitBack
|
|||
|
||||
def index
|
||||
@dictionary_vocab_categorys = get_categories_for_index("DictionaryVocabCategory")
|
||||
# @archive_file_categorys = ArchiveFileCategory.all
|
||||
@dictionary_vocab_category = DictionaryVocabCategory.new(:display => 'List')
|
||||
|
||||
@url = panel_dictionary_back_end_dictionary_vocab_categorys_path
|
||||
|
@ -19,4 +18,127 @@ class Panel::Dictionary::BackEnd::DictionaryVocabCategorysController < OrbitBack
|
|||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@dictionary_vocab_category = DictionaryVocabCategory.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# GET /dictionary_vocabs/new
|
||||
# GET /dictionary_vocabs/new.xml
|
||||
def new
|
||||
@dictionary_vocab_category = DictionaryVocabCategory.new(:display => 'List')
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# GET /dictionary_vocabs/1/edit
|
||||
def edit
|
||||
@dictionary_vocab_category = DictionaryVocabCategory.find(params[:id])
|
||||
|
||||
@url = panel_dictionary_back_end_dictionary_vocab_category_path(@dictionary_vocab_category)
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# POST /dictionary_vocabs
|
||||
# POST /dictionary_vocabs.xml
|
||||
def create
|
||||
@dictionary_vocab_category = DictionaryVocabCategory.new(params[:dictionary_vocab_category])
|
||||
|
||||
respond_to do |format|
|
||||
if @dictionary_vocab_category.save
|
||||
format.html { redirect_to(panel_dictionary_back_end_dictionary_vocab_categorys_url, :notice => t('dictionary_vocab_category.create_dictionary_vocab_category_success')) }
|
||||
format.js
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render action: "new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /dictionary_vocabs/1
|
||||
# PUT /dictionary_vocabs/1.xml
|
||||
def update
|
||||
@dictionary_vocab_category = DictionaryVocabCategory.find(params[:id])
|
||||
|
||||
@url = panel_archive_back_end_dictionary_vocab_category_path(@dictionary_vocab_category)
|
||||
|
||||
respond_to do |format|
|
||||
if @dictionary_vocab_category.update_attributes(params[:dictionary_vocab_category])
|
||||
format.html { redirect_to(panel_archive_back_end_dictionary_vocab_categorys_url, :notice => t('dictionary_vocab_category.update_dictionary_vocab_category_success')) }
|
||||
# format.xml { head :ok }
|
||||
format.js
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.js { render :action => "edit" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /dictionary_vocabs/1
|
||||
# DELETE /dictionary_vocabs/1.xml
|
||||
def destroy
|
||||
@dictionary_vocab_category = DictionaryVocabCategory.find(params[:id])
|
||||
@dictionary_vocab_category.disable = @dictionary_vocab_category.disable ? false : true
|
||||
|
||||
if @dictionary_vocab_category.save!
|
||||
respond_to do |format|
|
||||
flash[:notice] = t("update.success_")
|
||||
# flash[:error] += @dictionary_vocab_category.disable ? t(:enable) : t(disable)
|
||||
format.html { redirect_to(panel_archive_back_end_dictionary_vocab_categorys_url) }
|
||||
# format.xml { head :ok }
|
||||
format.js
|
||||
end
|
||||
else
|
||||
flash[:error] = t("update.fail")
|
||||
format.html { render :action => "index" }
|
||||
end
|
||||
end
|
||||
|
||||
def get_categorys_json
|
||||
categorys = DictionaryVocabCategory.all
|
||||
data = Array.new
|
||||
|
||||
categorys.each do |c|
|
||||
data << {
|
||||
category: c.title,
|
||||
link: "#{url_for( :action => "index",
|
||||
:controller => "panel/dictionary/front_end/dictionary_vocabs",
|
||||
:format => :rss,
|
||||
:only_path => false,
|
||||
:inner=>true,
|
||||
:category_id => c )}"
|
||||
}
|
||||
end
|
||||
|
||||
render :json => JSON.pretty_generate(data)
|
||||
end
|
||||
|
||||
def get_dictionary_vocabs_json
|
||||
dictionary_vocab = DictionaryVocabCategory.find(params[:dictionary_vocab_category_id]).dictionary_vocabs
|
||||
p dictionary_vocab
|
||||
data = Array.new
|
||||
|
||||
dictionary_vocab.each do |b|
|
||||
|
||||
data << {
|
||||
title: b.title,
|
||||
link: "http://#{request.host_with_port}#{panel_dictionary_front_end_dictionary_vocab_path(b, :category_id => b.dictionary_vocab_category.id)}",
|
||||
tag: b.sorted_tags.to_a,
|
||||
}
|
||||
end
|
||||
|
||||
render :json => JSON.pretty_generate(data)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
<tr id="<%= dom_id dictionary_vocab_category %>" class="with_action">
|
||||
<td>
|
||||
<%= dictionary_vocab_category.key %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills hide">
|
||||
<% if is_admin?%>
|
||||
<li><%= link_to t(:edit), edit_panel_dictionary_back_end_dictionary_vocab_category_path(dictionary_vocab_category), :remote => true %></li>
|
||||
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<td><%= dictionary_vocab_category.title_translations[locale] rescue nil %></td>
|
||||
<% end %>
|
||||
</tr>
|
|
@ -0,0 +1,29 @@
|
|||
<% # encoding: utf-8 %>
|
||||
|
||||
<%= form_for(@dictionary_vocab_category, :url => @url) do |f| %>
|
||||
|
||||
<h2><%= (@dictionary_vocab_category.new_record? ? 'Add' : 'Edit') %></h2>
|
||||
|
||||
<div id="widget-title">
|
||||
<%= f.label :key %>
|
||||
<%= f.text_field :key %>
|
||||
</div>
|
||||
|
||||
<div id="widget-title">
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<div class="control-group">
|
||||
<%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= f.text_field locale, :class =>' input-xxlarge', :value => (@dictionary_vocab_category.title_translations[locale] rescue nil) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.submit 'Submit/送出', :class=>'btn btn-primary' %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
|
@ -0,0 +1,2 @@
|
|||
$('<%= j render :partial => 'dictionary_file_category', :collection => [@dictionary_file_category] %>').appendTo('#dictionary_file_categorys').hide().fadeIn();
|
||||
$("#new_dictionary_file_category")[0].reset();
|
|
@ -0,0 +1,19 @@
|
|||
<%= flash_messages %>
|
||||
|
||||
<table id="dictionary_file_categorys" class="table main-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span1-2"><%= t('dictionary_file_category.key') %></th>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<th class="span1-2"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<%= render :partial => 'dictionary_vocab_category', :collection => @dictionary_vocab_categorys %>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="form"><%= render :partial => "form" %></div>
|
|
@ -0,0 +1 @@
|
|||
$("#form > form").replaceWith("<%= j render "form" %>");
|
|
@ -67,9 +67,9 @@ module Dictionary
|
|||
:available_for => [:sub_manager]
|
||||
|
||||
context_link 'categories',
|
||||
:link_path=>"panel_archive_back_end_archive_file_categorys_path" ,
|
||||
:priority=>3,
|
||||
:active_for_action=>{:archive_file_categorys=>:index},
|
||||
:link_path => "panel_dictionary_back_end_dictionary_vocab_categorys_path" ,
|
||||
:priority => 3,
|
||||
:active_for_action => { :dictionary_vocab_categorys => :index },
|
||||
:available_for => [:manager]
|
||||
|
||||
# context_link 'tags',
|
||||
|
@ -79,9 +79,9 @@ module Dictionary
|
|||
# :available_for => [:manager]
|
||||
|
||||
context_link 'module_authorization',
|
||||
:link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'Archive'}))",
|
||||
:priority=>6,
|
||||
:active_for_app_auth => 'Archive'
|
||||
:link_path => "admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'Dictionary'}))",
|
||||
:priority => 6,
|
||||
:active_for_app_auth => 'Dictionary'
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue