1.修改竞赛作品时增加作品类别下拉框选择

2.修改竞赛作品时增加获取选择其他时作品类别
This commit is contained in:
sw 2014-07-21 17:23:45 +08:00
parent c8aaa2776c
commit b1251db30c
4 changed files with 60 additions and 12 deletions

View File

@ -175,8 +175,16 @@ class SoftapplicationsController < ApplicationController
@softapplication.save_attachments(params[:attachments]) @softapplication.save_attachments(params[:attachments])
#@softapplication.deposit_project = params[:project] #@softapplication.deposit_project = params[:project]
@softapplication.project = Project.find_by_id(params[:project]) @softapplication.project = Project.find_by_id(params[:project])
@softapplication.name = params[:softapplication][:name]
@softapplication.android_min_version_available = params[:softapplication][:android_min_version_available]
@softapplication.app_type_name = params[:other_input] == "" ? params[:softapplication][:app_type_name] : params[:other_input]
@softapplication.description = params[:softapplication][:description]
@softapplication.application_developers = params[:softapplication][:application_developers]
#@softapplication.app_type_name = params[:other_input] if params[:other_input] != ""
respond_to do |format| respond_to do |format|
if @softapplication.update_attributes(params[:softapplication]) #if @softapplication.update_attributes(params[:softapplication])
if @softapplication.save
format.html { redirect_to @softapplication, notice: l(:notice_softapplication_was_successfully_updated) } format.html { redirect_to @softapplication, notice: l(:notice_softapplication_was_successfully_updated) }
format.json { head :no_content } format.json { head :no_content }
else else

View File

@ -14,6 +14,19 @@ module SoftapplicationsHelper
content_tag('div', content, :class => "tabs") content_tag('div', content, :class => "tabs")
end end
#作品分类下拉框
def work_type_opttion
type = []
#work_types = WorksCategory.all
WorksCategory.all.each do |work_type|
option = []
option << work_type.category
option << work_type.category
type << option
end
type
end
# def select_option_helper option # def select_option_helper option
# tmp = Hash.new # tmp = Hash.new
# option.each do |project| # option.each do |project|

View File

@ -1,3 +1,19 @@
<script type="text/javascript" language="javascript">
function selectChange(obj)
{
if(obj.value=="其他")
{
//document.getElementById("a").style.display = ""
$("#other_span").show();
}
else
{
$("#other_span").hide();
$("#other_input").val("");
//document.getElementById("a").style.display = "none"
}
}
</script>
<%= form_for(softapplication) do |f| %> <%= form_for(softapplication) do |f| %>
<% if softapplication.errors.any? %> <% if softapplication.errors.any? %>
@ -17,7 +33,7 @@
<span><%= l(:label_work_name) %></span> <span><%= l(:label_work_name) %></span>
<span class="contest-star"> * </span>: <td ><%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %></td> <span class="contest-star"> * </span>: <td ><%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %></td>
<span><%= l(:label_softapplication_name_condition)%></span> <span><%= l(:label_softapplication_name_condition)%></span>
</tr></ br> </tr><br/>
<br /> <br />
<br /> <br />
@ -25,16 +41,24 @@
<span><%= l(:label_running_platform) %></span> <span><%= l(:label_running_platform) %></span>
<span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %></td> <span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %></td>
</tr></ br> </tr>
<br/>
<br /> <br />
<br /> <br />
<tr style="width:800px;"> <tr style="width:800px;">
<span><%= l(:label_work_type) %></span> <span><%= l(:label_work_type) %></span>
<span class="contest-star"> * </span>:
<span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %></td> <td style="width: 100px">
<%#= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %>
</tr></ br> <%= f.select :app_type_name,work_type_opttion, {},{:style => "width:410px;",:onchange => "selectChange(this)"} %>
<span style="font-size: 10px;display: none" id="other_span">
<%#= f.text_field :other_input, :required => true, :size => 60, :style => "width:100px;" %>
<input type="text" style="width: 100px;" id="other_input" name = "other_input"/>
</span>
</td>
</tr>
<br/>
<br /> <br />
<br /> <br />
@ -42,7 +66,8 @@
<span><%= l(:label_work_description) %></span> <span><%= l(:label_work_description) %></span>
<span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %></td> <span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %></td>
<span><%= l(:label_softapplication_description_condition)%></span> <span><%= l(:label_softapplication_description_condition)%></span>
</tr></ br> </tr>
<br/>
<br /> <br />
<br /> <br />
@ -50,7 +75,8 @@
<span><%= l(:label_softapplication_developers) %></span> <span><%= l(:label_softapplication_developers) %></span>
<span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:400px;" %></td> <span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:400px;" %></td>
</tr></ br> </tr>
<br/>
<br /> <br />
<br /> <br />
@ -58,7 +84,8 @@
<span><%= l(:label_work_deposit_project) %></span> <span><%= l(:label_work_deposit_project) %></span>
<span style="padding-left: 4px"><%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline3' %></span> <span style="padding-left: 4px"><%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline3' %></span>
<span><%#= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target=>'_blank'%></span> <span><%#= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target=>'_blank'%></span>
</tr><br/> </tr>
<br/>
<br /> <br />
<br /> <br />

View File

@ -2,7 +2,7 @@
<%= render partial: 'form', locals:{softapplication: @softapplication} %> <%= render partial: 'form', locals:{softapplication: @softapplication} %>
<!-- <%= link_to 'Show', @softapplication %> <!-- <%#= link_to 'Show', @softapplication %>
<%= link_to 'Back', softapplications_path %> --> <%#= link_to 'Back', softapplications_path %> -->