ywana-core8 0.0.17 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +99 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +99 -4
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +99 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.js +2 -2
package/dist/index.cjs
CHANGED
@@ -3134,7 +3134,7 @@ var CollectionAdder = function CollectionAdder(_ref11) {
|
|
3134
3134
|
* Create Content Dialog
|
3135
3135
|
*/
|
3136
3136
|
|
3137
|
-
var CreateContentDialog = function CreateContentDialog(_ref) {
|
3137
|
+
var CreateContentDialog$1 = function CreateContentDialog(_ref) {
|
3138
3138
|
var label = _ref.label,
|
3139
3139
|
type = _ref.type,
|
3140
3140
|
_ref$value = _ref.value,
|
@@ -3301,6 +3301,101 @@ var EditContentDialog = function EditContentDialog(_ref) {
|
|
3301
3301
|
}));
|
3302
3302
|
};
|
3303
3303
|
|
3304
|
+
/**
|
3305
|
+
* Create Content Dialog
|
3306
|
+
*/
|
3307
|
+
|
3308
|
+
var CreateContentDialog = function CreateContentDialog(_ref) {
|
3309
|
+
var label = _ref.label,
|
3310
|
+
type = _ref.type,
|
3311
|
+
validator = _ref.validator,
|
3312
|
+
onOK = _ref.onOK,
|
3313
|
+
_ref$onActionClose = _ref.onActionClose,
|
3314
|
+
onActionClose = _ref$onActionClose === void 0 ? true : _ref$onActionClose;
|
3315
|
+
var site = React.useContext(SiteContext);
|
3316
|
+
|
3317
|
+
var _useState = React.useState({}),
|
3318
|
+
form = _useState[0],
|
3319
|
+
setForm = _useState[1];
|
3320
|
+
|
3321
|
+
var _useState2 = React.useState(false),
|
3322
|
+
isValid = _useState2[0],
|
3323
|
+
setValid = _useState2[1];
|
3324
|
+
|
3325
|
+
var _useState3 = React.useState([]),
|
3326
|
+
errors = _useState3[0],
|
3327
|
+
setErrors = _useState3[1];
|
3328
|
+
|
3329
|
+
function change(form, validForm) {
|
3330
|
+
setForm(form);
|
3331
|
+
|
3332
|
+
if (validator) {
|
3333
|
+
var _validator = validator(form),
|
3334
|
+
validation = _validator.validation,
|
3335
|
+
_validator$errors = _validator.errors,
|
3336
|
+
_errors = _validator$errors === void 0 ? [] : _validator$errors;
|
3337
|
+
|
3338
|
+
setValid(validForm && validation);
|
3339
|
+
setErrors(_errors);
|
3340
|
+
} else {
|
3341
|
+
setValid(validForm);
|
3342
|
+
}
|
3343
|
+
}
|
3344
|
+
|
3345
|
+
function onAction(action) {
|
3346
|
+
if (action === 'OK' && onOK) onOK(form);
|
3347
|
+
if (action === 'CLOSE' || onActionClose === true) site.closeDialog();
|
3348
|
+
}
|
3349
|
+
|
3350
|
+
function isRequired(field) {
|
3351
|
+
var _field$required = field.required,
|
3352
|
+
required = _field$required === void 0 ? false : _field$required;
|
3353
|
+
return required;
|
3354
|
+
}
|
3355
|
+
|
3356
|
+
function isOptional(field) {
|
3357
|
+
var _field$creation = field.creation,
|
3358
|
+
creation = _field$creation === void 0 ? false : _field$creation;
|
3359
|
+
return creation;
|
3360
|
+
}
|
3361
|
+
|
3362
|
+
var actions = /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, /*#__PURE__*/React__default["default"].createElement(Button, {
|
3363
|
+
label: "CLOSE",
|
3364
|
+
action: function action() {
|
3365
|
+
return onAction("CLOSE");
|
3366
|
+
}
|
3367
|
+
}), /*#__PURE__*/React__default["default"].createElement(Button, {
|
3368
|
+
label: "OK",
|
3369
|
+
action: function action() {
|
3370
|
+
return onAction("OK");
|
3371
|
+
},
|
3372
|
+
disabled: !isValid,
|
3373
|
+
raised: true
|
3374
|
+
}));
|
3375
|
+
var title = /*#__PURE__*/React__default["default"].createElement(Text, {
|
3376
|
+
use: "headline6"
|
3377
|
+
}, label);
|
3378
|
+
var content = new Content(type, form);
|
3379
|
+
return /*#__PURE__*/React__default["default"].createElement(Dialog, {
|
3380
|
+
title: title,
|
3381
|
+
open: true,
|
3382
|
+
onAction: onAction,
|
3383
|
+
actions: actions
|
3384
|
+
}, /*#__PURE__*/React__default["default"].createElement(ContentForm, {
|
3385
|
+
content: content,
|
3386
|
+
filter: function filter(field) {
|
3387
|
+
return isRequired(field) || isOptional(field);
|
3388
|
+
},
|
3389
|
+
onChange: change
|
3390
|
+
}), errors.map(function (error) {
|
3391
|
+
return /*#__PURE__*/React__default["default"].createElement(Text, {
|
3392
|
+
use: "overline",
|
3393
|
+
tag: "div",
|
3394
|
+
className: "error"
|
3395
|
+
}, error);
|
3396
|
+
}));
|
3397
|
+
};
|
3398
|
+
|
3304
3399
|
function _catch(body, recover) {
|
3305
3400
|
try {
|
3306
3401
|
var result = body();
|
@@ -3376,8 +3471,8 @@ var CollectionPage = function CollectionPage(props) {
|
|
3376
3471
|
}
|
3377
3472
|
};
|
3378
3473
|
|
3379
|
-
site.openDialog( /*#__PURE__*/React__default["default"].createElement(
|
3380
|
-
label: "
|
3474
|
+
site.openDialog( /*#__PURE__*/React__default["default"].createElement(CreateContentDialog, {
|
3475
|
+
label: "" + name,
|
3381
3476
|
type: schema,
|
3382
3477
|
onOK: onOK
|
3383
3478
|
}));
|
@@ -4092,7 +4187,7 @@ exports.CollectionPage = CollectionPage;
|
|
4092
4187
|
exports.Content = Content;
|
4093
4188
|
exports.ContentEditor = ContentEditor;
|
4094
4189
|
exports.ContentForm = ContentForm;
|
4095
|
-
exports.CreateContentDialog = CreateContentDialog;
|
4190
|
+
exports.CreateContentDialog = CreateContentDialog$1;
|
4096
4191
|
exports.DataTable = DataTable;
|
4097
4192
|
exports.Dialog = Dialog;
|
4098
4193
|
exports.DropDown = DropDown;
|