Skip to content

Commit 9831154

Browse files
D.T Components: Location Meta field support (#2779)
* Implemented location-map component * Removed unused location & location_meta code * Removed logging * Added render_location back * Updated component package version to 0.8.0 * Updated dt-components to v0.8.1 * Update components * update components lib --------- Co-authored-by: corsac <corsacca@gmail.com>
1 parent 6a9e7dd commit 9831154

8 files changed

Lines changed: 45 additions & 81 deletions

File tree

dt-assets/build/components/index.es.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { E as s, C as e, w as D, B as o, D as i, b as l, c as n, e as r, f as c, g as p, a as u, v as C, A as M, h as T, x as m, i as x, j as S, k as d, y as g, l as B, u as h, t as A, m as L, n as b, o as v, p as f, q as w, z as y, r as F, d as j } from "./index-B8g7mjSm.js";
1+
import { E as s, C as e, w as D, B as o, D as i, b as l, c as n, e as r, f as c, g as p, a as u, v as C, A as M, h as T, x as m, i as x, j as S, k as d, y as g, l as B, u as h, t as A, m as L, n as b, o as v, p as f, q as w, z as y, r as F, d as j } from "./index-CQUnH6ya.js";
22
export {
33
s as ApiService,
44
e as ComponentService,

dt-assets/build/components/index.js

Lines changed: 14 additions & 14 deletions
Large diffs are not rendered by default.

dt-assets/build/components/index.umd.cjs

Lines changed: 14 additions & 14 deletions
Large diffs are not rendered by default.

dt-core/global-functions.php

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,9 @@ function render_field_for_display( $field_key, $fields, $post, $show_extra_contr
645645
case 'textarea':
646646
DT_Components::render_textarea( $field_key, $fields, $post, $params );
647647
break;
648+
case 'location_meta':
649+
DT_Components::render_location_meta( $field_key, $fields, $post, $params );
650+
break;
648651
default:
649652
$is_legacy = true;
650653
break;
@@ -702,11 +705,6 @@ class="add-link__option"
702705
</div>
703706

704707
<?php endif; ?>
705-
<?php if ( ( $field_type === 'location' || 'location_meta' === $field_type ) && DT_Mapbox_API::get_key() && !$is_empty_post ) : ?>
706-
<button data-list-class="<?php echo esc_html( $field_key ) ?>" class="add-button" id="new-mapbox-search" type="button" <?php echo esc_html( $disabled ); ?>>
707-
<img src="<?php echo esc_html( get_template_directory_uri() . '/dt-assets/images/small-add.svg' ) ?>"/>
708-
</button>
709-
<?php endif ?>
710708
</div>
711709
<?php
712710
// render fields
@@ -796,42 +794,6 @@ class="text-input" value="<?php echo esc_html( $post[$field_key] ?? '' ) ?>" <?p
796794
<button id="<?php echo esc_html( $display_field_id ); ?>-clear-button" class="button alert clear-date-button" data-inputid="<?php echo esc_html( $display_field_id ); ?>" title="Delete Date" type="button" <?php echo esc_html( $disabled ); ?>>x</button>
797795
</div>
798796
</div>
799-
<?php elseif ( $field_type === 'location_meta' ) : ?>
800-
<?php if ( DT_Mapbox_API::get_key() && $is_empty_post ) : // test if Mapbox key is present ?>
801-
<div id="mapbox-autocomplete" class="mapbox-autocomplete input-group" data-autosubmit="false">
802-
<input id="mapbox-search" type="text" class="input-group-field" name="mapbox_search" placeholder="Search Location" autocomplete="off" dir="auto" <?php echo esc_html( $disabled ); ?>/>
803-
<div class="input-group-button">
804-
<button id="mapbox-spinner-button" class="button hollow" style="display:none;" <?php echo esc_html( $disabled ); ?>><span class="loading-spinner active"></span></button>
805-
<button id="mapbox-clear-autocomplete" class="button alert input-height delete-button-style mapbox-delete-button" style="display:none;" type="button" <?php echo esc_html( $disabled ); ?>>&times;</button>
806-
</div>
807-
<div id="mapbox-autocomplete-list" class="mapbox-autocomplete-items"></div>
808-
</div>
809-
<script>
810-
jQuery(document).ready(function(){
811-
window.write_input_widget()
812-
})
813-
</script>
814-
<?php elseif ( DT_Mapbox_API::get_key() ) : // test if Mapbox key is present ?>
815-
<div id="mapbox-wrapper"></div>
816-
<?php endif; ?>
817-
<?php elseif ( $field_type === 'location' ) :?>
818-
<div class="dt_location_grid" data-id="<?php echo esc_html( $field_key ); ?>">
819-
<var id="<?php echo esc_html( $field_key ); ?>-result-container" class="result-container"></var>
820-
<div id="<?php echo esc_html( $field_key ); ?>_t" name="form-<?php echo esc_html( $field_key ); ?>" class="scrollable-typeahead typeahead-margin-when-active">
821-
<div class="typeahead__container">
822-
<div class="typeahead__field">
823-
<span class="typeahead__query">
824-
<input class="js-typeahead-<?php echo esc_html( $display_field_id ); ?> input-height"
825-
data-field="<?php echo esc_html( $field_key ); ?>"
826-
data-field_type="location"
827-
name="<?php echo esc_html( $field_key ); ?>[query]"
828-
placeholder="<?php echo esc_html( sprintf( _x( 'Search %s', "Search 'something'", 'disciple_tools' ), $fields[$field_key]['name'] ) )?>"
829-
autocomplete="off" <?php echo esc_html( $disabled ); ?>/>
830-
</span>
831-
</div>
832-
</div>
833-
</div>
834-
</div>
835797
<?php elseif ( $field_type === 'user_select' ) : ?>
836798
<div id="<?php echo esc_html( $field_key ); ?>" class="<?php echo esc_html( $display_field_id ); ?> dt_user_select">
837799
<var id="<?php echo esc_html( $display_field_id ); ?>-result-container" class="result-container <?php echo esc_html( $display_field_id ); ?>-result-container"></var>

dt-core/utilities/dt-components.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,12 @@ public static function render_key_select( $field_key, $fields, $post, $params =
192192
public static function render_location_meta( $field_key, $fields, $post, $params = [] ) {
193193
$shared_attributes = self::shared_attributes( $field_key, $fields, $post, $params );
194194
?>
195-
<dt-location <?php echo wp_kses_post( $shared_attributes ) ?>
196-
value="<?php echo esc_html( $post[$field_key] ?? '' ) ?>">
195+
<dt-location-map <?php echo wp_kses_post( $shared_attributes ) ?>
196+
value='<?php echo esc_html( isset( $post[$field_key] ) ? json_encode( $post[$field_key] ) : '' ) ?>'
197+
mapbox-token='<?php echo esc_html( DT_Mapbox_API::get_key() ?? '' ) ?>'
198+
google-token='<?php echo esc_html( Disciple_Tools_Google_Geocode_API::get_key() ?? '' ) ?>'>
197199
<?php dt_render_icon_slot( $fields[$field_key] ) ?>
198-
</dt-location>
200+
</dt-location-map>
199201
<?php
200202
}
201203

dt-mapping/geocode-api/mapbox-api.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class DT_Mapbox_API {
2121
/**
2222
* Mapbox GL for loading in the header
2323
*/
24-
public static $mapbox_gl_js = 'https://api.mapbox.com/mapbox-gl-js/v1.1.0/mapbox-gl.js';
25-
public static $mapbox_gl_css = 'https://api.mapbox.com/mapbox-gl-js/v1.1.0/mapbox-gl.css';
26-
public static $mapbox_gl_version = '1.1.0';
24+
public static $mapbox_gl_js = 'https://api.mapbox.com/mapbox-gl-js/v2.11.0/mapbox-gl.js';
25+
public static $mapbox_gl_css = 'https://api.mapbox.com/mapbox-gl-js/v2.11.0/mapbox-gl.css';
26+
public static $mapbox_gl_version = '2.11.0';
2727

2828
/**
2929
* Mapbox Geocoder loaded in the body

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"devDependencies": {
1313
"@babel/eslint-parser": "^7.28.4",
1414
"@babel/preset-env": "^7.28.3",
15-
"@disciple.tools/web-components": "^0.8.1",
15+
"@disciple.tools/web-components": "^0.8.2",
1616
"@eslint/js": "^9.37.0",
1717
"autoprefixer": "^10.4.21",
1818
"browser-sync": "^3.0.3",

0 commit comments

Comments
 (0)