Skip to content

Commit

Permalink
Replace 'values' key with 'default_value' when updating value for field
Browse files Browse the repository at this point in the history
  • Loading branch information
eclarizio committed May 6, 2019
1 parent 1afd116 commit 7dcb1f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
4 changes: 1 addition & 3 deletions src/dialog-user/components/dialog-user/dialogUser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ describe('Dialog test', () => {
read_only: 'new read_only',
required: true,
visible: false,
values: 'new values',
default_value: 'new default_value'
};

Expand All @@ -246,7 +245,7 @@ describe('Dialog test', () => {
});

it('updates the field value', () => {
expect(dialogCtrl.dialogValues['service_name']).toBe('new values');
expect(dialogCtrl.dialogValues['service_name']).toBe('new default_value');
});

it('updates properties of the field', () => {
Expand All @@ -255,7 +254,6 @@ describe('Dialog test', () => {
expect(dialogCtrl.dialogFields['service_name'].read_only).toBe('new read_only');
expect(dialogCtrl.dialogFields['service_name'].required).toBe(true);
expect(dialogCtrl.dialogFields['service_name'].visible).toBe(false);
expect(dialogCtrl.dialogFields['service_name'].values).toBe('new values');
expect(dialogCtrl.dialogFields['service_name'].default_value).toBe('new default_value');
});
});
Expand Down
19 changes: 2 additions & 17 deletions src/dialog-user/components/dialog-user/dialogUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,8 @@ export class DialogUserController extends DialogClass implements IDialogs {

private refreshFieldCallback(field, data) {
this.dialogFields[field] = this.updateDialogFieldData(field, data);
if (this.isASortedItemDialogField(data.type)) {
this.dialogValues[field] = data.default_value;
} else {
this.dialogValues[field] = data.values;
}

this.dialogValues[field] = data.default_value;
this.dialogFields[field].fieldBeingRefreshed = false;

this.saveDialogData();
Expand All @@ -238,18 +235,6 @@ export class DialogUserController extends DialogClass implements IDialogs {
}
}

/**
* Determines if the given field type is a subclass of DialogFieldSortedItem
* @memberof DialogUserController
* @function isASortedItemDialogField
* @param fieldType {string} This is the field type that should be used for comparison
*/
private isASortedItemDialogField(fieldType) {
return fieldType === 'DialogFieldDropDownList' ||
fieldType === 'DialogFieldRadioButton' ||
fieldType === 'DialogFieldTagControl';
}

/**
* Deals with updating select properties on a dialog field after the field has been refreshed
* @memberof DialogUserController
Expand Down

0 comments on commit 7dcb1f7

Please sign in to comment.