Coder Social home page Coder Social logo

techouse / intl-date-time Goto Github PK

View Code? Open in Web Editor NEW
57.0 5.0 21.0 7.24 MB

International DateTime for Laravel Nova

License: MIT License

JavaScript 27.16% Vue 37.73% PHP 26.30% Python 8.36% SCSS 0.44%
laravel-nova laravel php vue datepicker datetimepicker date

intl-date-time's Introduction

International DateTime

Latest Version on Packagist Total Downloads Licence PHP version Codacy Badge GitHub stars

International datepicker for Laravel Nova

Apply localisation in 71 different locales to Laravel Nova's default DateTime field that currently doesn't support localisation out of the box.

International DateTime

Installation

You can install the package in to a Laravel app that uses Nova via composer:

composer require techouse/intl-date-time

Usage

The API is adapted from Nova's default DateTime Field.

The module itself offers a few optional configurations:

  • locale - OPTIONAL - Set the module's locale. If you do not it will automatically use your app's config('app.locale'). If you manually define an unsupported locale it will throw an Exception!
  • dateFormat - OPTIONAL - Set a date format. If you do not provide it the module will automatically use the appropriate locale's date format. The format must be MomentJS compatible!
  • timeFormat - OPTIONAL - Set a time format. The format must be MomentJS compatible! If you manually define an unsupported time format it will throw an Exception!
  • minDate - OPTIONAL - Set a minimum/earliest date (inclusively) allowed for selection. Has to be an instance of \DateTime or Carbon\Carbon. Defaults to null.
  • maxDate - OPTIONAL - Set a maximum/latest date (inclusively) allowed for selection. Has to be an instance of \DateTime or Carbon\Carbon. Defaults to null.
  • placeholder - OPTIONAL - Set a placeholder. If you do not want a placeholder set it to false.
  • errorMessage - OPTIONAL - Set a custom error message in case of an invalid date format. If you do not set it it will display an error message in the current locale.
  • errorMessageLocale - OPTIONAL - Set a custom error message locale. If not set it equals the set locale or your app's config('app.locale'). If you manually define an unsupported locale it will throw an Exception! Here is the list of all supported locales.
  • hideUserTimeZone - OPTIONAL - When applied hides the user time zone next to the form field. Default is false.
  • withShortcutButtons - OPTIONAL - When applied shows the user 3 shortcut buttons for 'yesterday, 'today' and 'tomorrow' below the calendar. The buttons are all in English and in order to translate them please edit your language JSON file in the directory resources/lang/vendor/nova.
  • withTime - OPTIONAL - Shortcut for displaying the full locale time, e.g. HH:mm:ss. NOTE: The timeFormat option has precedence over withTime.
  • withTimeShort - OPTIONAL - Shortcut for displaying the short locale time, e.g. HH:mm. NOTE: The timeFormat option has precedence over withTimeShort.
  • userTimeZone - OPTIONAL - Define custom Timezone for specific field - by default Nova.config.userTimezone is used.

Simply use IntlDateTime class instead of DateTime directly or alias it like the example below so you won't have to refactor too much existing code.

<?php

namespace App\Nova;

use Carbon\Carbon;
use Illuminate\Http\Request;
use Techouse\IntlDateTime\IntlDateTime as DateTime;

