Coder Social home page Coder Social logo

temba-components's Introduction

temba-components is a suite of ui widgets used by various RapidPro projects.

Some of the components:

  • <temba-select/> Advanced select widget with support for remote fetching and filtering. Also supports multi selection with the ability to enter expressions.

  • <temba-completion/> Completion widget for completing RP-style expressions

  • <temba-textinput/> - Standard text field with baked in support for date picking

  • <temba-charcount/> - SMS segment counter attachable to elements for monitoring

  • <temba-store/> - In page cache for RP core data types

  • <temba-options/> - Generic option list with configurable rendering, remote list paging, and keyboard support. Used by temba-select, temba-completion, and temba-list

  • <temba-list/> - Block rendered option list

  • <temba-dialog/> - Basic modal

  • <temba-modax/> - Fancier modal that fetches and submits html rendered forms and is triggered by a slot element

  • .. and many more

Install

We use yarn, so you'll want to install with that if you care about our lock file.

% yarn install

Demo

To view the interactive demo, use start.

% yarn start

Testing

All tests live under /test. When running tests, some tests capture screenshots for pixel comparision under /screenshots. Running tests requires that you have Chromium installed.

% yarn test

Usage

Simply include the built file as a module and you should be off to the races!

<html>
  <head>
    <script type="module">
      import '../out-tsc/temba-components.js';
    </script>
  </head>
  <body>
    <temba-select name="color">
      <temba-option name="Red" value="r"></temba-option>
      <temba-option name="Green" value="g"></temba-option>
      <temba-option name="Blue" value="b"></temba-option>
    </temba-select>
  </body>
</html>

To interactively work with components whilst embedded in another project, it can easily be done with a couple nginx rules.

  location ~ /out-tsc/(.*) {
      proxy_pass http://localhost:3010/out-tsc/$1;
  }

  location ~ /node_modules/(.*) {
      proxy_pass http://localhost:3010/node_modules/$1;
  }

temba-components's People

Contributors

ericnewcomer avatar susanm74 avatar rowanseymour avatar dependabot[bot] avatar norkans7 avatar nicpottier avatar

Stargazers

Imani 'K!ΠG' Niyigena  avatar Mohd Shamoon avatar vignesh anand avatar  avatar

Watchers

 avatar  avatar James Cloos avatar  avatar  avatar  avatar  avatar

temba-components's Issues

Modals don't scale-in animate on Safari

This works in Chrome, but in Safari, instead of animating there is a brief pause (presumably the duration of the animation) with the mask shown and then the modal pops in instantly.

compose - set focus back on the chatbox - part deux

  • whenever clicking the bottom "row" area containing the paperclip, counter, and send button... set the focus back on the chatbox
  • immediately after selecting/uploading attachments...set the focus back on the chatbox

Modaxes shouldn't expect rendered view to be returned if being dismissed

Discussed in #241

Originally posted by rowanseymour June 16, 2021
There should be a way for the view to pass back a response that says "please close" without passing back a rendering of the form. Sometimes the rendered form ends up invalid and for split second before the modal disappears the user needs new validation errors.

