+ zin: add users widget.

This commit is contained in:
liugang
2023-11-30 14:18:18 +08:00
parent f03d558a68
commit 73b5ea2e4c
2 changed files with 57 additions and 0 deletions
+8
View File
@@ -1823,3 +1823,11 @@ function contactList(): contactList
{
return createWg('contactList', func_get_args());
}
/**
* Users widget.
*/
function users(): users
{
return createWg('users', func_get_args());
}
+49
View File
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
/**
* The users widget class file of zin module of ZenTaoPMS.
*
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Gang Liu <liugang@easycorp.ltd>
* @package zin
* @link http://www.zentao.net
*/
namespace zin;
class users extends wg
{
protected static array $defineProps = array(
'name?: string="users[]"', // 控件名称。
'value?: string', // 控件默认值。
'items?: array', // picker 列表项或表项获取方法。
'menu?: array', // picker 附加的菜单选项。
'multiple?: boolean|number=false', // picker 是否允许选择多个值,如果指定为数字,则限制多选的数目,默认 `false`。
'contactList?: boolean=true' // 是否显示联系人列表。
);
protected static array $defaultProps = array(
'multiple' => true
);
protected function created()
{
$items = $this->prop('items');
if(!$items)
{
global $app;
$users = $app->control->loadModel('user')->getPairs('noclosed|nodeleted');
$items = array_map(function($account, $name){return array('text' => $name, 'value' => $account);}, array_keys($users), $users);
$this->setProp('items', $items);
}
}
protected function build(): wg|array
{
return inputGroup
(
picker(set($this->getDefinedProps())),
$this->prop('contactList') ? contactList() : null
);
}
}