diff --git a/vendor/built_in_modules/dictionary/app/controllers/panel/dictionary/back_end/dictionary_vocab_categorys_controller.rb b/vendor/built_in_modules/dictionary/app/controllers/panel/dictionary/back_end/dictionary_vocab_categorys_controller.rb index caf40df90..85b3db6a0 100644 --- a/vendor/built_in_modules/dictionary/app/controllers/panel/dictionary/back_end/dictionary_vocab_categorys_controller.rb +++ b/vendor/built_in_modules/dictionary/app/controllers/panel/dictionary/back_end/dictionary_vocab_categorys_controller.rb @@ -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 \ No newline at end of file diff --git a/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/_dictionary_vocab_category.html.erb b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/_dictionary_vocab_category.html.erb new file mode 100644 index 000000000..4fc259123 --- /dev/null +++ b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/_dictionary_vocab_category.html.erb @@ -0,0 +1,17 @@ + + + <%= dictionary_vocab_category.key %> +
+ +
+ + <% @site_valid_locales.each do |locale| %> + <%= dictionary_vocab_category.title_translations[locale] rescue nil %> + <% end %> + diff --git a/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/_form.html.erb b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/_form.html.erb new file mode 100644 index 000000000..d4c079d43 --- /dev/null +++ b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/_form.html.erb @@ -0,0 +1,29 @@ +<% # encoding: utf-8 %> + +<%= form_for(@dictionary_vocab_category, :url => @url) do |f| %> + +

<%= (@dictionary_vocab_category.new_record? ? 'Add' : 'Edit') %>

+ +
+ <%= f.label :key %> + <%= f.text_field :key %> +
+ +
+ <%= f.fields_for :title_translations do |f| %> + <% @site_valid_locales.each do |locale| %> +
+ <%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> +
+ <%= f.text_field locale, :class =>' input-xxlarge', :value => (@dictionary_vocab_category.title_translations[locale] rescue nil) %> +
+
+ <% end %> + <% end %> +
+ +
+ <%= f.submit 'Submit/送出', :class=>'btn btn-primary' %> +
+ +<% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/create.js.erb b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/create.js.erb new file mode 100644 index 000000000..9a2a1a960 --- /dev/null +++ b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/create.js.erb @@ -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(); \ No newline at end of file diff --git a/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/index.html.erb b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/index.html.erb new file mode 100644 index 000000000..019ee9d82 --- /dev/null +++ b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/index.html.erb @@ -0,0 +1,19 @@ +<%= flash_messages %> + + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + <%= render :partial => 'dictionary_vocab_category', :collection => @dictionary_vocab_categorys %> + + +
<%= t('dictionary_file_category.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
+ +
<%= render :partial => "form" %>
diff --git a/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/new.js.erb b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/new.js.erb new file mode 100644 index 000000000..eaff01fa3 --- /dev/null +++ b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocab_categorys/new.js.erb @@ -0,0 +1 @@ +$("#form > form").replaceWith("<%= j render "form" %>"); \ No newline at end of file diff --git a/vendor/built_in_modules/dictionary/init.rb b/vendor/built_in_modules/dictionary/init.rb index e6b182233..9584e039d 100644 --- a/vendor/built_in_modules/dictionary/init.rb +++ b/vendor/built_in_modules/dictionary/init.rb @@ -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