forms-angular 0.12.0-beta.243 → 0.12.0-beta.245
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/server/data_form.js +100 -63
- package/dist/server/index.d.ts +1 -0
- package/package.json +18 -23
package/dist/server/data_form.js
CHANGED
|
@@ -220,7 +220,7 @@ class FormsAngular {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
extend(resource.options, this.preprocess(resource, resource.model.schema['paths']
|
|
223
|
+
extend(resource.options, this.preprocess(resource, resource.model.schema['paths']));
|
|
224
224
|
if (resource.options.searchImportance) {
|
|
225
225
|
this.searchFunc = async.forEachSeries;
|
|
226
226
|
}
|
|
@@ -695,69 +695,100 @@ class FormsAngular {
|
|
|
695
695
|
return outPath;
|
|
696
696
|
}
|
|
697
697
|
;
|
|
698
|
-
preprocess(resource, paths, formSchema) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
let subSchemaInfo = this.preprocess(null, paths[element].schema.paths);
|
|
709
|
-
outPath[element] = { schema: subSchemaInfo.paths };
|
|
710
|
-
if (paths[element].options.form) {
|
|
711
|
-
outPath[element].options = { form: extend(true, {}, paths[element].options.form) };
|
|
712
|
-
}
|
|
713
|
-
// this provides support for entire nested schemas that wish to remain hidden
|
|
714
|
-
if (paths[element].options.secure) {
|
|
715
|
-
hiddenFields.push(element);
|
|
716
|
-
}
|
|
717
|
-
// to support hiding individual properties of nested schema would require us
|
|
718
|
-
// to do something with subSchemaInfo.hide here
|
|
719
|
-
}
|
|
720
|
-
else {
|
|
721
|
-
// check for arrays
|
|
722
|
-
let realType = paths[element].caster ? paths[element].caster : paths[element];
|
|
723
|
-
if (!realType.instance) {
|
|
724
|
-
if (realType.options.type) {
|
|
725
|
-
let type = realType.options.type(), typeType = typeof type;
|
|
726
|
-
if (typeType === 'string') {
|
|
727
|
-
realType.instance = (!isNaN(Date.parse(type))) ? 'Date' : 'String';
|
|
728
|
-
}
|
|
729
|
-
else {
|
|
730
|
-
realType.instance = typeType;
|
|
698
|
+
preprocess(resource, paths, formName, formSchema) {
|
|
699
|
+
function processInternalObject(obj) {
|
|
700
|
+
return Object.keys(obj).reduce((acc, cur) => {
|
|
701
|
+
const curType = typeof obj[cur];
|
|
702
|
+
if (!['$', '_'].includes(cur.charAt(0)) && curType !== 'function') {
|
|
703
|
+
const val = obj[cur];
|
|
704
|
+
if (val) {
|
|
705
|
+
if (Array.isArray(val)) {
|
|
706
|
+
if (val.length > 0) {
|
|
707
|
+
acc[cur] = val;
|
|
731
708
|
}
|
|
732
709
|
}
|
|
710
|
+
else if (curType === 'object') {
|
|
711
|
+
acc[cur] = processInternalObject(obj[cur]);
|
|
712
|
+
}
|
|
713
|
+
else {
|
|
714
|
+
acc[cur] = obj[cur];
|
|
715
|
+
}
|
|
733
716
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
717
|
+
}
|
|
718
|
+
return acc;
|
|
719
|
+
}, {});
|
|
720
|
+
}
|
|
721
|
+
let outPath = {}, hiddenFields = [], listFields = [];
|
|
722
|
+
if (resource && resource.preprocessed && resource.preprocessed[formName || "__default"]) {
|
|
723
|
+
return resource.preprocessed[formName || "__default"].paths;
|
|
724
|
+
}
|
|
725
|
+
else {
|
|
726
|
+
if (resource && resource.options && resource.options.idIsList) {
|
|
727
|
+
paths['_id'].options = paths['_id'].options || {};
|
|
728
|
+
paths['_id'].options.list = resource.options.idIsList;
|
|
729
|
+
}
|
|
730
|
+
for (let element in paths) {
|
|
731
|
+
if (paths.hasOwnProperty(element) && element !== '__v') {
|
|
732
|
+
// check for schemas
|
|
733
|
+
if (paths[element].schema) {
|
|
734
|
+
let subSchemaInfo = this.preprocess(null, paths[element].schema.paths);
|
|
735
|
+
outPath[element] = { schema: subSchemaInfo.paths };
|
|
736
|
+
if (paths[element].options.form) {
|
|
737
|
+
outPath[element].options = { form: extend(true, {}, paths[element].options.form) };
|
|
738
|
+
}
|
|
739
|
+
// this provides support for entire nested schemas that wish to remain hidden
|
|
740
|
+
if (paths[element].options.secure) {
|
|
741
|
+
hiddenFields.push(element);
|
|
742
|
+
}
|
|
743
|
+
// to support hiding individual properties of nested schema would require us
|
|
744
|
+
// to do something with subSchemaInfo.hide here
|
|
740
745
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
let
|
|
744
|
-
if (
|
|
745
|
-
|
|
746
|
+
else {
|
|
747
|
+
// check for arrays
|
|
748
|
+
let realType = paths[element].caster ? paths[element].caster : paths[element];
|
|
749
|
+
if (!realType.instance) {
|
|
750
|
+
if (realType.options.type) {
|
|
751
|
+
let type = realType.options.type(), typeType = typeof type;
|
|
752
|
+
if (typeType === 'string') {
|
|
753
|
+
realType.instance = (!isNaN(Date.parse(type))) ? 'Date' : 'String';
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
realType.instance = typeType;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
outPath[element] = processInternalObject(paths[element]);
|
|
761
|
+
if (paths[element].options.secure) {
|
|
762
|
+
hiddenFields.push(element);
|
|
763
|
+
}
|
|
764
|
+
if (paths[element].options.match) {
|
|
765
|
+
outPath[element].options.match = paths[element].options.match.source || paths[element].options.match;
|
|
766
|
+
}
|
|
767
|
+
let schemaListInfo = paths[element].options.list;
|
|
768
|
+
if (schemaListInfo) {
|
|
769
|
+
let listFieldInfo = { field: element };
|
|
770
|
+
if (typeof schemaListInfo === 'object' && Object.keys(schemaListInfo).length > 0) {
|
|
771
|
+
listFieldInfo.params = schemaListInfo;
|
|
772
|
+
}
|
|
773
|
+
listFields.push(listFieldInfo);
|
|
746
774
|
}
|
|
747
|
-
listFields.push(listFieldInfo);
|
|
748
775
|
}
|
|
749
776
|
}
|
|
750
777
|
}
|
|
778
|
+
outPath = this.applySchemaSubset(outPath, formSchema);
|
|
779
|
+
let returnObj = { paths: outPath };
|
|
780
|
+
if (hiddenFields.length > 0) {
|
|
781
|
+
returnObj.hide = hiddenFields;
|
|
782
|
+
}
|
|
783
|
+
if (listFields.length > 0) {
|
|
784
|
+
returnObj.listFields = listFields;
|
|
785
|
+
}
|
|
786
|
+
if (resource) {
|
|
787
|
+
resource.preprocessed = resource.preprocessed || {};
|
|
788
|
+
resource.preprocessed[formName || "__default"] = returnObj;
|
|
789
|
+
}
|
|
790
|
+
return returnObj;
|
|
751
791
|
}
|
|
752
|
-
outPath = this.applySchemaSubset(outPath, formSchema);
|
|
753
|
-
let returnObj = { paths: outPath };
|
|
754
|
-
if (hiddenFields.length > 0) {
|
|
755
|
-
returnObj.hide = hiddenFields;
|
|
756
|
-
}
|
|
757
|
-
if (listFields.length > 0) {
|
|
758
|
-
returnObj.listFields = listFields;
|
|
759
|
-
}
|
|
760
|
-
return returnObj;
|
|
761
792
|
}
|
|
762
793
|
;
|
|
763
794
|
schema() {
|
|
@@ -766,16 +797,22 @@ class FormsAngular {
|
|
|
766
797
|
return res.status(404).end();
|
|
767
798
|
}
|
|
768
799
|
let formSchema = null;
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
800
|
+
const formName = req.params.formName;
|
|
801
|
+
if (req.resource.preprocessed?.[formName || "__default"]) {
|
|
802
|
+
res.send(req.resource.preprocessed[formName || "__default"].paths);
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
if (formName) {
|
|
806
|
+
try {
|
|
807
|
+
formSchema = req.resource.model.schema.statics['form'](formName, req);
|
|
808
|
+
}
|
|
809
|
+
catch (e) {
|
|
810
|
+
return res.status(500).send(e.message);
|
|
811
|
+
}
|
|
775
812
|
}
|
|
813
|
+
let paths = this.preprocess(req.resource, req.resource.model.schema.paths, formName, formSchema).paths;
|
|
814
|
+
res.send(paths);
|
|
776
815
|
}
|
|
777
|
-
let paths = this.preprocess(req.resource, req.resource.model.schema.paths, formSchema).paths;
|
|
778
|
-
res.send(paths);
|
|
779
816
|
}, this);
|
|
780
817
|
}
|
|
781
818
|
;
|
package/dist/server/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Mark Chapman <support@forms-angular.org>",
|
|
4
4
|
"description": "A form builder that sits on top of Angular.js, Twitter Bootstrap, jQuery UI, Angular-UI, Express and Mongoose. Opinionated or what?",
|
|
5
5
|
"homepage": "http://forms-angular.org",
|
|
6
|
-
"version": "0.12.0-beta.
|
|
6
|
+
"version": "0.12.0-beta.245",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=8.x",
|
|
9
9
|
"npm": ">=5.x"
|
|
@@ -46,56 +46,51 @@
|
|
|
46
46
|
"angular-messages": "1.8.3",
|
|
47
47
|
"angular-sanitize": "1.8.3",
|
|
48
48
|
"angular-ui-bootstrap": "1.3.2 || 2.5.6",
|
|
49
|
-
"angular-ui-grid": "4.
|
|
50
|
-
"async": "3.2.
|
|
49
|
+
"angular-ui-grid": "4.12.4",
|
|
50
|
+
"async": "3.2.5",
|
|
51
51
|
"lodash": "^4.17.21",
|
|
52
52
|
"ng-infinite-scroll": "1.3.0",
|
|
53
|
-
"node.extend": "2.0.
|
|
53
|
+
"node.extend": "2.0.3"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"express": "^4",
|
|
57
|
-
"mongoose": "
|
|
57
|
+
"mongoose": "^7.3.3 || ^8"
|
|
58
58
|
},
|
|
59
|
-
"devDependenciesComments": [
|
|
60
|
-
"mongoose pinned to 7.3.2 to avoid problem testing fng-ui-select:",
|
|
61
|
-
" Converting circular structure to JSON --> starting at object with constructor DocumentArrayPath property $embeddedSchemaType -> object with constructor DocumentArrayElement --- property $parentSchemaType closes the circle",
|
|
62
|
-
" Must be a way we can work around it in time, but trying to get releases out atm"
|
|
63
|
-
],
|
|
64
59
|
"devDependencies": {
|
|
65
|
-
"@types/angular": "1.8.
|
|
66
|
-
"@types/lodash": "4.14.
|
|
67
|
-
"@types/mocha": "^10.0.
|
|
60
|
+
"@types/angular": "1.8.9",
|
|
61
|
+
"@types/lodash": "4.14.202",
|
|
62
|
+
"@types/mocha": "^10.0.6",
|
|
68
63
|
"@types/node": "^18.11.13",
|
|
69
64
|
"angular-mocks": "1.8.3",
|
|
70
|
-
"body-parser": "1.20.
|
|
65
|
+
"body-parser": "1.20.2",
|
|
71
66
|
"bower": "^1.8.14",
|
|
72
|
-
"del": "6.
|
|
67
|
+
"del": "6.1.1",
|
|
73
68
|
"express": "4.18.2",
|
|
74
69
|
"gulp": "^4.0.2",
|
|
75
70
|
"gulp-angular-templatecache": "3.0.1",
|
|
76
71
|
"gulp-clean-css": "4.3.0",
|
|
77
72
|
"gulp-concat": "2.6.1",
|
|
78
73
|
"gulp-less": "5.0.0",
|
|
79
|
-
"gulp-mocha": "
|
|
74
|
+
"gulp-mocha": "9.0.0",
|
|
80
75
|
"gulp-ng-annotate": "2.1.0",
|
|
81
76
|
"gulp-rename": "2.0.0",
|
|
82
|
-
"gulp-replace": "^1.1.
|
|
77
|
+
"gulp-replace": "^1.1.4",
|
|
83
78
|
"gulp-typescript": "5.0.1",
|
|
84
79
|
"gulp-uglify": "3.0.2",
|
|
85
80
|
"gulp-umd": "2.0.0",
|
|
86
|
-
"jasmine-core": "
|
|
87
|
-
"karma": "^6.4.
|
|
88
|
-
"karma-chrome-launcher": "^3.
|
|
81
|
+
"jasmine-core": "5.1.1",
|
|
82
|
+
"karma": "^6.4.2",
|
|
83
|
+
"karma-chrome-launcher": "^3.2.0",
|
|
89
84
|
"karma-firefox-launcher": "^2.1.2",
|
|
90
85
|
"karma-jasmine": "5.1.0",
|
|
91
86
|
"karma-junit-reporter": "2.0.1",
|
|
92
87
|
"karma-ng-html2js-preprocessor": "1.0.0",
|
|
93
88
|
"matchdep": "2.0.0",
|
|
94
89
|
"mocha": "^10.2.0",
|
|
95
|
-
"mongoose": "
|
|
96
|
-
"prettier": "
|
|
90
|
+
"mongoose": "^8",
|
|
91
|
+
"prettier": "3.1.1",
|
|
97
92
|
"pump": "3.0.0",
|
|
98
|
-
"typescript": "4.
|
|
93
|
+
"typescript": "=4.9.5"
|
|
99
94
|
},
|
|
100
95
|
"license": "MIT"
|
|
101
96
|
}
|