Browse Source

Rule forms.

pull/282/head
Sebastian Stehle 8 years ago
parent
commit
70862cdebd
  1. 4
      src/Squidex/app/features/rules/pages/rules/actions/algolia-action.component.html
  2. 57
      src/Squidex/app/features/rules/pages/rules/actions/algolia-action.component.ts
  3. 2
      src/Squidex/app/features/rules/pages/rules/actions/azure-queue-action.component.html
  4. 51
      src/Squidex/app/features/rules/pages/rules/actions/azure-queue-action.component.ts
  5. 4
      src/Squidex/app/features/rules/pages/rules/actions/elastic-search-action.component.html
  6. 65
      src/Squidex/app/features/rules/pages/rules/actions/elastic-search-action.component.ts
  7. 4
      src/Squidex/app/features/rules/pages/rules/actions/fastly-action.component.html
  8. 49
      src/Squidex/app/features/rules/pages/rules/actions/fastly-action.component.ts
  9. 45
      src/Squidex/app/features/rules/pages/rules/actions/slack-action.component.ts
  10. 4
      src/Squidex/app/features/rules/pages/rules/actions/webhook-action.component.html
  11. 43
      src/Squidex/app/features/rules/pages/rules/actions/webhook-action.component.ts
  12. 54
      src/Squidex/app/features/rules/pages/rules/rule-wizard.component.html
  13. 28
      src/Squidex/app/features/rules/pages/rules/rule-wizard.component.scss
  14. 40
      src/Squidex/app/features/rules/pages/rules/rule-wizard.component.ts
  15. 5
      src/Squidex/app/features/rules/pages/rules/triggers/asset-changed-trigger.component.html
  16. 46
      src/Squidex/app/features/rules/pages/rules/triggers/asset-changed-trigger.component.ts
  17. 8
      src/Squidex/app/features/rules/pages/rules/triggers/content-changed-trigger.component.html
  18. 57
      src/Squidex/app/features/rules/pages/rules/triggers/content-changed-trigger.component.ts
  19. 4
      src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts
  20. 2
      src/Squidex/app/features/schemas/pages/schema/types/string-validation.component.html
  21. 4
      src/Squidex/app/framework/angular/modals/dialog-renderer.component.html

4
src/Squidex/app/features/rules/pages/rules/actions/algolia-action.component.html

@ -1,6 +1,6 @@
<h3 class="wizard-title">Populate index in algolia with content</h3> <h3 class="wizard-title">Populate index in algolia with content</h3>
<form [formGroup]="actionForm" class="form-horizontal" (ngSubmit)="save()"> <div [formGroup]="actionForm" class="form-horizontal">
<div class="form-group row"> <div class="form-group row">
<label class="col col-3 col-form-label" for="appId">App ID</label> <label class="col col-3 col-form-label" for="appId">App ID</label>
@ -42,4 +42,4 @@
</small> </small>
</div> </div>
</div> </div>
</form> </div>

57
src/Squidex/app/features/rules/pages/rules/actions/algolia-action.component.ts

@ -5,8 +5,8 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms'; import { FormControl, FormGroup, Validators } from '@angular/forms';
@Component({ @Component({
selector: 'sqx-algolia-action', selector: 'sqx-algolia-action',
@ -17,49 +17,26 @@ export class AlgoliaActionComponent implements OnInit {
@Input() @Input()
public action: any; public action: any;
@Output() @Input()
public actionChanged = new EventEmitter<object>(); public actionForm: FormGroup;
@Input()
public actionFormSubmitted = false; public actionFormSubmitted = false;
public actionForm =
this.formBuilder.group({
appId: ['',
[
Validators.required
]
],
apiKey: ['',
[
Validators.required
]
],
indexName: ['$SCHEMA_NAME',
[
Validators.required
]
]
});
constructor(
private readonly formBuilder: FormBuilder
) {
}
public ngOnInit() { public ngOnInit() {
this.action = Object.assign({}, { appId: '', apiKey: '', indexName: '$SCHEMA_NAME' }, this.action || {}); this.actionForm.setControl('appId',
new FormControl(this.action.appId || '', [
this.actionFormSubmitted = false; Validators.required
this.actionForm.reset(); ]));
this.actionForm.setValue(this.action);
}
public save() {
this.actionFormSubmitted = true;
if (this.actionForm.valid) { this.actionForm.setControl('apiKey',
const action = this.actionForm.value; new FormControl(this.action.apiKey || '', [
Validators.required
]));
this.actionChanged.emit(action); this.actionForm.setControl('indexName',
} new FormControl(this.action.indexName || '$SCHEMA_NAME', [
Validators.required
]));
} }
} }

2
src/Squidex/app/features/rules/pages/rules/actions/azure-queue-action.component.html

@ -1,6 +1,6 @@
<h3 class="wizard-title">Send event payload to Azure Storage Queue</h3> <h3 class="wizard-title">Send event payload to Azure Storage Queue</h3>
<form [formGroup]="actionForm" class="form-horizontal" (ngSubmit)="save()"> <form [formGroup]="actionForm" class="form-horizontal">
<div class="form-group row"> <div class="form-group row">
<label class="col col-3 col-form-label" for="connectionString">Connection String</label> <label class="col col-3 col-form-label" for="connectionString">Connection String</label>

51
src/Squidex/app/features/rules/pages/rules/actions/azure-queue-action.component.ts

@ -5,8 +5,8 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms'; import { FormControl, FormGroup, Validators } from '@angular/forms';
import { ValidatorsEx } from '@app/shared'; import { ValidatorsEx } from '@app/shared';
@ -19,45 +19,22 @@ export class AzureQueueActionComponent implements OnInit {
@Input() @Input()
public action: any; public action: any;
@Output() @Input()
public actionChanged = new EventEmitter<object>(); public actionForm: FormGroup;
@Input()
public actionFormSubmitted = false; public actionFormSubmitted = false;
public actionForm =
this.formBuilder.group({
connectionString: ['',
[
Validators.required
]
],
queue: ['squidex',
[
Validators.required,
ValidatorsEx.pattern('[a-z][a-z0-9]{2,}(\-[a-z0-9]+)*', 'Name must be a valid azure queue name.')
]
]
});
constructor(
private readonly formBuilder: FormBuilder
) {
}
public ngOnInit() { public ngOnInit() {
this.action = Object.assign({}, { connectionString: '', queue: 'squidex' }, this.action || {}); this.actionForm.setControl('connectionString',
new FormControl(this.action.connectionString || '', [
this.actionFormSubmitted = false; Validators.required
this.actionForm.reset(); ]));
this.actionForm.setValue(this.action);
}
public save() {
this.actionFormSubmitted = true;
if (this.actionForm.valid) {
const action = this.actionForm.value;
this.actionChanged.emit(action); this.actionForm.setControl('queue',
} new FormControl(this.action.queue || 'squidex', [
Validators.required,
ValidatorsEx.pattern('[a-z][a-z0-9]{2,}(\-[a-z0-9]+)*', 'Name must be a valid azure queue name.')
]));
} }
} }

4
src/Squidex/app/features/rules/pages/rules/actions/elastic-search-action.component.html

@ -1,6 +1,6 @@
<h3 class="wizard-title">Populate index in ElasticSearch with content</h3> <h3 class="wizard-title">Populate index in ElasticSearch with content</h3>
<form [formGroup]="actionForm" class="form-horizontal" (ngSubmit)="save()"> <div [formGroup]="actionForm" class="form-horizontal">
<div class="form-group row"> <div class="form-group row">
<label class="col col-3 col-form-label" for="host">Host</label> <label class="col col-3 col-form-label" for="host">Host</label>
@ -70,4 +70,4 @@
</small> </small>
</div> </div>
</div> </div>
</form> </div>

65
src/Squidex/app/features/rules/pages/rules/actions/elastic-search-action.component.ts

@ -5,8 +5,8 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms'; import { FormControl, FormGroup, Validators } from '@angular/forms';
@Component({ @Component({
selector: 'sqx-elastic-search-action', selector: 'sqx-elastic-search-action',
@ -17,57 +17,30 @@ export class ElasticSearchActionComponent implements OnInit {
@Input() @Input()
public action: any; public action: any;
@Output() @Input()
public actionChanged = new EventEmitter<object>(); public actionForm: FormGroup;
@Input()
public actionFormSubmitted = false; public actionFormSubmitted = false;
public actionForm =
this.formBuilder.group({
host: ['',
[
Validators.required
]
],
indexName: ['$APP_NAME',
[
Validators.required
]
],
indexType: ['$SCHEMA_NAME',
[
// Validators.required
]
],
username: '',
password: ''
});
constructor(
private readonly formBuilder: FormBuilder
) {
}
public ngOnInit() { public ngOnInit() {
this.action = Object.assign({}, { this.actionForm.setControl('host',
host: '', new FormControl(this.action.host || '', [
indexName: '$APP_NAME', Validators.required
indexType: '$SCHEMA_NAME', ]));
username: '',
password: ''
}, this.action || {});
this.actionFormSubmitted = false; this.actionForm.setControl('indexName',
this.actionForm.reset(); new FormControl(this.action.indexName || '$APP_NAME', [
this.actionForm.setValue(this.action); Validators.required
} ]));
public save() { this.actionForm.setControl('indexType',
this.actionFormSubmitted = true; new FormControl(this.action.indexType || '$SCHEMA_NAME'));
if (this.actionForm.valid) { this.actionForm.setControl('username',
const action = this.actionForm.value; new FormControl(this.action.username));
this.actionChanged.emit(action); this.actionForm.setControl('password',
} new FormControl(this.action.password));
} }
} }

4
src/Squidex/app/features/rules/pages/rules/actions/fastly-action.component.html

@ -1,6 +1,6 @@
<h3 class="wizard-title">Purge cache entries in Fastly</h3> <h3 class="wizard-title">Purge cache entries in Fastly</h3>
<form [formGroup]="actionForm" class="form-horizontal" (ngSubmit)="save()"> <div [formGroup]="actionForm" class="form-horizontal">
<div class="form-group row"> <div class="form-group row">
<label class="col col-3 col-form-label" for="serviceId">Service ID</label> <label class="col col-3 col-form-label" for="serviceId">Service ID</label>
@ -28,4 +28,4 @@
</small> </small>
</div> </div>
</div> </div>
</form> </div>

49
src/Squidex/app/features/rules/pages/rules/actions/fastly-action.component.ts

@ -5,8 +5,8 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms'; import { FormControl, FormGroup, Validators } from '@angular/forms';
@Component({ @Component({
selector: 'sqx-fastly-action', selector: 'sqx-fastly-action',
@ -17,44 +17,21 @@ export class FastlyActionComponent implements OnInit {
@Input() @Input()
public action: any; public action: any;
@Output() @Input()
public actionChanged = new EventEmitter<object>(); public actionForm: FormGroup;
@Input()
public actionFormSubmitted = false; public actionFormSubmitted = false;
public actionForm =
this.formBuilder.group({
serviceId: ['',
[
Validators.required
]
],
apiKey: ['',
[
Validators.required
]
]
});
constructor(
private readonly formBuilder: FormBuilder
) {
}
public ngOnInit() { public ngOnInit() {
this.action = Object.assign({}, { serviceId: '', apiKey: '' }, this.action || {}); this.actionForm.setControl('serviceId',
new FormControl(this.action.serviceId || '', [
this.actionFormSubmitted = false; Validators.required
this.actionForm.reset(); ]));
this.actionForm.setValue(this.action);
}
public save() {
this.actionFormSubmitted = true;
if (this.actionForm.valid) {
const action = this.actionForm.value;
this.actionChanged.emit(action); this.actionForm.setControl('apiKey',
} new FormControl(this.action.apiKey || '', [
Validators.required
]));
} }
} }

45
src/Squidex/app/features/rules/pages/rules/actions/slack-action.component.ts

@ -5,8 +5,8 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms'; import { FormControl, FormGroup, Validators } from '@angular/forms';
@Component({ @Component({
selector: 'sqx-slack-action', selector: 'sqx-slack-action',
@ -17,40 +17,21 @@ export class SlackActionComponent implements OnInit {
@Input() @Input()
public action: any; public action: any;
@Output() @Input()
public actionChanged = new EventEmitter<object>(); public actionForm: FormGroup;
@Input()
public actionFormSubmitted = false; public actionFormSubmitted = false;
public actionForm =
this.formBuilder.group({
webhookUrl: ['',
[
Validators.required
]
],
text: ''
});
constructor(
private readonly formBuilder: FormBuilder
) {
}
public ngOnInit() { public ngOnInit() {
this.action = Object.assign({}, { webhookUrl: '', text: '' }, this.action || {}); this.actionForm.setControl('webhookUrl',
new FormControl(this.action.webhookUrl || '', [
this.actionFormSubmitted = false; Validators.required
this.actionForm.reset(); ]));
this.actionForm.setValue(this.action);
}
public save() {
this.actionFormSubmitted = true;
if (this.actionForm.valid) {
const action = this.actionForm.value;
this.actionChanged.emit(action); this.actionForm.setControl('text',
} new FormControl(this.action.text || '', [
Validators.required
]));
} }
} }

4
src/Squidex/app/features/rules/pages/rules/actions/webhook-action.component.html

@ -1,6 +1,6 @@
<h3 class="wizard-title">Send event payload to webhook</h3> <h3 class="wizard-title">Send event payload to webhook</h3>
<form [formGroup]="actionForm" class="form-horizontal" (ngSubmit)="save()"> <div [formGroup]="actionForm" class="form-horizontal">
<div class="form-group row"> <div class="form-group row">
<label class="col col-3 col-form-label" for="url">Url</label> <label class="col col-3 col-form-label" for="url">Url</label>
@ -28,4 +28,4 @@
</small> </small>
</div> </div>
</div> </div>
</form> </div>

43
src/Squidex/app/features/rules/pages/rules/actions/webhook-action.component.ts

@ -5,8 +5,8 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms'; import { FormControl, FormGroup, Validators } from '@angular/forms';
@Component({ @Component({
selector: 'sqx-webhook-action', selector: 'sqx-webhook-action',
@ -17,40 +17,19 @@ export class WebhookActionComponent implements OnInit {
@Input() @Input()
public action: any; public action: any;
@Output() @Input()
public actionChanged = new EventEmitter<object>(); public actionForm: FormGroup;
@Input()
public actionFormSubmitted = false; public actionFormSubmitted = false;
public actionForm =
this.formBuilder.group({
url: ['',
[
Validators.required
]
],
sharedSecret: ''
});
constructor(
private readonly formBuilder: FormBuilder
) {
}
public ngOnInit() { public ngOnInit() {
this.action = Object.assign({}, { url: '', sharedSecret: '' }, this.action || {}); this.actionForm.setControl('url',
new FormControl(this.action.url || '', [
this.actionFormSubmitted = false; Validators.required
this.actionForm.reset(); ]));
this.actionForm.setValue(this.action);
}
public save() {
this.actionFormSubmitted = true;
if (this.actionForm.valid) {
const action = this.actionForm.value;
this.actionChanged.emit(action); this.actionForm.setControl('sharedSecret',
} new FormControl(this.action.sharedSecret || ''));
} }
} }

54
src/Squidex/app/features/rules/pages/rules/rule-wizard.component.html

@ -1,4 +1,4 @@
<sqx-modal-dialog large="true" (closed)="cancel()"> <sqx-modal-dialog large="true" fullHeight="true" (closed)="cancel()">
<ng-container title> <ng-container title>
<ng-container *ngIf="mode === 'EditTrigger'"> <ng-container *ngIf="mode === 'EditTrigger'">
Edit Trigger Edit Trigger
@ -33,21 +33,25 @@
</ng-container> </ng-container>
<ng-container *ngIf="step === 2 && schemas"> <ng-container *ngIf="step === 2 && schemas">
<form [formGroup]="triggerForm.form" (submit)="saveTrigger()">
<ng-container [ngSwitch]="triggerType"> <ng-container [ngSwitch]="triggerType">
<ng-container *ngSwitchCase="'AssetChanged'"> <ng-container *ngSwitchCase="'AssetChanged'">
<sqx-asset-changed-trigger #triggerControl <sqx-asset-changed-trigger
[trigger]="trigger" [trigger]="trigger"
(triggerChanged)="selectTrigger($event)"> [triggerForm]="triggerForm.form"
[triggerFormSubmitted]="triggerForm.submitted | async">
</sqx-asset-changed-trigger> </sqx-asset-changed-trigger>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'ContentChanged'"> <ng-container *ngSwitchCase="'ContentChanged'">
<sqx-content-changed-trigger #triggerControl <sqx-content-changed-trigger
[schemas]="schemas" [schemas]="schemas"
[trigger]="trigger" [trigger]="trigger"
(triggerChanged)="selectTrigger($event)"> [triggerForm]="triggerForm.form"
[triggerFormSubmitted]="triggerForm.submitted | async">
</sqx-content-changed-trigger> </sqx-content-changed-trigger>
</ng-container> </ng-container>
</ng-container> </ng-container>
</form>
</ng-container> </ng-container>
<ng-container *ngIf="step === 3"> <ng-container *ngIf="step === 3">
@ -62,61 +66,71 @@
</ng-container> </ng-container>
<ng-container *ngIf="step === 4"> <ng-container *ngIf="step === 4">
<form [formGroup]="actionForm.form" (submit)="saveAction()">
<ng-container [ngSwitch]="actionType"> <ng-container [ngSwitch]="actionType">
<ng-container *ngSwitchCase="'Algolia'"> <ng-container *ngSwitchCase="'Algolia'">
<sqx-algolia-action #actionControl <sqx-algolia-action
[action]="action" [action]="action"
(actionChanged)="selectAction($event)"> [actionForm]="actionForm.form"
[actionFormSubmitted]="actionForm.submitted | async">
</sqx-algolia-action> </sqx-algolia-action>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'AzureQueue'"> <ng-container *ngSwitchCase="'AzureQueue'">
<sqx-azure-queue-action #actionControl <sqx-azure-queue-action
[action]="action" [action]="action"
(actionChanged)="selectAction($event)"> [actionForm]="actionForm.form"
[actionFormSubmitted]="actionForm.submitted | async">
</sqx-azure-queue-action> </sqx-azure-queue-action>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'ElasticSearch'"> <ng-container *ngSwitchCase="'ElasticSearch'">
<sqx-elastic-search-action #actionControl <sqx-elastic-search-action
[action]="action" [action]="action"
(actionChanged)="selectAction($event)"> [actionForm]="actionForm.form"
[actionFormSubmitted]="actionForm.submitted | async">
</sqx-elastic-search-action> </sqx-elastic-search-action>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'Fastly'"> <ng-container *ngSwitchCase="'Fastly'">
<sqx-fastly-action #actionControl <sqx-fastly-action
[action]="action" [action]="action"
(actionChanged)="selectAction($event)"> [actionForm]="actionForm.form"
[actionFormSubmitted]="actionForm.submitted | async">
</sqx-fastly-action> </sqx-fastly-action>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'Slack'"> <ng-container *ngSwitchCase="'Slack'">
<sqx-slack-action #actionControl <sqx-slack-action
[action]="action" [action]="action"
(actionChanged)="selectAction($event)"> [actionForm]="actionForm.form"
[actionFormSubmitted]="actionForm.submitted | async">
</sqx-slack-action> </sqx-slack-action>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'Webhook'"> <ng-container *ngSwitchCase="'Webhook'">
<sqx-webhook-action #actionControl <sqx-webhook-action
[action]="action" [action]="action"
(actionChanged)="selectAction($event)"> [actionForm]="actionForm.form"
[actionFormSubmitted]="actionForm.submitted | async">
</sqx-webhook-action> </sqx-webhook-action>
</ng-container> </ng-container>
</ng-container> </ng-container>
</form>
</ng-container> </ng-container>
</ng-container> </ng-container>
<ng-container footer> <ng-container footer>
<div>
<ng-container *ngIf="mode === 'Wizard' && step === 2"> <ng-container *ngIf="mode === 'Wizard' && step === 2">
<button type="reset" class="float-left btn btn-secondary" (click)="cancel()">Cancel</button> <button type="reset" class="float-left btn btn-secondary" (click)="cancel()">Cancel</button>
<button type="submit" class="float-right btn btn-primary" (click)="triggerControl.save()">Next</button> <button type="submit" class="float-right btn btn-primary" (click)="saveTrigger()">Next</button>
</ng-container> </ng-container>
<ng-container *ngIf="mode !== 'Wizard' && step === 2"> <ng-container *ngIf="mode !== 'Wizard' && step === 2">
<button type="reset" class="float-left btn btn-secondary" (click)="cancel()">Cancel</button> <button type="reset" class="float-left btn btn-secondary" (click)="cancel()">Cancel</button>
<button type="submit" class="float-right btn btn-primary" (click)="triggerControl.save()">Save</button> <button type="submit" class="float-right btn btn-primary" (click)="saveTrigger()">Save</button>
</ng-container> </ng-container>
<ng-container *ngIf="step === 4"> <ng-container *ngIf="step === 4">
<button type="reset" class="float-left btn btn-secondary" (click)="cancel()">Cancel</button> <button type="reset" class="float-left btn btn-secondary" (click)="cancel()">Cancel</button>
<button type="submit" class="float-right btn btn-primary" (click)="actionControl.save()">Save</button> <button type="submit" class="float-right btn btn-primary" (click)="saveAction()">Save</button>
</ng-container> </ng-container>
</div>
</ng-container> </ng-container>
</sqx-modal-dialog> </sqx-modal-dialog>

28
src/Squidex/app/features/rules/pages/rules/rule-wizard.component.scss

@ -1,34 +1,6 @@
@import '_vars'; @import '_vars';
@import '_mixins'; @import '_mixins';
.modal {
&-dialog {
height: 70%;
}
&-content {
min-height: 100%;
max-height: 100%;
}
&-body {
overflow-y: auto;
}
&-header {
@include flex-shrink(0);
}
&-footer {
@include flex-shrink(0);
}
&-form {
padding-top: 1em;
padding-bottom: 0;
}
}
.rule-element { .rule-element {
margin-right: .5rem; margin-right: .5rem;
} }

40
src/Squidex/app/features/rules/pages/rules/rule-wizard.component.ts

@ -5,12 +5,14 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { import {
AppContext, AppContext,
CreateRuleDto, CreateRuleDto,
DateTime, DateTime,
Form,
ruleActions, ruleActions,
ruleTriggers, ruleTriggers,
RuleDto, RuleDto,
@ -35,17 +37,15 @@ export class RuleWizardComponent implements OnInit {
public ruleActions = ruleActions; public ruleActions = ruleActions;
public ruleTriggers = ruleTriggers; public ruleTriggers = ruleTriggers;
public triggerType: string; public actionForm = new Form<FormGroup>(new FormGroup({}));
public trigger: any = {};
public actionType: string; public actionType: string;
public action: any = {}; public action: any = {};
public step = 1;
@ViewChild('triggerControl') public triggerForm = new Form<FormGroup>(new FormGroup({}));
public triggerControl: any; public triggerType: string;
public trigger: any = {};
@ViewChild('actionControl') public step = 1;
public actionControl: any;
@Output() @Output()
public cancelled = new EventEmitter(); public cancelled = new EventEmitter();
@ -74,17 +74,13 @@ export class RuleWizardComponent implements OnInit {
if (this.mode === MODE_EDIT_ACTION) { if (this.mode === MODE_EDIT_ACTION) {
this.step = 4; this.step = 4;
this.action = Object.assign({}, this.rule.action); this.action = this.rule.action;
this.actionType = this.rule.actionType; this.actionType = this.rule.actionType;
delete this.action.actionType;
} else if (this.mode === MODE_EDIT_TRIGGER) { } else if (this.mode === MODE_EDIT_TRIGGER) {
this.step = 2; this.step = 2;
this.trigger = Object.assign({}, this.rule.trigger); this.trigger = this.rule.trigger;
this.triggerType = this.rule.triggerType; this.triggerType = this.rule.triggerType;
delete this.trigger.triggerType;
} }
} }
@ -98,8 +94,11 @@ export class RuleWizardComponent implements OnInit {
this.step++; this.step++;
} }
public selectTrigger(value: any) { public saveTrigger() {
this.trigger = Object.assign({}, value, { triggerType: this.triggerType }); const value = this.triggerForm.submit();
if (value) {
this.trigger = { ...value, triggerType: this.triggerType };
if (this.mode === MODE_WIZARD) { if (this.mode === MODE_WIZARD) {
this.step++; this.step++;
@ -107,9 +106,13 @@ export class RuleWizardComponent implements OnInit {
this.updateTrigger(); this.updateTrigger();
} }
} }
}
public saveAction() {
const value = this.actionForm.submit();
public selectAction(value: any) { if (value) {
this.action = Object.assign({}, value, { actionType: this.actionType }); this.action = { ...value, actionType: this.actionType };
if (this.mode === MODE_WIZARD) { if (this.mode === MODE_WIZARD) {
this.createRule(); this.createRule();
@ -117,6 +120,7 @@ export class RuleWizardComponent implements OnInit {
this.updateAction(); this.updateAction();
} }
} }
}
private createRule() { private createRule() {
const requestDto = new CreateRuleDto(this.trigger, this.action); const requestDto = new CreateRuleDto(this.trigger, this.action);

5
src/Squidex/app/features/rules/pages/rules/triggers/asset-changed-trigger.component.html

@ -1,7 +1,6 @@
<h3 class="wizard-title">Trigger rule when asset has been...</h3> <h3 class="wizard-title">Trigger rule when asset has been...</h3>
<div [formGroup]="triggerForm" class="form-horizontal">
<form [formGroup]="triggerForm" class="form-horizontal" (ngSubmit)="save()">
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="checkbox" id="sendCreate" formControlName="sendCreate" /> <input class="form-check-input" type="checkbox" id="sendCreate" formControlName="sendCreate" />
@ -34,4 +33,4 @@
</label> </label>
</div> </div>
</div> </div>
</form> </div>

46
src/Squidex/app/features/rules/pages/rules/triggers/asset-changed-trigger.component.ts

@ -5,8 +5,8 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder } from '@angular/forms'; import { FormControl, FormGroup } from '@angular/forms';
@Component({ @Component({
selector: 'sqx-asset-changed-trigger', selector: 'sqx-asset-changed-trigger',
@ -17,43 +17,23 @@ export class AssetChangedTriggerComponent implements OnInit {
@Input() @Input()
public trigger: any; public trigger: any;
@Output() @Input()
public triggerChanged = new EventEmitter<object>(); public triggerForm: FormGroup;
@Input()
public triggerFormSubmitted = false; public triggerFormSubmitted = false;
public triggerForm =
this.formBuilder.group({
sendCreate: false,
sendUpdate: false,
sendRename: false,
sendDelete: false
});
constructor(
private readonly formBuilder: FormBuilder
) {
}
public ngOnInit() { public ngOnInit() {
this.trigger = Object.assign({}, { this.triggerForm.setControl('sendCreate',
sendCreate: false, new FormControl(this.trigger.sendCreate || false));
sendUpdate: false,
sendRename: false,
sendDelete: false
}, this.trigger || {});
this.triggerFormSubmitted = false;
this.triggerForm.reset();
this.triggerForm.setValue(this.trigger);
}
public save() { this.triggerForm.setControl('sendUpdate',
this.triggerFormSubmitted = true; new FormControl(this.trigger.sendUpdate || false));
if (this.triggerForm.valid) { this.triggerForm.setControl('sendRename',
const trigger = this.triggerForm.value; new FormControl(this.trigger.sendRename || false));
this.triggerChanged.emit(trigger); this.triggerForm.setControl('sendDelete',
} new FormControl(this.trigger.sendDelete || false));
} }
} }

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

@ -60,7 +60,7 @@
</tr> </tr>
</table> </table>
<div class="section" *ngIf="!handleAll && schemasToAdd.length > 0"> <div class="section" *ngIf="!triggerForm.controls.handleAll.value && schemasToAdd.length > 0">
<form class="form-inline" (ngSubmit)="addSchema()"> <form class="form-inline" (ngSubmit)="addSchema()">
<div class="form-group mr-1"> <div class="form-group mr-1">
<select class="form-control schemas-control" [(ngModel)]="schemaToAdd" name="schema"> <select class="form-control schemas-control" [(ngModel)]="schemaToAdd" name="schema">
@ -72,9 +72,11 @@
</form> </form>
</div> </div>
<div class="form-check"> <div class="form-group" [formGroup]="triggerForm">
<input class="form-check-input" type="checkbox" [(ngModel)]="handleAll" id="handleAll" /> <div class="form-check">
<input class="form-check-input" type="checkbox" id="handleAll" formControlName="handleAll" />
<label class="form-check-label" for="handleAll"> <label class="form-check-label" for="handleAll">
Trigger on all content events Trigger on all content events
</label> </label>
</div>
</div> </div>

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

@ -5,7 +5,8 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { import {
ImmutableArray, ImmutableArray,
@ -34,10 +35,11 @@ export class ContentChangedTriggerComponent implements OnInit {
@Input() @Input()
public trigger: any; public trigger: any;
@Output() @Input()
public triggerChanged = new EventEmitter<object>(); public triggerForm: FormGroup;
public handleAll = false; @Input()
public triggerFormSubmitted = false;
public triggerSchemas: ImmutableArray<TriggerSchemaForm>; public triggerSchemas: ImmutableArray<TriggerSchemaForm>;
@ -49,9 +51,13 @@ export class ContentChangedTriggerComponent implements OnInit {
} }
public ngOnInit() { public ngOnInit() {
const triggerSchemas: any[] = (this.trigger.schemas = this.trigger.schemas || []); this.triggerForm.setControl('schemas',
new FormControl(this.trigger.schemas || {}));
this.handleAll = Types.isBoolean(this.trigger.handleAll) ? this.trigger.handleAll : false; this.triggerForm.setControl('handleAll',
new FormControl(Types.isBoolean(this.trigger.handleAll) ? this.trigger.handleAll : false));
const triggerSchemas: any[] = (this.trigger.schemas = this.trigger.schemas || []);
this.triggerSchemas = this.triggerSchemas =
ImmutableArray.of( ImmutableArray.of(
@ -81,24 +87,11 @@ export class ContentChangedTriggerComponent implements OnInit {
this.schemaToAdd = this.schemasToAdd.values[0]; this.schemaToAdd = this.schemasToAdd.values[0];
} }
public save() {
const schemas =
this.triggerSchemas.values.map(s => {
return {
schemaId: s.schema.id,
sendCreate: s.sendCreate,
sendUpdate: s.sendUpdate,
sendDelete: s.sendDelete,
sendPublish: s.sendPublish
};
});
this.triggerChanged.emit({ schemas, handleAll: this.handleAll });
}
public removeSchema(schemaForm: TriggerSchemaForm) { public removeSchema(schemaForm: TriggerSchemaForm) {
this.triggerSchemas = this.triggerSchemas.remove(schemaForm); this.triggerSchemas = this.triggerSchemas.remove(schemaForm);
this.updateValue();
this.schemasToAdd = this.schemasToAdd.push(schemaForm.schema).sortByStringAsc(x => x.name); this.schemasToAdd = this.schemasToAdd.push(schemaForm.schema).sortByStringAsc(x => x.name);
this.schemaToAdd = this.schemasToAdd.values[0]; this.schemaToAdd = this.schemasToAdd.values[0];
} }
@ -115,6 +108,8 @@ export class ContentChangedTriggerComponent implements OnInit {
sendPublish: false sendPublish: false
})).sortByStringAsc(x => x.schema.name); })).sortByStringAsc(x => x.schema.name);
this.updateValue();
this.schemasToAdd = this.schemasToAdd.remove(this.schemaToAdd).sortByStringAsc(x => x.name); this.schemasToAdd = this.schemasToAdd.remove(this.schemaToAdd).sortByStringAsc(x => x.name);
this.schemaToAdd = this.schemasToAdd.values[0]; this.schemaToAdd = this.schemasToAdd.values[0];
} }
@ -123,12 +118,31 @@ export class ContentChangedTriggerComponent implements OnInit {
const newSchema = this.updateSendAll(Object.assign({}, schemaForm, { [property]: !schemaForm[property] })); const newSchema = this.updateSendAll(Object.assign({}, schemaForm, { [property]: !schemaForm[property] }));
this.triggerSchemas = this.triggerSchemas.replace(schemaForm, newSchema); this.triggerSchemas = this.triggerSchemas.replace(schemaForm, newSchema);
this.updateValue();
} }
public toggleAll(schemaForm: TriggerSchemaForm) { public toggleAll(schemaForm: TriggerSchemaForm) {
const newSchema = this.updateAll(<any>{ schema: schemaForm.schema }, !schemaForm.sendAll); const newSchema = this.updateAll(<any>{ schema: schemaForm.schema }, !schemaForm.sendAll);
this.triggerSchemas = this.triggerSchemas.replace(schemaForm, newSchema); this.triggerSchemas = this.triggerSchemas.replace(schemaForm, newSchema);
this.updateValue();
}
private updateValue() {
const schemas =
this.triggerSchemas.values.map(s => {
return {
schemaId: s.schema.id,
sendCreate: s.sendCreate,
sendUpdate: s.sendUpdate,
sendDelete: s.sendDelete,
sendPublish: s.sendPublish
};
});
this.triggerForm.controls['schemas'].setValue(schemas);
} }
private updateAll(schemaForm: TriggerSchemaForm, value: boolean): TriggerSchemaForm { private updateAll(schemaForm: TriggerSchemaForm, value: boolean): TriggerSchemaForm {
@ -137,6 +151,7 @@ export class ContentChangedTriggerComponent implements OnInit {
schemaForm.sendUpdate = value; schemaForm.sendUpdate = value;
schemaForm.sendDelete = value; schemaForm.sendDelete = value;
schemaForm.sendPublish = value; schemaForm.sendPublish = value;
return schemaForm; return schemaForm;
} }

4
src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts

@ -108,9 +108,7 @@ export class SchemaPageComponent implements OnDestroy, OnInit {
private export() { private export() {
const result: any = { const result: any = {
fields: this.schema.fields.map(field => { fields: this.schema.fields.map(field => {
const copy: any = Object.assign({}, field); const { fieldId, ...copy } = field;
delete copy.fieldId;
for (const key in copy.properties) { for (const key in copy.properties) {
if (copy.properties.hasOwnProperty(key)) { if (copy.properties.hasOwnProperty(key)) {

2
src/Squidex/app/features/schemas/pages/schema/types/string-validation.component.html

@ -36,7 +36,7 @@
<div *ngIf="patterns.length > 0 && (patternsModal.isOpen | async) && (showPatternSuggestions | async)" [sqxModalTarget]="patternInput" class="control-dropdown"> <div *ngIf="patterns.length > 0 && (patternsModal.isOpen | async) && (showPatternSuggestions | async)" [sqxModalTarget]="patternInput" class="control-dropdown">
<h4>Suggestions</h4> <h4>Suggestions</h4>
<div *ngFor="let pattern of pattern" class="control-dropdown-item control-dropdown-item-selectable" (mousedown)="setPattern(suggestion)"> <div *ngFor="let pattern of pattern" class="control-dropdown-item control-dropdown-item-selectable" (mousedown)="setPattern(pattern)">
<div class="truncate">{{pattern.name}}</div> <div class="truncate">{{pattern.name}}</div>
<div class="truncate text-muted">{{pattern.pattern}}</div> <div class="truncate text-muted">{{pattern.pattern}}</div>
</div> </div>

4
src/Squidex/app/framework/angular/modals/dialog-renderer.component.html

@ -2,11 +2,11 @@
<sqx-modal-dialog *sqxModalView="dialogView;onRoot:true" showClose="false"> <sqx-modal-dialog *sqxModalView="dialogView;onRoot:true" showClose="false">
<ng-container title> <ng-container title>
{{dialogRequest.title}} {{dialogRequest?.title}}
</ng-container> </ng-container>
<ng-container content> <ng-container content>
{{dialogRequest.text}} {{dialogRequest?.text}}
</ng-container> </ng-container>
<ng-container footer> <ng-container footer>

Loading…
Cancel
Save