Browse Source

Fix condition update for content changed triggers.

pull/346/head
Sebastian Stehle 7 years ago
parent
commit
3b31b2b164
  1. 11
      src/Squidex/app/features/rules/pages/rules/triggers/content-changed-trigger.component.html
  2. 10
      src/Squidex/app/features/rules/pages/rules/triggers/content-changed-trigger.component.ts

11
src/Squidex/app/features/rules/pages/rules/triggers/content-changed-trigger.component.html

@ -16,15 +16,18 @@
<th></th> <th></th>
</tr> </tr>
<tr *ngFor="let schema of triggerSchemas"> <tr *ngFor="let triggerSchema of triggerSchemas">
<td> <td>
<span class="truncate">{{schema.schema.displayName}}</span> <span class="truncate">{{triggerSchema.schema.displayName}}</span>
</td> </td>
<td class="text-center"> <td class="text-center">
<input type="text" class="form-control code" [(ngModel)]="schema.condition" (blur)="updateValue()" placeholder="Optional condition as javascript expression" /> <input type="text" class="form-control code" placeholder="Optional condition as javascript expression"
[ngModelOptions]="{ updateOn: 'blur' }"
[ngModel]="triggerSchema.condition"
(ngModelChange)="updateCondition(triggerSchema.schema, $event)" />
</td> </td>
<td class="text-center"> <td class="text-center">
<button type="button" class="btn btn-text-secondary" (click)="removeSchema(schema)"> <button type="button" class="btn btn-text-secondary" (click)="removeSchema(triggerSchema)">
<i class="icon-close"></i> <i class="icon-close"></i>
</button> </button>
</td> </td>

10
src/Squidex/app/features/rules/pages/rules/triggers/content-changed-trigger.component.ts

@ -61,7 +61,9 @@ export class ContentChangedTriggerComponent implements OnInit {
const schema = this.schemas.find(s => s.id === triggerSchema.schemaId); const schema = this.schemas.find(s => s.id === triggerSchema.schemaId);
if (schema) { if (schema) {
schemas.push({ schema, condition: triggerSchema.condition }); const condition = triggerSchema.condition;
schemas.push({ schema, condition });
} }
} }
} }
@ -85,6 +87,12 @@ export class ContentChangedTriggerComponent implements OnInit {
this.updateSchemaToAdd(); this.updateSchemaToAdd();
} }
public updateCondition(schema: SchemaDto, condition: string) {
this.triggerSchemas = this.triggerSchemas.map(s => s.schema === schema ? { schema, condition } : s);
this.updateValue();
}
public updateValue() { public updateValue() {
const schemas = this.triggerSchemas.values.map(s => ({ schemaId: s.schema.id, condition: s.condition })); const schemas = this.triggerSchemas.values.map(s => ({ schemaId: s.schema.id, condition: s.condition }));

Loading…
Cancel
Save