diff --git a/module/repo/control.php b/module/repo/control.php index e940ee3a82..bf51c4a382 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -1139,17 +1139,12 @@ class repo extends control * @access public * @return void */ - public function ajaxGetDropMenu($repoID, $type = 'repo', $objectID = 0) + public function ajaxGetDropMenu($repoID, $module = 'repo', $method = 'browse') { - $repos = $this->repo->getRepoPairs($type, $objectID); - $reposHtml = "
"; - foreach($repos as $id => $repoName) - { - $selected = $id == $repoID ? 'selected' : ''; - $reposHtml .= html::a($this->createLink('repo', 'browse', "repoID=$id&branchID=&objectID=$objectID"), $repoName, '', "class='$selected' data-app='{$this->app->tab}'"); - } - $reposHtml .= '
'; + $repo = $this->repo->getRepoByID($repoID); + $link = $this->createLink($module, $method, "repoID=%s"); + $reposHtml = $this->repo->getReposMenu($repo, 0, $link); return print($reposHtml); } diff --git a/module/repo/css/common.css b/module/repo/css/common.css index c107a8aff7..a19688123e 100644 --- a/module/repo/css/common.css +++ b/module/repo/css/common.css @@ -193,15 +193,18 @@ h3 {font-size: 16px;} #repoPageSize {right: 90px;} /* Style for repo select. */ -#repoList .tree li {padding: 0 0 0 15px;} -#repoList .hide-in-search .hidden {display: block !important; visibility: inherit !important;} +#dropMenu .tree li {padding: 3px 0 0 10px;} +#dropMenu .col-left {padding: 0;} +#dropMenu .label {margin-left: 3px;} +#dropMenu .hide-in-search {display: flex; flex-flow: row nowrap; justify-content: flex-start; align-items: center; padding-left: 8px;} +#dropMenu .hide-in-search .hidden {display: block !important; visibility: inherit !important;} #dropMenuRepo > div.table-row > div > div > ul > li > div {padding-left: 10px;} +#dropMenu .tree li.has-list.open:before {border-left: 0px;} +#dropMenu ul.tree-angles {margin-bottom: 0;} +#dropMenu {margin: 0;} +#dropMenu ul > li > ul > li > a:hover {color: white; background-color: #0c64eb; text-decoration: none;} +#dropMenu .tree li > a {max-width: 100%;} +#dropMenu .hide-in-search .hidden {display: block !important; visibility: inherit !important;} +#dropMenu .tree li > a {line-height: 20px; border-radius: 2px;} li > a.selected {color: #3123ae !important; background: #f2eafc !important; line-height: 20px; border-radius: 5px;} -#repoList .tree li.has-list.open:before {border-left: 0px;} -#repoList ul.tree-angles {margin-bottom: 0;} -#repoList {margin: 0;} -#repoList .tree > li {padding: 2px;} -.pull-left ul > li > ul > li > a:hover {color: white; background-color: #0c64eb; text-decoration: none;} -.pull-left .tree li > a {max-width: 100%;} -#repoList .hide-in-search .hidden {display: block !important; visibility: inherit !important;} -#repoList .tree li > a {line-height: 20px; border-radius: 2px;} +.search-list .list-group {padding: 7px 10px;} diff --git a/module/repo/model.php b/module/repo/model.php index c5fcfa2945..44ba9e9d86 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -35,7 +35,6 @@ class repoModel extends model */ public function setMenu($repos, $repoID = '', $showSeleter = true) { - if(empty($repos)) $this->lang->switcherMenu = ''; if(empty($repoID)) $repoID = $this->session->repoID ? $this->session->repoID : key($repos); if(!isset($repos[$repoID])) $repoID = key($repos); @@ -56,6 +55,8 @@ class repoModel extends model } } + $this->lang->switcherMenu = $this->getSwitcher($repoID); + common::setMenuVars('devops', $repoID); if(!session_id()) session_start(); $this->session->set('repoID', $repoID); @@ -63,54 +64,31 @@ class repoModel extends model } /** - * Create the select code of repos. + * Get switcher. * - * @param array $repos - * @param int $repoID - * @param string $type - * @param int $objectID + * @param int $repoID * @access public * @return string */ - public function select($repos, $repoID, $type = 'repo', $objectID = 0) + public function getSwitcher($repoID) { - $output = ''; - if(!empty($repos)) + $currentModule = $this->app->moduleName; + $currentMethod = $this->app->methodName; + $currentRepo = $this->getRepoByID($repoID); + $currentRepoName = $currentRepo->name; + + if($this->app->viewType == 'mhtml' and $repoID) { - $dropMenuLink = helper::createLink('repo', 'ajaxGetDropMenu', "repoID=$repoID&type=$type&objectID=$objectID"); - - $repo = $this->dao->findById($repoID)->from(TABLE_REPO)->fetch(); - $scm = $repo->SCM == 'Subversion' ? 'svn' : 'git'; - - $output = "
"; - - $branches = $this->getBranches($repo); - if(empty($branches)) - { - $this->setRepoBranch(''); - } - else - { - $branchID = 'master'; - if($this->cookie->repoBranch) $branchID = $this->cookie->repoBranch; - if(!isset($branches[$branchID])) $branchID = 'master'; - - $branch = zget($branches, $branchID); - if(empty($branch)) $branchID = $branch = current($branches); - - $this->setRepoBranch($branchID); - - $branchName = isset($branches[$branch]) ? $branches[$branch] : $branches[0]; - - $dropMenuLink = helper::createLink('repo', 'ajaxGetBranchDropMenu', "repID=$repoID&branchID=" . base64_encode($branchID) . "&objectID=$objectID"); - $output .= "
"; - } + $output = $this->lang->repo->common . $this->lang->colon; + $output .= "{$currentRepoName} "; + return $output; } + $dropMenuLink = helper::createLink('repo', 'ajaxGetDropMenu', "repoID=$repoID&module=$currentModule&method=$currentMethod"); + + $output = "
"; + return $output; } @@ -2134,25 +2112,15 @@ class repoModel extends model * @param string $link * @param string $scm * @access public - * @return void + * @return string */ public function getReposMenu($repo, $objectID = 0, $link = '', $scm = '') { if(empty($link)) $link = helper::createLink('repo', 'browse', "repoID=%s&branchID=&objectID=$objectID"); - $html = ""; - $html .= "