class User extends Resource
{
    /**
     *  This is how you use and configure this module
     */
    public function fields(Request $request)
    {
        return [
            DateTime::make(__('Updated at'), 'updated_at')
                    /**
                     * The module automatically uses your app's locale 
                     * from config('app.locale'), however you can manually
                     * override this by setting it like this.
                     * 
                     * IMPORTANT: Check the list of supported locales below in this readme!
                     * 
                     * NOTE: If the automatic locale is not supported by MomentJS 
                     * the module defaults to 'en-gb' (British English).
                     */
                    ->locale('sl'),
                    
            DateTime::make(__('Created at'), 'created_at')
                    /**
                      * You can optionally set a custom DATE format.
                      * 
                      * It has to be compatible with MomentJS!!!
                      * https://momentjs.com/docs/#/displaying/format/
                      */
                    ->dateFormat('DD.MM.YYYY'),   
                    
            DateTime::make(__('Deleted at'), 'deleted_at')
                    /**
                      * You can optionally set a custom TIME format
                      * 
                      * It has to be compatible with MomentJS!!!
                      * https://momentjs.com/docs/#/displaying/format/
                      */
                    ->timeFormat('HH:mm:ss'),
                    
            DateTime::make(__('Packaged on'), 'packaged_on')
                    /**
                      * You can optionally set a placeholder, otherwise
                      * it will default to your timezone's date format 
                      */
                    ->placeholder('DD.MM.LLLL'),
                    
            DateTime::make(__('Shipped on'), 'shipped_on')
                    /**
                      * You can disable the placeholder by setting it to false
                      */
                    ->placeholder(false),
                    
            DateTime::make(__('Birthday'), 'birthday')
                    /**
                      * You can override the default date invalid error message
                      */
                    ->errorMessage("I don't think you were born on that day mate :D"),
                    
            DateTime::make(__('Day of graduation'), 'graduated_on')
                    /**
                      * Unless you override the error message locale it equals the locale setting
                      */
                    ->errorMessageLocale('de'),
                    
            DateTime::make(__('Takes place at'), 'takes_place_at')
                    /**
                     * Set a minimum/earliest date (inclusively) allowed for selection.
                     */
                    ->minDate(Carbon::parse('1990-05-30'))
                    /**
                     * Set a maximum/latest date (inclusively) allowed for selection.
                     */
                    ->maxDate(Carbon::today()),
            
            DateTime::make(__('Day you got married'), 'day_you_got_married')
                    /**
                     * Hide the user time zone next to the form input field.
                     */
                    ->hideUserTimeZone(),

            DateTime::make(__('Date of travel'), 'date_of_travel')
                    /**
                     * Display shortcut buttons for "yesterday", "today" and "tomorrow".
                     * Translate them in your language's JSON file located in resources/lang/vendor/nova.
                     */
                    ->withShortcutButtons(),

            DateTime::make(__('Time of arrival'), 'time_of_arrival')
                    /**
                     * Shortcut for displaying the full locale time, e.g. HH:mm:ss.
                     * 
                     * NOTE: The timeFormat option has precedence over withTime.
                     */
                    ->withTime(),

            DateTime::make(__('Time of reservation'), 'time_of_reservation')
                    /**
                     * Shortcut for displaying the short locale time, e.g. HH:mm.
                     * 
                     * NOTE: The timeFormat option has precedence over withTimeShort.
                     */
                    ->withTimeShort(),

            DateTime::make(__('Time of reservation'), 'deleted_at')
                    /**
                     * Set default hour of time selector
                     */
                    ->defaultHour(9),

            DateTime::make(__('Time of reservation'), 'uploaded_at')
                    /**
                     * Set default minute of time selector
                     */
                    ->defaultMinute(30),
        ];
    }

    /**
     * The rest of the Resource ... bla bla bla :)
     */
}

Programmed filling

Like many Laravel Nova Fields, this field implement the programmed filling. You can emit a Laravel Nova javascript event in order to fill the field in the update form.

Nova.$emit('my-field-name-value', '29/06/1998')

Please make sure that the value emitted correspond to your local date.

List of supported locales

This module supports only locales that are SUPPORTED BY BOTH MomentJS AND Flatpickr!

The 71 locales that are currently supported are:

