add: project explore management

This commit is contained in:
2021-10-27 16:50:18 +08:00
parent 0970a402c8
commit 91852d7957
11 changed files with 242 additions and 10 deletions

View File

@@ -9,7 +9,18 @@
</div>
<%= form_for @project_category, url: {controller: "project_categories", action: "#{type}"} do |p| %>
<div class="modal-body">
<%= p.text_field :name,class: "form-control input-lg",placeholder: "分类名称",required: true, maxlength: 64%>
<div class="form-group">
<label>
分类名称 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :name,class: "form-control input-lg",placeholder: "分类名称",required: true, maxlength: 64%>
</div>
<div class="form-group">
<label>
精选级别
</label>
<%= p.number_field :pinned_index,class: "form-control input-lg",placeholder: "精选级别",required: true%>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>

View File

@@ -3,6 +3,7 @@
<tr>
<th width="5%">序号</th>
<th width="30%">名称</th>
<th width="20%"><%= sort_tag('精选', name: 'pinned_index', path: admins_project_categories_path) %></th>
<th width="20%"><%= sort_tag('项目数', name: 'projects_count', path: admins_project_categories_path) %></th>
<th width="20%"><%= sort_tag('创建时间', name: 'created_at', path: admins_project_categories_path) %></th>
<th width="25%">操作</th>
@@ -16,6 +17,7 @@
<td>
<%= link_to(project_category.name, "/projects?category_id=#{project_category.id}", target: '_blank') %>
</td>
<td><%= project_category.pinned_index == 0 ? "" : "√" %></td>
<td><%= project_category.projects_count %></td>
<td><%= project_category.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
<td class="action-container">

View File

@@ -0,0 +1,2 @@
$("#projects-modals").html("<%= j render(partial: 'admins/projects/shared/form_modal', locals: {type: 'update'}) %>")
$(".project-change-modal").modal('show');

View File

@@ -12,4 +12,7 @@
<div class="box admin-list-container project-list-container">
<%= render partial: 'admins/projects/shared/list', locals: { projects: @projects } %>
</div>
</div>
<div id="projects-modals">
</div>

View File

@@ -0,0 +1,26 @@
<div class="modal fade project-change-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= type == "create" ? "新增" : "编辑" %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<%= form_for @project, url: {controller: "projects", action: "#{type}"} do |p| %>
<div class="modal-body">
<div class="form-group">
<label>
推荐等级
</label>
<%= p.number_field :recommend_index,class: "form-control input-lg"%>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= p.submit "确认", class: "btn btn-primary submit-btn" %>
</div>
<% end %>
</div>
</div>
</div>

View File

@@ -5,6 +5,8 @@
<th width="4%">ID</th>
<th width="15%" class="text-left">项目名称</th>
<th width="6%">公开</th>
<th width="6%">精选</th>
<th width="6%">推荐</th>
<th width="5%">issue</th>
<th width="5%">资源</th>
<th width="6%">版本库</th>
@@ -12,8 +14,8 @@
<th width="6%">里程碑</th>
<th width="10%">成员</th>
<th width="10%">管理员</th>
<th width="11%"><%= sort_tag('创建时间', name: 'created_on', path: admins_projects_path) %></th>
<th width="10%">操作</th>
<th width="15%"><%= sort_tag('创建时间', name: 'created_on', path: admins_projects_path) %></th>
<th width="25%">操作</th>
</tr>
</thead>
<tbody>
@@ -26,6 +28,8 @@
<%= link_to(project.name, "/projects/#{project&.owner&.login}/#{project.identifier}", target: '_blank') %>
</td>
<td><%= project.is_public ? '√' : '' %></td>
<td><%= project.is_pinned ? '√' : '' %></td>
<td><%= project.recommend ? '√' : '' %></td>
<td><%= project.issues.size %></td>
<td><%= project.attachments.size %></td>
<td><%= project&.project_score.try(:changeset_num).to_i %></td>
@@ -37,8 +41,15 @@
</td>
<td><%= project.created_on&.strftime('%Y-%m-%d %H:%M') %></td>
<td class="action-container">
<% if project.is_public %>
<%= javascript_void_link '精选', class: 'action pinned-action', data: { id: project.id }, style: project.is_pinned ? 'display: none;' : '' %>
<%= javascript_void_link '取消精选', class: 'action unpinned-action', data: { id: project.id }, style: project.is_pinned ? '' : 'display: none;' %>
<%= javascript_void_link '推荐', class: 'action recommend-action', data: { id: project.id }, style: project.recommend ? 'display: none;' : '' %>
<%= javascript_void_link '取消推荐', class: 'action unrecommend-action', data: { id: project.id }, style: project.recommend ? '' : 'display: none;' %>
<%= link_to "设置推荐等级", edit_admins_project_path(project.id), remote: true, class: "action", style: project.recommend ? '' : 'display: none;' %>
<% end %>
<%= link_to "删除", admins_project_path(project.id), method: :delete, data:{confirm: "确认删除的吗?"}, class: "delete-project-action" %>
</td>
</td>
</tr>
<% end %>
<% else %>