Git Product home page Git Product logo

Comments (7)

keegan-lillo avatar keegan-lillo commented on July 17, 2024

How would you go about setting appKeys? How does the current implementation work as far as serializing the data?

from clay.

valorin avatar valorin commented on July 17, 2024

My current implementation doesn't actually serialise any data back to the Pebble - it sends it to my server via an ajax post request, but that's not really the point. I should probably open another issue for that though - since it's a very common use case if you're working on a timeline enabled app. :-)

The way I currently handle it is by using html arrays. Consider these basic form elements:

<!-- block one -->
<input type="text" name="name[1]" value="nameValue1">
<input type="text" name="description[1]" value="descValue1">

<!-- block two -->
<input type="text" name="name[2]" value="nameValue2">
<input type="text" name="description[2]" value="descValue2">

The data would be received with an array for each of name and description:

name: ["nameValue1", "nameValue2"],
description: ["descValue1", "descValue2"]

I don't really know how this would apply to appKeys, etc... but it's definitely a valid use case for complex apps with multiple configurable "things".

from clay.

keegan-lillo avatar keegan-lillo commented on July 17, 2024

Interesting...
Maybe if there was a component called something like "dynamic-group" that had very similar syntax to a "section" but would have an add and remove buttons as well as the ability to re-order. The config would look something like:

{
  type: 'dynamic-group',
  structure: [
    // Any combination of components
    {
      type: 'input',
      appKey: 'name',
      label: 'Name'
    },
    {
      type: 'color',
      appKey: 'fave_color',
      'Favorite Color'
    }
  ]
}

And would end up being serialized into something like:

{
  name: ['Joe', 'Fred'],
  fave_color: [0xFF0000, 0x00FF00]  
}

from clay.

valorin avatar valorin commented on July 17, 2024

Yeah, something like that should do what I need it to do! :-)

from clay.

pautomas avatar pautomas commented on July 17, 2024

Sorry for bumping this one, but wanted to add one requests for the future dynamic-group component: the ability to define the max and min number of items in the group. ie: if my config page allows the user to define their favorite contacts to a maximum of 10 the component should look something like:

 {
  type: 'dynamic-group',
  min-items: 1, // this might be the value by default
  max-items: 10,
  structure: [
    {
      type: 'input',
      appKey: 'name',
      label: 'Name'
    },
    {
      type: 'color',
      appKey: 'fave_color',
      'Favorite Color'
    }
  ]
}

from clay.

ignat980 avatar ignat980 commented on July 17, 2024

Is this currently possible via a Clay Custom function, or is it impossible unless the package is updated to handle dynamic fields?

from clay.

keegan-lillo avatar keegan-lillo commented on July 17, 2024

@ignat980 You could achieve it with a custom component, but it will not be trivial. Sorry.

from clay.

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.