Git Product home page Git Product logo

Comments (9)

arielsalminen avatar arielsalminen commented on August 24, 2024 1

@WickyNilliams @RiqueBR The first issue I see here is that you can’t change just one value inside the localization object. You need to pass in the whole object for things to work. Please see the last example on this page: https://duetds.github.io/date-picker/

from date-picker.

RiqueBR avatar RiqueBR commented on August 24, 2024 1

Hey @viljamis @WickyNilliams, thank you so much for this! I'll send a wee update of the docs to reflect this at some point this week.

from date-picker.

WickyNilliams avatar WickyNilliams commented on August 24, 2024

Hey, would you be able to create a codepen/jsfiddle/whatever which demonstrates your issue? I'm unfamiliar with Vue, so would take me a long time to recreate (and even then, it might not match your setup!). Would make it a lot easier to help out :)

from date-picker.

RiqueBR avatar RiqueBR commented on August 24, 2024

Hi, absolutely. Here's a link for a quick repro.
https://github.com/RiqueBR/datepicker-test

Thanks for taking the time!

from date-picker.

RiqueBR avatar RiqueBR commented on August 24, 2024

That's brilliant! How about the dateAdapter? I've been trying to pass as a prop as well an object with those functions and it's not picking up. I've updated the repo.

<template>
  <div id="app">
    <h1>UoE Datepicker - duet date picker</h1>
    <duet-date-picker
      :dateAdapter="format_date()"
      :localization="localization_uk"/>
  </div>
</template>

<script>

export default {
  name: 'App',
  data() {
    return {
      localization_uk: {
        //... lots more to add here
        placeholder: 'DD/MM/YYYY'
      }
    }
  },
  methods: {
    format_date: function() {
      const DATE_REGEX = /^20[0-9]{2}-[0,1][0-9]-[0-3][0-9]$/;
      return {
        parse(value = '', createDate) {
          const validated = value.match(DATE_REGEX);
          if (validated) {
            return createDate(validated[3], validated[2], validated[1]);
          }
        },
        format(date) {
          return `${date.getDate()}/${date.getMonth() + 1}/${date.getFullYear()}`;
        }
      };
    }
  }
}
</script>

from date-picker.

RiqueBR avatar RiqueBR commented on August 24, 2024

By the way, I can submit a wee PR that would cover what we're chatting in here to the docs if that's alright. :)

from date-picker.

WickyNilliams avatar WickyNilliams commented on August 24, 2024

I think you need to explicitly tell vue to pass the objects as a property, not an attribute. Since it can't determine which to use, it defaults to attribute. If you look in dev tools you will see dateAdapter="[Object object]".

I just tested and this should work:

<duet-date-picker :dateAdapter.prop="format_date()" />
                               ^^^^

This answer on stackoverflow pointed me in the right direction: https://stackoverflow.com/questions/61385404/vuejs-cant-pass-object-to-web-component-using-v-bind

I removed the localization part since it was incomplete and causing errors, but the same is true there once you complete the object. Hope that helps :)

from date-picker.

WickyNilliams avatar WickyNilliams commented on August 24, 2024

and yes PRs welcome!

from date-picker.

RiqueBR avatar RiqueBR commented on August 24, 2024

I've just submitted a PR for what we talked here and will close this issue now. Thanks for the prompt response, appreciate it!

from date-picker.

Related Issues (20)

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.