apptreesoftware / pikaday-dart

package:js bindings for Pikaday by David Bushnell.
BSD 3-Clause "New" or "Revised" License
3 stars 3 forks source link

initial start date visible in dart-form (Dartium) but not after compilation to js #2

Closed simon-void closed 6 years ago

simon-void commented 7 years ago

1) i added to arguments (setDefaultDate and defaultDate) to the default configuration of your example Pikaday-usage

  new Pikaday(new PikadayOptions(
    field: document.getElementById('datepicker'),
    firstDay: 1,
    minDate: new DateTime(2010,  1,  1),
    maxDate: new DateTime(2020, 12, 31),
    yearRange: [2000, 2020],
    showTime: false,
    setDefaultDate: true,
    defaultDate: new DateTime(2015, 1, 1),
  ));

As expected this shows the datepicker with an initially selected date of 1.1.2015. At least it does its dart-version in Dartium. When compiled to js, the datepicker stays empty until a new value is selected manually (tested in Firefox and Chromium).

2) another problem when compiling to js, seems to be the paths to the pikaday resources. You link them as

    <link rel="stylesheet" href="/packages/pikaday/pikaday.css">
    <script defer src="/packages/pikaday/pikaday.js"></script>
    <script defer src="/packages/pikaday/pikaday_dart_helpers.js"></script>

but this interpretes the paths as absolute which is not what you want. Adding a '.' in the beginning seems to do the trick though:

    <link rel="stylesheet" href="./packages/pikaday/pikaday.css">
    <script defer src="./packages/pikaday/pikaday.js"></script>
    <script defer src="./packages/pikaday/pikaday_dart_helpers.js"></script>
simon-void commented 7 years ago

Your lib/date.dart file triggers a warning from my linter for @JS('Date')

_The @JS() annotation can only be used if it is also declared on the library directive. (missing_js_libannotation)

Currently date.dart doesn't even have a library directive! Maybe that's an issue? Update: adding an annotated library directive here doesn't seem to change anything. But maybe it's still worth investigating?

simon-void commented 7 years ago

i forked my own version of pikaday-dart and commit a workaround adding three helper methods that allow me to (mostly) circumvent the inability to handle DateTime objects by adding three new helper methods:

You can checkout my branch here. Not sure how to apply my commit to your branch (or remerging my fork). Never done this before, but there should be a way. Given you like my changes.

johnpryan commented 6 years ago

@simon-void went ahead and made PR from your branch to master

thanks for the contribution! (and sorry for the slow response)