创建作业增加js验证
This commit is contained in:
parent
c7caa08c70
commit
82b23da54b
|
@ -22,15 +22,22 @@
|
||||||
|
|
||||||
<%= error_messages_for 'bid' %>
|
<%= error_messages_for 'bid' %>
|
||||||
<p><%= l(:label_homeworks_form_new_description) %></p>
|
<p><%= l(:label_homeworks_form_new_description) %></p>
|
||||||
<p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT %></p>
|
<p>
|
||||||
|
<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT, :onblur => "regexName();" %>
|
||||||
|
|
||||||
<p style="margin-left:-10px;padding-right: 20px;"><%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT %></p>
|
</p>
|
||||||
|
<p><span id="bid_name_span"></span></p>
|
||||||
|
|
||||||
|
<p><%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT %></p>
|
||||||
<!-- <p><%#= select_tag 'bid_reward_type', "<option value = '0'>#{l(:label_choose_reward)}</option><option value = '1'>#{l(:label_money)}</option><option value = '3'>#{l(:label_bids_credit)}</option><option value = '2'>#{l(:label_reward_1)}</option>".html_safe,
|
<!-- <p><%#= select_tag 'bid_reward_type', "<option value = '0'>#{l(:label_choose_reward)}</option><option value = '1'>#{l(:label_money)}</option><option value = '3'>#{l(:label_bids_credit)}</option><option value = '2'>#{l(:label_reward_1)}</option>".html_safe,
|
||||||
:onChange => "show('bid_reward_type', 'bid_budget', '"+l(:label_bids_reward_what)+"','"+l(:label_bids_new_money)+"','"+l(:label_bids_new_credit)+"','"+l(:label_bids_new_content)+"')" %>
|
:onChange => "show('bid_reward_type', 'bid_budget', '"+l(:label_bids_reward_what)+"','"+l(:label_bids_new_money)+"','"+l(:label_bids_new_credit)+"','"+l(:label_bids_new_content)+"')" %>
|
||||||
<%#= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %>
|
<%#= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %>
|
||||||
</p> -->
|
</p> -->
|
||||||
<% time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') %>
|
<% time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') %>
|
||||||
<p><%= f.text_field(:deadline, :required => true, :size => 60, :style => "width:150px;",:value => "#{time}",:readonly => "readonly") %><%= calendar_for('bid_deadline')%>
|
<p><%= f.text_field(:deadline, :required => true, :size => 60, :style => "width:150px;",:value => "#{time}", :onchange => "regexDeadLine();") %><%= calendar_for('bid_deadline')%>
|
||||||
|
<span id="bid_deadline_span">
|
||||||
|
|
||||||
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p><%= f.select :is_evaluation, is_evaluation_option %>
|
<p><%= f.select :is_evaluation, is_evaluation_option %>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -1,9 +1,60 @@
|
||||||
|
<script type="text/javascript">
|
||||||
|
function regexName()
|
||||||
|
{
|
||||||
|
var name = $("#bid_name").val();
|
||||||
|
|
||||||
|
if(name=="")
|
||||||
|
{
|
||||||
|
$("#bid_name_span").text("名称不能为空");
|
||||||
|
$("#bid_name_span").css('color','#ff0000');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#bid_name_span").text("填写正确");
|
||||||
|
$("#bid_name_span").css('color','#008000');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function regexDeadLine()
|
||||||
|
{
|
||||||
|
var deadline = $("#bid_deadline").val();
|
||||||
|
var regex = /^\d{4}-\d{2}-\d{2}$/;
|
||||||
|
if(deadline=="")
|
||||||
|
{
|
||||||
|
$("#bid_deadline_span").text("截止日期不能为空");
|
||||||
|
$("#bid_deadline_span").css('color','#ff0000');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if(regex.test(deadline))
|
||||||
|
{
|
||||||
|
$("#bid_deadline_span").text("填写正确");
|
||||||
|
$("#bid_deadline_span").css('color','#008000');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#bid_deadline_span").text("截止日期格式错误");
|
||||||
|
$("#bid_deadline_span").css('color','#ff0000');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function submitHomework()
|
||||||
|
{
|
||||||
|
if(regexDeadLine()&®exName())
|
||||||
|
{
|
||||||
|
$("#new_bid").submit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<h3><%=l(:label_course_new_homework)%></h3>
|
<h3><%=l(:label_course_new_homework)%></h3>
|
||||||
|
|
||||||
<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %>
|
<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %>
|
||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
<%= render :partial => 'homework_form', :locals => { :f => f } %>
|
<%= render :partial => 'homework_form', :locals => { :f => f } %>
|
||||||
<%= submit_tag l(:button_create), :class => "enterprise" %>
|
<input type="button" onclick="submitHomework();" value="<%= l(:button_create)%>" class="enterprise">
|
||||||
<%= javascript_tag "$('#bid_name').focus();" %>
|
<%= javascript_tag "$('#bid_name').focus();" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
99
db/schema.rb
99
db/schema.rb
|
@ -177,6 +177,58 @@ ActiveRecord::Schema.define(:version => 20140826072838) do
|
||||||
|
|
||||||
add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true
|
add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true
|
||||||
|
|
||||||
|
create_table "code_review_assignments", :force => true do |t|
|
||||||
|
t.integer "issue_id"
|
||||||
|
t.integer "change_id"
|
||||||
|
t.integer "attachment_id"
|
||||||
|
t.string "file_path"
|
||||||
|
t.string "rev"
|
||||||
|
t.string "rev_to"
|
||||||
|
t.string "action_type"
|
||||||
|
t.integer "changeset_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "code_review_project_settings", :force => true do |t|
|
||||||
|
t.integer "project_id"
|
||||||
|
t.integer "tracker_id"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
t.integer "updated_by"
|
||||||
|
t.boolean "hide_code_review_tab", :default => false
|
||||||
|
t.integer "auto_relation", :default => 1
|
||||||
|
t.integer "assignment_tracker_id"
|
||||||
|
t.text "auto_assign"
|
||||||
|
t.integer "lock_version", :default => 0, :null => false
|
||||||
|
t.boolean "tracker_in_review_dialog", :default => false
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "code_review_user_settings", :force => true do |t|
|
||||||
|
t.integer "user_id", :default => 0, :null => false
|
||||||
|
t.integer "mail_notification", :default => 0, :null => false
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "code_reviews", :force => true do |t|
|
||||||
|
t.integer "project_id"
|
||||||
|
t.integer "change_id"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
t.integer "line"
|
||||||
|
t.integer "updated_by_id"
|
||||||
|
t.integer "lock_version", :default => 0, :null => false
|
||||||
|
t.integer "status_changed_from"
|
||||||
|
t.integer "status_changed_to"
|
||||||
|
t.integer "issue_id"
|
||||||
|
t.string "action_type"
|
||||||
|
t.string "file_path"
|
||||||
|
t.string "rev"
|
||||||
|
t.string "rev_to"
|
||||||
|
t.integer "attachment_id"
|
||||||
|
t.integer "file_count", :default => 0, :null => false
|
||||||
|
t.boolean "diff_all"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "comments", :force => true do |t|
|
create_table "comments", :force => true do |t|
|
||||||
t.string "commented_type", :limit => 30, :default => "", :null => false
|
t.string "commented_type", :limit => 30, :default => "", :null => false
|
||||||
t.integer "commented_id", :default => 0, :null => false
|
t.integer "commented_id", :default => 0, :null => false
|
||||||
|
@ -389,10 +441,10 @@ ActiveRecord::Schema.define(:version => 20140826072838) do
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "sort_type"
|
t.integer "sort_type"
|
||||||
t.integer "image_width", :default => 107
|
|
||||||
t.integer "image_height", :default => 63
|
|
||||||
t.integer "show_course", :default => 1
|
t.integer "show_course", :default => 1
|
||||||
t.integer "show_contest", :default => 1
|
t.integer "show_contest", :default => 1
|
||||||
|
t.integer "image_width", :default => 107
|
||||||
|
t.integer "image_height", :default => 63
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "forums", :force => true do |t|
|
create_table "forums", :force => true do |t|
|
||||||
|
@ -826,18 +878,18 @@ ActiveRecord::Schema.define(:version => 20140826072838) do
|
||||||
create_table "relative_memos", :force => true do |t|
|
create_table "relative_memos", :force => true do |t|
|
||||||
t.integer "osp_id"
|
t.integer "osp_id"
|
||||||
t.integer "parent_id"
|
t.integer "parent_id"
|
||||||
t.string "subject", :null => false
|
t.string "subject", :null => false
|
||||||
t.text "content", :null => false
|
t.text "content", :limit => 16777215, :null => false
|
||||||
t.integer "author_id"
|
t.integer "author_id"
|
||||||
t.integer "replies_count", :default => 0
|
t.integer "replies_count", :default => 0
|
||||||
t.integer "last_reply_id"
|
t.integer "last_reply_id"
|
||||||
t.boolean "lock", :default => false
|
t.boolean "lock", :default => false
|
||||||
t.boolean "sticky", :default => false
|
t.boolean "sticky", :default => false
|
||||||
t.boolean "is_quote", :default => false
|
t.boolean "is_quote", :default => false
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "viewed_count_crawl", :default => 0
|
t.integer "viewed_count_crawl", :default => 0
|
||||||
t.integer "viewed_count_local", :default => 0
|
t.integer "viewed_count_local", :default => 0
|
||||||
t.string "url"
|
t.string "url"
|
||||||
t.string "username"
|
t.string "username"
|
||||||
t.string "userhomeurl"
|
t.string "userhomeurl"
|
||||||
|
@ -861,6 +913,19 @@ ActiveRecord::Schema.define(:version => 20140826072838) do
|
||||||
|
|
||||||
add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
|
add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
|
||||||
|
|
||||||
|
create_table "rich_rich_files", :force => true do |t|
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
t.string "rich_file_file_name"
|
||||||
|
t.string "rich_file_content_type"
|
||||||
|
t.integer "rich_file_file_size"
|
||||||
|
t.datetime "rich_file_updated_at"
|
||||||
|
t.string "owner_type"
|
||||||
|
t.integer "owner_id"
|
||||||
|
t.text "uri_cache"
|
||||||
|
t.string "simplified_type", :default => "file"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "roles", :force => true do |t|
|
create_table "roles", :force => true do |t|
|
||||||
t.string "name", :limit => 30, :default => "", :null => false
|
t.string "name", :limit => 30, :default => "", :null => false
|
||||||
t.integer "position", :default => 1
|
t.integer "position", :default => 1
|
||||||
|
@ -911,10 +976,11 @@ ActiveRecord::Schema.define(:version => 20140826072838) do
|
||||||
t.string "url"
|
t.string "url"
|
||||||
t.string "title"
|
t.string "title"
|
||||||
t.integer "share_type"
|
t.integer "share_type"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "project_id"
|
t.integer "project_id"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
|
t.string "description"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "softapplications", :force => true do |t|
|
create_table "softapplications", :force => true do |t|
|
||||||
|
@ -1020,8 +1086,8 @@ ActiveRecord::Schema.define(:version => 20140826072838) do
|
||||||
t.integer "zip_code"
|
t.integer "zip_code"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "identity"
|
|
||||||
t.string "technical_title"
|
t.string "technical_title"
|
||||||
|
t.integer "identity"
|
||||||
t.string "student_id"
|
t.string "student_id"
|
||||||
t.string "teacher_realname"
|
t.string "teacher_realname"
|
||||||
t.string "student_realname"
|
t.string "student_realname"
|
||||||
|
@ -1079,9 +1145,6 @@ ActiveRecord::Schema.define(:version => 20140826072838) do
|
||||||
t.integer "active"
|
t.integer "active"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "level"
|
|
||||||
t.integer "file"
|
|
||||||
t.integer "issue"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "user_statuses", :force => true do |t|
|
create_table "user_statuses", :force => true do |t|
|
||||||
|
|
Loading…
Reference in New Issue