diff --git a/frontend/projects/ui/src/app/components/form-object/form-label.component.html b/frontend/projects/ui/src/app/components/form-object/form-label/form-label.component.html
similarity index 82%
rename from frontend/projects/ui/src/app/components/form-object/form-label.component.html
rename to frontend/projects/ui/src/app/components/form-object/form-label/form-label.component.html
index 0827348ad..2095516ad 100644
--- a/frontend/projects/ui/src/app/components/form-object/form-label.component.html
+++ b/frontend/projects/ui/src/app/components/form-object/form-label/form-label.component.html
@@ -2,7 +2,7 @@
*ngIf="data.description"
class="slot-start"
fill="clear"
- (click)="presentAlertDescription($event)"
+ (click.stop)="presentAlertDescription()"
>
@@ -13,4 +13,4 @@
(New Options)
(Edited)
- *
+ *
diff --git a/frontend/projects/ui/src/app/components/form-object/form-label/form-label.component.scss b/frontend/projects/ui/src/app/components/form-object/form-label/form-label.component.scss
new file mode 100644
index 000000000..99e8f5d91
--- /dev/null
+++ b/frontend/projects/ui/src/app/components/form-object/form-label/form-label.component.scss
@@ -0,0 +1,9 @@
+:host {
+ display: flex;
+ align-items: center;
+}
+
+.slot-start {
+ --padding-start: 0;
+ --padding-end: 7px;
+}
diff --git a/frontend/projects/ui/src/app/components/form-object/form-label/form-label.component.ts b/frontend/projects/ui/src/app/components/form-object/form-label/form-label.component.ts
new file mode 100644
index 000000000..45b7a0144
--- /dev/null
+++ b/frontend/projects/ui/src/app/components/form-object/form-label/form-label.component.ts
@@ -0,0 +1,35 @@
+import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
+import { AlertController } from '@ionic/angular'
+
+@Component({
+ selector: 'form-label',
+ templateUrl: './form-label.component.html',
+ styleUrls: ['./form-label.component.scss'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+})
+export class FormLabelComponent {
+ @Input() data!: {
+ name: string
+ new: boolean
+ edited: boolean
+ description?: string
+ required?: boolean
+ newOptions?: boolean
+ }
+
+ constructor(private readonly alertCtrl: AlertController) {}
+
+ async presentAlertDescription() {
+ const alert = await this.alertCtrl.create({
+ header: this.data.name,
+ message: this.data.description,
+ buttons: [
+ {
+ text: 'OK',
+ cssClass: 'enter-click',
+ },
+ ],
+ })
+ await alert.present()
+ }
+}
diff --git a/frontend/projects/ui/src/app/components/form-object/form-object.component.scss b/frontend/projects/ui/src/app/components/form-object/form-object.component.scss
deleted file mode 100644
index a98a0ff72..000000000
--- a/frontend/projects/ui/src/app/components/form-object/form-object.component.scss
+++ /dev/null
@@ -1,42 +0,0 @@
-.slot-start {
- display: inline-block;
- vertical-align: middle;
- --padding-start: 0;
- --padding-end: 7px;
-}
-
-.error-border {
- border-color: var(--ion-color-danger-shade);
- --border-color: var(--ion-color-danger-shade);
-}
-
-.redacted {
- font-family: 'Redacted'
-}
-
-ion-input {
- font-family: 'Courier New';
- font-weight: bold;
- --placeholder-font-weight: 400;
-}
-
-ion-item-divider {
- text-transform: unset;
- --padding-top: 18px;
- --padding-start: 0;
- border-bottom: 1px solid var(--ion-item-border-color, var(--ion-border-color, var(--ion-color-step-150, rgba(0, 0, 0, 0.13))))
-}
-
-.nested-wrapper {
- padding: 0 0 16px 24px;
-}
-
-.error-message {
- margin-top: 2px;
- font-size: small;
- color: var(--ion-color-danger);
-}
-
-.indent {
- margin-left: 24px;
-}
\ No newline at end of file
diff --git a/frontend/projects/ui/src/app/components/form-object/form-object.component.module.ts b/frontend/projects/ui/src/app/components/form-object/form-object.module.ts
similarity index 81%
rename from frontend/projects/ui/src/app/components/form-object/form-object.component.module.ts
rename to frontend/projects/ui/src/app/components/form-object/form-object.module.ts
index 06af388c0..229015290 100644
--- a/frontend/projects/ui/src/app/components/form-object/form-object.component.module.ts
+++ b/frontend/projects/ui/src/app/components/form-object/form-object.module.ts
@@ -1,10 +1,15 @@
-import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
-import {
- FormObjectComponent,
- FormUnionComponent,
- FormLabelComponent,
-} from './form-object.component'
+import { NgModule } from '@angular/core'
+import { FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { IonicModule } from '@ionic/angular'
+import { SharedPipesModule } from '@start9labs/shared'
+import { TuiElasticContainerModule } from '@taiga-ui/kit'
+import { TuiExpandModule } from '@taiga-ui/core'
+import { EnumListPageModule } from 'src/app/modals/enum-list/enum-list.module'
+
+import { FormLabelComponent } from './form-label/form-label.component'
+import { FormObjectComponent } from './form-object/form-object.component'
+import { FormUnionComponent } from './form-union/form-union.component'
import {
GetErrorPipe,
ToWarningTextPipe,
@@ -13,12 +18,6 @@ import {
ToEnumListDisplayPipe,
ToRangePipe,
} from './form-object.pipes'
-import { IonicModule } from '@ionic/angular'
-import { FormsModule, ReactiveFormsModule } from '@angular/forms'
-import { SharedPipesModule } from '@start9labs/shared'
-import { TuiElasticContainerModule } from '@taiga-ui/kit'
-import { EnumListPageModule } from 'src/app/modals/enum-list/enum-list.module'
-import { TuiExpandModule } from '@taiga-ui/core'
@NgModule({
declarations: [
@@ -44,4 +43,4 @@ import { TuiExpandModule } from '@taiga-ui/core'
],
exports: [FormObjectComponent, FormLabelComponent],
})
-export class FormObjectComponentModule {}
+export class FormObjectModule {}
diff --git a/frontend/projects/ui/src/app/components/form-object/form-object.pipes.ts b/frontend/projects/ui/src/app/components/form-object/form-object.pipes.ts
index 49af5c307..8a8ad74f0 100644
--- a/frontend/projects/ui/src/app/components/form-object/form-object.pipes.ts
+++ b/frontend/projects/ui/src/app/components/form-object/form-object.pipes.ts
@@ -8,7 +8,7 @@ import {
import { IonicSafeString } from '@ionic/angular'
import { ListValueSpecOf } from 'start-sdk/types/config-types'
import { Range } from 'src/app/util/config-utilities'
-import { getElementId } from './form-object.component'
+import { getElementId } from './form-object/form-object.component'
@Pipe({
name: 'getError',
diff --git a/frontend/projects/ui/src/app/components/form-object/form-object.component.html b/frontend/projects/ui/src/app/components/form-object/form-object/form-object.component.html
similarity index 99%
rename from frontend/projects/ui/src/app/components/form-object/form-object.component.html
rename to frontend/projects/ui/src/app/components/form-object/form-object/form-object.component.html
index 48b649764..b1c0b1529 100644
--- a/frontend/projects/ui/src/app/components/form-object/form-object.component.html
+++ b/frontend/projects/ui/src/app/components/form-object/form-object/form-object.component.html
@@ -26,13 +26,14 @@
+ @Input() original?: Record
@Output() onInputChange = new EventEmitter()
@Output() hasNewOptions = new EventEmitter()
warningAck: { [key: string]: boolean } = {}
@@ -330,96 +326,6 @@ export class FormObjectComponent {
}
}
-@Component({
- selector: 'form-union',
- templateUrl: './form-union.component.html',
- styleUrls: ['./form-object.component.scss'],
- changeDetection: ChangeDetectionStrategy.OnPush,
-})
-export class FormUnionComponent {
- @Input() formGroup!: UntypedFormGroup
- @Input() spec!: ValueSpecUnion
- @Input() current?: Config
- @Input() original?: Config
-
- get unionValue() {
- return this.formGroup.get(this.spec.tag.id)?.value
- }
-
- get isNew() {
- return !this.original
- }
-
- get hasNewOptions() {
- const tagId = this.spec.tag.id
- return (
- this.original?.[tagId] === this.current?.[tagId] &&
- !!Object.keys(this.current || {}).find(
- key => this.original![key] === undefined,
- )
- )
- }
-
- objectId = v4()
-
- constructor(private readonly formService: FormService) {}
-
- updateUnion(e: any): void {
- const tagId = this.spec.tag.id
-
- Object.keys(this.formGroup.controls).forEach(control => {
- if (control === tagId) return
- this.formGroup.removeControl(control)
- })
-
- const unionGroup = this.formService.getUnionObject(
- this.spec as ValueSpecUnion,
- e.detail.value,
- )
-
- Object.keys(unionGroup.controls).forEach(control => {
- if (control === tagId) return
- this.formGroup.addControl(control, unionGroup.controls[control])
- })
- }
-}
-
-@Component({
- selector: 'form-label',
- templateUrl: './form-label.component.html',
- styleUrls: ['./form-object.component.scss'],
- changeDetection: ChangeDetectionStrategy.OnPush,
-})
-export class FormLabelComponent {
- @Input() data!: {
- name: string
- new: boolean
- edited: boolean
- description: string | null
- required?: boolean
- newOptions?: boolean
- }
-
- constructor(private readonly alertCtrl: AlertController) {}
-
- async presentAlertDescription(event: Event) {
- event.stopPropagation()
- const { name, description } = this.data
-
- const alert = await this.alertCtrl.create({
- header: name,
- message: description || '',
- buttons: [
- {
- text: 'OK',
- cssClass: 'enter-click',
- },
- ],
- })
- await alert.present()
- }
-}
-
export function getElementId(objectId: string, key: string, index = 0): string {
return `${key}-${index}-${objectId}`
}
diff --git a/frontend/projects/ui/src/app/components/form-object/form-union.component.html b/frontend/projects/ui/src/app/components/form-object/form-union/form-union.component.html
similarity index 100%
rename from frontend/projects/ui/src/app/components/form-object/form-union.component.html
rename to frontend/projects/ui/src/app/components/form-object/form-union/form-union.component.html
diff --git a/frontend/projects/ui/src/app/components/form-object/form-union/form-union.component.scss b/frontend/projects/ui/src/app/components/form-object/form-union/form-union.component.scss
new file mode 100644
index 000000000..41a0c3e89
--- /dev/null
+++ b/frontend/projects/ui/src/app/components/form-object/form-union/form-union.component.scss
@@ -0,0 +1,24 @@
+:host {
+ display: block;
+}
+
+ion-item-divider {
+ text-transform: unset;
+ border-bottom: 1px solid
+ var(
+ --ion-item-border-color,
+ var(--ion-border-color, var(--ion-color-step-150, rgba(0, 0, 0, 0.13)))
+ );
+
+ --padding-top: 18px;
+ --padding-start: 0;
+
+ &.error-border {
+ border-color: var(--ion-color-danger-shade);
+ --border-color: var(--ion-color-danger-shade);
+ }
+}
+
+.indent {
+ margin-left: 24px;
+}
diff --git a/frontend/projects/ui/src/app/components/form-object/form-union/form-union.component.ts b/frontend/projects/ui/src/app/components/form-object/form-union/form-union.component.ts
new file mode 100644
index 000000000..ca30083ac
--- /dev/null
+++ b/frontend/projects/ui/src/app/components/form-object/form-union/form-union.component.ts
@@ -0,0 +1,59 @@
+import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
+import { UntypedFormGroup } from '@angular/forms'
+import { v4 } from 'uuid'
+import { FormService } from 'src/app/services/form.service'
+import { ValueSpecUnion } from 'src/app/pkg-config/config-types'
+
+@Component({
+ selector: 'form-union',
+ templateUrl: './form-union.component.html',
+ styleUrls: ['./form-union.component.scss'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+})
+export class FormUnionComponent {
+ @Input() formGroup!: UntypedFormGroup
+ @Input() spec!: ValueSpecUnion
+ @Input() current?: Record
+ @Input() original?: Record
+
+ get unionValue() {
+ return this.formGroup.get(this.spec.tag.id)?.value
+ }
+
+ get isNew() {
+ return !this.original
+ }
+
+ get hasNewOptions() {
+ const tagId = this.spec.tag.id
+ return (
+ this.original?.[tagId] === this.current?.[tagId] &&
+ !!Object.keys(this.current || {}).find(
+ key => this.original![key] === undefined,
+ )
+ )
+ }
+
+ objectId = v4()
+
+ constructor(private readonly formService: FormService) {}
+
+ updateUnion(e: any): void {
+ const tagId = this.spec.tag.id
+
+ Object.keys(this.formGroup.controls).forEach(control => {
+ if (control === tagId) return
+ this.formGroup.removeControl(control)
+ })
+
+ const unionGroup = this.formService.getUnionObject(
+ this.spec as ValueSpecUnion,
+ e.detail.value,
+ )
+
+ Object.keys(unionGroup.controls).forEach(control => {
+ if (control === tagId) return
+ this.formGroup.addControl(control, unionGroup.controls[control])
+ })
+ }
+}
diff --git a/frontend/projects/ui/src/app/modals/app-config/app-config.module.ts b/frontend/projects/ui/src/app/modals/app-config/app-config.module.ts
index fde422826..db9933f54 100644
--- a/frontend/projects/ui/src/app/modals/app-config/app-config.module.ts
+++ b/frontend/projects/ui/src/app/modals/app-config/app-config.module.ts
@@ -4,7 +4,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { IonicModule } from '@ionic/angular'
import { AppConfigPage } from './app-config.page'
import { TextSpinnerComponentModule } from '@start9labs/shared'
-import { FormObjectComponentModule } from 'src/app/components/form-object/form-object.component.module'
+import { FormObjectModule } from 'src/app/components/form-object/form-object.module'
@NgModule({
declarations: [AppConfigPage],
@@ -13,7 +13,7 @@ import { FormObjectComponentModule } from 'src/app/components/form-object/form-o
FormsModule,
IonicModule,
TextSpinnerComponentModule,
- FormObjectComponentModule,
+ FormObjectModule,
ReactiveFormsModule,
],
exports: [AppConfigPage],
diff --git a/frontend/projects/ui/src/app/modals/generic-form/generic-form.module.ts b/frontend/projects/ui/src/app/modals/generic-form/generic-form.module.ts
index f66306d06..3ca863c3d 100644
--- a/frontend/projects/ui/src/app/modals/generic-form/generic-form.module.ts
+++ b/frontend/projects/ui/src/app/modals/generic-form/generic-form.module.ts
@@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common'
import { IonicModule } from '@ionic/angular'
import { GenericFormPage } from './generic-form.page'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
-import { FormObjectComponentModule } from 'src/app/components/form-object/form-object.component.module'
+import { FormObjectModule } from 'src/app/components/form-object/form-object.module'
@NgModule({
declarations: [GenericFormPage],
@@ -12,8 +12,8 @@ import { FormObjectComponentModule } from 'src/app/components/form-object/form-o
IonicModule,
FormsModule,
ReactiveFormsModule,
- FormObjectComponentModule,
+ FormObjectModule,
],
exports: [GenericFormPage],
})
-export class GenericFormPageModule { }
\ No newline at end of file
+export class GenericFormPageModule {}