Skip to content

Commit

Permalink
Updated how fields get refreshed to be recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
chalettu committed Jul 12, 2017
1 parent 7c6ddbe commit f710160
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
19 changes: 11 additions & 8 deletions dist/js/ui-components.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/js/ui-components.js.map

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions src/dialogs/components/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,26 @@ constructor(private DialogData: any){
if (refreshable > -1) {
this.refreshField({ field: this.dialogFields[dialogFieldName] }).then((data) => {
this.dialogFields[dialogFieldName] = this.updateDialogFieldData(dialogFieldName, data);
this.updateRefreshableFields(dialogFieldName);
const fieldsToRefresh = _.without(this.refreshableFields, dialogFieldName);
this.updateRefreshableFields(fieldsToRefresh);
});
}
this.saveDialogData();
}
/**
* This method is meant to handle auto updating of all dialog fields that are eligable to be refreshed after a field has just been refreshed
* @function updateRefreshableFields
* @param triggerFieldName {string} This is the dialog fields name that was triggered. This is passed to ensure we don't attempt to refresh something that was just refreshed
* @param refreshableFields {array} This is the dialog fields name that was triggered. This is passed to ensure we don't attempt to refresh something that was just refreshed
*/
public updateRefreshableFields(triggerFieldName){
const fieldsToRefresh = _.without(this.refreshableFields, triggerFieldName);
fieldsToRefresh.forEach((field) => {
this.refreshField({ field: this.dialogFields[field] }).then((data) => {
public updateRefreshableFields(refreshableFields): void {
const field = refreshableFields[0];
const fieldsLeftToRefresh = _.without(refreshableFields,field);
this.refreshField({ field: this.dialogFields[field] }).then((data) => {
this.dialogFields[field] = this.updateDialogFieldData(field, data);
});
});
if (fieldsLeftToRefresh.length > 0) {
this.updateRefreshableFields(fieldsLeftToRefresh);
}
});
}
/**
* Deals with updating select properties on a dialog field after the field has been refreshed
Expand Down

0 comments on commit f710160

Please sign in to comment.