Language locale
Albanian sq
Arabic ar
Azerbaijani az
Bangla bn
Belarusian be
Bosnian bs
Bulgarian bg
Burmese my
Catalan ca
Chinese (China) zh-cn
Chinese (Hong Kong) zh-hk
Chinese (Taiwan) zh-tw
Croatian hr
Czech cs
Danish da
Dutch nl
English en
English (Australia) en-au
English (Canada) en-ca
English (Ireland) en-ie
English (New Zealand) en-nz
English (United Kingdom) en-gb
Esperanto eo
Estonian et
Faroese fo
Finnish fi
French fr
French (Canada) fr-ca
French (Switzerland) fr-ch
Georgian ka
German de
German (Austria) de-at
German (Switzerland) de-ch
Greek el
Hebrew he
Hindi hi
Hungarian hu
Indonesian id
Icelandic is
Irish Gaelic ga
Italian it
Japanese ja
Kazakh kk
Khmer km
Korean ko
Latvian lv
Lithuanian lt
Macedonian mk
Malaysian ms
Mongolian mn
Norwegian nb
Persian fa
Polish pl
Portuguese pt
Portuguese (Brazil) pt-br
Punjabi pa-in
Romanian ro
Russian ru
Serbian sr
Serbian (Cyrillic) sr-cyrl
Sinhala si
Slovak sk
Slovenian sl
Spanish es
Spanish (Dominican Republic) es-do
Spanish (United States) es-us
Swedish sv
Thai th
Turkish tr
Ukrainian uk
Vietnamese vi
Welsh cy
NOTE

This an evolution of my original Slovenian DateTime

intl-date-time's People

Contributors

alexrififi avatar danielztolnai avatar dependabot[bot] avatar eavio avatar gautierdele avatar henryavila avatar jon78 avatar kyryl-bogach avatar nibri10 avatar simonestefani avatar techouse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

intl-date-time's Issues

Help text not working

When using the following field:

IntlDateTime::make(__('Label'), 'field_name')
                ->hideUserTimeZone()
                ->help(__('Some help text'))
                ->withTimeShort()
                ->minDate(now()->addDay())
                ->rules('required', 'date'),

The help text is not shown in the form.

In Vue Dev Tools I can see that the IntlDateTimePicker component has the property showHelpText set to true, but it seems this property is not (properly) passed to the default-field of Nova.

Please allow devs to add custom placeholders, or none placeholder

Hello.

Please allow devs to add custom placeholders, or none placeholder. See my issue:

Here on Brazil we say format as (DD/MM/AAAA) not (DD/MM/YYYY)... obviously when coding, will use the right compatible pattern DD/MM/YYYY but when show it to users in frontend, need to inform DD/MM/AAAA so they will understand. But the field not allow custom placeholder and add the mask as it...

So i add a ->help('DD/MM/AAAA') to give a tip to users, but tis is weird... because it renders both patterns:

IntlDateTime::make('Nascimento', 'nascimento')
            ->dateFormat('DD/MM/YYYY')
            ->help('DD/MM/AAAA')

See image below:
intl2

Global Settings

Would it be possible to have a configuration file that you can publish via
php artisan vendor:publish

which you will be able to configure all the defaults so you don't have to apply settings to each instance of the plugin

Translatable timezones

It would be nice to be able to change the way timezones are displayed, by providing translations.

-<span v-if="field.displayUserTimeZone" class="text-80 text-sm ml-2">({{ userTimezone }})</span>
+<span v-if="field.displayUserTimeZone" class="text-80 text-sm ml-2">({{ __(userTimezone) }})</span>

Then we would be able to, for example, present the user with (UK time) instead of (Europe/London), by putting:

"Europe/London": "UK time"

into resources/lang/vendor/nova/en.json.

I'm not sure whether __ is available as Vue helper out of the box, if not, it can be easily implemented like so:

let __ = function (original) {
    let translated = window.config.translations[original];
    if (translated !== undefined) return translated;
    return original;
}

Fail when upgrade to Nova 3.0: intl-date-time does not have support to nova 3.0/laravel 7

Hello.

Try to update to laravel nova 3.0 and Laravel 7.0 but it breakes on intl-date-time... See message:

