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 @@ +
<%= t('dictionary_file_category.key') %> | + <% @site_valid_locales.each do |locale| %> +<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> | + <% end %> +
---|