| @@ -632,8 +632,11 @@ show_dataset= Dataset | |||||
| edit_dataset= Edit Dataset | edit_dataset= Edit Dataset | ||||
| update_dataset= Update Dataset | update_dataset= Update Dataset | ||||
| category = Category | category = Category | ||||
| no_category = No Category | |||||
| task = Task | task = Task | ||||
| no_task = No Task | |||||
| license = License | license = License | ||||
| no_license = No License | |||||
| file = Dataset File | file = Dataset File | ||||
| download = download | download = download | ||||
| edit = edit | edit = edit | ||||
| @@ -632,8 +632,11 @@ show_dataset=数据集 | |||||
| edit_dataset=编辑数据集 | edit_dataset=编辑数据集 | ||||
| update_dataset=更新数据集 | update_dataset=更新数据集 | ||||
| category=分类 | category=分类 | ||||
| task=针对的具体任务 | |||||
| no_category=未设置分类 | |||||
| task=研究方向/应用领域 | |||||
| no_task=未设置研究方向/应用领域 | |||||
| license=license | license=license | ||||
| no_license=没有设置license | |||||
| file=数据集文件 | file=数据集文件 | ||||
| download=下载附件 | download=下载附件 | ||||
| edit=编辑 | edit=编辑 | ||||
| @@ -15,7 +15,7 @@ const ( | |||||
| func DatasetIndex(ctx *context.Context) { | func DatasetIndex(ctx *context.Context) { | ||||
| ctx.Data["PageIsDataset"] = true | ctx.Data["PageIsDataset"] = true | ||||
| ctx.Data["Title"] = ctx.Tr("dataset.show_dataset") | ctx.Data["Title"] = ctx.Tr("dataset.show_dataset") | ||||
| ctx.Data["Link"] = ctx.Repo.RepoLink + "/datasets/5/edit" | |||||
| ctx.Data["Link"] = ctx.Repo.RepoLink + "/datasets" | |||||
| user := ctx.User | user := ctx.User | ||||
| dataset, err := models.GetDatasetByID(5) | dataset, err := models.GetDatasetByID(5) | ||||
| if err != nil { | if err != nil { | ||||
| @@ -38,13 +38,14 @@ func DatasetIndex(ctx *context.Context) { | |||||
| } | } | ||||
| func EditDatasetPost(ctx *context.Context, form auth.EditDatasetForm) { | func EditDatasetPost(ctx *context.Context, form auth.EditDatasetForm) { | ||||
| ctx.Data["PageIsDataset"] = true | |||||
| ctx.Data["Title"] = ctx.Tr("dataset.edit_dataset") | ctx.Data["Title"] = ctx.Tr("dataset.edit_dataset") | ||||
| rel, err := models.GetDatasetByID(ctx.ParamsInt64(":id")) | |||||
| rel, err := models.GetDatasetByID(5) | |||||
| ctx.Data["dataset"] = rel | ctx.Data["dataset"] = rel | ||||
| if err != nil { | if err != nil { | ||||
| ctx.Data["Error"] = true | |||||
| ctx.ServerError("GetDataset", err) | ctx.ServerError("GetDataset", err) | ||||
| return | return | ||||
| } | } | ||||
| @@ -61,7 +62,9 @@ func EditDatasetPost(ctx *context.Context, form auth.EditDatasetForm) { | |||||
| rel.Task = form.Task | rel.Task = form.Task | ||||
| rel.License = form.License | rel.License = form.License | ||||
| if err = models.UpdateDataset(models.DefaultDBContext(), rel); err != nil { | if err = models.UpdateDataset(models.DefaultDBContext(), rel); err != nil { | ||||
| ctx.Data["Error"] = true | |||||
| ctx.HTML(200, tplIndex) | |||||
| log.Error("%v", err) | log.Error("%v", err) | ||||
| } | } | ||||
| ctx.HTML(200, tplIndex) | |||||
| ctx.Redirect(ctx.Repo.RepoLink + "/datasets") | |||||
| } | } | ||||
| @@ -764,7 +764,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| }, context.RepoMustNotBeArchived()) | }, context.RepoMustNotBeArchived()) | ||||
| m.Group("/datasets", func() { | m.Group("/datasets", func() { | ||||
| m.Get("", repo.DatasetIndex) | m.Get("", repo.DatasetIndex) | ||||
| m.Post("/:id/edit", bindIgnErr(auth.EditDatasetForm{}), repo.EditDatasetPost) | |||||
| m.Post("", bindIgnErr(auth.EditDatasetForm{}), repo.EditDatasetPost) | |||||
| }, context.RepoMustNotBeArchived()) | }, context.RepoMustNotBeArchived()) | ||||
| m.Group("/comments/:id", func() { | m.Group("/comments/:id", func() { | ||||
| m.Post("", repo.UpdateCommentContent) | m.Post("", repo.UpdateCommentContent) | ||||
| @@ -29,7 +29,7 @@ | |||||
| </div> | </div> | ||||
| <div class="sixteen wide column"> | <div class="sixteen wide column"> | ||||
| <a class="ui button" id="cancel">{{.i18n.Tr "cancel"}}</a> | <a class="ui button" id="cancel">{{.i18n.Tr "cancel"}}</a> | ||||
| <button class="ui primary button">{{.i18n.Tr "dataset.update_dataset"}}</button> | |||||
| <button class="ui primary button" id="submit">{{.i18n.Tr "dataset.update_dataset"}}</button> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| @@ -9,18 +9,23 @@ | |||||
| {{svg "octicon-gear" 16}} | {{svg "octicon-gear" 16}} | ||||
| </span> | </span> | ||||
| <div class="filter menu"> | <div class="filter menu"> | ||||
| <input type="hidden" name="category" id="category" value="{{.dataset.Category}}"> | |||||
| {{range $category := categories}} | {{range $category := categories}} | ||||
| <a class="item" data-id="{{$category}}" data-href="{{$.RepoLink}}/issues?milestone={{$category}}"> {{$.i18n.Tr (printf "dataset.category.%s" $category)}}</a> | |||||
| <a class="checked item" data-category-id="{{$category}}"> | |||||
| {{if eq $category $.dataset.Category}} | |||||
| <span class="octicon-check">{{svg "octicon-check" 16}}</span> | |||||
| {{end}} | |||||
| {{$.i18n.Tr (printf "dataset.category.%s" $category)}} | |||||
| </a> | |||||
| {{end}} | {{end}} | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <div class="ui select-milestone list"> | <div class="ui select-milestone list"> | ||||
| <span class="no-select item {{if .Issue.Milestone}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_milestone"}}</span> | |||||
| <div class="selected"> | |||||
| {{if .dataset.Category}} | |||||
| <a class="item" href="{{.RepoLink}}/milestone/{{.Issue.Milestone.ID}}"> {{$.i18n.Tr (printf "dataset.category.%s" .dataset.Category)}}</a> | |||||
| {{end}} | |||||
| </div> | |||||
| {{if .dataset.Category}} | |||||
| <a class="item" href="javascript:void(0)"> {{$.i18n.Tr (printf "dataset.category.%s" .dataset.Category)}}</a> | |||||
| {{else}} | |||||
| <span class="no-select item">{{.i18n.Tr "dataset.no_category"}}</span> | |||||
| {{end}} | |||||
| </div> | </div> | ||||
| <div class="ui divider"></div> | <div class="ui divider"></div> | ||||
| <div class="ui floating jump select-milestone dropdown"> | <div class="ui floating jump select-milestone dropdown"> | ||||
| @@ -29,18 +34,18 @@ | |||||
| {{svg "octicon-gear" 16}} | {{svg "octicon-gear" 16}} | ||||
| </span> | </span> | ||||
| <div class="filter menu"> | <div class="filter menu"> | ||||
| <input type="hidden" name="task" id="task" value="{{.dataset.Task}}"> | |||||
| {{range $task := tasks}} | {{range $task := tasks}} | ||||
| <a class="item" data-id="{{$task}}" data-href="{{$.RepoLink}}/issues?milestone={{$task}}"> {{$.i18n.Tr (printf "dataset.task.%s" $task)}}</a> | |||||
| <a class="item" data-task-id="{{$task}}"> {{$.i18n.Tr (printf "dataset.task.%s" $task)}}</a> | |||||
| {{end}} | {{end}} | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <div class="ui select-milestone list"> | <div class="ui select-milestone list"> | ||||
| <span class="no-select item {{if .Issue.Milestone}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_milestone"}}</span> | |||||
| <div class="selected"> | |||||
| {{if .dataset.Task}} | |||||
| <a class="item" href="{{.RepoLink}}/milestone/{{.Issue.Milestone.ID}}"> {{$.i18n.Tr (printf "dataset.category.%s" .dataset.Task)}}</a> | |||||
| {{end}} | |||||
| </div> | |||||
| {{if .dataset.Task}} | |||||
| <a class="item" href="javascript:void(0)"> {{$.i18n.Tr (printf "dataset.task.%s" .dataset.Task)}}</a> | |||||
| {{else}} | |||||
| <span class="no-select item">{{.i18n.Tr "dataset.no_task"}}</span> | |||||
| {{end}} | |||||
| </div> | </div> | ||||
| <div class="ui divider"></div> | <div class="ui divider"></div> | ||||
| <div class="ui floating jump select-milestone dropdown"> | <div class="ui floating jump select-milestone dropdown"> | ||||
| @@ -49,17 +54,17 @@ | |||||
| {{svg "octicon-gear" 16}} | {{svg "octicon-gear" 16}} | ||||
| </span> | </span> | ||||
| <div class="filter menu"> | <div class="filter menu"> | ||||
| <input type="hidden" name="license" id="license" value="{{.dataset.License}}"> | |||||
| {{range $license := licenses}} | {{range $license := licenses}} | ||||
| <a class="item" data-id="{{$license}}" data-href="{{$.RepoLink}}/issues?milestone={{$license}}"> {{$license}}</a> | |||||
| <a class="item" data-license-id="{{$license}}"> {{$license}}</a> | |||||
| {{end}} | {{end}} | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <div class="ui select-milestone list"> | <div class="ui select-milestone list"> | ||||
| <span class="no-select item {{if .Issue.Milestone}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_milestone"}}</span> | |||||
| <div class="selected"> | |||||
| {{if .dataset.License}} | |||||
| <a class="item" href="{{.RepoLink}}/milestone/{{.Issue.Milestone.ID}}"> {{.dataset.License}}</a> | |||||
| {{end}} | |||||
| </div> | |||||
| {{if .dataset.License}} | |||||
| <a class="item" href="javascript:void(0)"> {{.dataset.License}}</a> | |||||
| {{else}} | |||||
| <span class="no-select item">{{.i18n.Tr "dataset.no_license"}}</span> | |||||
| {{end}} | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| @@ -1094,6 +1094,21 @@ async function initRepository() { | |||||
| $('#dataset-content input').focus(); | $('#dataset-content input').focus(); | ||||
| return false; | return false; | ||||
| }; | }; | ||||
| $('[data-category-id]').on('click', function () { | |||||
| const category = $(this).data('category-id'); | |||||
| $('#category').val(category); | |||||
| $('#submit').click(); | |||||
| }); | |||||
| $('[data-task-id]').on('click', function () { | |||||
| const task = $(this).data('task-id'); | |||||
| $('#task').val(task); | |||||
| $('#submit').click(); | |||||
| }); | |||||
| $('[data-license-id]').on('click', function () { | |||||
| const license = $(this).data('license-id'); | |||||
| $('#license').val(license); | |||||
| $('#submit').click(); | |||||
| }); | |||||
| $('#dataset-edit').on('click', editContentToggle); | $('#dataset-edit').on('click', editContentToggle); | ||||
| $('#cancel').on('click', editContentToggle); | $('#cancel').on('click', editContentToggle); | ||||
| } | } | ||||