Skip to content

Commit

Permalink
fix(admin-ui): Correctly handle boolean configurable inputs
Browse files Browse the repository at this point in the history
Relates to #112
  • Loading branch information
michaelbromley committed Jun 11, 2019
1 parent f136117 commit b5d10c1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export class CollectionDetailComponent extends BaseDetailComponent<Collection.Fr
return operations.map((o, i) => {
return {
code: o.code,
arguments: Object.values(formValueOperations[i].args).map((value, j) => ({
arguments: Object.values(formValueOperations[i].args).map((value: any, j) => ({
name: o.args[j].name,
value: value.toString(),
type: o.args[j].type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
<div *ngFor="let arg of operation.args" class="arg-row">
<label>{{ arg.name | sentenceCase }}</label>
<div *ngIf="arg.type === ConfigArgType.BOOLEAN" class="checkbox">
<input type="checkbox" [formControlName]="arg.name" [id]="arg.name" />
<label [for]="arg.name"></label>
<clr-checkbox-wrapper>
<input type="checkbox" clrCheckbox [formControlName]="arg.name" [id]="arg.name" />
<label>{{ arg.name }}</label>
</clr-checkbox-wrapper>
</div>
<input
*ngIf="arg.type === ConfigArgType.INT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ export class ConfigurableInputComponent implements OnChanges, OnDestroy, Control
this.form = new FormGroup({});
if (this.operation.args) {
for (const arg of this.operation.args) {
this.form.addControl(arg.name, new FormControl(arg.value, Validators.required));
let value: any = arg.value;
if (arg.type === ConfigArgType.BOOLEAN) {
value = arg.value === 'true';
}
this.form.addControl(arg.name, new FormControl(value, Validators.required));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class RichTextEditorComponent implements ControlValueAccessor, AfterViewI
}

writeValue(value: any) {
if (this.trix.innerHTML !== value) {
if (this.trix.innerHTML !== value || value === '') {
if (!this.initialized) {
setTimeout(() => {
this.trix.editor.loadHTML(value);
Expand Down

0 comments on commit b5d10c1

Please sign in to comment.