feat:优化项目空间样式

pull/425/head
lifei6671 2018-11-21 11:03:16 +08:00
parent 9b0c649738
commit f1957dd9c0
14 changed files with 116 additions and 94 deletions

View File

@ -145,7 +145,7 @@ func initialization() {
item.ItemName = "默认项目"
item.MemberId = 1
if err := item.Save(); err != nil {
panic("初始化项目失败 -> " + err.Error())
panic("初始化项目空间失败 -> " + err.Error())
os.Exit(1)
}
}

View File

@ -159,7 +159,7 @@ func (c *BookController) SaveBook() {
}
}
if !models.NewItemsets().Exist(itemId) {
c.JsonResult(6006,"项目不存在")
c.JsonResult(6006,"项目空间不存在")
}
if editor != "markdown" && editor != "html" {
editor = "markdown"
@ -458,7 +458,7 @@ func (c *BookController) Create() {
privatelyOwned = 1
}
if !models.NewItemsets().Exist(itemId) {
c.JsonResult(6005, "项目不存在")
c.JsonResult(6005, "项目空间不存在")
}
if commentStatus != "open" && commentStatus != "closed" && commentStatus != "group_only" && commentStatus != "registered_only" {
commentStatus = "closed"
@ -588,7 +588,7 @@ func (c *BookController) Import() {
c.JsonResult(6003, "项目标识只能包含小写字母、数字,以及“-”和“_”符号,并且只能小写字母开头")
}
if !models.NewItemsets().Exist(itemId) {
c.JsonResult(6007, "项目不存在")
c.JsonResult(6007, "项目空间不存在")
}
if strings.Count(identify, "") > 50 {
c.JsonResult(6004, "文档标识不能超过50字")
@ -950,7 +950,7 @@ func (c *BookController) TeamSearch() {
}
//项目搜索.
//项目空间搜索.
func (c *BookController) ItemsetsSearch() {
c.Prepare()

View File

@ -355,7 +355,7 @@ func (c *ManagerController) EditBook() {
}
}
if !models.NewItemsets().Exist(itemId) {
c.JsonResult(6006,"项目不存在")
c.JsonResult(6006,"项目空间不存在")
}
book.Publisher = publisher
book.HistoryCount = historyCount
@ -1097,7 +1097,7 @@ func (c *ManagerController) TeamBookDelete() {
c.JsonResult(0, "OK")
}
//项目列表.
//项目空间列表.
func (c *ManagerController) Itemsets() {
c.Prepare()
c.TplName = "manager/itemsets.tpl"
@ -1126,7 +1126,7 @@ func (c *ManagerController) Itemsets() {
}
//编辑或添加项目.
//编辑或添加项目空间.
func (c *ManagerController) ItemsetsEdit() {
c.Prepare()
itemId, _ := c.GetInt("itemId")
@ -1140,9 +1140,9 @@ func (c *ManagerController) ItemsetsEdit() {
if itemId > 0 {
if item, err = models.NewItemsets().First(itemId); err != nil {
if err == orm.ErrNoRows {
c.JsonResult(5002, "项目不存在")
c.JsonResult(5002, "项目空间不存在")
} else {
c.JsonResult(5003, "查询项目出错")
c.JsonResult(5003, "查询项目空间出错")
}
}
} else {
@ -1161,7 +1161,7 @@ func (c *ManagerController) ItemsetsEdit() {
c.JsonResult(0, "OK")
}
//删除项目.
//删除项目空间.
func (c *ManagerController) ItemsetsDelete() {
c.Prepare()
itemId, _ := c.GetInt("itemId")

View File

@ -31,7 +31,7 @@ type Book struct {
BookId int `orm:"pk;auto;unique;column(book_id)" json:"book_id"`
// BookName 项目名称.
BookName string `orm:"column(book_name);size(500)" json:"book_name"`
//所属项目
//所属项目空间
ItemId int `orm:"column(item_id);type(int);default(1)" json:"item_id"`
// Identify 项目唯一标识.
Identify string `orm:"column(identify);size(100);unique" json:"identify"`

View File

@ -9,7 +9,7 @@ import (
"github.com/lifei6671/mindoc/utils/cryptil"
)
//项目
//项目空间
type Itemsets struct {
ItemId int `orm:"column(item_id);pk;auto;unique" json:"item_id"`
ItemName string `orm:"column(item_name);size(500)" json:"item_name"`
@ -22,6 +22,7 @@ type Itemsets struct {
BookNumber int `orm:"-" json:"book_number"`
CreateTimeString string `orm:"-" json:"create_time_string"`
CreateName string `orm:"-" json:"create_name"`
}
// TableName 获取对应数据库表名.
@ -51,21 +52,21 @@ func (item *Itemsets) First(itemId int) (*Itemsets, error) {
}
err := item.QueryTable().Filter("item_id", itemId).One(item)
if err != nil {
beego.Error("查询项目失败 -> item_id=", itemId, err)
beego.Error("查询项目空间失败 -> item_id=", itemId, err)
} else {
item.Include()
}
return item, err
}
func (item *Itemsets) FindFirst(itemKey string) (*Itemsets,error) {
err := item.QueryTable().Filter("item_key",itemKey).One(item)
func (item *Itemsets) FindFirst(itemKey string) (*Itemsets, error) {
err := item.QueryTable().Filter("item_key", itemKey).One(item)
if err != nil {
beego.Error("查询项目失败 -> itemKey=", itemKey, err)
beego.Error("查询项目空间失败 -> itemKey=", itemKey, err)
} else {
item.Include()
}
return item,err
return item, err
}
func (item *Itemsets) Exist(itemId int) bool {
@ -76,14 +77,14 @@ func (item *Itemsets) Exist(itemId int) bool {
func (item *Itemsets) Save() (err error) {
if item.ItemName == "" {
return errors.New("项目名称不能为空")
return errors.New("项目空间名称不能为空")
}
if item.ItemKey == "" {
item.ItemKey = cryptil.NewRandChars(16)
}
if item.QueryTable().Filter("item_id__ne", item.ItemId).Filter("item_key", item.ItemKey).Exist() {
return errors.New("项目标识已存在")
return errors.New("项目空间标识已存在")
}
if item.ItemId > 0 {
_, err = orm.NewOrm().Update(item)
@ -99,10 +100,10 @@ func (item *Itemsets) Delete(itemId int) (err error) {
return ErrInvalidParameter
}
if itemId == 1 {
return errors.New("默认项目不能删除")
return errors.New("默认项目空间不能删除")
}
if !item.Exist(itemId) {
return errors.New("项目不存在")
return errors.New("项目空间不存在")
}
o := orm.NewOrm()
if err := o.Begin(); err != nil {
@ -111,12 +112,12 @@ func (item *Itemsets) Delete(itemId int) (err error) {
}
_, err = o.QueryTable(item.TableNameWithPrefix()).Filter("item_id", itemId).Delete()
if err != nil {
beego.Error("删除项目失败 -> item_id=", itemId, err)
beego.Error("删除项目空间失败 -> item_id=", itemId, err)
o.Rollback()
}
_, err = o.Raw("update md_books set item_id=1 where item_id=?;", itemId).Exec()
if err != nil {
beego.Error("删除项目失败 -> item_id=", itemId, err)
beego.Error("删除项目空间失败 -> item_id=", itemId, err)
o.Rollback()
}
@ -127,6 +128,16 @@ func (item *Itemsets) Include() (*Itemsets, error) {
item.CreateTimeString = item.CreateTime.Format("2006-01-02 15:04:05")
if item.MemberId > 0 {
if m,err := NewMember().Find(item.MemberId,"account","real_name");err == nil {
if m.RealName != "" {
item.CreateName = m.RealName
} else {
item.CreateName = m.Account
}
}
}
i, err := NewBook().QueryTable().Filter("item_id", item.ItemId).Count()
if err != nil && err != orm.ErrNoRows {
return item, err
@ -159,7 +170,7 @@ func (item *Itemsets) FindToPager(pageIndex, pageSize int) (list []*Itemsets, to
return
}
//根据项目名称查询.
//根据项目空间名称查询.
func (item *Itemsets) FindItemsetsByName(name string, limit int) (*SelectMemberResult, error) {
result := SelectMemberResult{}
@ -172,7 +183,7 @@ func (item *Itemsets) FindItemsetsByName(name string, limit int) (*SelectMemberR
_, err = item.QueryTable().Filter("item_name__icontains", name).Limit(limit).All(&itemsets)
}
if err != nil {
beego.Error("查询项目失败 ->", err)
beego.Error("查询项目空间失败 ->", err)
return &result, err
}
@ -189,14 +200,14 @@ func (item *Itemsets) FindItemsetsByName(name string, limit int) (*SelectMemberR
return &result, err
}
//根据项目集标识查询项目集的项目列表.
func (item *Itemsets) FindItemsetsByItemKey(key string, pageIndex, pageSize, memberId int) (books []*BookResult, totalCount int, err error){
//根据项目空间标识查询项目空间的项目列表.
func (item *Itemsets) FindItemsetsByItemKey(key string, pageIndex, pageSize, memberId int) (books []*BookResult, totalCount int, err error) {
o := orm.NewOrm()
err = item.QueryTable().Filter("item_key",key).One(item)
err = item.QueryTable().Filter("item_key", key).One(item)
if err != nil {
return nil,0,err
return nil, 0, err
}
offset := (pageIndex - 1) * pageSize
//如果是登录用户

View File

@ -947,7 +947,34 @@ textarea{
margin: 0;
padding: 1em 0
}
/**************项目空间样式******************/
.ui-card{
display: inline-block;
width: 22%;
margin: 10px 15px;
border: solid 1px #d4d4d5;
border-radius: 4px;
padding: 15px 25px;
text-align: center;
color: #333333;
}
.ui-card:hover{
-webkit-box-shadow: 0 1px 3px 0 #d4d4d5,0 0 0 1px #d4d4d5;
box-shadow: 0 1px 3px 0 #d4d4d5,0 0 0 1px #d4d4d5;
-webkit-transition: -webkit-box-shadow .1s ease,-webkit-transform .1s ease;
transition: -webkit-box-shadow .1s ease,-webkit-transform .1s ease;
transition: box-shadow .1s ease,transform .1s ease;
transition: box-shadow .1s ease,transform .1s ease,-webkit-box-shadow .1s ease,-webkit-transform .1s ease;
}
.ui-card>.header{
font-weight: 500;
font-size: 18px;
}
.ui-card>.description{
font-size: 12px;
color: #666;
text-align: left;
}
/**************网站底部样式*************************/
.footer{
color: #777;

View File

@ -139,7 +139,7 @@
<div class="form-group">
<div class="pull-left" style="width: 620px">
<div class="form-group required">
<label class="text-label col-sm-2">项目</label>
<label class="text-label col-sm-2">项目空间</label>
<div class="col-sm-10">
<select class="js-data-example-ajax-add form-control" multiple="multiple" name="itemId" id="itemId"></select>
</div>
@ -207,7 +207,7 @@
<div class="modal-body">
<div class="form-group">
<div class="form-group required">
<label class="text-label">项目</label>
<label class="text-label">项目空间</label>
<select class="js-data-example-ajax-import form-control" multiple="multiple" name="itemId"></select>
</div>
<div class="form-group required">
@ -503,7 +503,7 @@
var itemId = $("#itemId").val();
if (itemId <= 0) {
return showError("请选择项目")
return showError("请选择项目空间")
}
var bookName = $.trim($("#bookName").val());
if (bookName === "") {
@ -571,7 +571,7 @@
var itemId = $then.find("input[name='itemId']").val();
if (itemId <= 0) {
return showError("请选择项目")
return showError("请选择项目空间")
}
var bookName = $.trim($then.find("input[name='book_name']").val());

View File

@ -62,7 +62,7 @@
<p class="text">项目标识用来标记项目的唯一性,不可修改。</p>
</div>
<div class="form-group">
<label>项目</label>
<label>项目空间</label>
<select class="js-data-example-ajax form-control" multiple="multiple" name="itemId">
<option value="{{.Model.ItemId}}" selected="selected">{{.Model.ItemName}}</option>
</select>

View File

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>项目列表 - Powered by MinDoc</title>
<title>项目空间列表 - Powered by MinDoc</title>
<meta name="keywords" content="MinDoc,文档在线管理系统,WIKI,wiki,wiki在线,文档在线管理,接口文档在线管理,接口文档管理">
<meta name="description" content="MinDoc文档在线管理系统 {{.site_description}}">
<meta name="author" content="Minho" />
@ -15,45 +15,29 @@
<link href="{{cdncss "/static/font-awesome/css/font-awesome.min.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/css/main.css" "version"}}" rel="stylesheet">
</head>
<body>
<div class="manual-reader manual-container manual-search-reader">
{{template "widgets/header.tpl" .}}
<div class="container manual-body">
<div class="search-head">
<strong class="search-title">项目列表</strong>
<strong class="search-title">项目空间列表</strong>
</div>
<div class="row">
<div class="hide tag-container-outer" style="border: 0;margin-top: 0;padding: 5px 15px;min-height: 200px;">
<div class="attach-list" id="ItemsetsList">
<table class="table">
<thead>
<tr>
<th width="10%">#</th>
<th width="30%">项目集名称</th>
<th width="20%">项目集标识</th>
<th width="10%">项目数量</th>
<th width="15%">创建时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{{range $index,$item := .Lists}}
<tr>
<td>{{$item.ItemId}}</td>
<td>{{$item.ItemName}}</td>
<td>{{$item.ItemKey}}</td>
<td>{{$item.BookNumber}}</td>
<td>{{$item.CreateTimeString}}</td>
<td>
<a href="{{urlfor "ItemsetsController.List" ":key" $item.ItemKey}}" class="btn btn-success btn-sm" target="_blank" title="{{$item.ItemName}}">详情</a>
</td>
</tr>
<a href="{{urlfor "ItemsetsController.List" ":key" $item.ItemKey}}" class="ui-card" title="{{$item.ItemName}}">
<div class="header">{{$item.ItemName}}</div>
<div class="description">项目数量:{{$item.BookNumber}} &nbsp; 创建人:{{$item.CreateName}}<br/> 创建时间:{{$item.CreateTimeString}}</div>
</a>
{{else}}
<tr><td class="text-center" colspan="6">暂无数据</td></tr>
<div class="search-empty">
<img src="{{cdnimg "/static/images/search_empty.png"}}" class="empty-image">
<span class="empty-text">没有项目空间</span>
</div>
{{end}}
</tbody>
</table>
</div>
</div>

View File

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>项目{{.Model.ItemName}}的项目列表 - Powered by MinDoc</title>
<title>项目空间{{.Model.ItemName}}的项目列表 - Powered by MinDoc</title>
<meta name="keywords" content="MinDoc,文档在线管理系统,WIKI,wiki,wiki在线,文档在线管理,接口文档在线管理,接口文档管理,{{.Model.ItemName}}">
<meta name="description" content="MinDoc文档在线管理系统 {{.site_description}}">
<!-- Bootstrap -->
@ -19,7 +19,7 @@
{{template "widgets/header.tpl" .}}
<div class="container manual-body">
<div class="search-head">
<strong class="search-title">显示项目为"{{.Model.ItemName}}"的项目</strong>
<strong class="search-title">显示项目空间为"{{.Model.ItemName}}"的项目</strong>
</div>
<div class="row">
<div class="manual-list">

View File

@ -49,7 +49,7 @@
<input type="text" class="form-control" value="{{urlfor "DocumentController.Index" ":key" .Model.Identify}}" disabled placeholder="项目标识">
</div>
<div class="form-group">
<label>项目</label>
<label>项目空间</label>
<select class="js-data-example-ajax form-control" multiple="multiple" name="itemId">
<option value="{{.Model.ItemId}}" selected="selected">{{.Model.ItemName}}</option>
</select>

View File

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>项目管理 - Powered by MinDoc</title>
<title>项目空间管理 - Powered by MinDoc</title>
<!-- Bootstrap -->
<link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet" type="text/css">
@ -22,9 +22,9 @@
<div class="page-right">
<div class="m-box">
<div class="box-head">
<strong class="box-title">项目管理</strong>
<strong class="box-title">项目空间管理</strong>
{{if eq .Member.Role 0}}
<button type="button" class="btn btn-success btn-sm pull-right" data-toggle="modal" data-target="#addItemsetsDialogModal"><i class="fa fa-plus" aria-hidden="true"></i> 创建项目</button>
<button type="button" class="btn btn-success btn-sm pull-right" data-toggle="modal" data-target="#addItemsetsDialogModal"><i class="fa fa-plus" aria-hidden="true"></i> 创建项目空间</button>
{{end}}
</div>
</div>
@ -34,8 +34,8 @@
<thead>
<tr>
<th width="10%">#</th>
<th width="30%">项目名称</th>
<th width="20%">项目标识</th>
<th width="30%">项目空间名称</th>
<th width="20%">项目空间标识</th>
<th width="20%">项目数量</th>
<th>操作</th>
</tr>
@ -75,20 +75,20 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">创建项目</h4>
<h4 class="modal-title" id="myModalLabel">创建项目空间</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label class="col-sm-3 control-label" for="account">项目名称<span class="error-message">*</span></label>
<label class="col-sm-3 control-label" for="account">项目空间名称<span class="error-message">*</span></label>
<div class="col-sm-9">
<input type="text" name="itemName" class="form-control" placeholder="项目名称" id="itemName" maxlength="50">
<input type="text" name="itemName" class="form-control" placeholder="项目空间名称" id="itemName" maxlength="50">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="itemKey">项目标识<span class="error-message">*</span></label>
<label class="col-sm-3 control-label" for="itemKey">项目空间标识<span class="error-message">*</span></label>
<div class="col-sm-9">
<input type="text" name="itemKey" id="itemKey" class="form-control" placeholder="项目标识" maxlength="50">
<p class="text">项目标识只能由字母和数字组成且在2-100字符之间</p>
<input type="text" name="itemKey" id="itemKey" class="form-control" placeholder="项目空间标识" maxlength="50">
<p class="text">项目空间标识只能由字母和数字组成且在2-100字符之间</p>
</div>
</div>
<div class="clearfix"></div>
@ -110,19 +110,19 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">编辑项目</h4>
<h4 class="modal-title" id="myModalLabel">编辑项目空间</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label class="col-sm-2 control-label" for="itemName">项目集名称<span class="error-message">*</span></label>
<div class="col-sm-10">
<input type="text" name="itemName" id="itemName" class="form-control" placeholder="项目名称" maxlength="50">
<label class="col-sm-3 control-label" for="itemName">项目空间名称<span class="error-message">*</span></label>
<div class="col-sm-9">
<input type="text" name="itemName" id="itemName" class="form-control" placeholder="项目空间名称" maxlength="50">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="itemKey">项目集标识<span class="error-message">*</span></label>
<div class="col-sm-10">
<input type="text" name="itemKey" id="itemKey" class="form-control" placeholder="项目标识" maxlength="50">
<label class="col-sm-3 control-label" for="itemKey">项目空间标识<span class="error-message">*</span></label>
<div class="col-sm-9">
<input type="text" name="itemKey" id="itemKey" class="form-control" placeholder="项目空间标识" maxlength="50">
</div>
</div>
<div class="clearfix"></div>
@ -164,10 +164,10 @@
var $itemKey = addItemsetsDialogForm.find("input[name='itemKey']").val();
if ($itemName == "") {
showError("项目名称不能为空","#create-form-error-message");
showError("项目空间名称不能为空","#create-form-error-message");
}
if ($itemKey == "") {
showError("项目标识不能为空","#create-form-error-message");
showError("项目空间标识不能为空","#create-form-error-message");
}
$("#btnAddItemsets").button("loading");
showError("","#create-form-error-message");
@ -194,10 +194,10 @@
var $itemKey = editItemsetsDialogForm.find("input[name='itemKey']").val();
if ($itemName == "") {
showError("项目名称不能为空","#edit-form-error-message");
showError("项目空间名称不能为空","#edit-form-error-message");
}
if ($itemKey == "") {
showError("项目标识不能为空","#edit-form-error-message");
showError("项目空间标识不能为空","#edit-form-error-message");
}
$("#btnEditItemsets").button("loading");
showError("","#edit-form-error-message");

View File

@ -4,7 +4,7 @@
<li{{if eq "users" .}} class="active"{{end}}><a href="{{urlfor "ManagerController.Users" }}" class="item"><i class="fa fa-user" aria-hidden="true"></i> 用户管理</a> </li>
<li{{if eq "team" .}} class="active"{{end}}><a href="{{urlfor "ManagerController.Team" }}" class="item"><i class="fa fa-group" aria-hidden="true"></i> 团队管理</a> </li>
<li{{if eq "books" .}} class="active"{{end}}><a href="{{urlfor "ManagerController.Books" }}" class="item"><i class="fa fa-book" aria-hidden="true"></i> 项目管理</a> </li>
<li{{if eq "itemsets" .}} class="active"{{end}}><a href="{{urlfor "ManagerController.Itemsets" }}" class="item"><i class="fa fa-archive" aria-hidden="true"></i> 项目管理</a> </li>
<li{{if eq "itemsets" .}} class="active"{{end}}><a href="{{urlfor "ManagerController.Itemsets" }}" class="item"><i class="fa fa-archive" aria-hidden="true"></i> 项目空间管理</a> </li>
{{/*<li><a href="{{urlfor "ManagerController.Comments" }}" class="item"><i class="fa fa-comments-o" aria-hidden="true"></i> </a> </li>*/}}
<li{{if eq "setting" .}} class="active"{{end}}><a href="{{urlfor "ManagerController.Setting" }}" class="item"><i class="fa fa-cogs" aria-hidden="true"></i> 配置管理</a> </li>

View File

@ -17,7 +17,7 @@
<a href="{{urlfor "BlogController.List" }}" title="文章">文章</a>
</li>
<li {{if eq .ControllerName "ItemsetsController"}}class="active"{{end}}>
<a href="{{urlfor "ItemsetsController.Index" }}" title="项目集">项目集</a>
<a href="{{urlfor "ItemsetsController.Index" }}" title="项目空间">项目空间</a>
</li>
</ul>
<div class="searchbar pull-left visible-lg-inline-block visible-md-inline-block">