mirror of https://gitee.com/karson/fastadmin.git
新增多个FormBuilder用于生成组件的方法
修复datetimerange的format特殊情况下失效的BUG 优化layer-footer的显示 新增CRUD一键生成switcher组件pull/MERGE v1.0.0.20180630_beta
parent
1b08595857
commit
4198f126a9
|
|
@ -598,11 +598,9 @@ class Crud extends Command
|
|||
if (!$itemArr) {
|
||||
$itemArr = [$yes => 'Yes', $no => 'No'];
|
||||
}
|
||||
$formAddElement = $formEditElement = Form::hidden($fieldName, $no, array_merge(['checked' => ''], $attrArr));
|
||||
$attrArr['id'] = $fieldName . "-switch";
|
||||
$formAddElement .= sprintf(Form::label("{$attrArr['id']}", "%s {:__('Yes')}", ['class' => 'control-label']), Form::checkbox($fieldName, $yes, $defaultValue === $yes, $attrArr));
|
||||
$formEditElement .= sprintf(Form::label("{$attrArr['id']}", "%s {:__('Yes')}", ['class' => 'control-label']), Form::checkbox($fieldName, $yes, 0, $attrArr));
|
||||
$formEditElement = str_replace('type="checkbox"', 'type="checkbox" {in name="' . "\$row.{$field}" . '" value="' . $yes . '"}checked{/in}', $formEditElement);
|
||||
$stateNoClass = 'fa-flip-horizontal text-gray';
|
||||
$formAddElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldYes' => $yes, 'fieldNo' => $no, 'attrStr' => Form::attributes($attrArr), 'fieldValue' => $defaultValue, 'fieldSwitchClass' => $defaultValue == $no ? $stateNoClass : '']);
|
||||
$formEditElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldYes' => $yes, 'fieldNo' => $no, 'attrStr' => Form::attributes($attrArr), 'fieldValue' => "{\$row.{$field}}", 'fieldSwitchClass' => "{eq name=\"\$row.{$field}\" value=\"{$no}\"}fa-flip-horizontal text-gray{/eq}"]);
|
||||
} else if ($inputType == 'citypicker') {
|
||||
$attrArr['class'] = implode(' ', $cssClassArr);
|
||||
$attrArr['data-toggle'] = "city-picker";
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace app\common\behavior;
|
|||
|
||||
use think\Config;
|
||||
use think\Lang;
|
||||
use think\Loader;
|
||||
|
||||
class Common
|
||||
{
|
||||
|
|
@ -57,6 +58,8 @@ class Common
|
|||
{
|
||||
\think\Cookie::set('think_var', $request->get('lang'));
|
||||
}
|
||||
// Form别名
|
||||
class_alias('fast\\Form', 'Form');
|
||||
}
|
||||
|
||||
public function addonBegin(&$request)
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ return [
|
|||
//自动检测更新
|
||||
'checkupdate' => false,
|
||||
//版本号
|
||||
'version' => '1.0.0.20180618_beta',
|
||||
'version' => '1.0.0.20180630_beta',
|
||||
//API接口地址
|
||||
'api_url' => 'https://api.fastadmin.net',
|
||||
],
|
||||
|
|
|
|||
1372
extend/fast/Form.php
1372
extend/fast/Form.php
File diff suppressed because it is too large
Load Diff
|
|
@ -105,10 +105,6 @@ html.ios-fix body {
|
|||
margin-bottom: 0;
|
||||
padding: 10px;
|
||||
}
|
||||
/* 包裹在layer外层 */
|
||||
.layer-footer {
|
||||
display: none;
|
||||
}
|
||||
table.table-template {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
|
@ -165,6 +161,9 @@ table.table-template {
|
|||
.is-dialog #main {
|
||||
background: #fff;
|
||||
}
|
||||
.is-dialog .layer-footer {
|
||||
display: none;
|
||||
}
|
||||
form.form-horizontal .control-label {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
|
@ -984,4 +983,12 @@ table.table-nowrap thead > tr > th {
|
|||
.wipecache li a {
|
||||
color: #444444 !important;
|
||||
}
|
||||
/*修正开关关闭下的颜色值*/
|
||||
.btn-switcher.disabled {
|
||||
opacity: .6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.btn-switcher .text-gray {
|
||||
color: #d2d6de !important;
|
||||
}
|
||||
/*# sourceMappingURL=../css/backend.css.map */
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -8603,7 +8603,7 @@ define('form',['jquery', 'bootstrap', 'upload', 'validator'], function ($, undef
|
|||
ranges: ranges,
|
||||
};
|
||||
var origincallback = function (start, end) {
|
||||
$(this.element).val(start.format(options.locale.format) + " - " + end.format(options.locale.format));
|
||||
$(this.element).val(start.format(this.locale.format) + " - " + end.format(this.locale.format));
|
||||
$(this.element).trigger('blur');
|
||||
};
|
||||
$(".datetimerange", form).each(function () {
|
||||
|
|
@ -8758,6 +8758,28 @@ define('form',['jquery', 'bootstrap', 'upload', 'validator'], function ($, undef
|
|||
});
|
||||
}
|
||||
},
|
||||
switcher: function (form) {
|
||||
form.on("click", "[data-toggle='switcher']", function () {
|
||||
if ($(this).hasClass("disabled")) {
|
||||
return false;
|
||||
}
|
||||
var input = $(this).prev("input");
|
||||
input = $(this).data("input-id") ? $("#" + $(this).data("input-id")) : input;
|
||||
if (input.size() > 0) {
|
||||
var yes = $(this).data("yes");
|
||||
var no = $(this).data("no");
|
||||
if (input.val() == yes) {
|
||||
input.val(no);
|
||||
$("i", this).addClass("fa-flip-horizontal text-gray");
|
||||
} else {
|
||||
input.val(yes);
|
||||
$("i", this).removeClass("fa-flip-horizontal text-gray");
|
||||
}
|
||||
input.trigger('change');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
},
|
||||
bindevent: function (form) {
|
||||
|
||||
}
|
||||
|
|
@ -8858,6 +8880,8 @@ define('form',['jquery', 'bootstrap', 'upload', 'validator'], function ($, undef
|
|||
events.faselect(form);
|
||||
|
||||
events.fieldlist(form);
|
||||
|
||||
events.switcher(form);
|
||||
},
|
||||
custom: {}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator'], function ($, undefined, U
|
|||
ranges: ranges,
|
||||
};
|
||||
var origincallback = function (start, end) {
|
||||
$(this.element).val(start.format(options.locale.format) + " - " + end.format(options.locale.format));
|
||||
$(this.element).val(start.format(this.locale.format) + " - " + end.format(this.locale.format));
|
||||
$(this.element).trigger('blur');
|
||||
};
|
||||
$(".datetimerange", form).each(function () {
|
||||
|
|
@ -342,6 +342,28 @@ define(['jquery', 'bootstrap', 'upload', 'validator'], function ($, undefined, U
|
|||
});
|
||||
}
|
||||
},
|
||||
switcher: function (form) {
|
||||
form.on("click", "[data-toggle='switcher']", function () {
|
||||
if ($(this).hasClass("disabled")) {
|
||||
return false;
|
||||
}
|
||||
var input = $(this).prev("input");
|
||||
input = $(this).data("input-id") ? $("#" + $(this).data("input-id")) : input;
|
||||
if (input.size() > 0) {
|
||||
var yes = $(this).data("yes");
|
||||
var no = $(this).data("no");
|
||||
if (input.val() == yes) {
|
||||
input.val(no);
|
||||
$("i", this).addClass("fa-flip-horizontal text-gray");
|
||||
} else {
|
||||
input.val(yes);
|
||||
$("i", this).removeClass("fa-flip-horizontal text-gray");
|
||||
}
|
||||
input.trigger('change');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
},
|
||||
bindevent: function (form) {
|
||||
|
||||
}
|
||||
|
|
@ -442,6 +464,8 @@ define(['jquery', 'bootstrap', 'upload', 'validator'], function ($, undefined, U
|
|||
events.faselect(form);
|
||||
|
||||
events.fieldlist(form);
|
||||
|
||||
events.switcher(form);
|
||||
},
|
||||
custom: {}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -134,11 +134,6 @@ html.ios-fix, html.ios-fix body {
|
|||
padding: 10px;
|
||||
}
|
||||
|
||||
/* 包裹在layer外层 */
|
||||
.layer-footer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
table.table-template {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
|
@ -207,6 +202,9 @@ table.table-template {
|
|||
#main {
|
||||
background: #fff;
|
||||
}
|
||||
.layer-footer {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
form.form-horizontal .control-label {
|
||||
|
|
@ -556,7 +554,7 @@ form.form-horizontal .control-label {
|
|||
margin-top: 0;
|
||||
}
|
||||
.treeview-menu > li > a {
|
||||
font-size:inherit;
|
||||
font-size: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1115,4 +1113,15 @@ table.table-nowrap {
|
|||
|
||||
.wipecache li a {
|
||||
color: #444444 !important;
|
||||
}
|
||||
}
|
||||
|
||||
/*修正开关关闭下的颜色值*/
|
||||
.btn-switcher {
|
||||
&.disabled {
|
||||
opacity: .6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.text-gray {
|
||||
color: #d2d6de !important;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue