mirror of https://github.com/Squidex/squidex.git
30 changed files with 142 additions and 174 deletions
@ -0,0 +1,26 @@ |
|||||
|
/* |
||||
|
* Squidex Headless CMS |
||||
|
* |
||||
|
* @license |
||||
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
||||
|
*/ |
||||
|
|
||||
|
import { AlgoliaActionComponent } from './algolia-action.component'; |
||||
|
import { AzureQueueActionComponent } from './azure-queue-action.component'; |
||||
|
import { ElasticSearchActionComponent } from './elastic-search-action.component'; |
||||
|
import { FastlyActionComponent } from './fastly-action.component'; |
||||
|
import { MediumActionComponent } from './medium-action.component'; |
||||
|
import { SlackActionComponent } from './slack-action.component'; |
||||
|
import { TweetActionComponent } from './tweet-action.component'; |
||||
|
import { WebhookActionComponent } from './webhook-action.component'; |
||||
|
|
||||
|
export default { |
||||
|
Algolia: AlgoliaActionComponent, |
||||
|
AzureQueue: AzureQueueActionComponent, |
||||
|
ElasticSearch: ElasticSearchActionComponent, |
||||
|
Fastly: FastlyActionComponent, |
||||
|
Medium: MediumActionComponent, |
||||
|
Slack: SlackActionComponent, |
||||
|
Tweet: TweetActionComponent, |
||||
|
Webhook: WebhookActionComponent |
||||
|
}; |
||||
@ -0,0 +1,59 @@ |
|||||
|
/* |
||||
|
* Squidex Headless CMS |
||||
|
* |
||||
|
* @license |
||||
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
||||
|
*/ |
||||
|
|
||||
|
import { ChangeDetectionStrategy, Component, ComponentFactoryResolver, ComponentRef, Input, OnChanges, OnInit, ViewChild, ViewContainerRef } from '@angular/core'; |
||||
|
import { FormGroup } from '@angular/forms'; |
||||
|
|
||||
|
import actions from './actions'; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'sqx-rule-action', |
||||
|
template: '<div #element></div>', |
||||
|
changeDetection: ChangeDetectionStrategy.OnPush |
||||
|
}) |
||||
|
export class RuleActionComponent implements OnChanges, OnInit { |
||||
|
@Input() |
||||
|
public actionType: string; |
||||
|
|
||||
|
@Input() |
||||
|
public action: any; |
||||
|
|
||||
|
@Input() |
||||
|
public actionForm: FormGroup; |
||||
|
|
||||
|
@Input() |
||||
|
public actionFormSubmitted = false; |
||||
|
|
||||
|
@ViewChild('element', { read: ViewContainerRef }) |
||||
|
public viewContainer: ViewContainerRef; |
||||
|
|
||||
|
private component: ComponentRef<any>; |
||||
|
|
||||
|
constructor( |
||||
|
private readonly componentFactoryResolver: ComponentFactoryResolver |
||||
|
) { |
||||
|
} |
||||
|
|
||||
|
public ngOnChanges() { |
||||
|
if (this.component) { |
||||
|
this.component.instance.action = this.action; |
||||
|
this.component.instance.actionForm = this.actionForm; |
||||
|
this.component.instance.actionFormSubmitted = this.actionFormSubmitted; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public ngOnInit() { |
||||
|
const factoryType: any = actions[this.actionType]; |
||||
|
const factory: any = this.componentFactoryResolver.resolveComponentFactory(factoryType); |
||||
|
|
||||
|
this.component = this.viewContainer.createComponent(factory); |
||||
|
|
||||
|
this.component.instance.action = this.action; |
||||
|
this.component.instance.actionForm = this.actionForm; |
||||
|
this.component.instance.actionFormSubmitted = this.actionFormSubmitted; |
||||
|
} |
||||
|
} |
||||
@ -1,40 +0,0 @@ |
|||||
/* |
|
||||
* Squidex Headless CMS |
|
||||
* |
|
||||
* @license |
|
||||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|
||||
*/ |
|
||||
|
|
||||
import { ComponentFactoryResolver, ComponentRef, Input, OnInit, ViewChild, ViewContainerRef } from '@angular/core'; |
|
||||
import { FormGroup } from '@angular/forms'; |
|
||||
|
|
||||
export class RuleActionContainer implements OnInit { |
|
||||
@Input() |
|
||||
public actionType: string; |
|
||||
|
|
||||
@Input() |
|
||||
public action: any; |
|
||||
|
|
||||
@Input() |
|
||||
public actionForm: FormGroup; |
|
||||
|
|
||||
@Input() |
|
||||
public actionFormSubmitted = false; |
|
||||
|
|
||||
@ViewChild('container', { read: ViewContainerRef }) |
|
||||
public entry: ViewContainerRef; |
|
||||
|
|
||||
private component: ComponentRef<any>; |
|
||||
|
|
||||
constructor( |
|
||||
private readonly componentFactoryResolver: ComponentFactoryResolver |
|
||||
) { |
|
||||
} |
|
||||
|
|
||||
public ngOnInit() { |
|
||||
const factories = Array.from(this.componentFactoryResolver['_factories'].values()); |
|
||||
const factory: any = factories.find((x: any) => x.selector === this.actionType); |
|
||||
|
|
||||
this.component = this.entry.createComponent(factory); |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue