Skip to content

Commit a435620

Browse files
committed
Fixes for the cases where default is 0
1 parent f3399c3 commit a435620

File tree

5 files changed

+11
-31
lines changed

5 files changed

+11
-31
lines changed

src/client/js/services/form-generator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ module fng.services {
222222
if (mongooseOptions.readonly) {
223223
formInstructions['readonly'] = true;
224224
}
225-
if (mongooseType.defaultValue) {
225+
if (mongooseType.defaultValue !== undefined) {
226226
formInstructions.defaultValue = mongooseType.defaultValue;
227-
} else if (mongooseType.options && mongooseType.options.default) {
227+
} else if (mongooseType.options && mongooseType.options.default !== undefined) {
228228
console.log('No support for default with no value, yet')
229229
}
230230
return formInstructions;

src/client/js/services/record-handler.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -862,29 +862,6 @@ module fng.services {
862862
setData(anObject, fieldname, null, newVal);
863863
}
864864
}
865-
// // Convert {lookup:'List description for 012abcde'} to {lookup:'012abcde'}
866-
// const idList = $scope[suffixCleanId(schemaI, '_ids')];
867-
// let thisConversion: any;
868-
// if (idList && idList.length > 0) {
869-
// updateObject(fieldname, anObject, function (value) {
870-
// return convertToForeignKeys(schemaI, value, $scope[suffixCleanId(schemaI, 'Options')], idList);
871-
// });
872-
// } else if (thisConversion = getConversionObject($scope, fieldname, schemaName)) {
873-
// const lookup = getData(anObject, fieldname, null);
874-
// let newVal;
875-
// if (schemaI.array) {
876-
// newVal = [];
877-
// if (lookup) {
878-
// for (let n = 0; n < lookup.length; n++) {
879-
// newVal[n] = convertLookup(lookup[n], thisConversion);
880-
// }
881-
// }
882-
// } else {
883-
// newVal = convertLookup(lookup, thisConversion);
884-
// }
885-
// setData(anObject, fieldname, null, newVal);
886-
// }
887-
888865
}
889866
}
890867
return anObject;
@@ -1220,7 +1197,7 @@ module fng.services {
12201197
$scope.setDefaults = function(formSchema: IFormInstruction[], base = ''): any {
12211198
const retVal = {};
12221199
formSchema.forEach(s => {
1223-
if (s.defaultValue) {
1200+
if (s.defaultValue !== undefined) {
12241201
retVal[s.name.replace(base, '')] = s.defaultValue;
12251202
}
12261203
});

src/client/template/base-edit.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ <h4>{{modelNameDisplay}} :
1313
<div class="container-fluid page-body edit-body">
1414
<form-input name="baseForm" schema="baseSchema()" formstyle="compact"></form-input>
1515
</div>
16-
<!--{{ formSchema | json }}-->
16+
<!-- <pre>-->
17+
<!-- {{ formSchema | json }}-->
18+
<!-- {{ record | json }}-->
19+
<!-- </pre>-->
1720
</div>

website/app/models/f_nested_schema.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/app/models/f_nested_schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { IFngSchemaDefinition } from "../../../src/fng-schema";
55
const ExamsSchemaDef : IFngSchemaDefinition = {
66
subject: {type: String, required: true},
77
examDate: {type: Date, required: true, default: new Date(), form: {add: " ng-model-options=\"{timezone:'UTC'}\""}},
8-
score: Number,
9-
result: {type: String, enum: ['distinction', 'merit', 'pass', 'fail']},
8+
score: {type: Number, default: 60},
9+
result: {type: String, enum: ['distinction', 'merit', 'pass', 'fail'], default: 'pass'},
1010
scan: {type: [new Schema(jqUploads.FileSchema)], form: {hidden: true, help:'Attach a scan of the paper - maximum size 0.5MB', directive: 'fng-jq-upload-form', fngJqUploadForm:{single:true, autoUpload: true, sizeLimit:524288}}},
1111
grader: { type: Schema.Types.ObjectId, ref:'b_enhanced_schema', form: {directive: 'fng-ui-select', fngUiSelect: {fngAjax: true}, label: 'Marked By'}},
1212
retakeDate: {type: Date, form: {showWhen: {lhs: '$exams.result', comp: 'eq', rhs: 'fail'}}}

0 commit comments

Comments
 (0)