remove NEW from config

This commit is contained in:
Matt Hill
2023-03-22 07:51:19 -06:00
committed by Aiden McClelland
parent ddf1f9bcd5
commit f6e142baf5
7 changed files with 16 additions and 32 deletions

View File

@@ -9,7 +9,6 @@
<span>{{ data.name }}</span> <span>{{ data.name }}</span>
<ion-text color="success" *ngIf="data.new">&nbsp;(New)</ion-text>
<ion-text color="success" *ngIf="data.newOptions">&nbsp;(New Options)</ion-text> <ion-text color="success" *ngIf="data.newOptions">&nbsp;(New Options)</ion-text>
<ion-text color="warning" *ngIf="data.edited">&nbsp;(Edited)</ion-text> <ion-text color="warning" *ngIf="data.edited">&nbsp;(Edited)</ion-text>

View File

@@ -12,7 +12,6 @@ export class FormLabelComponent {
name: string name: string
description: string | null description: string | null
edited?: boolean edited?: boolean
new?: boolean
required?: boolean required?: boolean
newOptions?: boolean newOptions?: boolean
} }

View File

@@ -3,7 +3,6 @@
[data]="{ [data]="{
name: spec.name, name: spec.name,
description: spec.description, description: spec.description,
new: form.original?.[name] === undefined,
edited: control.dirty, edited: control.dirty,
required: !spec.nullable required: !spec.nullable
}" }"

View File

@@ -24,7 +24,6 @@
[data]="{ [data]="{
name: spec.name, name: spec.name,
description: spec.description, description: spec.description,
new: original?.[entry.key] === undefined,
edited: entry.value.dirty edited: entry.value.dirty
}" }"
></form-label> ></form-label>
@@ -68,7 +67,6 @@
[data]="{ [data]="{
name: spec.name, name: spec.name,
description: spec.description, description: spec.description,
new: original?.[entry.key] === undefined,
edited: entry.value.dirty, edited: entry.value.dirty,
newOptions: objectDisplay[entry.key].hasNewOptions newOptions: objectDisplay[entry.key].hasNewOptions
}" }"
@@ -121,7 +119,6 @@
[data]="{ [data]="{
name: spec.name, name: spec.name,
description: spec.description, description: spec.description,
new: original?.[entry.key] === undefined,
edited: entry.value.dirty, edited: entry.value.dirty,
required: !!(spec.range | toRange).min required: !!(spec.range | toRange).min
}" }"
@@ -166,7 +163,6 @@
objectListDisplay[entry.key][i].displayAs || objectListDisplay[entry.key][i].displayAs ||
'Entry ' + (i + 1), 'Entry ' + (i + 1),
description: null, description: null,
new: false,
edited: abstractControl.dirty edited: abstractControl.dirty
}" }"
></form-label> ></form-label>
@@ -272,7 +268,6 @@
[data]="{ [data]="{
name: spec.name, name: spec.name,
description: spec.description, description: spec.description,
new: original?.[entry.key] === undefined,
edited: entry.value.dirty edited: entry.value.dirty
}" }"
></form-label> ></form-label>

View File

@@ -62,13 +62,7 @@ export class FormObjectComponent {
// setTimeout hack to avoid ExpressionChangedAfterItHasBeenCheckedError // setTimeout hack to avoid ExpressionChangedAfterItHasBeenCheckedError
setTimeout(() => { setTimeout(() => {
if ( // if (this.original && Object.values(this.objectSpec).some(spec => spec['is-new'])) this.hasNewOptions.emit()
this.original &&
Object.keys(this.current || {}).some(
key => this.original![key] === undefined,
)
)
this.hasNewOptions.emit()
}) })
} }
@@ -144,7 +138,7 @@ export class FormObjectComponent {
this.hasNewOptions.emit() this.hasNewOptions.emit()
setTimeout(() => { setTimeout(() => {
this.objectDisplay[key].hasNewOptions = true this.objectDisplay[key].hasNewOptions = true
}, 100) })
} }
handleBooleanChange(key: string, spec: ValueSpecBoolean) { handleBooleanChange(key: string, spec: ValueSpecBoolean) {

View File

@@ -5,7 +5,6 @@
[data]="{ [data]="{
name: spec.tag.name, name: spec.tag.name,
description: spec.tag.description, description: spec.tag.description,
new: isNew,
newOptions: hasNewOptions, newOptions: hasNewOptions,
edited: formGroup.dirty edited: formGroup.dirty
}" }"
@@ -19,7 +18,7 @@
slot="end" slot="end"
placeholder="Select" placeholder="Select"
[formControlName]="spec.tag.id" [formControlName]="spec.tag.id"
[selectedText]="spec.tag['variant-names'][unionValue]" [selectedText]="variantName"
(ionChange)="updateUnion($event)" (ionChange)="updateUnion($event)"
> >
<ion-select-option <ion-select-option
@@ -31,9 +30,9 @@
</ion-select> </ion-select>
</ion-item-divider> </ion-item-divider>
<tui-elastic-container [id]="objectId | toElementId: 'union'" class="indent"> <tui-elastic-container [id]="objectId | toElementId : 'union'" class="indent">
<form-object <form-object
[objectSpec]="spec.variants[unionValue]" [objectSpec]="variantSpec"
[formGroup]="formGroup" [formGroup]="formGroup"
[current]="current" [current]="current"
[original]="original" [original]="original"

View File

@@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
import { UntypedFormGroup } from '@angular/forms' import { UntypedFormGroup } from '@angular/forms'
import { v4 } from 'uuid' import { v4 } from 'uuid'
import { FormService } from 'src/app/services/form.service' import { FormService } from 'src/app/services/form.service'
import { ValueSpecUnion } from 'start-sdk/types/config-types' import { ValueSpecUnion, InputSpec } from 'start-sdk/types/config-types'
@Component({ @Component({
selector: 'form-union', selector: 'form-union',
@@ -16,22 +16,21 @@ export class FormUnionComponent {
@Input() current?: Record<string, any> @Input() current?: Record<string, any>
@Input() original?: Record<string, any> @Input() original?: Record<string, any>
get unionValue() { get selectedVariant(): string {
return this.formGroup.get(this.spec.tag.id)?.value return this.formGroup.get(this.spec.tag.id)?.value
} }
get isNew() { get variantName(): string {
return !this.original return this.spec.tag['variant-names'][this.selectedVariant]
} }
get hasNewOptions() { get variantSpec(): InputSpec {
const tagId = this.spec.tag.id return this.spec.variants[this.selectedVariant]
return ( }
this.original?.[tagId] === this.current?.[tagId] &&
!!Object.keys(this.current || {}).find( get hasNewOptions(): boolean {
key => this.original![key] === undefined, // return Object.values(this.variantSpec).some(spec => spec['is-new'])
) return false
)
} }
objectId = v4() objectId = v4()