Skip to content

Commit

Permalink
feat: use toggle instead of checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesjo committed Dec 21, 2023
1 parent 187ac08 commit 4cf8d8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/app/features/config/config-form/config-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { GlobalConfigSectionKey } from '../global-config.model';
import { ProjectCfgFormKey } from '../../project/project.model';
import { T } from '../../../t.const';
import { exists } from '../../../util/exists';
import { addDebounceToFormlyInputs } from '../../../util/add-debounce-to-formly-inputs';
import { adjustToLiveFormlyForm } from '../../../util/adjust-to-live-formly-form';

@Component({
selector: 'config-form',
Expand Down Expand Up @@ -41,7 +41,7 @@ export class ConfigFormComponent {
// NOTE2: since we don't have a save button anymore we need to debounce inputs

@Input() set formCfg(val: FormlyFieldConfig[]) {
this.fields = addDebounceToFormlyInputs(val);
this.fields = adjustToLiveFormlyForm(val);
}

updateCfg(cfg: Record<string, unknown>): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { FormlyFieldConfig } from '@ngx-formly/core';

export const addDebounceToFormlyInputs = (
export const adjustToLiveFormlyForm = (
items: FormlyFieldConfig[],
): FormlyFieldConfig[] => {
return items.map((item) => {
if (item.type === 'checkbox') {
return {
...item,
type: 'toggle',
};
}
if (item.type === 'input') {
return {
...item,
Expand Down

0 comments on commit 4cf8d8d

Please sign in to comment.