You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

select_pro.tmpl 12 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <style>
  2. .text-right{
  3. float:right !important;
  4. }
  5. .header{
  6. font-weight:bold;
  7. font-size: 18px;
  8. font-family: SourceHanSansSC-medium;
  9. }
  10. .cor{
  11. color:#0366D6 !important;
  12. }
  13. .header_card{
  14. /* color:#003A8C !important; */
  15. color:#0366D6 !important;
  16. margin: 10px 0 0px 0;
  17. height: 25px;
  18. }
  19. .marg{
  20. margin: 0 5px !important;
  21. }
  22. .content_list{
  23. max-height: 130px;
  24. overflow: auto;
  25. }
  26. .Relist{
  27. color:#0366D6 !important;
  28. }
  29. .descript_height{
  30. color: #101010 !important;
  31. margin: 10px 0;
  32. height: 40px !important;
  33. word-break:break-all;
  34. line-height: 20px;
  35. overflow: hidden;
  36. /* overflow: hidden!important;
  37. word-wrap:break-word!important; */
  38. }
  39. .tags_height{
  40. height: 30px !important;
  41. }
  42. .full_height{
  43. height: 100%;
  44. }
  45. .omit{
  46. overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  47. }
  48. /deep/ ui.checkbox input[type=checkbox]::after{
  49. border: 1px solid #0366D6 !important;
  50. }
  51. .nowrap-2 {
  52. /* height: 2.837em; */
  53. /* line-height: 1.4285em; */
  54. overflow: hidden;
  55. overflow: hidden;
  56. display: -webkit-box;
  57. -webkit-line-clamp: 2;
  58. -webkit-box-orient: vertical;
  59. }
  60. .ui.cards>.card>.extra .tags > a{
  61. margin-top: 5px;
  62. }
  63. </style>
  64. <div class="ui stackable grid">
  65. <div style="width: 100%;margin:15px 0;">
  66. {{if .tags}}
  67. <span class="header">
  68. {{.i18n.Tr "org.selected_project"}}
  69. </span>
  70. <!-- {{.IsOrganizationOwner}} -->
  71. {{if .IsOrganizationOwner}}
  72. <a class="text-right" id="model" onclick="showcreate()" >{{svg "octicon-gear" 16}}{{.i18n.Tr "org.customize"}}</a>
  73. {{end}}
  74. {{end}}
  75. </div>
  76. <div style="width: 100%;">
  77. {{ range .tags}}
  78. {{if eq .TagName "精选项目"}}
  79. <div class="ui three cards" style="margin-bottom: 10px;">
  80. {{ range .RepoList}}
  81. <div class="card" >
  82. <div class="extra full_height cor" >
  83. <div class=" header header_card omit" >
  84. <a class="header_card image poping up " href="{{.Link}}" data-content="{{if .Alias}}{{.Alias}}{{else}}{{.Name}}{{end}}" data-position="top left" data-variation="tiny inverted">{{if .Alias}}{{.Alias}}{{else}}{{.Name}}{{end}}</a>
  85. </div>
  86. <div class='content descript_height nowrap-2'>
  87. {{.Description}}
  88. </div>
  89. <div class="content " >
  90. {{if .Topics }}
  91. <div class=" tags " style="position: relative;">
  92. {{range .Topics}}
  93. {{if ne . "" }}<a style="max-width:100%;display:inline-flex;" href="{{AppSubUrl}}/explore/repos?q={{.}}&topic={{$.Topic}}" ><span class="ui small label topic omit" >{{.}}</span></a>{{end}}
  94. {{end}}
  95. </div>
  96. {{end}}
  97. </div>
  98. </div>
  99. <div class=" extra " style="color:#888888;border-top: none !important;padding-top: 0">
  100. <div class="ui mini right compact marg" >
  101. <a class="item marg ">
  102. {{svg "octicon-eye" 16}} {{.NumWatches}}
  103. </a>
  104. <a class="item marg">
  105. {{svg "octicon-star" 16}} {{.NumStars}}
  106. </a>
  107. <a class="item marg">
  108. {{svg "octicon-git-branch" 16}} {{.NumForks}}
  109. </a>
  110. </div>
  111. </div>
  112. </div>
  113. {{end}}
  114. </div>
  115. {{end}}
  116. {{end}}
  117. </div>
  118. </div>
  119. <div class="ui modal">
  120. <div class="header" style="padding: 1rem;background-color: rgba(240, 240, 240, 100);">
  121. <h4 id="model_header">{{.i18n.Tr "org.custom_select_projects"}}</h4>
  122. </div>
  123. <div class="content content-padding" style="color: black;">
  124. <p>{{.i18n.Tr "org.max_selectedPro"}}</p>
  125. <div class="ui search" >
  126. <div class="ui input" style="width: 100%;">
  127. <input type="text" id = 'search_selectPro' placeholder="Search ..." value = '' oninput="search()">
  128. </div>
  129. </div>
  130. <div style="margin: 10px ;">
  131. <div id ='org_list' style="margin-bottom: 20px;"class="content_list" >
  132. </div>
  133. </div>
  134. <p id='recommend'></p>
  135. <div class="inline field" style="margin-left: 37%;">
  136. <div class="actions">
  137. <button id="submitId" type="button" class="ui create_train_job green deny button" onclick="saveSeletedPro(1)">
  138. {{.i18n.Tr "explore.save"}}
  139. </button>
  140. <button class="ui button cancel" >{{.i18n.Tr "explore.cancel"}}</button>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. <script>
  146. console.log({{.tags}})
  147. var data;
  148. var filterData=[];
  149. var num=0;
  150. function showcreate(obj){
  151. document.getElementById("search_selectPro").value=''
  152. $('.ui.modal')
  153. .modal({
  154. centered: false,
  155. onShow:function(){
  156. $("#org_list").empty()
  157. getPro(1)
  158. },
  159. onHide:function(){
  160. }
  161. })
  162. .modal('show')
  163. }
  164. function getPro(typeTag){
  165. $.ajax({
  166. type:"GET",
  167. url:"/org/{{.Org.Name}}/org_tag/repo_list?tagId="+typeTag,
  168. dataType:"json",
  169. async:false,
  170. success:function(json){
  171. data = json.data;
  172. var n_length = data.length
  173. pro_html = getHTML(data)
  174. $("#org_list").append(pro_html)
  175. // console.log('原始',data)
  176. checkedNum(0)
  177. }
  178. });
  179. }
  180. function getHTML(data){
  181. let pro_html=''
  182. for (let i=0;i<data.length;i++){
  183. if (data[i].Selected==true){
  184. console.log("data[i]:",data[i])
  185. pro_html += `<div class="ui checkbox" style="width: 33%;margin-bottom:10px" > <input type="checkbox" id = " ${i}" checked="" onclick="checkedNum(${i})" class="Relist" name ='select_pro_name' data-repoid="${data[i].RepoID}" data-reponame="${data[i].RepoName}" data-selected=${data[i].Selected} > <label class='omit image poping up' data-content=${data[i].RepoName}  data-position="top left " data-variation="mini"> ${data[i].RepoName}</label></div>`
  186. pro_html += '</div>'
  187. }
  188. else{
  189. pro_html += `<div class="ui checkbox" style="width: 33%;margin-bottom:10px" > <input type="checkbox" id = "${i}" onclick="checkedNum(${i})" class="Relist" name ='select_pro_name' data-repoid="${data[i].RepoID}" data-reponame="${data[i].RepoName}" data-selected= ${data[i].Selected}> <label class='omit image poping up' data-content=${data[i].RepoName}  data-position="top left " data-variation="mini"> ${data[i].RepoName} </label></div>`
  190. pro_html += '</div>'
  191. }
  192. }
  193. return pro_html
  194. }
  195. function saveSeletedPro(typeTag){
  196. var saveData=[];
  197. $('input[name="select_pro_name"]:checked').each(function(){
  198. // console.log('值',this.dataset.repoid)
  199. saveData.push(parseInt(this.dataset.repoid));
  200. })
  201. if(saveData.length>9){
  202. alert("{{.i18n.Tr "org.save_fail_tips"}}")
  203. return
  204. }
  205. // saveData = getSelecteDataID();
  206. // console.log("数据:",saveData)
  207. $.ajax({
  208. type:"POST",
  209. url:"/org/{{.Org.Name}}/org_tag/repo_submit?tagId="+typeTag,
  210. contentType:'application/json',
  211. dataType:"json",
  212. async:false,
  213. data:JSON.stringify({'repoList':saveData
  214. }),
  215. success:function(res){
  216. // console.log('保存成功');
  217. location.reload()
  218. }
  219. });
  220. }
  221. function getSelecteData(){
  222. var selectedData=[];
  223. $('input[name="select_pro_name"]:checked').each(function(){
  224. // console.log(this)
  225. // console.log('值',this.dataset.selected)
  226. selectedData.push({"RepoID":parseInt(this.dataset.repoid),"RepoName":this.dataset.reponame,"Selected":JSON.parse(this.dataset.selected)});
  227. })
  228. return selectedData
  229. }
  230. function search(){
  231. var selectedData = getSelecteData();
  232. var searchValue = document.getElementById("search_selectPro").value;
  233. filterData=[];
  234. console.log("searchValue:",searchValue)
  235. for (let i=0;i<data.length;i++){
  236. var isInclude=false;
  237. if(data[i].RepoName.toLowerCase().includes(searchValue.toLowerCase())){
  238. filterData.push(data[i])
  239. }
  240. }
  241. // console.log("选中的值:",selectedData)
  242. // console.log("筛选包括选中的值:",filterData)
  243. var showData=[];
  244. for(i=0;i<selectedData.length;i++){
  245. filterData =filterData.filter((item)=>{
  246. return item.RepoID!=selectedData[i].RepoID
  247. });
  248. }
  249. // console.log("筛选后不包括选中的值:",filterData)
  250. $("#org_list").empty()
  251. if(searchValue!=""){
  252. if (filterData.length!=0){
  253. var pro_html = getHTML(selectedData);
  254. console.log("selectedData_pro_html:",pro_html)
  255. $("#org_list").append(pro_html)
  256. pro_html= getHTML(filterData);
  257. $("#org_list").append(pro_html)
  258. }else{
  259. var pro_html = getHTML(selectedData);
  260. $("#org_list").append(pro_html)
  261. }
  262. }else{
  263. var pro_html = getHTML(data);
  264. $("#org_list").append(pro_html)
  265. }
  266. }
  267. function checkedNum(id){
  268. num=0;
  269. var inputs = document.getElementsByName("select_pro_name")
  270. for (var i=0;i<inputs.length;i++){
  271. if(inputs[i].checked){
  272. num++
  273. if(num>9){
  274. document.getElementById(id).checked=false
  275. alert("{{.i18n.Tr "org.select_again"}}")
  276. return
  277. }
  278. }
  279. }
  280. var show_num = 9-num;
  281. let rec = "{{.i18n.Tr "org.recommend_remain_pro"}}"
  282. document.getElementById("recommend").innerHTML=rec +" : "+ show_num
  283. }
  284. </script>