techouse/intl-date-time v1.5.0 requires illuminate/support ^5.6 || ^6.0 -> satisfiable by laravel/framework[v6.17.1, 5.8.x-dev], illuminate/support[5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, 6.x-dev, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9, v6.0.0, v6.0.1, v6.0.2, v6.0.3, v6.0.4, v6.1.0, v6.10.0, v6.11.0, v6.12.0, v6.13.0, v6.13.1, v6.14.0, v6.15.0, v6.15.1, v6.16.0, v6.17.0, v6.17.1, v6.18.0, v6.2.0, v6.3.0, v6.4.1, v6.5.0, v6.5.1, v6.5.2, v6.6.0, v6.6.1, v6.6.2, v6.7.0, v6.8.0].

Maybe you already know about that now, but if dont't, just telling you about this compatibility issue

Can't display Just thetime

HI. If I use:

IntlDateTime::make('Hora', 'time')
                    ->hideUserTimeZone()
                    ->withTimeShort()

Or even:

IntlDateTime::make('Hora', 'time')
                    ->timeFormat('HH:mm:ss')
                    ->withTimeShort()

It always select a date and the time.
It should allow to select just the time.

Adding new french translation

Hello !

I noticed that the 'fr' translation is not quite complete. Where can I add the missing translations?

Hello from Belgium!

Closing Modal when selecting next Month since Nova 3.30

I'm using the component in a Nova-Action that shows as a modal. The date picker get's triggered all right but when I select the right arrow for next month the action modal closes (the picker stays). This used to work and seems to be introduced by Nova 3.30 which states in it's changelog:

Fixed issue with clicking away from a modal when using an iPad.

But I'm not so sure about that. It used to work with Nova 3.29 just fine. Switching to the original date field Nova brings along, also works :-(

Date not showing and saving properly

Hello,
I have an issue in my project. My date is not showing and saving properly. Also when I check date it shows error The Booking Closing Date must be in the format dd/MM/yyyy. It also saving wrong data. For example if my date is 20-04-2020 then it saves 31-09-2031. I do't know where the problem exists.
Here is my Code
DateTime::make('Booking Closing Date', 'booking_closing_at') ->rules('required') ->dateFormat('DD-MM-YYYY') ->placeholder('DD-MM-YYYY'),

Using a psr-4 different from App

I'm using another psr-4 for my Laravel App with Nova and intl-date-time is not working properly. See IntlDateTimeController.php code:

<?php

namespace Techouse\IntlDateTime;

**use App\Http\Controllers\Controller;**
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Support\Facades\File;
use Laravel\Nova\Http\Requests\NovaRequest;

