@bigbinary/neeto-tags-frontend 0.0.30 → 0.0.31
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.js +48 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import ReactDOM from 'react-dom';
|
|
|
27
27
|
import axios from 'axios';
|
|
28
28
|
import { Container, Header, SubHeader, Scrollable, MenuBar } from '@bigbinary/neetoui/layouts';
|
|
29
29
|
import { Formik, Form } from 'formik';
|
|
30
|
-
import { Input, Textarea
|
|
30
|
+
import { Input, Textarea } from '@bigbinary/neetoui/formik';
|
|
31
31
|
import classnames from 'classnames';
|
|
32
32
|
|
|
33
33
|
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -3505,22 +3505,22 @@ var COMMON_COLUMNS = [{
|
|
|
3505
3505
|
},
|
|
3506
3506
|
width: "40%"
|
|
3507
3507
|
}];
|
|
3508
|
-
var TAG_SCHEMA = yup.object({
|
|
3508
|
+
var TAG_SCHEMA = yup.object().shape({
|
|
3509
3509
|
name: yup.string().typeError(instance.t("type", {
|
|
3510
3510
|
what: instance.t("name"),
|
|
3511
3511
|
type: instance.t("types.string")
|
|
3512
3512
|
})).required(instance.t("required", {
|
|
3513
3513
|
what: instance.t("name")
|
|
3514
|
-
})).max(50, instance.t("
|
|
3514
|
+
})).max(50, instance.t("maxLength", {
|
|
3515
3515
|
what: instance.t("name"),
|
|
3516
|
-
|
|
3516
|
+
length: 50
|
|
3517
3517
|
})),
|
|
3518
3518
|
description: yup.string().typeError(instance.t("type", {
|
|
3519
3519
|
what: instance.t("description"),
|
|
3520
3520
|
type: instance.t("types.string")
|
|
3521
|
-
})).nullable().max(
|
|
3521
|
+
})).nullable().max(255, instance.t("maxLength", {
|
|
3522
3522
|
what: instance.t("description"),
|
|
3523
|
-
|
|
3523
|
+
length: 255
|
|
3524
3524
|
}))
|
|
3525
3525
|
});
|
|
3526
3526
|
var PANE_TYPES = {
|
|
@@ -6858,7 +6858,8 @@ var useTagsForm = function useTagsForm(_ref) {
|
|
|
6858
6858
|
var createTags = _ref.createTags,
|
|
6859
6859
|
goToFirstPage = _ref.goToFirstPage,
|
|
6860
6860
|
isEdit = _ref.isEdit,
|
|
6861
|
-
|
|
6861
|
+
onPaneClose = _ref.onPaneClose,
|
|
6862
|
+
setHasSubmitted = _ref.setHasSubmitted,
|
|
6862
6863
|
tagType = _ref.tagType,
|
|
6863
6864
|
updateTags = _ref.updateTags;
|
|
6864
6865
|
var tagModification = isEdit ? useUpdateTag : useCreateTag;
|
|
@@ -6872,6 +6873,7 @@ var useTagsForm = function useTagsForm(_ref) {
|
|
|
6872
6873
|
var _values$description;
|
|
6873
6874
|
|
|
6874
6875
|
var resetForm = _ref2.resetForm;
|
|
6876
|
+
setHasSubmitted(true);
|
|
6875
6877
|
values.description = values === null || values === void 0 ? void 0 : (_values$description = values.description) === null || _values$description === void 0 ? void 0 : _values$description.trim();
|
|
6876
6878
|
var tagData = {
|
|
6877
6879
|
payload: {
|
|
@@ -6890,7 +6892,7 @@ var useTagsForm = function useTagsForm(_ref) {
|
|
|
6890
6892
|
|
|
6891
6893
|
!isEdit && goToFirstPage();
|
|
6892
6894
|
tagOperation === null || tagOperation === void 0 ? void 0 : (_tagOperation$onSucce = tagOperation.onSuccess) === null || _tagOperation$onSucce === void 0 ? void 0 : _tagOperation$onSucce.callback();
|
|
6893
|
-
|
|
6895
|
+
onPaneClose();
|
|
6894
6896
|
},
|
|
6895
6897
|
onError: function onError() {
|
|
6896
6898
|
resetForm();
|
|
@@ -6912,25 +6914,38 @@ var ManageTags = function ManageTags(_ref) {
|
|
|
6912
6914
|
tagType = _ref.tagType,
|
|
6913
6915
|
type = _ref.type,
|
|
6914
6916
|
updateTags = _ref.updateTags;
|
|
6915
|
-
var isEdit = type === PANE_TYPES.EDIT;
|
|
6916
|
-
var initValues = isEdit ? tag : INITIAL_TAG_VALUES;
|
|
6917
6917
|
|
|
6918
6918
|
var _useTranslation = useTranslation(),
|
|
6919
6919
|
t = _useTranslation.t;
|
|
6920
6920
|
|
|
6921
|
+
var _useState = useState(false),
|
|
6922
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
6923
|
+
hasSubmitted = _useState2[0],
|
|
6924
|
+
setHasSubmitted = _useState2[1];
|
|
6925
|
+
|
|
6926
|
+
var isEdit = type === PANE_TYPES.EDIT;
|
|
6927
|
+
var initValues = isEdit ? tag : INITIAL_TAG_VALUES;
|
|
6928
|
+
|
|
6929
|
+
var onPaneClose = function onPaneClose() {
|
|
6930
|
+
setHasSubmitted(false);
|
|
6931
|
+
onClose();
|
|
6932
|
+
};
|
|
6933
|
+
|
|
6921
6934
|
var _useTagsForm = useTagsForm({
|
|
6922
6935
|
createTags: createTags,
|
|
6923
6936
|
goToFirstPage: goToFirstPage,
|
|
6924
6937
|
isEdit: isEdit,
|
|
6925
|
-
|
|
6938
|
+
onPaneClose: onPaneClose,
|
|
6939
|
+
setHasSubmitted: setHasSubmitted,
|
|
6926
6940
|
tagType: tagType,
|
|
6927
6941
|
updateTags: updateTags
|
|
6928
6942
|
}),
|
|
6929
|
-
handleSubmit = _useTagsForm.handleSubmit
|
|
6943
|
+
handleSubmit = _useTagsForm.handleSubmit,
|
|
6944
|
+
isSubmitting = _useTagsForm.isSubmitting;
|
|
6930
6945
|
|
|
6931
6946
|
return /*#__PURE__*/React.createElement(Pane, {
|
|
6932
6947
|
isOpen: !!type,
|
|
6933
|
-
onClose:
|
|
6948
|
+
onClose: onPaneClose
|
|
6934
6949
|
}, /*#__PURE__*/React.createElement(Pane.Header, null, /*#__PURE__*/React.createElement(Typography, {
|
|
6935
6950
|
style: "h2",
|
|
6936
6951
|
weight: "semibold"
|
|
@@ -6940,15 +6955,16 @@ var ManageTags = function ManageTags(_ref) {
|
|
|
6940
6955
|
what: t("tag").toLocaleLowerCase()
|
|
6941
6956
|
}))), /*#__PURE__*/React.createElement(Formik, {
|
|
6942
6957
|
initialValues: initValues,
|
|
6943
|
-
validateOnBlur: false,
|
|
6944
|
-
validateOnChange: false,
|
|
6945
6958
|
onSubmit: handleSubmit,
|
|
6959
|
+
validateOnBlur: hasSubmitted,
|
|
6960
|
+
validateOnChange: hasSubmitted,
|
|
6946
6961
|
validationSchema: TAG_SCHEMA
|
|
6947
6962
|
}, function (_ref2) {
|
|
6948
|
-
var
|
|
6949
|
-
return /*#__PURE__*/React.createElement(
|
|
6950
|
-
className: "flex w-full flex-col space-y-4",
|
|
6963
|
+
var dirty = _ref2.dirty;
|
|
6964
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
6951
6965
|
noValidate: true
|
|
6966
|
+
}, /*#__PURE__*/React.createElement(Pane.Body, null, /*#__PURE__*/React.createElement("div", {
|
|
6967
|
+
className: "flex w-full flex-col space-y-4"
|
|
6952
6968
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
6953
6969
|
required: true,
|
|
6954
6970
|
autoFocus: true,
|
|
@@ -6962,16 +6978,21 @@ var ManageTags = function ManageTags(_ref) {
|
|
|
6962
6978
|
rows: 3,
|
|
6963
6979
|
"data-cy": "tag-description-text-area",
|
|
6964
6980
|
maxLength: 255
|
|
6965
|
-
}))), /*#__PURE__*/React.createElement(Pane.Footer, null, /*#__PURE__*/React.createElement(
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6981
|
+
}))), /*#__PURE__*/React.createElement(Pane.Footer, null, /*#__PURE__*/React.createElement(Button, {
|
|
6982
|
+
"data-cy": "neeto-tags-manage-tag-submit-button",
|
|
6983
|
+
disabled: !dirty || isSubmitting,
|
|
6984
|
+
label: t("saveChanges"),
|
|
6985
|
+
loading: isSubmitting,
|
|
6986
|
+
onClick: function onClick() {
|
|
6987
|
+
return setHasSubmitted(true);
|
|
6970
6988
|
},
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6989
|
+
style: "primary",
|
|
6990
|
+
type: "submit"
|
|
6991
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
6992
|
+
"data-cy": "neeto-tags-manage-tag-cancel-button",
|
|
6993
|
+
label: t("cancel"),
|
|
6994
|
+
onClick: onPaneClose,
|
|
6995
|
+
style: "text"
|
|
6975
6996
|
})));
|
|
6976
6997
|
}));
|
|
6977
6998
|
};
|