Skip to content

Commit 82d7339

Browse files
committed
fix(form) Revert 9ab7329
1 parent 30859cd commit 82d7339

File tree

6 files changed

+12
-29
lines changed

6 files changed

+12
-29
lines changed

config/karma.midway.conf.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ module.exports = function(config) {
1919
'test/midway/**/*.js'
2020
],
2121

22+
client: {
23+
captureConsole: true
24+
},
2225
autoWatch : true,
2326
usePolling: true,
2427

dist/forms-angular.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ var fng;
624624
var allInputsVars = formMarkupHelper.allInputsVars(scope, fieldInfo, options, modelString, idString, nameString);
625625
var common = allInputsVars.common;
626626
var value;
627+
var requiredStr = (isRequired || fieldInfo.required) ? ' required' : '';
627628
isRequired = isRequired || fieldInfo.required;
628629
var requiredStr = isRequired ? ' required' : '';
629630
var enumInstruction;
@@ -636,14 +637,7 @@ var fng;
636637
common += (fieldInfo.readonly ? 'disabled ' : '');
637638
common += fieldInfo.add ? (' ' + fieldInfo.add + ' ') : '';
638639
value = '<select ' + common + 'class="' + allInputsVars.formControl.trim() + allInputsVars.compactClass + allInputsVars.sizeClassBS2 + '" ' + requiredStr + '>';
639-
if (isRequired) {
640-
/*
641-
Tell the user to select a value
642-
This becomes disabled in updateRecordWithLookupValues (setting disabled now causes $pristine to be unset, which conflicts with the condition in updateRecordWithLookupValues)
643-
*/
644-
value += '<option class="disableMe" value="">Select a value</option>';
645-
}
646-
else {
640+
if (!isRequired) {
647641
value += '<option></option>';
648642
}
649643
if (angular.isArray(fieldInfo.options)) {
@@ -2717,9 +2711,6 @@ var fng;
27172711
if (newVal) {
27182712
setData($scope.record, schemaElement.name, undefined, newVal);
27192713
}
2720-
if (schemaElement.required) {
2721-
angular.element('#' + schemaElement.id + ' .disableMe').prop('disabled', true);
2722-
}
27232714
}
27242715
};
27252716
// Split a field name into the next level and all following levels

dist/forms-angular.min.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.

js/directives/form.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ module fng.directives {
110110
var allInputsVars = formMarkupHelper.allInputsVars(scope, fieldInfo, options, modelString, idString, nameString);
111111
var common = allInputsVars.common;
112112
var value;
113+
var requiredStr = (isRequired || fieldInfo.required) ? ' required' : '';
113114
isRequired = isRequired || fieldInfo.required;
114115
var requiredStr = isRequired ? ' required' : '';
115116
var enumInstruction:IEnumInstruction;
@@ -122,13 +123,8 @@ module fng.directives {
122123
common += (fieldInfo.readonly ? 'disabled ' : '');
123124
common += fieldInfo.add ? (' ' + fieldInfo.add + ' ') : '';
124125
value = '<select ' + common + 'class="' + allInputsVars.formControl.trim() + allInputsVars.compactClass + allInputsVars.sizeClassBS2 + '" ' + requiredStr + '>';
125-
if (isRequired) {
126-
/*
127-
Tell the user to select a value
128-
This becomes disabled in updateRecordWithLookupValues (setting disabled now causes $pristine to be unset, which conflicts with the condition in updateRecordWithLookupValues)
129-
*/
130-
value += '<option class="disableMe" value="">Select a value</option>';
131-
} else {
126+
127+
if (!isRequired) {
132128
value += '<option></option>';
133129
}
134130
if (angular.isArray(fieldInfo.options)) {

js/services/record-handler.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ module fng.services {
9898
if (newVal) {
9999
setData($scope.record, schemaElement.name, undefined, newVal);
100100
}
101-
if (schemaElement.required) {
102-
angular.element('#' + schemaElement.id + ' .disableMe').prop('disabled', true);
103-
}
104101
}
105102
};
106103

test/midway/selectSpec.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,9 @@ describe('Select.', function () {
7272
expect(input.val()).toBe('Brown');
7373

7474
input = input.find('option');
75-
expect(input.length).toBe(5);
76-
77-
var option = angular.element(input[0]);
78-
expect(option.text()).toBe('Select a value');
75+
expect(input.length).toBe(4);
7976

80-
option = angular.element(input[4]);
77+
var option = angular.element(input[3]);
8178
expect(option.text()).toBe('Hazel');
8279
});
8380

@@ -159,4 +156,3 @@ describe('Select.', function () {
159156
});
160157

161158
});
162-

0 commit comments

Comments
 (0)