class IntlDateTimeController extends Controller
{


As App\Http\Controllers\Controller is used I've got the following error:

[2019-11-06 23:00:35] local.ERROR: Class 'App\Http\Controllers\Controller' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 1): Class 'App\\Http\\Controllers\\Controller' not found at /home/newton/git/laravel/nova/galileo/vendor/techouse/intl-date-time/src/IntlDateTimeController.php:10)
[stacktrace]
#0 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(148): Symfony\\Component\\Debug\\Exception\\FatalErrorException->__construct()
#1 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(134): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->fatalExceptionFromError()
#2 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(0): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleShutdown()
#3 /home/newton/git/laravel/nova/galileo/vendor/composer/ClassLoader.php(444): ()
#4 /home/newton/git/laravel/nova/galileo/vendor/composer/ClassLoader.php(322): Composer\\Autoload\\includeFile()
#5 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Container/Container.php(788): Composer\\Autoload\\ClassLoader->loadClass()
#6 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Container/Container.php(788): spl_autoload_call()
#7 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Container/Container.php(788): ReflectionClass->__construct()
#8 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Container/Container.php(667): Illuminate\\Foundation\\Application->build()
#9 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Container/Container.php(615): Illuminate\\Foundation\\Application->resolve()
#10 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(767): Illuminate\\Foundation\\Application->make()
#11 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Route.php(233): Illuminate\\Foundation\\Application->make()
#12 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Route.php(833): Illuminate\\Routing\\Route->getController()
#13 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Route.php(794): Illuminate\\Routing\\Route->controllerMiddleware()
#14 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(693): Illuminate\\Routing\\Route->gatherMiddleware()
#15 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(673): Illuminate\\Routing\\Router->gatherRouteMiddleware()
#16 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(657): Illuminate\\Routing\\Router->runRouteWithinStack()
#17 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\\Routing\\Router->runRoute()
#18 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\\Routing\\Router->dispatchToRoute()
#19 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch()
#20 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Galileo\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:173-177}()
#21 /home/newton/git/laravel/nova/galileo/nova/src/Http/Middleware/ServeNova.php(26): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:28-36}()
#22 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Laravel\\Nova\\Http\\Middleware\\ServeNova->handle()
#23 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:140-169}()
#24 /home/newton/git/laravel/nova/galileo/app/Http/Middleware/Gll/NovaLocaleMiddleware.php(20): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:47-59}()
#25 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Galileo\\Http\\Middleware\\Gll\\NovaLocaleMiddleware->handle()
#26 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:140-169}()
#27 /home/newton/git/laravel/nova/galileo/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:47-59}()
#28 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Galileo\\Http\\Middleware\\TrustProxies->handle()
#29 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:140-169}()
#30 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:47-59}()
#31 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#32 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:140-169}()
#33 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:47-59}()
#34 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Galileo\\Http\\Middleware\\TrimStrings->handle()
#35 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:140-169}()
#36 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:47-59}()
#37 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#38 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:140-169}()
#39 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:47-59}()
#40 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Galileo\\Http\\Middleware\\CheckForMaintenanceMode->handle()
#41 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:140-169}()
#42 /home/newton/git/laravel/nova/galileo/vendor/hyn/multi-tenant/src/Middleware/EagerIdentification.php(29): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:47-59}()
#43 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Hyn\\Tenancy\\Middleware\\EagerIdentification->handle()
#44 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:140-169}()
#45 /home/newton/git/laravel/nova/galileo/vendor/hyn/multi-tenant/src/Middleware/HostnameActions.php(75): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:47-59}()
#46 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Hyn\\Tenancy\\Middleware\\HostnameActions->handle()
#47 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:140-169}()
#48 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure:/home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:47-59}()
#49 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Routing\\Pipeline->then()
#50 /home/newton/git/laravel/nova/galileo/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Galileo\\Http\\Kernel->sendRequestThroughRouter()
#51 /home/newton/git/laravel/nova/galileo/public/index.php(55): Galileo\\Http\\Kernel->handle()
#52 /home/newton/.composer/vendor/cpriego/valet-linux/server.php(204): ()
#53 /home/newton/.composer/vendor/cpriego/valet-linux/server.php(0): {main}()
#54 {main}
"} 


Error during installation

Hi!
I have to put all my dates on FR format.
I try to install intl-date-time, but:

PS D:_CLIENTS\Kidilist\www> composer require techouse/intl-date-time
Using version ^1.6 for techouse/intl-date-time
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals

  • Installing techouse/intl-date-time (v1.6.2): Downloading (100%)
    Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
    Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead.
    Writing lock file
    Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover --ansi

ErrorException

rename(D:_CLIENTS\Kidilist\www\bootstrap\cache\pac838A.tmp,D:_CLIENTS\Kidilist\www\bootstrap\cache\packages.php): Accès refusé. (code: 5)

