Skip to content

Commit

Permalink
Merge branch 'support/2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbrazzatti committed Sep 18, 2023
2 parents 82127e1 + 4227f36 commit 3ac553d
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 7 deletions.
2 changes: 1 addition & 1 deletion angular-legacy/shared/form/field-contributor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ export class ContributorComponent extends SimpleComponent {
let fmFamilyName = _.get(this.field.formModel.value, 'family_name');
let fmGivenName = _.get(this.field.formModel.value, 'given_name');
let selectedEmail = _.get(selected, 'email');
let selectedOrcid = _.get(selected, 'email');
let selectedOrcid = _.get(selected, 'orcid');
let fmEmail = _.get(this.field.formModel.value, 'email');
let fmOrcid = _.get(this.field.formModel.value, 'orcid');
if (selectedFamilyName && selectedFamilyName == fmFamilyName && selectedGivenName && selectedGivenName == fmGivenName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class RelatedObjectDataField extends FieldBase<any> {
}

setValue(value: any) {
this.value = value;
this.formModel.patchValue(value, { emitEvent: false });
this.formModel.markAsTouched();
}
Expand Down
80 changes: 80 additions & 0 deletions angular-legacy/shared/form/field-repeatable.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,86 @@ export class RepeatableContributor extends RepeatableContainer {
this.fields[0].setMissingFields(val);
return super.addElem(val);
}

public setVisibility(data, eventConf:any = {}) {
let newVisible = this.visible;
if (_.isArray(this.visibilityCriteria)) {
// save the value of this data in a map, so we can run complex conditional logic that depends on one or more fields
if (!_.isEmpty(eventConf) && !_.isEmpty(eventConf.srcName)) {
this.subscriptionData[eventConf.srcName] = data;
}
// only run the function set if we have all the data...
if (_.size(this.subscriptionData) == _.size(this.visibilityCriteria)) {
newVisible = true;
_.each(this.visibilityCriteria, (visibilityCriteria) => {
const dataEntry = this.subscriptionData[visibilityCriteria.fieldName];
newVisible = newVisible && this.execVisibilityFn(dataEntry, visibilityCriteria);
});

}
} else
if (_.isObject(this.visibilityCriteria) && _.get(this.visibilityCriteria, 'type') == 'function') {
newVisible = this.execVisibilityFn(data, this.visibilityCriteria);
} else {
newVisible = _.isEqual(data, this.visibilityCriteria);
}
const that = this;
setTimeout(() => {
if (!newVisible) {
if (that.visible) {
// remove validators
if (that.formModel) {
if(that['disableValidators'] != null && typeof(that['disableValidators']) == 'function') {
that['disableValidators']();
} else {
that.formModel.clearValidators();
}
that.formModel.updateValueAndValidity();
}
for(let field of that.fields) {
if(field.formModel) {
if(field['disableValidators'] != null && typeof(field['disableValidators']) == 'function') {
field['disableValidators']();
} else {
field.formModel.clearValidators();
}
field.formModel.updateValueAndValidity();
}
}
}
} else {
if (!that.visible) {
// restore validators
if (that.formModel) {
if(that['enableValidators'] != null && typeof(that['enableValidators']) == 'function') {
that['enableValidators']();
} else {
that.formModel.setValidators(that.validators);
}
that.formModel.updateValueAndValidity();
}
for(let field of that.fields) {
if(field.formModel) {
if(field['enableValidators'] != null && typeof(field['enableValidators']) == 'function') {
field['enableValidators']();
} else {
field.formModel.setValidators(field.validators);
}
setTimeout(() => {
field.setValue(field.formModel.value,false,true)
});
field.formModel.updateValueAndValidity();
}
}
}
}
that.visible = newVisible;
});
if(eventConf.returnData == true) {
return data;
}
}

}

@Component({
Expand Down
12 changes: 7 additions & 5 deletions angular-legacy/shared/form/record-meta.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ export class RecordMetadataRetrieverField extends FieldBase<string> {
}

public publishMetadata(oid: any, config: any) {
this.recordsService.getRecordMeta(oid).then(data => {
data.oid = oid;
this.onValueUpdate.emit(data);
});
// Only attempt to publish when there is an oid value
if (oid != undefined && oid != null && oid != "") {
this.recordsService.getRecordMeta(oid).then(data => {
data.oid = oid;
this.onValueUpdate.emit(data);
});
}
}

}

@Component({
Expand Down
10 changes: 9 additions & 1 deletion angular-legacy/shared/form/timer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ export class TimerField extends FieldBase<string> {

public startPolling(config:any = {}){
this.subscription =this.timer.subscribe(pollingTick => {
this.onPollingTick.emit(new Date());
let oid = this.fieldMap._rootComp.oid;
let emitData = {
emitDate: new Date(),
numberOfTicks: pollingTick,
oid: oid
}
this.onPollingTick.emit(
emitData
);
if(this.pollingTickLimit != 0 && pollingTick > this.pollingTickLimit) {
this.subscription.unsubscribe();
}
Expand Down

0 comments on commit 3ac553d

Please sign in to comment.