Skip to content

Commit

Permalink
Merge branch 'refs/heads/feat/setup-wizard' into feat/setup-wizard-ge…
Browse files Browse the repository at this point in the history
…ocoding

# Conflicts:
#	dt-core/admin/admin-settings-endpoints.php
#	dt-core/admin/menu/menu-setup-wizard.php
  • Loading branch information
corsacca committed Dec 18, 2024
2 parents daff6dc + c35effe commit 286972e
Show file tree
Hide file tree
Showing 11 changed files with 427 additions and 186 deletions.
25 changes: 24 additions & 1 deletion dt-core/admin/admin-settings-endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,13 @@ public function add_api_routes() {
'permission_callback' => [ $this, 'default_permission_check' ],
]
);

register_rest_route(
$this->namespace, '/modules-update', [
'methods' => 'POST',
'callback' => [ $this, 'update_modules' ],
'permission_callback' => [ $this, 'default_permission_check' ],
]
);
register_rest_route(
$this->namespace, '/update-dt-options', [
'methods' => 'POST',
Expand All @@ -247,6 +253,23 @@ public function update_dt_options( WP_REST_REQUEST $request ){
return $updated;
}

public function update_modules( WP_REST_REQUEST $request ) {
$modules_option_name = 'dt_post_type_modules';
$modules_to_update = $request->get_param( 'modules' );
$modules_to_update = dt_recursive_sanitize_array( $modules_to_update );

$modules = dt_get_option( $modules_option_name );

foreach ( $modules as $key => $module ) {
if ( array_key_exists( $key, $modules_to_update ) ) {
$modules[$key]['enabled'] = !empty( $modules_to_update[$key] ) ? true : false;
}
}

update_option( $modules_option_name, $modules );
return true;
}

public function update_languages( WP_REST_REQUEST $request ) {
$params = $request->get_params();
$languages = dt_get_option( 'dt_working_languages' );
Expand Down
48 changes: 48 additions & 0 deletions dt-core/admin/components/setup-wizard-celebration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { html } from 'https://cdn.jsdelivr.net/gh/lit/[email protected]/all/lit-all.min.js';
import { OpenLitElement } from './setup-wizard-open-element.js';

export class SetupWizardCelebration extends OpenLitElement {
static get properties() {
return {
step: { type: Object },
};
}

back() {
this.dispatchEvent(new CustomEvent('back'));
}
next() {
window.location.href = window.setupWizardShare.admin_url;
}

render() {
return html`
<div class="cover">
<h2>All finished</h2>
<div class="content flow">
<p>
You can change all of these choices in the Settings (D.T.) tab in
the WP admin.
</p>
<p>
D.T. has a huge ability to be customized to serve your needs. If you
have any questions or need any further assistance in getting D.T. to
work for you, please reach out on our community forum or our discord
channel.
</p>
<a href="https://community.disciple.tools/" target="_blank">
Community Forum
</a>
<a href="https://discord.gg/vrrcXYwwTU" target="_blank">
Discord Invitation
</a>
</div>
<setup-wizard-controls
@next=${this.next}
@back=${this.back}
></setup-wizard-controls>
</div>
`;
}
}
customElements.define('setup-wizard-celebration', SetupWizardCelebration);
1 change: 0 additions & 1 deletion dt-core/admin/components/setup-wizard-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { OpenLitElement } from './setup-wizard-open-element.js';
export class SetupWizardControls extends OpenLitElement {
static get properties() {
return {
translations: { type: Object },
hideBack: { type: Boolean },
backLabel: { type: String },
nextLabel: { type: String },
Expand Down
51 changes: 51 additions & 0 deletions dt-core/admin/components/setup-wizard-intro.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { html } from 'https://cdn.jsdelivr.net/gh/lit/[email protected]/all/lit-all.min.js';
import { OpenLitElement } from './setup-wizard-open-element.js';

export class SetupWizardIntro extends OpenLitElement {
static get properties() {
return {
step: { type: Object },
};
}

back() {
this.dispatchEvent(new CustomEvent('back'));
}
next() {
this.dispatchEvent(new CustomEvent('next'));
}

render() {
return html`
<div class="cover">
<h2>Setting up D.T. for you</h2>
<div class="content">
<p>
We're glad you are here, and want to help set you up so you can take
advantage of the powertool that is D.T.
</p>
<p>
D.T. can be used in many ways from managing connections and
relationships, all the way through to tracking and managing a
movement of Disciple Making.
</p>
<p>
In order to help you, we want to take you through a series of
choices to give you the best start at getting Disiple.Tools setup
ready to suit your needs.
</p>
<p>
Feel free to skip this setup stage if you already know what you
need. But if this will be helpful for you let's dive in.
</p>
</div>
<setup-wizard-controls
hideBack
@next=${this.next}
@back=${this.back}
></setup-wizard-controls>
</div>
`;
}
}
customElements.define('setup-wizard-intro', SetupWizardIntro);
Loading

0 comments on commit 286972e

Please sign in to comment.