Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace 'values' key with 'default_value' when updating value for field #384

Merged
merged 1 commit into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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