From 5b80ef82f6c4e6334ac98d418a8c6513cf0a8890 Mon Sep 17 00:00:00 2001 From: Nath Date: Mon, 16 Dec 2024 12:02:23 +0000 Subject: [PATCH] feat: add module selection --- .../admin/components/setup-wizard-modules.js | 67 +++++++++++++++---- dt-core/admin/components/setup-wizard.js | 32 ++++----- 2 files changed, 69 insertions(+), 30 deletions(-) diff --git a/dt-core/admin/components/setup-wizard-modules.js b/dt-core/admin/components/setup-wizard-modules.js index 3a77e6110..54a9ef7fe 100644 --- a/dt-core/admin/components/setup-wizard-modules.js +++ b/dt-core/admin/components/setup-wizard-modules.js @@ -1,18 +1,11 @@ import { html, css, + repeat, } from 'https://cdn.jsdelivr.net/gh/lit/dist@2.4.0/all/lit-all.min.js'; import { OpenLitElement } from './setup-wizard-open-element.js'; export class SetupWizardModules extends OpenLitElement { - static styles = [ - css` - :host { - display: block; - } - `, - ]; - static get properties() { return { step: { type: Object }, @@ -20,16 +13,19 @@ export class SetupWizardModules extends OpenLitElement { stage: { type: String, attribute: false }, useCases: { type: Array, attribute: false }, option: { type: Object, attribute: false }, + availableModules: { type: Array, attribute: false }, + selectedModules: { type: Array, attribute: false }, }; } constructor() { super(); - - this.stage = 'prompt'; + this.stage = 'work'; this.data = window.setupWizardShare.data; this.useCases = []; this.option = {}; + this.availableModules = []; + this.selectedModules = []; } firstUpdated() { @@ -43,8 +39,7 @@ export class SetupWizardModules extends OpenLitElement { this.useCases = useCaseKeys.map( (useCaseKey) => this.data.use_cases[useCaseKey], ); - - console.log(useCaseKeys, this.useCases); + this.availableModules = this.data.modules; } back() { @@ -74,15 +69,26 @@ export class SetupWizardModules extends OpenLitElement { break; } } - selectOption(option) { this.option = option; + this.selectedModules = option.recommended_modules; + } + toggleModule(key) { + if (this.selectedModules.includes(key)) { + const index = this.selectedModules.findIndex((module) => module === key); + this.selectedModules = [ + ...this.selectedModules.slice(0, index), + ...this.selectedModules.slice(index + 1), + ]; + } else { + this.selectedModules = [...this.selectedModules, key]; + } } render() { return html`
-
+
${this.stage === 'prompt' ? html`

Time to customize what fields are available.

@@ -126,6 +132,39 @@ export class SetupWizardModules extends OpenLitElement { : ''}
+
+

Available Modules

+
+ ${Object.keys(this.availableModules).length > 0 + ? html` +
+ ${repeat( + this.availableModules, + (module) => module.key, + (module) => { + return html` + + `; + }, + )} +
+ ` + : ''} +
+
` : ''} ${this.stage === 'follow-up' diff --git a/dt-core/admin/components/setup-wizard.js b/dt-core/admin/components/setup-wizard.js index 0e57b07dd..26a9da99f 100644 --- a/dt-core/admin/components/setup-wizard.js +++ b/dt-core/admin/components/setup-wizard.js @@ -121,22 +121,18 @@ export class SetupWizard extends LitElement { flex-direction: column; min-block-size: 80vh; } - .cover > * { margin-block: 0.5rem; } - + .cover > .content { + margin-block-end: auto; + } .cover > :first-child:not(.content) { margin-block-start: 0; } - .cover > :last-child:not(.content) { margin-block-end: 0; } - - .cover > .content { - margin-block-end: auto; - } /* Utilities */ .ms-auto { margin-left: auto; @@ -196,21 +192,25 @@ export class SetupWizard extends LitElement { .toggle { position: relative; display: inline-block; - input { display: none; } - span { + div { display: inline-block; padding-block: 1rem; - background-color: var(--default-dark); + background-color: var(--default-color); border-radius: 8px; width: 100%; text-align: center; } - input:checked + span { + input:checked + div { background-color: var(--secondary-color); color: white; + h1, + h2, + h3 { + color: white; + } } } .breadcrumbs { @@ -442,23 +442,23 @@ export class SetupWizard extends LitElement {

Stepper