* Refactor ui of entry::create.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
$config->entry->create = new stdclass();
|
||||
$config->entry->create->requiredFields = 'name, code, account, key';
|
||||
$config->entry->create->requiredFields = 'name,code,account,key';
|
||||
|
||||
$config->entry->edit = new stdclass();
|
||||
$config->entry->edit->requiredFields = 'name, code, account, key';
|
||||
$config->entry->edit->requiredFields = 'name,code,account,key';
|
||||
|
||||
$config->entry->errcode['PARAM_CODE_MISSING'] = 401;
|
||||
$config->entry->errcode['PARAM_TOKEN_MISSING'] = 401;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Create key for an entry.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function createKey()
|
||||
{
|
||||
var chars = '0123456789abcdefghiklmnopqrstuvwxyz'.split('');
|
||||
var key = '';
|
||||
for(var i = 0; i < 32; i ++)
|
||||
{
|
||||
key += chars[Math.floor(Math.random() * chars.length)];
|
||||
}
|
||||
$('#key').val(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable ip if allIP is checked.
|
||||
*
|
||||
* @param event $event
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function toggleAllIP(event)
|
||||
{
|
||||
if($(event.target).prop('checked'))
|
||||
{
|
||||
$('#ip').attr('disabled', 'disabled');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#ip').removeAttr('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide account row when enabling password-free login.
|
||||
*
|
||||
* @param event $event
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function toggleFreePasswd(event)
|
||||
{
|
||||
if($(event.target).val() == '1')
|
||||
{
|
||||
$('#account').closest('.form-row').addClass('hidden');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#account').closest('.form-row').removeClass('hidden');
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,7 @@ class entryModel extends model
|
||||
$entry = fixer::input('post')
|
||||
->setDefault('ip', '*')
|
||||
->setIF($this->post->allIP, 'ip', '*')
|
||||
->setIF($this->post->freePasswd == '1', 'account', '')
|
||||
->add('createdBy', $this->app->user->account)
|
||||
->add('createdDate', helper::now())
|
||||
->remove('allIP')
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The create view file of entry 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 Mengyi Liu <liumengyi@easycorp.ltd>
|
||||
* @package entry
|
||||
* @link https://www.zentao.net
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
formPanel
|
||||
(
|
||||
set::title($lang->entry->create),
|
||||
to::headingActions
|
||||
(
|
||||
toolbar
|
||||
(
|
||||
a
|
||||
(
|
||||
setClass('text-darken'),
|
||||
set::href($lang->entry->helpLink),
|
||||
set('target', '_blank'),
|
||||
$lang->entry->help,
|
||||
),
|
||||
div(setClass('toolbar-divider')),
|
||||
a
|
||||
(
|
||||
setClass('text-darken'),
|
||||
set::href($lang->entry->notifyLink),
|
||||
set('target', '_blank'),
|
||||
$lang->entry->notify,
|
||||
),
|
||||
),
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::label($lang->entry->name),
|
||||
set::name('name'),
|
||||
set::title($lang->entry->note->name),
|
||||
set::placeholder($lang->entry->note->name),
|
||||
set::value('')
|
||||
),
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::label($lang->entry->code),
|
||||
set::name('code'),
|
||||
set::title($lang->entry->note->code),
|
||||
set::placeholder($lang->entry->note->code),
|
||||
set::value('')
|
||||
),
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::label($lang->entry->freePasswd),
|
||||
radioList
|
||||
(
|
||||
on::change('toggleFreePasswd'),
|
||||
set::name('freePasswd'),
|
||||
set::items($lang->entry->freePasswdList),
|
||||
set::value(0),
|
||||
set::inline(true),
|
||||
),
|
||||
),
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::label($lang->entry->account),
|
||||
set::placeholder($lang->entry->note->account),
|
||||
set::name('account'),
|
||||
set::items($users),
|
||||
set::value(''),
|
||||
),
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::label($lang->entry->key),
|
||||
set::placeholder($lang->entry->note->key),
|
||||
set::name('key'),
|
||||
set::value(md5((string)rand())),
|
||||
set::readonly(true),
|
||||
),
|
||||
formGroup
|
||||
(
|
||||
a
|
||||
(
|
||||
setClass('btn ml-2 text-darken'),
|
||||
on::click('createKey()'),
|
||||
$lang->entry->createKey,
|
||||
),
|
||||
),
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::label($lang->entry->ip),
|
||||
set::title($lang->entry->note->ip),
|
||||
set::placeholder($lang->entry->note->ip),
|
||||
set::name('ip'),
|
||||
set::value(''),
|
||||
),
|
||||
formGroup
|
||||
(
|
||||
setClass('items-center ml-2'),
|
||||
checkbox
|
||||
(
|
||||
set::name('allIP'),
|
||||
on::change('toggleAllIP'),
|
||||
$lang->entry->note->allIP,
|
||||
),
|
||||
),
|
||||
),
|
||||
formGroup
|
||||
(
|
||||
set::label($lang->entry->desc),
|
||||
editor
|
||||
(
|
||||
set::name('desc'),
|
||||
set::rows('3'),
|
||||
)
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
render();
|
||||
|
||||
Reference in New Issue
Block a user