* Refact manage view page and priv by group page of group.

This commit is contained in:
liugang
2018-04-23 17:47:23 +08:00
parent 6dbe39bf81
commit 8153dae1bd
9 changed files with 214 additions and 175 deletions
+7 -4
View File
@@ -130,8 +130,10 @@ class group extends control
{
if($_POST)
{
$result = $this->group->updateView($groupID);
die(js::alert($result ? $this->lang->group->successSaved : $this->lang->group->errorNotSaved));
$this->group->updateView($groupID);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
}
$group = $this->group->getById($groupID);
@@ -167,8 +169,9 @@ class group extends control
{
if($type == 'byGroup') $result = $this->group->updatePrivByGroup($groupID, $menu, $version);
if($type == 'byModule') $result = $this->group->updatePrivByModule();
print(js::alert($result ? $this->lang->group->successSaved : $this->lang->group->errorNotSaved));
exit;
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
}
if($type == 'byGroup')
+1
View File
@@ -0,0 +1 @@
.checkbox-inline {display: inline-block !important; padding-left: 0px;}
+1
View File
@@ -3,3 +3,4 @@
.group-item {display:block; width:200px; float:left; font-size: 14px}
.outer .table.table-form tbody > tr:last-child td {border-top: 1px solid #ddd}
@-moz-document url-prefix(){.outer .table.table-form tbody > tr:last-child td, .outer .table.table-form tbody > tr:last-child th {border-bottom: 1px solid #ddd}}
.checkbox-inline {display: inline-block !important; padding-left: 0px;}
+18
View File
@@ -25,3 +25,21 @@ function setNoChecked()
})
$('#noChecked').val(noCheckValue);
}
$(function()
{
$('#privList > tbody > tr > th input[type=checkbox]').change(function()
{
var id = $(this).attr('id');
var checked = $(this).prop('checked');
if(id == 'allChecker')
{
$('input[type=checkbox]').prop('checked', checked);
}
else
{
$(this).parents('tr').find('input[type=checkbox]').prop('checked', checked);
}
});
})
+3 -3
View File
@@ -44,10 +44,10 @@
<td title='<?php echo $users;?>'><?php echo $users;?></td>
<td class='c-actions'>
<?php $lang->group->managepriv = $lang->group->managePrivByGroup;?>
<?php common::printIcon('group', 'manageView', "groupID=$group->id", $group, 'list', 'plus');?>
<?php common::printIcon('group', 'managepriv', "type=byGroup&param=$group->id", $group, 'list', 'plus');?>
<?php common::printIcon('group', 'manageView', "groupID=$group->id", $group, 'list', 'pencil');?>
<?php common::printIcon('group', 'managepriv', "type=byGroup&param=$group->id", $group, 'list', 'pencil');?>
<?php $lang->group->managemember = $lang->group->manageMember;?>
<?php common::printIcon('group', 'managemember', "groupID=$group->id", $group, 'list', 'plus', '', 'iframe', 'yes');?>
<?php common::printIcon('group', 'managemember', "groupID=$group->id", $group, 'list', 'pencil', '', 'iframe', 'yes');?>
<?php common::printIcon('group', 'edit', "groupID=$group->id", $group, 'list', '', '', 'iframe', 'yes', "data-width='550'");?>
<?php common::printIcon('group', 'copy', "groupID=$group->id", $group, 'list', '', '', 'iframe', 'yes', "data-width='550'");?>
<?php
+5 -2
View File
@@ -27,9 +27,12 @@
</tr>
<tr>
<th><?php echo $lang->group->option;?></th>
<td><?php echo html::checkbox('options', $lang->group->copyOptions);?></td>
<td><?php echo html::checkbox('options', $lang->group->copyOptions, '', '', 'inline');?></td>
</tr>
<tr><th></th><td><?php echo html::submitButton();?></td></tr>
<tr>
<th></th>
<td><?php echo html::submitButton('', '', 'btn btn-wide btn-primary');?></td>
</tr>
</table>
</form>
</div>
+59 -55
View File
@@ -11,61 +11,65 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<div id='titlebar'>
<div class='heading'>
<span class='prefix' title='GROUP'><?php echo html::icon($lang->icons['group']);?> <strong><?php echo $group->id;?></strong></span>
<strong><?php echo $group->name;?></strong>
<small class='text-muted'> <?php echo $lang->group->manageView;?></small>
<div id='mainContent' class='main-content'>
<div class='main-header'>
<h2>
<span class='label-id'><?php echo $group->id;?></span>
<?php echo $group->name;?>
<small> <?php echo $lang->arrow . $lang->group->manageView;?></small>
</h2>
</div>
<form class="load-indicator main-form form-ajax" id="manageViewForm" method="post" target='hiddenwin'>
<table class='table table-form'>
<tr>
<th class='w-180px'>
<?php echo $lang->group->viewList;?>
</th>
<td class='w-p60'>
<?php foreach($lang->menu as $menu):?>
<?php if(!is_string($menu)) continue;?>
<?php list($moduleName, $module) = explode('|', $menu);?>
<?php if($module == 'my') continue;?>
<?php $moduleName = strip_tags($moduleName);?>
<div class='group-item'>
<div class='checkbox-primary'>
<input type='checkbox' id='<?php echo $module?>' name='actions[views][<?php echo strtolower($module);?>]' value='<?php echo $module;?>' <?php if(isset($group->acl['views'][$module]) or empty($group->acl['views'])) echo "checked";?> />
<label class='priv' for='<?php echo $module?>'>
<?php echo $moduleName;?>
</label>
</div>
</div>
<?php endforeach;?>
<div class='group-item'>
<div class='checkbox-primary'>
<input type="checkbox" id='allchecker' name="allchecker" onclick="selectAll(this, '', 'checkbox')" <?php if(empty($group->acl['views'])) echo "checked";?> />
<label class='priv' for='allchecker'>
<?php echo $lang->selectAll?>
</label>
</div>
</div>
</td>
<td></td>
</tr>
<tr id='productBox' style='display:none'>
<th class='text-right'><?php echo $lang->group->productList?></th>
<td><?php echo html::select("actions[products][]", $products, isset($group->acl['products']) ? join(',', $group->acl['products']) : '', "class='chosen' multiple")?></td>
<td><?php echo $lang->group->noticeVisit?></td>
</tr>
<tr id='projectBox' style='display:none'>
<th class='text-right'><?php echo $lang->group->projectList?></th>
<td><?php echo html::select("actions[projects][]", $projects, isset($group->acl['projects']) ? join(',', $group->acl['projects']) : '', "class='chosen' multiple")?></td>
<td><?php echo $lang->group->noticeVisit?></td>
</tr>
<tr>
<th><span class='hidden'><?php echo html::selectAll('', 'checkbox')?></span></th>
<td colspan='2'>
<?php echo html::submitButton('', "onclick='setNoChecked()'", 'btn btn-wide btn-primary');?>
<?php echo html::backButton('', '', 'btn btn-wide');?>
<?php echo html::hidden('foo'); // Just a hidden var, to make sure $_POST is not empty.?>
</td>
</tr>
</table>
</form>
</div>
<form class='form-condensed' method='post' target='hiddenwin'>
<table class='table table-form'>
<tr>
<th class='w-180px'>
<?php echo $lang->group->viewList;?>
</th>
<td class='w-p60'>
<?php foreach($lang->menu as $menu):?>
<?php if(!is_string($menu)) continue;?>
<?php list($moduleName, $module) = explode('|', $menu);?>
<?php if($module == 'my') continue;?>
<?php $moduleName = strip_tags($moduleName);?>
<div class='group-item'>
<label class='priv' for='<?php echo $module?>'>
<input type='checkbox' id='<?php echo $module?>' name='actions[views][<?php echo strtolower($module);?>]' value='<?php echo $module;?>' <?php if(isset($group->acl['views'][$module]) or empty($group->acl['views'])) echo "checked";?> />
<?php echo $moduleName;?>
</label>
</div>
<?php endforeach;?>
<div class='group-item'>
<label class='priv' for='allchecker'>
<input type="checkbox" id='allchecker' name="allchecker" onclick="selectAll(this, '', 'checkbox')" <?php if(empty($group->acl['views'])) echo "checked";?> />
<?php echo $lang->selectAll?>
</label>
</div>
</td>
<td></td>
</tr>
<tr id='productBox' style='display:none'>
<th class='text-right'><?php echo $lang->group->productList?></th>
<td><?php echo html::select("actions[products][]", $products, isset($group->acl['products']) ? join(',', $group->acl['products']) : '', "class='chosen' multiple")?></td>
<td><?php echo $lang->group->noticeVisit?></td>
</tr>
<tr id='projectBox' style='display:none'>
<th class='text-right'><?php echo $lang->group->projectList?></th>
<td><?php echo html::select("actions[projects][]", $projects, isset($group->acl['projects']) ? join(',', $group->acl['projects']) : '', "class='chosen' multiple")?></td>
<td><?php echo $lang->group->noticeVisit?></td>
</tr>
<tr>
<th><span class='hidden'><?php echo html::selectAll('', 'checkbox')?></span></th>
<td colspan='2'>
<?php
echo html::submitButton($lang->save);
echo html::linkButton($lang->goback, $this->createLink('group', 'browse'));
echo html::hidden('foo'); // Just a hidden var, to make sure $_POST is not empty.
?>
</td>
</tr>
</table>
</form>
<?php include '../../common/view/footer.html.php';?>
+117 -106
View File
@@ -10,114 +10,125 @@
* @link http://www.zentao.net
*/
?>
<form class='form-condensed' method='post' target='hiddenwin'>
<?php if($group->role == 'limited'):?>
<div id='featurebar'>
<div class='heading'><i class='icon-lock'> <?php echo $group->name;?></i></div>
<?php if($group->role == 'limited'):?>
<div id='mainMenu' class='clearfix'>
<div class='btn-toolbar pull-left'>
<a href='javascript:;' class='btn btn-link btn-active-text'><span class='text'><?php echo $group->name;?></span></a>
</div>
<table class='table table-hover table-striped table-bordered table-form'>
<thead>
<tr>
<th><?php echo $lang->group->module;?></th>
<th><?php echo $lang->group->method;?></th>
</div>
<div id='mainContent' class='main-content'>
<form class="load-indicator main-form form-ajax" id="managePrivForm" method="post" target='hiddenwin'>
<table class='table table-hover table-striped table-bordered'>
<thead>
<tr class='text-center'>
<th><?php echo $lang->group->module;?></th>
<th><?php echo $lang->group->method;?></th>
</tr>
</thead>
<tr class='<?php echo cycle('even, bg-gray');?>'>
<th class='text-right w-150px'><?php echo $lang->my->common;?></th>
<td id='my' class='pv-10px'>
<div class='checkbox-primary'>
<input type='checkbox' name='actions[my][]' value='limited' <?php if(isset($groupPrivs['my']['limited'])) echo "checked";?> />
<label class='priv' id="my-limited"><?php echo $lang->my->limited;?></label>
</div>
</td>
</tr>
</thead>
<tr class='<?php echo cycle('even, bg-gray');?>'>
<th class='text-right w-150px'><?php echo $lang->my->common;?></th>
<td id='my' class='pv-10px'>
<input type='checkbox' name='actions[my][]' value='limited' <?php if(isset($groupPrivs['my']['limited'])) echo "checked";?> />
<span class='priv' id="my-limited"><?php echo $lang->my->limited;?></span>
</td>
</tr>
<tr>
<th class='text-right'></th>
<td>
<?php
echo html::submitButton($lang->save, "onclick='setNoChecked()'");
echo html::linkButton($lang->goback, $this->createLink('group', 'browse'));
echo html::hidden('noChecked'); // Save the value of no checked.
?>
</td>
</tr>
</table>
<?php else:?>
<div id='featurebar'>
<div class='heading'><i class='icon-lock'> <?php echo $group->name;?></i></div>
<ul class='nav'>
<?php $params = "type=byGroup&param=$groupID&menu=%s&version=$version";?>
<li <?php echo empty($menu) ? "class='active'" : ""?>>
<?php echo html::a(inlink('managePriv', sprintf($params, '')), $lang->group->all)?>
</li>
<?php foreach($lang->menu as $module => $title):?>
<?php if(!is_string($title)) continue;?>
<li <?php echo $menu == $module ? "class='active'" : ""?>>
<?php echo html::a(inlink('managePriv', sprintf($params, $module)), substr($title, 0, strpos($title, '|')))?>
</li>
<?php endforeach;?>
<li <?php echo $menu == 'other' ? "class='active'" : "";?>>
<?php echo html::a(inlink('managePriv', sprintf($params, 'other')), $lang->group->other);?>
</li>
<li class='w-150px'><?php echo html::select('version', $this->lang->group->versions, $version, "onchange=showPriv(this.value) class='form-control chosen'");?></li>
</ul>
</div>
<table class='table table-hover table-striped table-bordered table-form'>
<thead>
<tr>
<th><?php echo $lang->group->module;?></th>
<th><?php echo $lang->group->method;?></th>
<th class='text-right'></th>
<td>
<?php echo html::submitButton('', "onclick='setNoChecked()'", 'btn btn-wide btn-primary');?>
<?php echo html::backButton('', '', 'btn btn-wide');?>
<?php echo html::hidden('noChecked'); // Save the value of no checked.?>
</td>
</tr>
</thead>
<?php foreach($lang->resource as $moduleName => $moduleActions):?>
<?php if(!count((array)$moduleActions)) continue;?>
<?php if(!$this->group->checkMenuModule($menu, $moduleName)) continue;?>
<?php
/* Check method in select version. */
if($version)
{
$hasMethod = false;
foreach($moduleActions as $action => $actionLabel)
{
if(strpos($changelogs, ",$moduleName-$actionLabel,") !== false)
{
$hasMethod = true;
break;
}
}
if(!$hasMethod) continue;
}
?>
<tr class='<?php echo cycle('even, bg-gray');?>'>
<th class='text-right w-150px'><?php echo $lang->$moduleName->common;?><?php echo html::selectAll($moduleName, 'checkbox')?></th>
<td id='<?php echo $moduleName;?>' class='pv-10px'>
<?php $i = 1;?>
<?php if($moduleName == 'caselib') $moduleName = 'testsuite';?>
<?php foreach($moduleActions as $action => $actionLabel):?>
<?php if(!empty($version) and strpos($changelogs, ",$moduleName-$actionLabel,") === false) continue;?>
<div class='group-item'>
<input type='checkbox' name='actions[<?php echo $moduleName;?>][]' value='<?php echo $action;?>' <?php if(isset($groupPrivs[$moduleName][$action])) echo "checked";?> />
<span class='priv' id="<?php echo $moduleName . '-' . $actionLabel;?>"><?php echo $lang->$moduleName->$actionLabel;?></span>
</div>
<?php endforeach;?>
</td>
</tr>
</table>
</form>
</div>
<?php else:?>
<div id='mainMenu' class='clearfix'>
<div class='btn-toolbar pull-left'>
<?php $params = "type=byGroup&param=$groupID&menu=%s&version=$version";?>
<?php $active = empty($menu) ? 'btn-active-text' : '';?>
<?php echo html::a(inlink('managePriv', sprintf($params, '')), "<span class='text'>{$lang->group->all}</span>", '', "class='btn btn-link $active'")?>
<?php foreach($lang->menu as $module => $title):?>
<?php if(!is_string($title)) continue;?>
<?php $active = $menu == $module ? 'btn-active-text' : '';?>
<?php echo html::a(inlink('managePriv', sprintf($params, $module)), "<span class='text'>" . substr($title, 0, strpos($title, '|')) . '</span>', '', "class='btn btn-link $active'")?>
<?php endforeach;?>
<tr>
<th class='text-right'><?php echo $lang->selectAll . html::selectAll('', 'checkbox')?></th>
<td>
<?php
echo html::submitButton($lang->save, "onclick='setNoChecked()'");
echo html::linkButton($lang->goback, $this->createLink('group', 'browse'));
echo html::hidden('noChecked'); // Save the value of no checked.
?>
</td>
</tr>
</table>
<?php endif;?>
</form>
<script type='text/javascript'>
var groupID = <?php echo $groupID?>;
var menu = "<?php echo $menu?>";
</script>
<?php $active = $menu == 'other' ? 'btn-active-text' : '';?>
<?php echo html::a(inlink('managePriv', sprintf($params, 'other')), "<span class='text'>{$lang->group->other}</span>", '', "class='btn btn-link $active'");?>
<div class='input-control space w-150px'>
<?php echo html::select('version', $this->lang->group->versions, $version, "onchange=showPriv(this.value) class='form-control chosen'");?>
</div>
</div>
</div>
<div id='mainContent' class='main-content'>
<form class="load-indicator main-form form-ajax" id="managePrivForm" method="post" target='hiddenwin'>
<table class='table table-hover table-striped table-bordered' id='privList'>
<thead>
<tr class='text-center'>
<th class='w-150px'><?php echo $lang->group->module;?></th>
<th><?php echo $lang->group->method;?></th>
</tr>
</thead>
<?php foreach($lang->resource as $moduleName => $moduleActions):?>
<?php if(!count((array)$moduleActions)) continue;?>
<?php if(!$this->group->checkMenuModule($menu, $moduleName)) continue;?>
<?php
/* Check method in select version. */
if($version)
{
$hasMethod = false;
foreach($moduleActions as $action => $actionLabel)
{
if(strpos($changelogs, ",$moduleName-$actionLabel,") !== false)
{
$hasMethod = true;
break;
}
}
if(!$hasMethod) continue;
}
?>
<tr class='<?php echo cycle('even, bg-gray');?>'>
<th class='text-middle text-right w-150px'>
<div class="checkbox-primary checkbox-inline checkbox-right check-all">
<input type='checkbox' id='allChecker<?php echo $moduleName;?>'>
<label class='text-right' for='allChecker<?php echo $moduleName;?>'><?php echo $lang->$moduleName->common;?></label>
</div>
</th>
<td id='<?php echo $moduleName;?>' class='pv-10px'>
<?php $i = 1;?>
<?php if($moduleName == 'caselib') $moduleName = 'testsuite';?>
<?php foreach($moduleActions as $action => $actionLabel):?>
<?php if(!empty($version) and strpos($changelogs, ",$moduleName-$actionLabel,") === false) continue;?>
<div class='group-item'>
<?php echo html::checkbox("actions[{$moduleName}]", array($action => $lang->$moduleName->$actionLabel), isset($groupPrivs[$moduleName][$action]) ? $action : '', '', 'inline');?>
</div>
<?php endforeach;?>
</td>
</tr>
<?php endforeach;?>
<tr>
<th class='text-right'>
<div class="checkbox-primary checkbox-inline checkbox-right check-all">
<input type='checkbox' id='allChecker'>
<label class='text-right' for='allChecker'><?php echo $lang->selectAll;?></label>
</div>
</th>
<td>
<?php echo html::submitButton('', "onclick='setNoChecked()'", 'btn btn-wide btn-primary');?>
<?php echo html::backButton('', '', 'btn btn-wide');?>
<?php echo html::hidden('noChecked'); // Save the value of no checked.?>
</td>
</tr>
</table>
</form>
</div>
<?php endif;?>
<?php js::set('groupID', $groupID);?>
<?php js::set('menu', $menu);?>
+3 -5
View File
@@ -41,11 +41,9 @@
</tr>
<tr>
<td class='text-center' colspan='3'>
<?php
echo html::submitButton($lang->save);
echo html::linkButton($lang->goback, $this->createLink('group', 'browse'));
echo html::hidden('foo'); // Just make $_POST not empty..
?>
<?php echo html::submitButton('', "onclick='setNoChecked()'", 'btn btn-wide btn-primary');?>
<?php echo html::backButton('', '', 'btn btn-wide');?>
<?php echo html::hidden('foo'); // Just make $_POST not empty..?>
</td>
</tr>
</table>