Skip to content

Upgrade Atk UI develop, future version 4.0 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

abbadon1334
Copy link

@mvorisek I think the best option is to release the actual dev as a 2.3 version and use this as the new develop
@ibelar
I need to change this line :
https://github.com/abbadon1334/atk4-google-address/blob/de791a14313a72618eb29080159f640e472cf780/src/Form/Control/AddressLookup.php#L108

I get a javascript error atkAddressLookup is not defined function changing the init in that file to AddressLookup it works as excepted. Am i missing something or is the right change to do?

i changed even the version to be recovered from cdn.jsdelivr.net to 4.0.0, the file needs to be uploaded?

@ibelar
Copy link
Collaborator

ibelar commented Oct 20, 2022

@abbadon1334 - Before recent Js changes, registering a plugin automatically append the 'atk' prefix to the plugin name. I think this is not the case anymore therefore your changes should work correctly.

@@ -17,7 +17,7 @@ class JsLoader
public static $cdn = 'https://cdn.jsdelivr.net/gh/atk4/google-address';

/** @var string Javascript file version. */
public static $version = '2.2.2';
public static $version = '4.0.0';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it, no CDN, JS files are versioned together with atk4/ui files

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove CDN and set the actual as default fallback: /public/atk-google-maps.min.js but that path is unusable in a real env, so I change it /assets/atk-google-maps.min.js

@@ -16,19 +16,19 @@
class AddressLookup extends Line
{
/** @var array An array of Google address_components to fill specific controls with. */
public $controlMap = [];
public array $controlMap = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either remove @var array phpdoc or revert

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add typed array in PHPDoc, I think is better

@@ -106,7 +105,7 @@ public function renderView(): void
{
JsLoader::load($this->getApp());

$this->js(true)->atkAddressLookup($this->getLookupSettings());
$this->js(true)->AddressLookup($this->getLookupSettings());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does the AddressLookup JS comes from? In atk4/ui AFAK there is no such plugin

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here in the repo, there is the js source

@@ -10,14 +10,16 @@
* address lookup plugin concatenating each property using the specified
* glue in order to set input value.
*/
class Build
final class Build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why final?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the internal call to static gives a stan error, and this class is not intended to be reused so i think is the easy way to avoid it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even this has the same stan error and the same future use as Build class : https://github.com/abbadon1334/atk4-google-address/blob/cb472c3c3197e26ce0a724771ed51bcb25183c06/src/Utils/Value.php#L7

final is the best option, those classes are intended for internal usage strictly related to GoogleAPI

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer non final, final is sometimes very hard to overcome to workaround some problems on user side.

if: matrix.type == 'StaticAnalysis'
run: |
echo "memory_limit = 2G" > /usr/local/etc/php/conf.d/custom-memory-limit.ini
vendor/bin/phpstan analyse
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix EOL

image

@@ -1,6 +1,6 @@
{
"name": "atk-google-address",
"version": "2.2.0",
"version": "4.0.0",
Copy link
Member

@mvorisek mvorisek Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be 1.0.0 as in https://github.com/atk4/ui/blob/fadc7680ed16ce15267968524bbc3217c8ea323b/js/package.json#L3

JS is versioned using composer (and git)

@@ -15,20 +15,20 @@
*/
class AddressLookup extends Line
{
/** @var array An array of Google address_components to fill specific controls with. */
public $controlMap = [];
/** @var list<array{name:string,value:Build}> An array of Google address_components to fill specific controls with. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** @var list<array{name:string,value:Build}> An array of Google address_components to fill specific controls with. */
/** @var list<array{name:string, value:Build}> An array of Google address_components to fill specific controls with. */


if (!self::$apiKey) {
if (self::$apiKey === '') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we define prop like protected static string $apiKey;, ex. is not needed with typed property :)

/** @var bool */
private static $isLoaded = false;
/** Default location of js file, use this if $locationUrl is not specified in JsLoader::load($app, '/new/path/to/js-file.min.js'); */
protected static string $defaultLocationUrl = '/assets/atk-google-maps.min.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/** @var string Google maps version. */
protected static $apiVerstion = 'quarterly';
/** Google maps version. */
protected static string $apiVerstion = 'quarterly';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apiVerstion typo


public static function setGoogleApiKey(string $key): void
{
self::$apiKey = $key;
}

/**
* @param array<string, int|string|string[]|mixed> $options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param array<string, int|string|string[]|mixed> $options
* @param array<string, mixed> $options

mixed is always what phpstan reads in both cases :)


/** @var string Google Map property to use. (long_name or short_name) */
private $property;
/** Google Map property to use. (long_name or short_name) */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shortName or is it some G API name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants