Skip to content

Commit

Permalink
display new and new options in config
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Hill authored and elvece committed Jun 15, 2022
1 parent c4e7acb commit 737c176
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class AppWizardComponent {

ionViewDidEnter() {
this.initializing = false
this.swiper.allowTouchMove = false
this.loadSlide()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<span>{{ data.spec.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="warning" *ngIf="data.edited">&nbsp;(Edited)</ion-text>

<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h4 class="input-label">
<form-label
[data]="{
spec: spec,
new: !!current && current[entry.key] === undefined,
new: original?.[entry.key] === undefined,
edited: entry.value.dirty
}"
></form-label>
Expand Down Expand Up @@ -116,9 +116,20 @@ <h4 class="input-label">
size="small"
></ion-icon>
</ion-button>
<ion-label
><b>{{ spec.name }}</b></ion-label
>
<ion-label>
<b>
{{ spec.name }}
<ion-text *ngIf="entry.value.dirty" color="warning">
(Edited)</ion-text
>
<ion-text
*ngIf="original?.[entry.key] === undefined"
color="success"
>
(New)</ion-text
>
</b>
</ion-label>
<!-- boolean -->
<ion-toggle
*ngIf="spec.type === 'boolean'"
Expand Down Expand Up @@ -157,7 +168,8 @@ <h4 class="input-label">
<form-label
[data]="{
spec: spec,
new: !!current && current[entry.key] === undefined,
new: original?.[entry.key] === undefined,
newOptions: objectDisplay[entry.key].hasNewOptions,
edited: entry.value.dirty
}"
></form-label>
Expand Down Expand Up @@ -190,7 +202,8 @@ <h4 class="input-label">
: 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)"
></form-object>
Expand All @@ -208,7 +221,7 @@ <h4 class="input-label">
<form-label
[data]="{
spec: spec,
new: !!current && current[entry.key] === undefined,
new: original?.[entry.key] === undefined,
edited: entry.value.dirty
}"
></form-label>
Expand Down Expand Up @@ -282,6 +295,7 @@ <h4 class="input-label">
"
[formGroup]="abstractControl"
[current]="current?.[entry.key]?.[i]"
[original]="original?.[entry.key]?.[i]"
[unionSpec]="
spec.subtype === 'union' ? $any(spec.spec) : undefined
"
Expand Down Expand Up @@ -347,7 +361,7 @@ <h4 class="input-label">
<form-label
[data]="{
spec: spec,
new: !!current && current[entry.key] === undefined,
new: original?.[entry.key] === undefined,
edited: entry.value.dirty
}"
></form-label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>()
@Output() onExpand = new EventEmitter<void>()
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 }[]
} = {}
Expand Down Expand Up @@ -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,
}
}
})
Expand Down Expand Up @@ -110,6 +126,7 @@ export class FormObjectComponent {
this.objectDisplay[key] = {
expanded: false,
height: '0px',
hasNewOptions: false,
}
}
},
Expand Down Expand Up @@ -354,6 +371,7 @@ interface HeaderData {
spec: ValueSpec
edited: boolean
new: boolean
newOptions?: boolean
invalid?: boolean
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h2 style="display: flex; align-items: center">
[objectSpec]="configSpec"
[formGroup]="configForm"
[current]="configForm.value"
[showEdited]="true"
[original]="original"
></form-object>
</form>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
14 changes: 6 additions & 8 deletions frontend/projects/ui/src/app/services/api/api.fixures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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': {
Expand Down

0 comments on commit 737c176

Please sign in to comment.