From b51e10eb9d1b8dd69b4165eb37421edc4f797319 Mon Sep 17 00:00:00 2001
From: thomaschen <99703040@nccu.edu.tw>
Date: Thu, 22 Aug 2013 16:13:21 +0800
Subject: [PATCH] build dictionary_vocabs back_end
---
.../back_end/dictionary_vocabs_controller.rb | 44 ++++++++++++++++++-
.../back_end/dictionary_vocabs/_form.html.erb | 17 +++++++
.../back_end/dictionary_vocabs/edit.html.erb | 3 ++
.../back_end/dictionary_vocabs/index.html.erb | 8 ++--
.../back_end/dictionary_vocabs/new.html.erb | 15 +++++++
.../dictionary/config/locales/en.yml | 11 ++++-
.../dictionary/config/locales/zh_tw.yml | 4 ++
vendor/built_in_modules/dictionary/init.rb | 4 +-
8 files changed, 98 insertions(+), 8 deletions(-)
create mode 100644 vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/_form.html.erb
create mode 100644 vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/edit.html.erb
create mode 100644 vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/new.html.erb
diff --git a/vendor/built_in_modules/dictionary/app/controllers/panel/dictionary/back_end/dictionary_vocabs_controller.rb b/vendor/built_in_modules/dictionary/app/controllers/panel/dictionary/back_end/dictionary_vocabs_controller.rb
index 1ac067388..f5d7da844 100644
--- a/vendor/built_in_modules/dictionary/app/controllers/panel/dictionary/back_end/dictionary_vocabs_controller.rb
+++ b/vendor/built_in_modules/dictionary/app/controllers/panel/dictionary/back_end/dictionary_vocabs_controller.rb
@@ -14,8 +14,18 @@ class Panel::Dictionary::BackEnd::DictionaryVocabsController < OrbitBackendContr
@vocabs = DictionaryVocab.all
end
+ def show
+ @vocab = DictionaryVocab.find(params[:id])
+ # @comment = @market_item.comments.build
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @vocab }
+ end
+ end
+
def new
@vocab = DictionaryVocab.new
+ # @categories = get_categories_for_index("MarketItemCategory")
respond_to do |format|
format.html # new.html.erb
@@ -23,8 +33,40 @@ class Panel::Dictionary::BackEnd::DictionaryVocabsController < OrbitBackendContr
end
end
- def edit
+ def create
+ @vocab = DictionaryVocab.new(params[:dictionary_vocab])
+ @vocab.create_user_id = current_user.id
+ @vocab.update_user_id = current_user.id
+ # @categories = get_categories_for_index("MarketItemCategory")
+ if @vocab.save
+ flash[:success] = "Success!"
+ redirect_to :action => :index
+ else
+ render 'new'
+ end
+ end
+
+ def edit
+ @vocab = DictionaryVocab.find(params[:id])
+ @categories = DictionaryVocabCategory.all
+ end
+
+ def update
+ @vocab = DictionaryVocab.find(params[:id])
+ @vocab.update_attributes(params[:dictionary_vocab])
+
+ redirect_to :action => :index
+ end
+
+ def destroy
+ @vocab = DictionaryVocab.find(params[:id])
+ @vocab.destroy
+ # @market_item.save
+ respond_to do |format|
+ format.html { redirect_to(panel_dictionary_back_end_dictionary_vocabs_url) }
+ format.js
+ end
end
end
\ No newline at end of file
diff --git a/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/_form.html.erb b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/_form.html.erb
new file mode 100644
index 000000000..9e905b478
--- /dev/null
+++ b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/_form.html.erb
@@ -0,0 +1,17 @@
+
+
+
<%= t :category, :scope => :dictionary %>
+ <%= f.collection_select :dictionary_vocab_category_id, @categories, :id, :title %>
+
+
+
<%= t :word, :scope => :dictionary %>
+ <%= f.text_field :title %>
+
+
+
<%= t :definition, :scope => :dictionary %>
+ <%= f.text_area :price %>
+
+
+
+ <%= f.submit t('submit'), class: 'btn btn-primary'%>
+
diff --git a/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/edit.html.erb b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/edit.html.erb
new file mode 100644
index 000000000..5793cfced
--- /dev/null
+++ b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/edit.html.erb
@@ -0,0 +1,3 @@
+<%= form_for @vocab, url: panel_dictionary_back_end_dictionary_vocab_path(@vocab) do |f| %>
+ <%= render 'form', f: f %>
+<% end %>
\ No newline at end of file
diff --git a/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/index.html.erb b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/index.html.erb
index 212bb9dfe..98a4b8a44 100644
--- a/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/index.html.erb
+++ b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/index.html.erb
@@ -7,10 +7,10 @@
- <%= t :Category, :scope => :dictionary %> |
- <%= t :Word, :scope => :dictionary %> |
- <%= t :Definition, :scope => :dictionary %> |
- <%= t :Time, :scope => :dictionary %> |
+ <%= t :category, :scope => :dictionary %> |
+ <%= t :word, :scope => :dictionary %> |
+ <%= t :definition, :scope => :dictionary %> |
+ <%= t :time, :scope => :dictionary %> |
|
diff --git a/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/new.html.erb b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/new.html.erb
new file mode 100644
index 000000000..23d95c7de
--- /dev/null
+++ b/vendor/built_in_modules/dictionary/app/views/panel/dictionary/back_end/dictionary_vocabs/new.html.erb
@@ -0,0 +1,15 @@
+<% if @vocab.errors.any? %>
+
+
+ 此表單包含了 <%= @vocab.errors.count.to_s + "個錯誤" %>.
+
+
+ <% @vocab.errors.full_messages.each do |msg| %>
+ - * <%= msg %>
+ <% end %>
+
+
+<% end %>
+<%= form_for @vocab, url: panel_dictionary_back_end_dictionary_vocabs_path do |f| %>
+ <%= render 'form', f: f %>
+<% end %>s
\ No newline at end of file
diff --git a/vendor/built_in_modules/dictionary/config/locales/en.yml b/vendor/built_in_modules/dictionary/config/locales/en.yml
index d108c4edd..1fee25ffe 100644
--- a/vendor/built_in_modules/dictionary/config/locales/en.yml
+++ b/vendor/built_in_modules/dictionary/config/locales/en.yml
@@ -8,4 +8,13 @@ en:
frontend:
archive: Archive Front-end
widget:
- index: Archive Widget
\ No newline at end of file
+ index: Archive Widget
+
+en:
+
+ dictionary:
+ dictionary: Dictionary
+ category: Category
+ word: Word
+ definition: Definition
+ time: Time
\ No newline at end of file
diff --git a/vendor/built_in_modules/dictionary/config/locales/zh_tw.yml b/vendor/built_in_modules/dictionary/config/locales/zh_tw.yml
index 65f1756e1..bab43cc47 100644
--- a/vendor/built_in_modules/dictionary/config/locales/zh_tw.yml
+++ b/vendor/built_in_modules/dictionary/config/locales/zh_tw.yml
@@ -18,3 +18,7 @@ zh_tw:
dictionary:
dictionary: 字彙辭典
+ category: 類別
+ word: 字彙
+ definition: 定義
+ time: 時間
diff --git a/vendor/built_in_modules/dictionary/init.rb b/vendor/built_in_modules/dictionary/init.rb
index 611c20270..e6b182233 100644
--- a/vendor/built_in_modules/dictionary/init.rb
+++ b/vendor/built_in_modules/dictionary/init.rb
@@ -55,9 +55,9 @@ module Dictionary
head_link_path "panel_dictionary_back_end_dictionary_vocabs_path"
context_link 'all',
- :link_path=>"panel_archive_back_end_archive_files_path" ,
+ :link_path=>"panel_dictionary_back_end_dictionary_vocabs_path" ,
:priority=>1,
- :active_for_action=>{:archive_files=>:index},
+ :active_for_action=>{:dictionary_vocabs=>:index},
:available_for => [:all]
context_link 'add',