zin: optimize history widgets.

This commit is contained in:
sunhao
2023-09-21 21:08:42 +08:00
parent c6deb64400
commit 74235cac3f
4 changed files with 23 additions and 6 deletions
+3
View File
@@ -8,6 +8,7 @@ class commentBtn extends btn
'dataTarget?:string',
'dataUrl?:string',
'dataType?:string',
'dataLoad?:string',
'icon?:string',
'iconClass?:string',
'text?:string',
@@ -30,12 +31,14 @@ class commentBtn extends btn
$dataTarget = $this->prop('dataTarget');
$dataUrl = $this->prop('dataUrl');
$dataType = $this->prop('dataType');
$dataLoad = $this->prop('dataLoad');
$props = parent::getProps();
$props['data-toggle'] = 'modal';
$props['data-type'] = $dataType;
$props['data-url'] = $dataUrl;
$props['data-target'] = $dataTarget;
$props['data-load'] = $dataLoad;
return $props;
}
+8 -2
View File
@@ -5,30 +5,36 @@ namespace zin;
class commentDialog extends wg
{
protected static array $defineProps = array(
'id?: string="comment-dialog"',
'title?:string',
'url?:string',
'name?:string="comment"',
'method?:string="post"'
'method?:string="post"',
'load?: bool|string',
);
protected function build(): wg
{
global $lang;
$id = $this->prop('id');
$title = $this->prop('title');
$name = $this->prop('name');
$url = $this->prop('url');
$method = $this->prop('method');
$load = $this->prop('load');
if(empty($title)) $title = $lang->action->create;
return modal
(
setID('comment-dialog'),
setID($id),
set::modalProps(array('title' => $title)),
commentForm
(
set::url($url),
set::method($method),
set::name($name),
set::closeModal(true),
set::load($load)
)
);
}
+9 -3
View File
@@ -7,15 +7,19 @@ class commentForm extends wg
protected static array $defineProps = array(
'url?:string',
'name?:string="comment"',
'closeModal?: bool',
'load?: bool|string',
'method?:string="POST"'
);
protected function build(): wg
{
global $lang;
$url = $this->prop('url');
$name = $this->prop('name');
$method = $this->prop('method');
$url = $this->prop('url');
$name = $this->prop('name');
$method = $this->prop('method');
$closeModal = $this->prop('closeModal');
$load = $this->prop('load');
if(empty($name)) $name = 'comment';
return form
@@ -23,6 +27,8 @@ class commentForm extends wg
set::url($url),
set::method($method),
set::submitBtnText($lang->save),
setData('close-modal', $closeModal),
setData('load', $load),
setClass('comment-form'),
editor
(
+3 -1
View File
@@ -230,7 +230,7 @@ class history extends wg
if(!$showCommentBtn && !str_contains(',view,objectlibs,viewcard,', ",$methodName,")) return null;
return commentBtn
(
set::dataTarget('#comment-dialog'),
set::dataTarget('#comment-dialog_'. $this->prop('moduleName') . '-' . $this->prop('methodName')),
setClass('btn-comment ml-4 size-sm ghost'),
set::icon('chat-line'),
set::iconClass('text-primary'),
@@ -275,8 +275,10 @@ class history extends wg
div(setClass('mt-3'), $this->historyList()),
$hasComment !== false ? commentDialog
(
set::id('comment-dialog_'. $this->prop('moduleName') . '-' . $this->prop('methodName')),
set::name('comment'),
set::url($commentUrl),
$isInModal ? set::load('modal') : null,
) : null
);
}