Skip to content

Commit

Permalink
added chunking property to send block
Browse files Browse the repository at this point in the history
Signed-off-by: artembuslaev <buslaew.ar@mail.ru>
  • Loading branch information
artembuslaev committed Apr 4, 2023
1 parent 78e0e3d commit de21050
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,17 @@
</td>
</tr>

<tr class="propRow" [attr.collapse]="propHidden.main" *ngIf="['database', 'auto'].includes(properties.dataSource)">
<td class="propRowCol"></td>
<td class="propRowCell cellName">Chunking</td>
<td class="propRowCell">
<input class="prop-input" type="checkbox" [(ngModel)]="properties.chunking" [readonly]="readonly">
</td>
</tr>

<tr class="propHeader">
<td class="propRowCol cellCollapse" (click)="onHide(propHidden, 'optionGroup')" [attr.collapse]="propHidden.optionGroup">
<td class="propRowCol cellCollapse" (click)="onHide(propHidden, 'optionGroup')"
[attr.collapse]="propHidden.optionGroup">
<mat-icon>arrow_drop_down</mat-icon>
</td>
<td class="propHeaderCell cellName">Options</td>
Expand All @@ -105,7 +114,8 @@

<ng-container *ngFor="let option of properties.options; let i=index">
<tr class="propRow" [attr.collapse]="propHidden.optionGroup">
<td class="propRowCol cellCollapse" (click)="onHide(propHidden.options, i)" [attr.collapse]="propHidden.options[i]">
<td class="propRowCol cellCollapse" (click)="onHide(propHidden.options, i)"
[attr.collapse]="propHidden.options[i]">
<mat-icon>arrow_drop_down</mat-icon>
</td>
<td class="propRowCell cellName">Option {{i}}</td>
Expand All @@ -132,4 +142,44 @@
</td>
</tr>
</ng-container>
</table>

<ng-template [ngIf]="properties.chunking">
<tr class="propHeader">
<td class="propRowCol cellCollapse" (click)="onHide(propHidden, 'conditionsGroup')"
[attr.collapse]="propHidden.fieldsGroup">
<mat-icon>arrow_drop_down</mat-icon>
</td>
<td class="propHeaderCell cellName">Fields</td>
<td class="propHeaderCell">
<div class="propAdd" (click)="addField()">
<mat-icon>add</mat-icon>
<span>Add Field</span>
</div>
</td>
</tr>
<ng-container *ngFor="let field of properties.fields; let i=index">
<tr class="propRow subRow" [attr.collapse]="propHidden.fieldsGroup">
<td class="propRowCol cellCollapse" (click)="onHide(propHidden.fields, i)"
[attr.collapse]="propHidden.fields[i]">
<mat-icon>arrow_drop_down</mat-icon>
</td>
<td class="propRowCell cellName">Field {{i}}</td>
<td class="propRowCell not-editable-text">
<span>{{field.fieldPath}}</span>
<span class="remove-prop" [attr.readonly]="readonly" (click)="onRemoveField(i)">
<mat-icon>delete</mat-icon>
</span>
</td>
</tr>
<tr class="propRow subRow" [attr.collapse]="propHidden.fieldsGroup || propHidden.fields[i]">
<td class="propRowCol"></td>
<td class="propRowCell cellName" title="Fields">
Fields
</td>
<td class="propRowCell">
<input class="prop-input" [(ngModel)]="field.fieldPath" [readonly]="readonly" (blur)="onSave()">
</td>
</tr>
</ng-container>
</ng-template>
</table>
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ export class SendConfigComponent implements OnInit {

private moduleVariables!: IModuleVariables | null;
private item!: PolicyBlockModel;

propHidden: any = {
main: false,
optionGroup: false,
fieldGroup: false,
fields: {},
options: {}
};

Expand All @@ -47,6 +49,7 @@ export class SendConfigComponent implements OnInit {
this.properties = block.properties;
this.properties.uiMetaData = this.properties.uiMetaData || {};
this.properties.options = this.properties.options || [];
this.properties.fields = this.properties.fields || [];
if (!this.properties.dataType && !this.properties.dataSource) {
this.properties.dataSource = 'auto';
}
Expand Down Expand Up @@ -81,8 +84,18 @@ export class SendConfigComponent implements OnInit {

onDataSource(event: any) {
}

onSave() {
this.item.changed = true;
}

onRemoveField(i: number) {
this.properties.fields.splice(i, 1);
}

addField() {
this.properties.fields.push({
fieldPath: ""
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum Operation {
PolicyOutputEventType.RefreshEvent,
PolicyOutputEventType.ErrorEvent
],
defaultEvent: true
defaultEvent: true,
},
variables: [
{ path: 'options.topic', alias: 'topic', type: 'Topic' }
Expand Down Expand Up @@ -384,6 +384,10 @@ export class SendToGuardianBlock {
ref: AnyBlockType
): Promise<IPolicyDocument> {
const operation: Operation = Operation.auto;
if (ref.options.chunking) {
document.documentFields =
ref.options.fields?.map((field) => field.fieldPath) || [];
}
if (type === DocumentType.DID) {
return await this.updateDIDRecord(document, operation, ref);
} else if (type === DocumentType.VerifiableCredential) {
Expand Down

0 comments on commit de21050

Please sign in to comment.