<commit_before><?php
/**
 * Copyright (c) Qobo Ltd. (https://www.qobo.biz)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Qobo Ltd. (https://www.qobo.biz)
 * @license       https://opensource.org/licenses/mit-license.php MIT License
 */
use Cake\Core\Configure;

$api_key = Configure::read("CsvMigrations.coordinates_field.GoogleMapKey");

if (empty($api_key)) {
    $attributes += [
        'type' => $type,
        'label' => $label,
        'required' => (bool)$required,
        'value' => $value,
        'placeholder' => $placeholder,
    ];

    echo $this->Form->control($name, $attributes);

    return;
}

$this->Html->script([
        'https://maps.googleapis.com/maps/api/js?key=' . $api_key
    ],
    ['async', 'defer','block' => 'scriptBottom']
);

$this->Html->script(
    [
        'CsvMigrations.coordinatespicker',
        'CsvMigrations.coordinatespicker.editinit',
    ],
    [
        'block' => 'scriptBottom'
    ]
);

$attributes = isset($attributes) ? $attributes : [];

$randId = rand(1, 1000000);
$attributes += [
    'type' => $type,
    'label' => $label,
    'data-provide' => 'coordinates',
    'required' => (bool)$required,
    'value' => $value,
    'placeholder' => $placeholder,
    'templates' => [
        'input' => '<div class="input-group" >
                        <div class="input-group-btn">
                        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-default-'. $randId .'"><i class="fa fa-map-marker"></i></button>
                        </div>
                        <input type="{{type}}" name="{{name}}"{{attrs}}/>
                    </div>',
    ]
];

echo $this->Form->control($name, $attributes);
?>

<div class="modal fade coordinates_modal" id="modal-default-<?php echo $randId; ?>">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">GPS : <span class="modal_gps_value"><?php echo $value; ?></span></h4>
      </div>
      <div class="modal-body"></div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>
        <button type="button" class="btn btn-primary save_gps" data-dismiss="modal">Apply</button>
      </div>
    </div>
  </div>
</div>

<commit_msg>New look on coordinates field (task #14621)<commit_after><?php
/**
 * Copyright (c) Qobo Ltd. (https://www.qobo.biz)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Qobo Ltd. (https://www.qobo.biz)
 * @license       https://opensource.org/licenses/mit-license.php MIT License
 */
use Cake\Core\Configure;

$api_key = Configure::read("CsvMigrations.coordinates_field.GoogleMapKey");

if (empty($api_key)) {
    $attributes += [
        'type' => $type,
        'label' => $label,
        'required' => (bool)$required,
        'value' => $value,
        'placeholder' => $placeholder,
    ];

    echo $this->Form->control($name, $attributes);

    return;
}

$this->Html->script([
        'https://maps.googleapis.com/maps/api/js?key=' . $api_key
    ],
    ['async', 'defer','block' => 'scriptBottom']
);

$this->Html->script(
    [
        'CsvMigrations.coordinatespicker',
        'CsvMigrations.coordinatespicker.editinit',
    ],
    [
        'block' => 'scriptBottom'
    ]
);

$attributes = isset($attributes) ? $attributes : [];

$randId = rand(1, 1000000);
$attributes += [
    'type' => $type,
    'label' => $label,
    'data-provide' => 'coordinates',
    'required' => (bool)$required,
    'value' => $value,
    'placeholder' => $placeholder,
    'templates' => [
        'input' => '<div class="input-group" >
                        <input type="{{type}}" name="{{name}}"{{attrs}}/>
                        <div class="input-group-btn">
                        <button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-default-'. $randId .'"><i class="fa fa-map"></i></button>
                        </div>
                    </div>',
    ]
];

echo $this->Form->control($name, $attributes);
?>

<div class="modal fade coordinates_modal" id="modal-default-<?php echo $randId; ?>">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title"><?php echo (string)__d('Qobo/CsvMigrations', 'Coordinates'); ?> : <span class="modal_gps_value"><?php echo $value; ?></span></h4>
      </div>
      <div class="modal-body"></div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>
        <button type="button" class="btn btn-primary save_gps" data-dismiss="modal">Apply</button>
      </div>
    </div>
  </div>
</div>


{'fraction_non_alphanumeric': 0.19244436132410697, 'fraction_numerical': 0.0046755189826070695, 'mean_word_length': 2.8613718411552345, 'pattern_counts': {'":': 0, '<': 76, '<?xml version=': 0, '>': 122, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5937012', 'n_tokens_mistral': 1715, 'n_tokens_neox': 1667, 'n_words': 335}