* Refactor isClickable method.

This commit is contained in:
tianshujie
2023-08-30 13:57:44 +08:00
parent d5836430d1
commit 4b6487269d
3 changed files with 34 additions and 58 deletions
+7 -7
View File
@@ -4336,6 +4336,7 @@ class executionModel extends model
}
/**
* 判断操作按钮是否可以点击。
* Judge an action is clickable or not.
*
* @param object $execution
@@ -4343,17 +4344,16 @@ class executionModel extends model
* @access public
* @return bool
*/
public static function isClickable($execution, $action)
public static function isClickable(object $execution, string $action): bool
{
$action = strtolower($action);
$clickable = commonModel::hasPriv('execution', $action);
if(!$clickable) return false;
if(!commonModel::hasPriv('execution', $action)) return false;
$action = strtolower($action);
if($action == 'start') return $execution->status == 'wait';
if($action == 'close') return $execution->status != 'closed';
if($action == 'suspend') return $execution->status == 'wait' or $execution->status == 'doing';
if($action == 'putoff') return $execution->status == 'wait' or $execution->status == 'doing';
if($action == 'activate') return $execution->status == 'suspended' or $execution->status == 'closed';
if($action == 'suspend') return $execution->status == 'wait' || $execution->status == 'doing';
if($action == 'putoff') return $execution->status == 'wait' || $execution->status == 'doing';
if($action == 'activate') return $execution->status == 'suspended' || $execution->status == 'closed';
return true;
}