From 737c17671ccaec30feb8942491130f091ed77ed3 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 14 Jun 2022 17:10:42 -0600 Subject: [PATCH] display new and new options in config --- .../app-wizard/app-wizard.component.ts | 1 + .../form-object/form-label.component.html | 1 + .../form-object/form-object.component.html | 30 ++++++++++++++----- .../form-object/form-object.component.ts | 22 ++++++++++++-- .../modals/app-config/app-config.page.html | 2 +- .../marketplace-show-controls.component.ts | 7 +---- .../ui/src/app/services/api/api.fixures.ts | 14 ++++----- 7 files changed, 52 insertions(+), 25 deletions(-) diff --git a/frontend/projects/ui/src/app/components/app-wizard/app-wizard.component.ts b/frontend/projects/ui/src/app/components/app-wizard/app-wizard.component.ts index 22245cedf..8ced2fb3e 100644 --- a/frontend/projects/ui/src/app/components/app-wizard/app-wizard.component.ts +++ b/frontend/projects/ui/src/app/components/app-wizard/app-wizard.component.ts @@ -58,6 +58,7 @@ export class AppWizardComponent { ionViewDidEnter() { this.initializing = false + this.swiper.allowTouchMove = false this.loadSlide() } 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.component.html index c6fd18428..dd555d560 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.component.html @@ -22,6 +22,7 @@ {{ data.spec.name }}  (New) + (New Options)  (Edited) @@ -116,9 +116,20 @@

size="small" > - {{ spec.name }} + + + {{ spec.name }} + + (Edited) + + (New) + + @@ -190,7 +202,8 @@

: spec.spec " [formGroup]="$any(entry.value)" - [current]="current ? current[entry.key] : undefined" + [current]="current?.[entry.key]" + [original]="original?.[entry.key]" [unionSpec]="spec.type === 'union' ? spec : undefined" (onExpand)="resize(entry.key)" > @@ -208,7 +221,7 @@

@@ -282,6 +295,7 @@

" [formGroup]="abstractControl" [current]="current?.[entry.key]?.[i]" + [original]="original?.[entry.key]?.[i]" [unionSpec]=" spec.subtype === 'union' ? $any(spec.spec) : undefined " @@ -347,7 +361,7 @@

diff --git a/frontend/projects/ui/src/app/components/form-object/form-object.component.ts b/frontend/projects/ui/src/app/components/form-object/form-object.component.ts index 0c02c40ae..cc3fb8599 100644 --- a/frontend/projects/ui/src/app/components/form-object/form-object.component.ts +++ b/frontend/projects/ui/src/app/components/form-object/form-object.component.ts @@ -36,12 +36,14 @@ export class FormObjectComponent { @Input() formGroup: FormGroup @Input() unionSpec?: ValueSpecUnion @Input() current?: { [key: string]: any } - @Input() showEdited: boolean = false + @Input() original?: { [key: string]: any } @Output() onInputChange = new EventEmitter() @Output() onExpand = new EventEmitter() warningAck: { [key: string]: boolean } = {} unmasked: { [key: string]: boolean } = {} - objectDisplay: { [key: string]: { expanded: boolean; height: string } } = {} + objectDisplay: { + [key: string]: { expanded: boolean; height: string; hasNewOptions: boolean } + } = {} objectListDisplay: { [key: string]: { expanded: boolean; height: string; displayAs: string }[] } = {} @@ -74,9 +76,23 @@ export class FormObjectComponent { } }) } else if (['object', 'union'].includes(spec.type)) { + let hasNewOptions = false + + // We can only really show new children for objects, not unions. + if (spec.type === 'object') { + hasNewOptions = Object.keys(spec.spec).some(childKey => { + const parentValue = this.original?.[key] + return !!parentValue && parentValue[childKey] === undefined + }) + } else if (spec.type === 'union') { + // @TODO + hasNewOptions = false + } + this.objectDisplay[key] = { expanded: false, height: '0px', + hasNewOptions, } } }) @@ -110,6 +126,7 @@ export class FormObjectComponent { this.objectDisplay[key] = { expanded: false, height: '0px', + hasNewOptions: false, } } }, @@ -354,6 +371,7 @@ interface HeaderData { spec: ValueSpec edited: boolean new: boolean + newOptions?: boolean invalid?: boolean } diff --git a/frontend/projects/ui/src/app/modals/app-config/app-config.page.html b/frontend/projects/ui/src/app/modals/app-config/app-config.page.html index c8d5d2fef..40cf050b6 100644 --- a/frontend/projects/ui/src/app/modals/app-config/app-config.page.html +++ b/frontend/projects/ui/src/app/modals/app-config/app-config.page.html @@ -81,7 +81,7 @@

[objectSpec]="configSpec" [formGroup]="configForm" [current]="configForm.value" - [showEdited]="true" + [original]="original" > diff --git a/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show-controls/marketplace-show-controls.component.ts b/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show-controls/marketplace-show-controls.component.ts index edad27bf5..c87b7d71d 100644 --- a/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show-controls/marketplace-show-controls.component.ts +++ b/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show-controls/marketplace-show-controls.component.ts @@ -81,16 +81,11 @@ export class MarketplaceShowControlsComponent { installAlert: alerts.install || undefined, } - const success = await wizardModal( + wizardModal( this.modalCtrl, action === 'update' ? this.wizards.update(value) : this.wizards.downgrade(value), ) - - if (!success) return - - await pauseFor(250) - this.navCtrl.back() } } diff --git a/frontend/projects/ui/src/app/services/api/api.fixures.ts b/frontend/projects/ui/src/app/services/api/api.fixures.ts index aee684fc9..dbd974159 100644 --- a/frontend/projects/ui/src/app/services/api/api.fixures.ts +++ b/frontend/projects/ui/src/app/services/api/api.fixures.ts @@ -1659,10 +1659,8 @@ export module Mock { }, } - export const MockConfig = {} - - export const MockDependencyConfig = { - testnet: true, + export const MockConfig = { + testnet: undefined, 'object-list': [ { 'first-name': 'First', @@ -1688,19 +1686,19 @@ export module Mock { law1: 'The first law Amended', law2: 'The second law', }, - rpcpass: null, + rpcpass: undefined, rpcuser: '123', rulemakers: [], }, - advanced: { - notifications: ['email', 'text', 'push'], - }, 'bitcoin-node': undefined, port: 20, rpcallowip: undefined, rpcauth: ['matt: 8273gr8qwoidm1uid91jeh8y23gdio1kskmwejkdnm'], + advanced: undefined, } + export const MockDependencyConfig = MockConfig + export const bitcoind: PackageDataEntry = { state: PackageState.Installed, 'static-files': {