Add multiple language localizations to compose component

  • compose component needs to support multi-language localization (aka translations cont'd)

  • add this as a searchable dropdown directly above the chatbox in the compose component that should allow the user to toggle back and forth between languages

  • translations dropdown should be hidden for usage such as the contact chat (when the user is sending a one-time text or attachments to a single recipient), and should be displayed for usage such as for broadcasts (when the user is sending text or attachments to multiple recipients, and needs to send the content in potentially multiple languages)

  • dropdown should display a list of languages filtered based on the org's languages

  • if the user has text and attachments for arabic, but then the org removes arabic from it's list of languages, don’t display the arabic translations in the component, and upon save, remove from the arabic translation from the translations

  • extra credit - show which languages content has been translated into vs. not translated via icons on the left side of the dropdown language option

  • todo - how to handle incomplete or partially localized attachments:

    • when a user provides text and attachments in one language - all good
    • when a user provides text and attachments in multiple languages - all good
    • when a user provides text in multiple languages (ex. english and spanish) but only provides attachments in one language (ex. english), when we go to save/send the spanish broadcast, do we send:
      • no attachments?
      • the english ones?
      • disallow the user from saving without specifying "spanish" attachments?
      • allow the user to specify how to handle and whether to send the english ones vs none, for any/all other languages for which attachments have not been provided?

potentially relevant broadcast discussions:

Datepicker in rare occasions doesn't init properly

One theory here is that the init is performed before the dependency is loaded. A soft refresh (or even a hard one) has fixed it. This has been reported a couple times by a couple different people. I believe each time was on staging verification, so the cache theory might have merit.

broadcast crud interface - switch from text field to compose component

  • current "create" scheduled message interface modal contains an area with a chatbox and char counter
  • update that area to use the compose component containing chatbox, attachments, counter, no button
  • needs to be updated in both old and new ui (with slight priority for new ui)
  • don't worry about "send now" stuff yet
  • rename "scheduled message" to "broadcast"

potentially relevant broadcast discussions:

when postUrl returns a rejected promise, pass the whole response back instead of just 'Server failure'

would make it easier for processing errors stored in the response.xyz (ex. response.body, response.json, response.json.error, response.json.file, etc) when it's desired to know more (or display more to the user) than just 'Server failure'

an idea that springs from issue 4347 / PR #276, but making a separate issue for this as the change itself and the testing burden would be nontrivial:

  • postJSON and postFormData both make a call to postUrl
  • postUrl is used directly by a few helpers and components:
    • contacts -> helpers -> closeTicket (although don't think this is actively used anywhere across TC, RP, FE repos)
    • Store
    • Modax
  • postJSON is used directly by:
    • 8 components
  • postFormData is used directly by:
    • 1 component

Can we add check for custom Elements definition

Hi Team, we are using these components in our application Glific and sometimes when we don't refresh the page and load the library once again after removing with react-router it shows this Error:

Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry

This happens because the page is not refreshed and we call the library once again after removing and it tries to register the custom elements again.

window.customElements.define('temba-alert', Alert);

Can we add a check for this in the code:

if (!window.customElements.get('temba-alert')) {
 window.customElements.define('temba-alert', Alert);  
 }

I know it won't affect anything in RapidPro since the page always gets refreshed on moving to a new flow that removes the custom Elements, but if you can add this check, that would be really helpful.

https://stackoverflow.com/a/58489650

Or If you guys have any other suggestions that would be super helpful.

Update format for channel events in contact history

Old incoming call...

{
    "type": "channel_event",
    "created_on": "2023-09-28T12:30Z",
    "channel_event_type": "mo_call",
    "duration": 5,
}

New incoming call...

{
    "type": "channel_event",
    "created_on": "2023-09-28T12:30Z",
    "event": {
        "type": "mo_call",
        "channel": {"uuid": "d7c9b320-3e48-486d-a4a9-7ca367823dfa", "name": "Test Channel"},
        "duration": 5,
    }
}

Old optin...

{
    "type": "channel_event",
    "created_on": "2023-09-28T12:30Z",
    "channel_event_type": "optin",
    "duration": null
}

New optin...

{
    "type": "channel_event",
    "created_on": "2023-09-28T12:30Z",
    "event": {
        "type": "optin",
        "channel": {"uuid": "d7c9b320-3e48-486d-a4a9-7ca367823dfa", "name": "Test Channel"},
        "optin": {"uuid": "22546e04-1e97-436d-a114-947f2ed96c77", "name": "Polls"},
    }
}

compose - double focus on send button click

When acting on the send button directly, you can get a "double" focus appearance. Additionally, focus is not returned to the input. Ideally, in this case, the send button would lose focus immediately after the action is complete and the focus is returned to the input.

Screenshot 2023-03-02 at 10 58 50 AM

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.