react-hook-core 0.1.25 → 0.2.1
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/lib/com.js +1 -1
- package/lib/components.js +64 -91
- package/lib/core.js +0 -28
- package/lib/edit.js +0 -13
- package/lib/formutil.js +36 -22
- package/lib/index.js +8 -0
- package/lib/input.js +0 -14
- package/lib/useEdit.js +423 -431
- package/lib/useSearch.js +0 -16
- package/lib/useView.js +107 -107
- package/package.json +1 -1
- package/src/com.ts +1 -1
- package/src/components.ts +58 -73
- package/src/core.ts +3 -2
- package/src/edit.ts +4 -2
- package/src/formutil.ts +31 -20
- package/src/index.ts +7 -0
- package/src/input.ts +3 -1
- package/src/useEdit.ts +14 -16
- package/src/useSearch.ts +15 -13
- package/src/useView.ts +3 -3
package/lib/com.js
CHANGED
|
@@ -6,7 +6,7 @@ function PageSizeSelect(p) {
|
|
|
6
6
|
var g = p.sizes;
|
|
7
7
|
var s = (!g || g.length === 0 ? core_1.pageSizes : g);
|
|
8
8
|
var opts = s.map(function (pgSize) { return React.createElement('option', { key: pgSize, value: pgSize }, pgSize); });
|
|
9
|
-
return React.createElement('select', { id: p.id, name: p.name,
|
|
9
|
+
return React.createElement('select', { id: p.id, name: p.name, defaultValue: p.size, onChange: p.onChange }, opts);
|
|
10
10
|
}
|
|
11
11
|
exports.PageSizeSelect = PageSizeSelect;
|
|
12
12
|
function Search(p) {
|
package/lib/components.js
CHANGED
|
@@ -117,7 +117,7 @@ var ViewComponent = (function (_super) {
|
|
|
117
117
|
ViewComponent.prototype.handleNotFound = function (form) {
|
|
118
118
|
var msg = core_2.message(this.resourceService.value, 'error_not_found', 'error');
|
|
119
119
|
if (form) {
|
|
120
|
-
formutil_1.
|
|
120
|
+
formutil_1.setReadOnly(form);
|
|
121
121
|
}
|
|
122
122
|
this.showError(msg.message, msg.title);
|
|
123
123
|
};
|
|
@@ -300,9 +300,6 @@ var BaseSearchComponent = (function (_super) {
|
|
|
300
300
|
_this.tmpPageIndex = 1;
|
|
301
301
|
_this.pageMaxSize = 7;
|
|
302
302
|
_this.pageSizes = core_2.pageSizes;
|
|
303
|
-
_this.viewable = true;
|
|
304
|
-
_this.addable = true;
|
|
305
|
-
_this.editable = true;
|
|
306
303
|
_this.pageSizeOnClick = function () {
|
|
307
304
|
_this.setState(function (prevState) { return ({ isPageSizeOpenDropDown: !prevState.isPageSizeOpenDropDown }); });
|
|
308
305
|
};
|
|
@@ -635,7 +632,7 @@ var SearchComponent = (function (_super) {
|
|
|
635
632
|
exports.SearchComponent = SearchComponent;
|
|
636
633
|
var BaseEditComponent = (function (_super) {
|
|
637
634
|
__extends(BaseEditComponent, _super);
|
|
638
|
-
function BaseEditComponent(props, resourceService, showMessage, showError, confirm, getLocale, ui, loading,
|
|
635
|
+
function BaseEditComponent(props, resourceService, showMessage, showError, confirm, getLocale, ui, loading, patchable, backOnSaveSuccess) {
|
|
639
636
|
var _this = _super.call(this, props, getLocale, (ui ? ui.removeError : undefined)) || this;
|
|
640
637
|
_this.resourceService = resourceService;
|
|
641
638
|
_this.showMessage = showMessage;
|
|
@@ -645,7 +642,6 @@ var BaseEditComponent = (function (_super) {
|
|
|
645
642
|
_this.loading = loading;
|
|
646
643
|
_this.backOnSuccess = true;
|
|
647
644
|
_this.patchable = true;
|
|
648
|
-
_this.addable = true;
|
|
649
645
|
_this.create = function (event) {
|
|
650
646
|
if (event) {
|
|
651
647
|
event.preventDefault();
|
|
@@ -672,7 +668,6 @@ var BaseEditComponent = (function (_super) {
|
|
|
672
668
|
_this.onSave(_this.backOnSuccess);
|
|
673
669
|
};
|
|
674
670
|
_this.resource = resourceService.resource();
|
|
675
|
-
_this.status = core_1.createEditStatus(status);
|
|
676
671
|
if (patchable === false) {
|
|
677
672
|
_this.patchable = patchable;
|
|
678
673
|
}
|
|
@@ -715,7 +710,7 @@ var BaseEditComponent = (function (_super) {
|
|
|
715
710
|
BaseEditComponent.prototype.handleNotFound = function (form) {
|
|
716
711
|
var msg = core_2.message(this.resourceService.value, 'error_not_found', 'error');
|
|
717
712
|
if (form) {
|
|
718
|
-
formutil_1.
|
|
713
|
+
formutil_1.setReadOnly(form);
|
|
719
714
|
}
|
|
720
715
|
this.showError(msg.message, msg.title);
|
|
721
716
|
};
|
|
@@ -737,7 +732,7 @@ var BaseEditComponent = (function (_super) {
|
|
|
737
732
|
objSet[modelName] = model;
|
|
738
733
|
this.setState(objSet, function () {
|
|
739
734
|
if (_this.readOnly) {
|
|
740
|
-
formutil_1.
|
|
735
|
+
formutil_1.setReadOnly(f);
|
|
741
736
|
}
|
|
742
737
|
});
|
|
743
738
|
};
|
|
@@ -754,45 +749,33 @@ var BaseEditComponent = (function (_super) {
|
|
|
754
749
|
BaseEditComponent.prototype.onSave = function (isBack) {
|
|
755
750
|
var _this = this;
|
|
756
751
|
var r = this.resourceService;
|
|
757
|
-
if (this.
|
|
758
|
-
var m = core_2.message(r.value, 'error_permission_add', 'error_permission');
|
|
759
|
-
this.showError(m.message, m.title);
|
|
752
|
+
if (this.running) {
|
|
760
753
|
return;
|
|
761
754
|
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
755
|
+
var com = this;
|
|
756
|
+
var obj = com.getModel();
|
|
757
|
+
if (this.newMode) {
|
|
758
|
+
com.validate(obj, function () {
|
|
759
|
+
var msg = core_2.message(r.value, 'msg_confirm_save', 'confirm', 'yes', 'no');
|
|
760
|
+
_this.confirm(msg.message, msg.title, function () {
|
|
761
|
+
com.doSave(obj, obj, isBack);
|
|
762
|
+
}, msg.no, msg.yes);
|
|
763
|
+
});
|
|
766
764
|
}
|
|
767
765
|
else {
|
|
768
|
-
|
|
769
|
-
|
|
766
|
+
var diffObj_1 = reflect_1.makeDiff(edit_1.initPropertyNullInModel(this.orginalModel, this.metadata), obj, this.keys, this.version);
|
|
767
|
+
var keys = Object.keys(diffObj_1);
|
|
768
|
+
if (keys.length === 0) {
|
|
769
|
+
this.showMessage(r.value('msg_no_change'));
|
|
770
770
|
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
if (this.newMode) {
|
|
774
|
-
com_2.validate(obj_1, function () {
|
|
771
|
+
else {
|
|
772
|
+
com.validate(obj, function () {
|
|
775
773
|
var msg = core_2.message(r.value, 'msg_confirm_save', 'confirm', 'yes', 'no');
|
|
776
774
|
_this.confirm(msg.message, msg.title, function () {
|
|
777
|
-
|
|
775
|
+
com.doSave(obj, diffObj_1, isBack);
|
|
778
776
|
}, msg.no, msg.yes);
|
|
779
777
|
});
|
|
780
778
|
}
|
|
781
|
-
else {
|
|
782
|
-
var diffObj_1 = reflect_1.makeDiff(edit_1.initPropertyNullInModel(this.orginalModel, this.metadata), obj_1, this.keys, this.version);
|
|
783
|
-
var keys = Object.keys(diffObj_1);
|
|
784
|
-
if (keys.length === 0) {
|
|
785
|
-
this.showMessage(r.value('msg_no_change'));
|
|
786
|
-
}
|
|
787
|
-
else {
|
|
788
|
-
com_2.validate(obj_1, function () {
|
|
789
|
-
var msg = core_2.message(r.value, 'msg_confirm_save', 'confirm', 'yes', 'no');
|
|
790
|
-
_this.confirm(msg.message, msg.title, function () {
|
|
791
|
-
com_2.doSave(obj_1, diffObj_1, isBack);
|
|
792
|
-
}, msg.no, msg.yes);
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
779
|
}
|
|
797
780
|
};
|
|
798
781
|
BaseEditComponent.prototype.validate = function (obj, callback) {
|
|
@@ -857,7 +840,6 @@ var BaseEditComponent = (function (_super) {
|
|
|
857
840
|
BaseEditComponent.prototype.postSave = function (res, origin, isPatch, backOnSave) {
|
|
858
841
|
this.running = false;
|
|
859
842
|
core_1.hideLoading(this.loading);
|
|
860
|
-
var st = this.status;
|
|
861
843
|
var newMod = this.newMode;
|
|
862
844
|
var successMsg = (newMod ? this.insertSuccessMsg : this.updateSuccessMsg);
|
|
863
845
|
var x = res;
|
|
@@ -866,18 +848,18 @@ var BaseEditComponent = (function (_super) {
|
|
|
866
848
|
this.fail(x);
|
|
867
849
|
}
|
|
868
850
|
else if (!isNaN(x)) {
|
|
869
|
-
if (x
|
|
851
|
+
if (x > 0) {
|
|
870
852
|
this.succeed(successMsg, origin, backOnSave);
|
|
871
853
|
}
|
|
872
854
|
else {
|
|
873
|
-
if (newMod && x
|
|
855
|
+
if (newMod && x <= 0) {
|
|
874
856
|
this.handleDuplicateKey();
|
|
875
857
|
}
|
|
876
|
-
else if (!newMod && x ===
|
|
858
|
+
else if (!newMod && x === 0) {
|
|
877
859
|
this.handleNotFound();
|
|
878
860
|
}
|
|
879
861
|
else {
|
|
880
|
-
|
|
862
|
+
this.showError(r.value('error_version'), r.value('error'));
|
|
881
863
|
}
|
|
882
864
|
}
|
|
883
865
|
}
|
|
@@ -907,8 +889,8 @@ var BaseEditComponent = (function (_super) {
|
|
|
907
889
|
exports.BaseEditComponent = BaseEditComponent;
|
|
908
890
|
var EditComponent = (function (_super) {
|
|
909
891
|
__extends(EditComponent, _super);
|
|
910
|
-
function EditComponent(props, service, param, showMessage, showError, confirm, getLocale, uis, loading,
|
|
911
|
-
var _this = _super.call(this, props, input_1.getResource(param), input_1.getMsgFunc(param, showMessage), input_1.getErrorFunc(param, showError), input_1.getConfirmFunc(param, confirm), input_1.getLocaleFunc(param, getLocale), input_1.getUIService(param, uis), input_1.getLoadingFunc(param, loading),
|
|
892
|
+
function EditComponent(props, service, param, showMessage, showError, confirm, getLocale, uis, loading, patchable, backOnSaveSuccess) {
|
|
893
|
+
var _this = _super.call(this, props, input_1.getResource(param), input_1.getMsgFunc(param, showMessage), input_1.getErrorFunc(param, showError), input_1.getConfirmFunc(param, confirm), input_1.getLocaleFunc(param, getLocale), input_1.getUIService(param, uis), input_1.getLoadingFunc(param, loading), patchable, backOnSaveSuccess) || this;
|
|
912
894
|
_this.service = service;
|
|
913
895
|
if (service.metadata) {
|
|
914
896
|
var metadata = service.metadata();
|
|
@@ -939,45 +921,45 @@ var EditComponent = (function (_super) {
|
|
|
939
921
|
var _this = this;
|
|
940
922
|
var id = _id;
|
|
941
923
|
if (id != null && id !== '') {
|
|
942
|
-
var
|
|
924
|
+
var com_2 = this;
|
|
943
925
|
this.running = true;
|
|
944
|
-
core_1.showLoading(
|
|
926
|
+
core_1.showLoading(com_2.loading);
|
|
945
927
|
this.service.load(id).then(function (obj) {
|
|
946
928
|
if (!obj) {
|
|
947
|
-
|
|
929
|
+
com_2.handleNotFound(_this.form);
|
|
948
930
|
}
|
|
949
931
|
else {
|
|
950
|
-
|
|
951
|
-
|
|
932
|
+
com_2.newMode = false;
|
|
933
|
+
com_2.orginalModel = reflect_1.clone(obj);
|
|
952
934
|
if (!callback) {
|
|
953
|
-
|
|
935
|
+
com_2.showModel(obj);
|
|
954
936
|
}
|
|
955
937
|
else {
|
|
956
|
-
callback(obj,
|
|
938
|
+
callback(obj, com_2.showModel);
|
|
957
939
|
}
|
|
958
940
|
}
|
|
959
|
-
|
|
960
|
-
core_1.hideLoading(
|
|
941
|
+
com_2.running = false;
|
|
942
|
+
core_1.hideLoading(com_2.loading);
|
|
961
943
|
}).catch(function (err) {
|
|
962
944
|
var data = (err && err.response) ? err.response : err;
|
|
963
|
-
var r =
|
|
945
|
+
var r = com_2.resourceService;
|
|
964
946
|
var gv = r.value;
|
|
965
947
|
var title = gv('error');
|
|
966
948
|
var msg = gv('error_internal');
|
|
967
949
|
if (data && data.status === 404) {
|
|
968
|
-
|
|
950
|
+
com_2.handleNotFound(com_2.form);
|
|
969
951
|
}
|
|
970
952
|
else {
|
|
971
953
|
if (data.status && !isNaN(data.status)) {
|
|
972
954
|
msg = core_2.messageByHttpStatus(data.status, gv);
|
|
973
955
|
}
|
|
974
956
|
if (data && (data.status === 401 || data.status === 403)) {
|
|
975
|
-
formutil_1.
|
|
957
|
+
formutil_1.setReadOnly(com_2.form);
|
|
976
958
|
}
|
|
977
|
-
|
|
959
|
+
com_2.showError(msg, title);
|
|
978
960
|
}
|
|
979
|
-
|
|
980
|
-
core_1.hideLoading(
|
|
961
|
+
com_2.running = false;
|
|
962
|
+
core_1.hideLoading(com_2.loading);
|
|
981
963
|
});
|
|
982
964
|
}
|
|
983
965
|
else {
|
|
@@ -1020,7 +1002,7 @@ var EditComponent = (function (_super) {
|
|
|
1020
1002
|
exports.EditComponent = EditComponent;
|
|
1021
1003
|
var BaseDiffApprComponent = (function (_super) {
|
|
1022
1004
|
__extends(BaseDiffApprComponent, _super);
|
|
1023
|
-
function BaseDiffApprComponent(props, keys, resourceService, showMessage, showError, loading
|
|
1005
|
+
function BaseDiffApprComponent(props, keys, resourceService, showMessage, showError, loading) {
|
|
1024
1006
|
var _this = _super.call(this, props) || this;
|
|
1025
1007
|
_this.keys = keys;
|
|
1026
1008
|
_this.resourceService = resourceService;
|
|
@@ -1035,7 +1017,6 @@ var BaseDiffApprComponent = (function (_super) {
|
|
|
1035
1017
|
_this.postReject = _this.postReject.bind(_this);
|
|
1036
1018
|
_this.format = _this.format.bind(_this);
|
|
1037
1019
|
_this.handleNotFound = _this.handleNotFound.bind(_this);
|
|
1038
|
-
_this.status = core_1.createDiffStatus(status);
|
|
1039
1020
|
_this.state = {
|
|
1040
1021
|
disabled: false
|
|
1041
1022
|
};
|
|
@@ -1048,37 +1029,29 @@ var BaseDiffApprComponent = (function (_super) {
|
|
|
1048
1029
|
BaseDiffApprComponent.prototype.postApprove = function (s, err) {
|
|
1049
1030
|
this.setState({ disabled: true });
|
|
1050
1031
|
var r = this.resourceService;
|
|
1051
|
-
|
|
1052
|
-
if (s === st.success) {
|
|
1032
|
+
if (s > 0) {
|
|
1053
1033
|
this.showMessage(r.value('msg_approve_success'));
|
|
1054
1034
|
}
|
|
1055
|
-
else if (s ===
|
|
1056
|
-
var msg = core_2.message(r.value, 'msg_approve_version_error', 'error');
|
|
1057
|
-
this.showError(msg.message, msg.title);
|
|
1058
|
-
}
|
|
1059
|
-
else if (s === st.not_found) {
|
|
1035
|
+
else if (s === 0) {
|
|
1060
1036
|
this.handleNotFound();
|
|
1061
1037
|
}
|
|
1062
1038
|
else {
|
|
1063
|
-
core_2.
|
|
1039
|
+
var msg = core_2.message(r.value, 'msg_approve_version_error', 'error');
|
|
1040
|
+
this.showError(msg.message, msg.title);
|
|
1064
1041
|
}
|
|
1065
1042
|
};
|
|
1066
1043
|
BaseDiffApprComponent.prototype.postReject = function (status, err) {
|
|
1067
1044
|
this.setState({ disabled: true });
|
|
1068
1045
|
var r = this.resourceService;
|
|
1069
|
-
|
|
1070
|
-
if (status === st.success) {
|
|
1046
|
+
if (status > 0) {
|
|
1071
1047
|
this.showMessage(r.value('msg_reject_success'));
|
|
1072
1048
|
}
|
|
1073
|
-
else if (status ===
|
|
1074
|
-
var msg = core_2.message(r.value, 'msg_approve_version_error', 'error');
|
|
1075
|
-
this.showError(msg.message, msg.title);
|
|
1076
|
-
}
|
|
1077
|
-
else if (status === st.not_found) {
|
|
1049
|
+
else if (status === 0) {
|
|
1078
1050
|
this.handleNotFound();
|
|
1079
1051
|
}
|
|
1080
1052
|
else {
|
|
1081
|
-
core_2.
|
|
1053
|
+
var msg = core_2.message(r.value, 'msg_approve_version_error', 'error');
|
|
1054
|
+
this.showError(msg.message, msg.title);
|
|
1082
1055
|
}
|
|
1083
1056
|
};
|
|
1084
1057
|
BaseDiffApprComponent.prototype.format = function () {
|
|
@@ -1132,8 +1105,8 @@ var BaseDiffApprComponent = (function (_super) {
|
|
|
1132
1105
|
exports.BaseDiffApprComponent = BaseDiffApprComponent;
|
|
1133
1106
|
var DiffApprComponent = (function (_super) {
|
|
1134
1107
|
__extends(DiffApprComponent, _super);
|
|
1135
|
-
function DiffApprComponent(props, service, param, showMessage, showError, loading
|
|
1136
|
-
var _this = _super.call(this, props, service.keys(), input_1.getResource(param), input_1.getMsgFunc(param, showMessage), input_1.getErrorFunc(param, showError), input_1.getLoadingFunc(param, loading)
|
|
1108
|
+
function DiffApprComponent(props, service, param, showMessage, showError, loading) {
|
|
1109
|
+
var _this = _super.call(this, props, service.keys(), input_1.getResource(param), input_1.getMsgFunc(param, showMessage), input_1.getErrorFunc(param, showError), input_1.getLoadingFunc(param, loading)) || this;
|
|
1137
1110
|
_this.service = service;
|
|
1138
1111
|
_this.approve = _this.approve.bind(_this);
|
|
1139
1112
|
_this.reject = _this.reject.bind(_this);
|
|
@@ -1153,32 +1126,32 @@ var DiffApprComponent = (function (_super) {
|
|
|
1153
1126
|
var id = _id;
|
|
1154
1127
|
if (id != null && id !== '') {
|
|
1155
1128
|
this.id = _id;
|
|
1156
|
-
var
|
|
1129
|
+
var com_3 = this;
|
|
1157
1130
|
this.running = true;
|
|
1158
1131
|
core_1.showLoading(this.loading);
|
|
1159
1132
|
this.service.diff(id).then(function (dobj) {
|
|
1160
1133
|
if (!dobj) {
|
|
1161
|
-
|
|
1134
|
+
com_3.handleNotFound();
|
|
1162
1135
|
}
|
|
1163
1136
|
else {
|
|
1164
|
-
var formatdDiff = diff_1.formatDiffModel(dobj,
|
|
1165
|
-
|
|
1137
|
+
var formatdDiff = diff_1.formatDiffModel(dobj, com_3.formatFields);
|
|
1138
|
+
com_3.setState({
|
|
1166
1139
|
origin: formatdDiff.origin,
|
|
1167
1140
|
value: formatdDiff.value
|
|
1168
|
-
},
|
|
1141
|
+
}, com_3.format);
|
|
1169
1142
|
}
|
|
1170
|
-
|
|
1171
|
-
core_1.hideLoading(
|
|
1143
|
+
com_3.running = false;
|
|
1144
|
+
core_1.hideLoading(com_3.loading);
|
|
1172
1145
|
}).catch(function (err) {
|
|
1173
1146
|
var data = (err && err.response) ? err.response : err;
|
|
1174
1147
|
if (data && data.status === 404) {
|
|
1175
|
-
|
|
1148
|
+
com_3.handleNotFound();
|
|
1176
1149
|
}
|
|
1177
1150
|
else {
|
|
1178
|
-
core_2.error(err,
|
|
1151
|
+
core_2.error(err, com_3.resourceService.value, com_3.showError);
|
|
1179
1152
|
}
|
|
1180
|
-
|
|
1181
|
-
core_1.hideLoading(
|
|
1153
|
+
com_3.running = false;
|
|
1154
|
+
core_1.hideLoading(com_3.loading);
|
|
1182
1155
|
});
|
|
1183
1156
|
}
|
|
1184
1157
|
};
|
package/lib/core.js
CHANGED
|
@@ -3,34 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var formutil_1 = require("./formutil");
|
|
4
4
|
exports.pageSizes = [12, 24, 60, 100, 120, 180, 300, 600];
|
|
5
5
|
exports.size = exports.pageSizes;
|
|
6
|
-
function createEditStatus(status) {
|
|
7
|
-
if (status) {
|
|
8
|
-
return status;
|
|
9
|
-
}
|
|
10
|
-
var s = {
|
|
11
|
-
duplicate_key: 0,
|
|
12
|
-
not_found: 0,
|
|
13
|
-
success: 1,
|
|
14
|
-
version_error: -1,
|
|
15
|
-
error: 2,
|
|
16
|
-
data_corrupt: 4
|
|
17
|
-
};
|
|
18
|
-
return s;
|
|
19
|
-
}
|
|
20
|
-
exports.createEditStatus = createEditStatus;
|
|
21
|
-
function createDiffStatus(status) {
|
|
22
|
-
if (status) {
|
|
23
|
-
return status;
|
|
24
|
-
}
|
|
25
|
-
var s = {
|
|
26
|
-
not_found: 0,
|
|
27
|
-
success: 1,
|
|
28
|
-
version_error: 2,
|
|
29
|
-
error: 4
|
|
30
|
-
};
|
|
31
|
-
return s;
|
|
32
|
-
}
|
|
33
|
-
exports.createDiffStatus = createDiffStatus;
|
|
34
6
|
var resource = (function () {
|
|
35
7
|
function resource() {
|
|
36
8
|
}
|
package/lib/edit.js
CHANGED
|
@@ -105,19 +105,6 @@ function initPropertyNullInModel(obj, m) {
|
|
|
105
105
|
return obj;
|
|
106
106
|
}
|
|
107
107
|
exports.initPropertyNullInModel = initPropertyNullInModel;
|
|
108
|
-
function handleStatus(x, st, gv, se) {
|
|
109
|
-
var title = gv('error');
|
|
110
|
-
if (x === st.version_error) {
|
|
111
|
-
se(gv('error_version'), title);
|
|
112
|
-
}
|
|
113
|
-
else if (x === st.data_corrupt) {
|
|
114
|
-
se(gv('error_data_corrupt'), title);
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
se(gv('error_internal'), title);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.handleStatus = handleStatus;
|
|
121
108
|
function handleVersion(obj, version) {
|
|
122
109
|
if (obj && version && version.length > 0) {
|
|
123
110
|
var v = obj[version];
|
package/lib/formutil.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function
|
|
3
|
+
function setReadOnly(form) {
|
|
4
|
+
var args = [];
|
|
5
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6
|
+
args[_i - 1] = arguments[_i];
|
|
7
|
+
}
|
|
4
8
|
if (!form) {
|
|
5
9
|
return;
|
|
6
10
|
}
|
|
@@ -8,34 +12,44 @@ function readOnly(form) {
|
|
|
8
12
|
for (var i = 0; i < len; i++) {
|
|
9
13
|
var ctrl = form[i];
|
|
10
14
|
var name_1 = ctrl.getAttribute('name');
|
|
15
|
+
var skip = false;
|
|
11
16
|
if (name_1 != null && name_1.length > 0 && name_1 !== 'btnBack') {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (nodeName !== 'BUTTON'
|
|
18
|
-
&& nodeName !== 'RESET'
|
|
19
|
-
&& nodeName !== 'SUBMIT'
|
|
20
|
-
&& nodeName !== 'SELECT') {
|
|
21
|
-
switch (type) {
|
|
22
|
-
case 'checkbox':
|
|
23
|
-
ctrl.disabled = true;
|
|
24
|
-
break;
|
|
25
|
-
case 'radio':
|
|
26
|
-
ctrl.disabled = true;
|
|
27
|
-
break;
|
|
28
|
-
default:
|
|
29
|
-
ctrl.readOnly = true;
|
|
17
|
+
if (arguments.length > 1) {
|
|
18
|
+
for (var j = 1; j < arguments.length; j++) {
|
|
19
|
+
if (arguments[j] === name_1) {
|
|
20
|
+
skip = true;
|
|
21
|
+
}
|
|
30
22
|
}
|
|
31
23
|
}
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
if (skip === false) {
|
|
25
|
+
var nodeName = ctrl.nodeName;
|
|
26
|
+
var type = ctrl.getAttribute('type');
|
|
27
|
+
if (nodeName === 'INPUT' && type !== null) {
|
|
28
|
+
nodeName = type.toUpperCase();
|
|
29
|
+
}
|
|
30
|
+
if (nodeName !== 'BUTTON'
|
|
31
|
+
&& nodeName !== 'RESET'
|
|
32
|
+
&& nodeName !== 'SUBMIT'
|
|
33
|
+
&& nodeName !== 'SELECT') {
|
|
34
|
+
switch (type) {
|
|
35
|
+
case 'checkbox':
|
|
36
|
+
ctrl.disabled = true;
|
|
37
|
+
break;
|
|
38
|
+
case 'radio':
|
|
39
|
+
ctrl.disabled = true;
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
ctrl.readOnly = true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
ctrl.disabled = true;
|
|
47
|
+
}
|
|
34
48
|
}
|
|
35
49
|
}
|
|
36
50
|
}
|
|
37
51
|
}
|
|
38
|
-
exports.
|
|
52
|
+
exports.setReadOnly = setReadOnly;
|
|
39
53
|
function focusFirstElement(form) {
|
|
40
54
|
var i = 0;
|
|
41
55
|
var len = form.length;
|
package/lib/index.js
CHANGED
|
@@ -82,6 +82,14 @@ exports.CurrencyInput = function (props) {
|
|
|
82
82
|
};
|
|
83
83
|
return React.createElement("input", { className: props.className, onBlur: onBlur, type: props.type, name: props.name, onChange: props.onChange ? props.onChange : onChange, disabled: props.disabled, "data-field": props['data-field'], min: props.min, max: props.max, value: state });
|
|
84
84
|
};
|
|
85
|
+
function getParam(url, i) {
|
|
86
|
+
var ps = url.split('/');
|
|
87
|
+
if (!i || i < 0) {
|
|
88
|
+
i = 0;
|
|
89
|
+
}
|
|
90
|
+
return ps[ps.length - 1 - i];
|
|
91
|
+
}
|
|
92
|
+
exports.getParam = getParam;
|
|
85
93
|
function formatDate(date, format) {
|
|
86
94
|
if (!date) {
|
|
87
95
|
return '';
|
package/lib/input.js
CHANGED
|
@@ -60,17 +60,3 @@ function getErrorFunc(p, showErr) {
|
|
|
60
60
|
return p.showError;
|
|
61
61
|
}
|
|
62
62
|
exports.getErrorFunc = getErrorFunc;
|
|
63
|
-
function getEditStatusFunc(p, status) {
|
|
64
|
-
if (status) {
|
|
65
|
-
return status;
|
|
66
|
-
}
|
|
67
|
-
return p.status;
|
|
68
|
-
}
|
|
69
|
-
exports.getEditStatusFunc = getEditStatusFunc;
|
|
70
|
-
function getDiffStatusFunc(p, status) {
|
|
71
|
-
if (status) {
|
|
72
|
-
return status;
|
|
73
|
-
}
|
|
74
|
-
return p.status;
|
|
75
|
-
}
|
|
76
|
-
exports.getDiffStatusFunc = getDiffStatusFunc;
|