src/app/blocks/block-prop-qr.ts
Compbaser
changeDetection | ChangeDetectionStrategy.OnPush |
host | { |
selector | block-prop-qr |
template |
|
setBlockData
|
|
Defined in src/app/blocks/block-prop-qr.ts:46
|
constructor(fb: FormBuilder, bs: BlockService)
|
Defined in src/app/blocks/block-prop-qr.ts:33
|
ngAfterViewInit |
ngAfterViewInit()
|
Defined in src/app/blocks/block-prop-qr.ts:55
|
Returns :
void
|
_render |
_render()
|
Defined in src/app/blocks/block-prop-qr.ts:59
|
Returns :
void
|
Protected saveToStore |
saveToStore()
|
Defined in src/app/blocks/block-prop-qr.ts:65
|
Returns :
void
|
destroy |
destroy()
|
Defined in src/app/blocks/block-prop-qr.ts:74
|
Returns :
void
|
Protected formInputs |
formInputs: |
Defined in src/app/blocks/block-prop-qr.ts:31
|
m_blockData |
m_blockData: |
Defined in src/app/blocks/block-prop-qr.ts:33
|
m_contGroup |
m_contGroup: |
Defined in src/app/blocks/block-prop-qr.ts:32
|
import {AfterViewInit, ChangeDetectionStrategy, Component, Input} from "@angular/core";
import {FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms";
import {BlockService, IBlockData} from "./block-service";
import {RedPepperService} from "../../services/redpepper.service";
import {Compbaser, NgmslibService} from "ng-mslib";
import {urlRegExp} from "../../Lib";
import * as _ from "lodash";
@Component({
selector: 'block-prop-qr',
host: {
'(input-blur)': 'saveToStore($event)'
},
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<small class="debug">{{me}}</small>
<form novalidate autocomplete="off" class="inner5" [formGroup]="m_contGroup">
<div class="row">
<ul class="list-group">
<li class="list-group-item">
<span i18n>QR code</span><br/>
<input class="default-prop-width" type="text" [formControl]="m_contGroup.controls['text']"/>
</li>
</ul>
</div>
</form>
`
})
export class BlockPropQR extends Compbaser implements AfterViewInit {
private formInputs = {};
m_contGroup: FormGroup;
m_blockData: IBlockData;
constructor(private fb: FormBuilder, private bs: BlockService) {
super();
this.m_contGroup = fb.group({
'text': []
});
_.forEach(this.m_contGroup.controls, (value, key: string) => {
this.formInputs[key] = this.m_contGroup.controls[key] as FormControl;
})
}
@Input()
set setBlockData(i_blockData) {
if (this.m_blockData && this.m_blockData.blockID != i_blockData.blockID) {
this.m_blockData = i_blockData;
this._render();
} else {
this.m_blockData = i_blockData;
}
}
ngAfterViewInit() {
this._render();
}
_render() {
var domPlayerData = this.m_blockData.playerDataDom
var xSnippet = jXML(domPlayerData).find('Text');
this.formInputs['text'].setValue(xSnippet.text());
}
private saveToStore() {
if (this.m_contGroup.status != 'VALID')
return;
var domPlayerData = this.m_blockData.playerDataDom;
var xSnippet = jXML(domPlayerData).find('Text');
jXML(xSnippet).text(this.m_contGroup.value.text);
this.bs.setBlockPlayerData(this.m_blockData, domPlayerData);
}
destroy() {
}
}