* zin: update zin lib.

This commit is contained in:
sunhao
2023-12-01 08:57:26 +08:00
parent 22a5299272
commit 738fbf980e
9 changed files with 138 additions and 11 deletions
+24
View File
@@ -1823,3 +1823,27 @@ function contactList(): contactList
{
return createWg('contactList', func_get_args());
}
/**
* Users widget.
*/
function users(): users
{
return createWg('users', func_get_args());
}
/**
* Mailto widget.
*/
function mailto(): mailto
{
return createWg('mailto', func_get_args());
}
/**
* whitelist widget.
*/
function whitelist(): whitelist
{
return createWg('whitelist', func_get_args());
}
+9 -3
View File
@@ -42,9 +42,15 @@ function loadContactUsers(target, ele)
const link = $.createLink('user', 'ajaxGetContactUsers', 'listID=' + listID);
$.getJSON(link, function(users)
{
let $targetPicker = $('[name^="' + target + '"]').zui('picker');
let targetUsers = $('[name^="' + target + '"]').val();
users.forEach(user => {targetUsers.push(user.value);});
const $target = target ? $("[name^='" + target + "']") : $(ele).parent().prev();
const $targetPicker = $target.zui('picker');
if($targetPicker === undefined)
{
if(config.debug) console.log('[ZIN] Target picker not found');
return;
}
const targetUsers = $targetPicker.$.valueList.concat(users.map(user => user.value));
$targetPicker.$.setValue(targetUsers);
});
}
+1 -1
View File
@@ -15,7 +15,7 @@ class contactList extends wg
{
protected static array $defineProps = array(
'name?: string="contactList"', // 控件名称。
'target?: string="mailto"', // 选中项改变时更新的目标
'target?: string', // 选中项改变时更新的目标
'items?: array', // picker 列表项或表项获取方法。
'placeholder?: string', // picker 占位符。
);
+3 -2
View File
@@ -35,9 +35,10 @@ class control extends wg
{
$name = $this->prop('name');
if($this->prop('type') === 'static' && $name === null) $this->setProp('name', '');
if($this->prop('id') === null && $name !== null)
if($this->prop('id') === null && $this->prop('name') !== null)
{
$id = substr($name, -2) == '[]' ? substr($name, 0, - 2) : $name;
$name = $this->prop('name');
$id = substr($name, -2) == '[]' ? substr($name, 0, - 2) : $name;
$this->setProp('id', $id);
}
}
+3 -2
View File
@@ -29,7 +29,7 @@ class formGroup extends wg
protected function build(): wg
{
list($name, $label, $labelClass, $labelProps, $labelWidth, $required, $tip, $tipClass, $tipProps, $control, $width, $strong, $value, $disabled, $items, $placeholder, $readonly, $multiple) = $this->prop(['name', 'label', 'labelClass', 'labelProps', 'labelWidth', 'required', 'tip', 'tipClass', 'tipProps', 'control', 'width', 'strong', 'value', 'disabled', 'items', 'placeholder', 'readonly', 'multiple']);
list($name, $label, $labelClass, $labelProps, $labelWidth, $required, $tip, $tipClass, $tipProps, $control, $width, $strong, $value, $disabled, $items, $placeholder, $readonly, $multiple, $id) = $this->prop(['name', 'label', 'labelClass', 'labelProps', 'labelWidth', 'required', 'tip', 'tipClass', 'tipProps', 'control', 'width', 'strong', 'value', 'disabled', 'items', 'placeholder', 'readonly', 'multiple', 'id']);
if($required === 'auto') $required = isFieldRequired($name);
@@ -46,6 +46,7 @@ class formGroup extends wg
if($placeholder !== null) $control['placeholder'] = $placeholder;
if($readonly !== null) $control['readonly'] = $readonly;
if($multiple !== null) $control['multiple'] = $multiple;
if($id) $control['id'] = '';
}
return div
@@ -54,7 +55,7 @@ class formGroup extends wg
zui::width($width),
set($this->getRestProps()),
setCssVar('form-grid-label-width', $labelWidth),
empty($label) ? null : new formLabel
empty($label) && $label !== '0' ? null : new formLabel
(
set::className($labelClass, $strong ? 'font-bold' : null),
set::required($required),
+21
View File
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* The mailto 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;
requireWg('users');
class mailto extends users
{
protected static array $defaultProps = array(
'name' => 'mailto[]'
);
}
+4 -3
View File
@@ -11,12 +11,13 @@ class sidebar extends wg
'minWidth?:string|number=160',
'showToggle?:bool=true',
'parent?:string',
'preserve?:string'
'preserve?:string',
'dragToResize?:bool'
);
protected function build(): wg
{
list($side, $showToggle, $width, $preserve, $parent, $maxWidth, $minWidth) = $this->prop(array('side', 'showToggle', 'width', 'preserve', 'parent', 'maxWidth', 'minWidth'));
list($side, $showToggle, $width, $preserve, $parent, $maxWidth, $minWidth, $dragToResize) = $this->prop(array('side', 'showToggle', 'width', 'preserve', 'parent', 'maxWidth', 'minWidth', 'dragToResize'));
if($preserve === null)
{
global $app;
@@ -26,7 +27,7 @@ class sidebar extends wg
(
setClass('sidebar'),
width($width),
setData(array('zui' => 'sidebar', 'side' => $side, 'toggleBtn' => $showToggle, 'preserve' => $preserve, 'parent' => $parent, 'maxWidth' => $maxWidth, 'minWidth' => $minWidth)),
setData(array('zui' => 'sidebar', 'side' => $side, 'toggleBtn' => $showToggle, 'preserve' => $preserve, 'parent' => $parent, 'maxWidth' => $maxWidth, 'minWidth' => $minWidth, 'dragToResize' => $dragToResize)),
set($this->getRestProps()),
$this->children()
);
+52
View File
@@ -0,0 +1,52 @@
<?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(
'label?: string', // 控件标签。
'id?: string', // 控件 ID。
'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
(
$this->prop('label', null),
picker(set($this->props->pick(array('id', 'name', 'value', 'items', 'menu', 'multiple')))),
$this->prop('contactList') ? contactList() : null
);
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* The whitelist 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;
requireWg('users');
class whitelist extends users
{
protected static array $defaultProps = array(
'name' => 'whitelist[]'
);
}