at D:_CLIENTS\Kidilist\www\vendor\laravel\framework\src\Illuminate\Filesystem\Filesystem.php:209
205▕ chmod($tempPath, 0777 - umask());
206▕
207▕ file_put_contents($tempPath, $content);
208▕
➜ 209▕ rename($tempPath, $path);
210▕ }
211▕
212▕ /**
213▕ * Prepend to a file.

1 D:_CLIENTS\Kidilist\www\vendor\laravel\framework\src\Illuminate\Filesystem\Filesystem.php:209
rename("D:_CLIENTS\Kidilist\www\bootstrap\cache\pac838A.tmp", "D:_CLIENTS\Kidilist\www\bootstrap\cache\packages.php")

2 D:_CLIENTS\Kidilist\www\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php:181
Illuminate\Filesystem\Filesystem::replace("D:_CLIENTS\Kidilist\www\bootstrap\cache\packages.php", "<?php return array (
'coderello/laravel-nova-lang' =>
array (
'providers' =>
array (
0 => 'Coderello\LaravelNovaLang\Providers\LaravelNovaLangServiceProvider',
),
),
'facade/ignition' =>
array (
'providers' =>
array (
0 => 'Facade\Ignition\IgnitionServiceProvider',
),
'aliases' =>
array (
'Flare' => 'Facade\Ignition\Facades\Flare',
),
),
'fideloper/proxy' =>
array (
'providers' =>
array (
0 => 'Fideloper\Proxy\TrustedProxyServiceProvider',
),
),
'fruitcake/laravel-cors' =>
array (
'providers' =>
array (
0 => 'Fruitcake\Cors\CorsServiceProvider',
),
),
'laravel/nova' =>
array (
'providers' =>
array (
0 => 'Laravel\Nova\NovaCoreServiceProvider',
),
'aliases' =>
array (
'Nova' => 'Laravel\Nova\Nova',
),
),
'laravel/tinker' =>
array (
'providers' =>
array (
0 => 'Laravel\Tinker\TinkerServiceProvider',
),
),
'laravel/ui' =>
array (
'providers' =>
array (
0 => 'Laravel\Ui\UiServiceProvider',
),
),
'nesbot/carbon' =>
array (
'providers' =>
array (
0 => 'Carbon\Laravel\ServiceProvider',
),
),
'nunomaduro/collision' =>
array (
'providers' =>
array (
0 => 'NunoMaduro\Collision\Adapters\Laravel\CollisionServiceProvider',
),
),
'techouse/intl-date-time' =>
array (
'providers' =>
array (
0 => 'Techouse\IntlDateTime\FieldServiceProvider',
),
),
'therobfonz/laravel-mandrill-driver' =>
array (
'providers' =>
array (
0 => 'LaravelMandrill\MandrillServiceProvider',
),
),
);")
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Installation failed, reverting ./composer.json to its original content.

Any ideas ?

Thanks a lot!

Programmed filling

There is an issue with the programmed filling.

When you set the "localized value" you need to click on the field to actualize the correct value when you are not using the normal value "Y-m-d". We are using "d/m/Y".

@techouse do you have any idea how to force the logic that is hapenning when clicking the component ?

I'm guessing that this logic is run on the mounted event in IntlDateTimePicker.vue

Incorrect date when using without time

Hi!
Thank for your package!

background info

My local timezone is UTC+05

config/app.php

return [
    ...
    'timezone' => 'UTC',
    'locale' => 'ru',
    ...
];

In model I have field birthdate (type date without time).

Nova resource

use Techouse\IntlDateTime\IntlDateTime;

IntlDateTime::make( 'Дата рождения', 'birthdate' )
    ->hideUserTimeZone()
    ->firstDayOfWeek( 1 ),

The problem

Date (field birthdate) is not saved correctly. It is equal to the previous day.

This is what the Vue Devtool shows when choosing a date, for example 16.01.1994

Screenshot

This is related to #15

timeFormat mandatory

Hi, I use this Nova package with timestamp field in the database.
In the readme file, you explain "timeFormat - OPTIONAL - Set a time format. If you do not provide it the module will automatically use HH:mm:ss.", but isn't true.
Because if I've a datetime field in the database, and not set the timeFormat, the time not showing at all.
If I set timeFormat, it's all right.
DateTime::make('expires_at') ->minDate(Carbon::today()) ->timeFormat('HH:mm:ss')

Thanks

Feature Request: Add Mask to input.

Hi. Great file.

Please add maskinput feature to be used with localization/format.

Example: If define a pt localization, uses the slash(/) as mask element... if use DD/MM/YYYY format, uses the slash too... if uses time, uses : too... point, dash, etc... of couse, depending on the display formatting.

Feature request: programmatically set the field

Hello there,

It could be a great feature to add the programmatic setting.
In laravel nova when you emit this event:
Nova.$emit('my-field-value', '20-06-1998')
The field is automatically being set. Would it be possible to implement such a feature ?

Thanks,
Gautier

Ability to add firstDayOfWeek function

On the Nova DateTime field there is an ability to change the first day of the week on the calendar.

Is it possible to introduce this functionality to IntlDateTime?

Customizing The First Day of the Week

By default, Nova's Date and DateTime fields recognize Sunday as the first day of the week (as the >United States, Canada, and Japan do). If you wish to customize this to follow the international >standard ISO 8601, you can set the firstDayOfWeek option on the field:

Date::make('Birthday')->firstDayOfWeek(1);
DateTime::make('Created At')->firstDayOfWeek(1);

Implement different Dateformat

in my project, I want it to show in the format as "MM/DD/YYYY" in US
I've tried

->format('MM-DD-YYYY)
->format('MM/DD/YYYY)
->dateFormat('MM-DD-YYYY')
->dateFormat('MM/DD/YYYY')

none of them is working

->dateFormat('MM/DD/YYYY') seems to work but gives an error message: The Expires must be in the format dd/MM/yyyy

Screen Shot 2021-01-19 at 1 46 28 PM

also when I try to use it with ->minDate(Carbon::now()), it gives the totally wrong date to start with

Screen Shot 2021-01-19 at 1 48 08 PM

Set initial year value

I make a museum site, and many exhibits date back to an average 1990 year. Every time flipping the date from 2019 to 1990 is not convenient.
Is it possible to set the initial year? (but not withMeta -> value).

Wrong date

Hi, great job
but if i select a date from datepicker when save resource the saved date it's a day before the selected day.
The locale it's 'it'

Possibility to define userTimezone for specific field

Thank you for the great package.

We how ever found one exception in our use case, where we would need to set different Timezone for one specific field.

Although our global Nova.config.userTimezone is set to "sl" we have one specific field where user needs to enter time in UTC.

Inspecting index.vue we found out that it is imposible to set userTimezone for specific field only:

userTimezone: () => Nova.config.userTimezone || moment.tz.guess(),

What we suggest is to change userTimezone to:

userTimezone()
            {
                if (this.field.userTimeZone) {
                    return this.field.userTimeZone
                }

                return Nova.config.userTimezone || moment.tz.guess();
            },

Then we can use "withMeta" on specific field:
DateTime::make('Date to', 'date_to')->withTimeShort()->locale(config('app.date_locale'))->timeFormat('HH:mm')->withMeta(['userTimeZone' => 'UTC']),

We also noticed that "timezone" is sometimes written as "timeZone" and sometimes as "timezone" maybe it would be good idea to unify that.

Field not showing

Hi, I ran into a problem after updating to 1.6.1.
After the update, the following scripts and styles stopped loading,

vendorsdetail-intl-date-timeform-intl-date-timeindex-intl-date-time.js | 404 |
vendors
form-intl-date-time.js | 404 |
form-intl-date-time.css | 404 |
form-intl-date-time.js | 404 |,

could you help?

Show time without need to format it

If I use the code (locale: pt-br): IntlDateTime::make('Data', 'created_at') I will get a Date Field (no time is displayed).

If I use the TimeFormat function: IntlDateTime::make('Data', 'created_at')->timeFormat('HH:mm:ss') the time is displayed but I don't have a way to display the time without defining it format.

I would be perfect if I can enable to show the time and the app get the current locale to format the time.

Invalid date in index view when field value is null

Hi.

When a Datetime field has null value in the index view it's displayed as 'Invalid date'.
In detail view it works and show '—'.

I think v-if/else is missing in resources/js/components/Index/DateTimeField.vue.

From:

<template>
    <span class="whitespace-no-wrap">{{ localizedDateTime }}</span>
</template>

To:

<template>
    <span v-if="field.value" class="whitespace-no-wrap">{{ localizedDateTime }}</span>
    <span v-else>&mdash;</span>
</template>
  • laravel/framework v5.7.27
  • laravel/nova v1.3.2
  • techouse/intl-date-time v1.0.4

Today-button

Not something that's necessarily relevant to this package, but my users are asking for a "today"-button, ie a button that selects the current time and date. This is something they were used to in the old jQuery-datepicker UI: https://jqueryui.com/datepicker/ Would be a nice enhancement.

Please add client side validation

As you told me in this issue: #5 i am opening this to request a feature to client side validation in a specific case... See the image below:

intl

User add only 05 and Field assumes current year and month and make a validad date from 2019-05-05 00:00:00.

Many times, when putting far away dates (as my birth date lol)... is boring to use visual date component to get back until 1973 or older dates and i's better manually type the date. If user add a invalid value like 05/0 it will result in a invalid date, fine in this case... but if user add a part of date like only 5 will be accepted as a valid date but in my opinion is not valid.

Add a way to clear a date

There is currently no way to clear a date once you set it. This is also a confirmed bug with the DateTime-field in Nova. One of the suggested solutions is to add a button to clear a date. A fix would come in handy (and gives people more reason to install this package over Nova's).

Please make submit action obey date/time format to be a validd date

Please make submit action obey date/time format to be a validd date

Example: User do not fill entire date format, just inform a part of date... but InlDateTime field accepts as dai **** from current month. If i'm forcing a format is because i want this pattern to be filled.

IntlDateTime::make('Birthdate', 'birthdate')
            ->rules('required', 'date')
            ->dateFormat('DD/MM/YYYY')
            ->hideFromIndex(),

intl

Other stuff: Make component accept only date, if i'm using a format DD/MM/YYYY or something like that don't need to complement it with 00:00:00

Timezones messing up

Hi,

I am wondering about the following issue (sitting in TZ Europe/Berlin):

  1. The NovaController sends the datetime string as it's saved in my database, which doesn't handle timezones (e.g. 2020-01-01 09:00:00 in the DB will be persisted exactly like this).

  2. My Nova resource index, detail and edit view will show 2020-01-01 09:00:00 (respectively 01.01.2020 09:00 likewise.

  3. Now I am saving my resource without opening the datepicker for changes. XHR sends 2020-01-01 09:00:00.

  4. NovaResourceController will take it and save it as it is. Db content shows 2020-01-01 09:00:00. XHR sends it likewise.

  5. Now I open the edit view again (still showing 01.01.2020 09:00) and click the DatePicker, regardless if a change was made. The date in my input field still shows 01.01.2020 09:00.

  6. Again, saving my resource. XHR now sends the time back to the server in UTC 2020-01-01 08:00:00 where it gets saved in that way.

Anyone having a hint how to approach this problem?

I am using the flatpickr in a standalone-version in another project, where the submission is correct.
Which option am I forgetting to use?

Thanks for your help!

96 validation_locale files importing... It's normal ?

Version: ^1.2.3

After recent updates, it's imports almost 100 files for validation locales files (validation_locales_01 to validation_locales_96)... it's importing individual files because i'm in development mode ? When generate a production build will generate only one import file ?

It's a lot of files...

User Timezone

Thank you for this great package!

I noticed a missing feature that original datetime field has.

This package doesn't handle time zone.

        Nova::userTimezone(function () {
            return 'Europe/Istanbul';
        });

Use just the date

Hi. Is possible to use just for date, and don't show the time (in view and picker)? use with a Date DB column?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.