Skip to content

Commit

Permalink
Fix incremental dates in database ui plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
scottreisdorf committed Nov 28, 2018
1 parent afb3be8 commit 90ebf8c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,26 @@ export class TablePropertiesComponent implements OnChanges, OnInit {
ref.close();
}

private updateRestrictIncrementalToDateOnly(){
let newVal = this.loadStrategyProperty.value;
if (newVal == 'FULL_LOAD') {
this.restrictIncrementalToDateOnly = false;
} else if (this.isIncrementalLoadStrategy(newVal)) {
let option = this.loadStrategyOptions.find((opt: any) => opt.strategy == newVal);
if (option) {
this.restrictIncrementalToDateOnly = option.restrictDates != undefined ? option.restrictDates : false;
}
}
}

/**
* on edit describe the table for incremental load to populate the tableField options
*/
private editIncrementalLoadDescribeTable() {
//get the property that stores the DBCPController Service
let dbcpProperty = this.dbConnectionProperty;
if (dbcpProperty != null && dbcpProperty.value != null && this.selectedTable != null) {
this.updateRestrictIncrementalToDateOnly();
let serviceId = dbcpProperty.value;
let serviceNameValue: any = null;
if (Array.isArray(dbcpProperty.propertyDescriptor.allowableValues)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,42 +89,47 @@ export class FeedDetailsProcessorFieldComponent implements OnInit, OnChanges, On
}

ngOnChanges(changes: SimpleChanges): void {
if (changes.processor) {
if (changes.processor || (changes.readonly && changes.readonly.currentValue == false)) {
// Unsubscribe from form status changes
if (this.statusSubscription != null) {
this.statusSubscription.unsubscribe();
}

if (changes.processor.currentValue) {
// Ensure form state matches readonly state
this.statusSubscription = this.processor.form.statusChanges.subscribe(status => {
if (this.readonly === true && status !== "DISABLED") {
this.processor.form.disable();
}
});

// Fetch template and update state
this.getProcessorTemplate().pipe(
single(),
catchError(err => {
if (err instanceof EmptyError) {
this.state = State.FORM;
changes.processor.currentValue.control = this.getProcessorForm();
return empty();
} else {
throw err;
let processor = changes.processor != undefined ? changes.processor.currentValue : this.processor;
let previousProcessorValue = changes.processor != undefined ? changes.processor.previousValue: undefined;
if(processor != undefined) {
if ((changes.processor && changes.processor.currentValue) || (changes.readonly && changes.readonly.currentValue == false)) {
// Ensure form state matches readonly state
this.statusSubscription = this.processor.form.statusChanges.subscribe(status => {
if (this.readonly === true && status !== "DISABLED") {
this.processor.form.disable();
}
})
).subscribe(null, (err: any) => {
console.error(err);
this.error = err;
this.state = State.ERROR;
});
} else {
this.childType = null;
this.state = State.LOADING;
if (changes.processor.previousValue) {
changes.processor.previousValue.control = null;
});


// Fetch template and update state
this.getProcessorTemplate().pipe(
single(),
catchError(err => {
if (err instanceof EmptyError) {
this.state = State.FORM;
processor.control = this.getProcessorForm();
return empty();
} else {
throw err;
}
})
).subscribe(null, (err: any) => {
console.error(err);
this.error = err;
this.state = State.ERROR;
});
} else {
this.childType = null;
this.state = State.LOADING;
if (previousProcessorValue) {
previousProcessorValue.control = null;
}
}
}
}
Expand All @@ -133,9 +138,12 @@ export class FeedDetailsProcessorFieldComponent implements OnInit, OnChanges, On
if (changes.readonly && this.processor != null) {
if (this.readonly) {
this.processor.form.disable();
this.getProcessorForm().disable();
} else {
this.processor.form.enable();
this.getProcessorForm().enable();
}

}
}

Expand Down

0 comments on commit 90ebf8c

Please sign in to comment.