项目配置--版本库代码简化及界面

This commit is contained in:
huang 2016-10-12 16:09:17 +08:00
parent fabe6bd999
commit 50f9c5244d
2 changed files with 64 additions and 3 deletions

View File

@ -362,9 +362,8 @@ class ProjectsController < ApplicationController
# 修改查看消息状态
applied_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =? and viewed =?", User.current.id, @project, "AppliedProject", 0)
applied_messages.each do |applied_message|
applied_message.update_attributes(:viewed => true)
end
applied_messages.update_all(:viewed => true)
# end
@issue_custom_fields = IssueCustomField.sorted.all
@issue_category ||= IssueCategory.new
@ -398,6 +397,12 @@ class ProjectsController < ApplicationController
flash.now[:error] = html if !html.to_s.blank?
end
# for设置默认分支
@gitlab_repository = Repository.where(:project_id => @project, :type => "Repository::Gitlab").first
unless @gitlab_repository.nil?
gitlab_address = Redmine::Configuration['gitlab_address']
@repos_url = gitlab_address.to_s+"/" + @creator + "/" + @repository.identifier+"."+"git"
end
scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
@repository = Repository.factory(scm)
@repository.is_default = @project.repository.nil?

View File

@ -1,3 +1,59 @@
<div class="pro_new_prompt ml15 mr15 mb10"><p>温馨提示:每个项目只能创建一个版本库</p></div>
<div class=" sy_new_tchbox clear " >
<% if @gitlab_repository.nil? %>
<a href="javascript:void(0);" class=" sy_btn_green mb10">新建版本库</a>
<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post",:autocomplete=>'off'} do |f| %>
<ul class="pro_newsetting_con mb15">
<li style="display: none">
<label class="label02"><%=l(:label_scm)%></label>
<%= select_tag('repository_scm', options_for_select(["Git"],@repository.class.name.demodulize), :data => {:remote => true, :method => 'get'}) %>
<% if @repository && ! @repository.class.scm_available %>
<span class="c_grey"><%= l(:text_scm_command_not_available) %></span>
<% end %>
</li>
<li>
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label class=" fl"><span class="c_red f12">*</span>&nbsp;版本库名称&nbsp;&nbsp;:&nbsp;</label>
<%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false, :label=>"", :no_label => true, :class => "w650 fl" %>
</li>
<li class="clear">
<label class=" fl">&nbsp;&nbsp;</label>
<p class=" fl c_grey pro_new_grey">1.长度必须在1到254个字符之间<br/>
2.仅限使用小写字母a-z、数字、破折号-和下划线_<br>
3.一旦保存,标识无法修改</p>
</li>
</ul>
<a href="<%= settings_project_path(@project, :tab => 'repositories')%>" class="fr sy_btn_grey"><%=l(:button_cancel)%></a>
<a href="#" onclick="$('#repository-form').submit();" class="fr sy_btn_blue mr5"><%=l(:lable_project_rep_create) %></a>
<% end %>
<% else %>
<div class=" clear ml15 mr15" >
<table class="sy_new_table clear mb15" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>版本库名</th>
<th >管理系统</th>
<th>库路径</th>
</tr>
</thead>
<tbody>
<tr>
<th><%= repository.identifier %></th>
<th>Gitlab</th>
<th><%=h truncate(@repos_url,:length=>10) %></th>
</tr>
</tbody>
</table>
</div>
<% end %>
</div>
<script>
function pro_st_show_ku()
{