forms-angular 0.12.0-beta.244 → 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 -64
- package/dist/server/index.d.ts +1 -0
- package/package.json +2 -2
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,70 +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
|
-
|
|
740
|
-
|
|
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
|
|
741
745
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
let
|
|
745
|
-
if (
|
|
746
|
-
|
|
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);
|
|
747
774
|
}
|
|
748
|
-
listFields.push(listFieldInfo);
|
|
749
775
|
}
|
|
750
776
|
}
|
|
751
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;
|
|
752
791
|
}
|
|
753
|
-
outPath = this.applySchemaSubset(outPath, formSchema);
|
|
754
|
-
let returnObj = { paths: outPath };
|
|
755
|
-
if (hiddenFields.length > 0) {
|
|
756
|
-
returnObj.hide = hiddenFields;
|
|
757
|
-
}
|
|
758
|
-
if (listFields.length > 0) {
|
|
759
|
-
returnObj.listFields = listFields;
|
|
760
|
-
}
|
|
761
|
-
return returnObj;
|
|
762
792
|
}
|
|
763
793
|
;
|
|
764
794
|
schema() {
|
|
@@ -767,16 +797,22 @@ class FormsAngular {
|
|
|
767
797
|
return res.status(404).end();
|
|
768
798
|
}
|
|
769
799
|
let formSchema = null;
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
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
|
+
}
|
|
776
812
|
}
|
|
813
|
+
let paths = this.preprocess(req.resource, req.resource.model.schema.paths, formName, formSchema).paths;
|
|
814
|
+
res.send(paths);
|
|
777
815
|
}
|
|
778
|
-
let paths = this.preprocess(req.resource, req.resource.model.schema.paths, formSchema).paths;
|
|
779
|
-
res.send(paths);
|
|
780
816
|
}, this);
|
|
781
817
|
}
|
|
782
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"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"express": "^4",
|
|
57
|
-
"mongoose": "^8"
|
|
57
|
+
"mongoose": "^7.3.3 || ^8"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/angular": "1.8.9",
|