npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

smf-rbox-helper

v1.0.1

Published

RepeatBox helper library for Smartface

Downloads

1

Readme

 ____                       _    __                      _       
/ ___| _ __ ___   __ _ _ __| |_ / _| __ _  ___ ___      (_) ___  
\___ \| '_ ` _ \ / _` | '__| __| |_ / _` |/ __/ _ \     | |/ _ \ 
 ___) | | | | | | (_| | |  | |_|  _| (_| | (_|  __/  _  | | (_) |
|____/|_| |_| |_|\__,_|_|   \__|_|  \__,_|\___\___| (_) |_|\___/ 
-----------------------------------------------------------------

rbpx-helper

This library contains helper functionalities for Smartface RepeatBox UI object. Provided functionalities:

  • data binding row render

Install

npm i smf-rbox-helper

Smartface

If you are within a Smartface workspace first switch to scripts folder. Here is a script that does it all:

(cd ~/workspace/scripts && npm i smf-rbox-helper)

Usage

var rboxDataRowRender = require("smf-rbox-helper").rboxDataRowRender;
//provides row render databinder

In order to use this databinder repeatbox templates has to be filled in some certain information. Every child object in repeatbox, if they are target to data-binding they have to have following properties set.

dataField

During assignment which property should be assigned. Name of this property as string is assigned to this value. Inside the library prototypes of some fundemental objects are set by the prototype.

  • SMF.UI.TextBox: text
  • SMF.UI.Image: image
  • SMF.UI.Label: text

For those object you do not need to set this property.

dataKey

In data which key should be assigned to the field property? With dot notation data model object is traversed and assigned. For example:

  • "id"
  • "patient.number"
  • "comments[0].text"

Examples

Data:

var data = [{
    "id": "23653713-6e1e-4410-94fc-e2a672edd6d7",
    "displayId": "23653713-6e1e-4410-94fc-e2a672edd6d7",
    "subject": "Automation Test - Case with attachment",
    "type": "NORMAL",
    "documentType": "Case",
    "clinicalReason": "Collaboration",
    "otherClinicalReason": null,
    "priority": "HIGH",
    "status": "FAILED",
    "creator": {
        "identifier": "a90765b2-3cbe-4319-aee0-1110a1671eaf",
        "name": {
            "given": [
                "CT",
                " "
            ],
            "family": [
                "Clinician"
            ],
            "prefix": [],
            "suffix": []
        }
    },
    "participants": [{
        "user": {
            "identifier": "a66e99e6-e9ab-4ea4-b4de-09ed1949e012",
            "name": {
                "given": [
                    "CT",
                    " "
                ],
                "family": [
                    "Radiologist"
                ],
                "prefix": [],
                "suffix": []
            }
        },
        "reviewed": false
    }, {
        "user": {
            "identifier": "a90765b2-3cbe-4319-aee0-1110a1671eaf",
            "name": {
                "given": [
                    "CT",
                    " "
                ],
                "family": [
                    "Clinician"
                ],
                "prefix": [],
                "suffix": []
            }
        },
        "reviewed": true
    }],
    "caseOrganization": {
        "id": "12",
        "name": "San Ramon"
    },
    "patient": {
        "identifier": "A16667_Alper",
        "name": {
            "given": [
                "J�rgen",
                "Klaus"
            ],
            "family": [
                "Smith"
            ],
            "prefix": null,
            "suffix": null
        },
        "birthDate": "19651018",
        "gender": "M"
    },
    "createdDate": 1455100690342,
    "updatedDate": 1455100694468
}, {
    "id": "f2876da3-9470-4ed5-ad70-920b8333fe94",
    "displayId": "f2876da3-9470-4ed5-ad70-920b8333fe94",
    "subject": "Automation Test - Case with attachment",
    "type": "NORMAL",
    "documentType": "Case",
    "clinicalReason": "Collaboration",
    "otherClinicalReason": null,
    "priority": "HIGH",
    "status": "FAILED",
    "creator": {
        "identifier": "a90765b2-3cbe-4319-aee0-1110a1671eaf",
        "name": {
            "given": [
                "CT",
                " "
            ],
            "family": [
                "Clinician"
            ],
            "prefix": [],
            "suffix": []
        }
    },
    "participants": [{
        "user": {
            "identifier": "a90765b2-3cbe-4319-aee0-1110a1671eaf",
            "name": {
                "given": [
                    "CT",
                    " "
                ],
                "family": [
                    "Clinician"
                ],
                "prefix": [],
                "suffix": []
            }
        },
        "reviewed": true
    }, {
        "user": {
            "identifier": "a66e99e6-e9ab-4ea4-b4de-09ed1949e012",
            "name": {
                "given": [
                    "CT",
                    " "
                ],
                "family": [
                    "Radiologist"
                ],
                "prefix": [],
                "suffix": []
            }
        },
        "reviewed": false
    }],
    "caseOrganization": {
        "id": "12",
        "name": "San Ramon"
    },
    "patient": {
        "identifier": "A16667",
        "name": {
            "given": [
                "J�rgen",
                "Klaus"
            ],
            "family": [
                "Smith"
            ],
            "prefix": null,
            "suffix": null
        },
        "birthDate": "19651018",
        "gender": "M"
    },
    "createdDate": 1455100677898,
    "updatedDate": 1455100681970
}];

Create your repeatbox and assign data

var rbox = new SMF.UI.RepeatBox({
    useActiveItem: true
});
page1.add(rbox);

Best approach to fill a RepeatBox is to use a template filler function

function fillTempalte(template, isActiveItem) {
    template.height = "20%";
	var lbl = new SMF.UI.Label({
		width: "90%",
		height: "100%",
		top: 0,
		left: "5%",
		fillColor: isActiveItem ? "AliceBlue" : "white",
		touchEnabled: false,
		backgroundTransparent: false
	});
	template.add(lbl);
	lbl.dataKey = "subject";
}

fillTempalte(rbox.itemTemplate, false);
fillTempalte(rbox.activeItemTemplate, true);

In order to show the data in this binding assign rowRender

rbox.onRowRender = rboxDataRowRender;
rbox.dataSource = data;
rbox.refresh(); //force draw once

Advanced Usage (setData)

For advanced databinding scenarios it is possible to use a setter function. Here is the example for setting name

function fullNameMaker(name) {
    name.given = name.given || [];
    name.family = name.family || [];
    var fullName = [name.prefix];
    fullName = fullName.concat(name.given, name.family);
    fullName.push(name.suffix);
    return fullName.filter(function(value) {
        if (value) {
            value = String(value).trim();
        }
        return Boolean(value);
    }).join(" ");
}

//a different example for template filling
function fillTempalte(template, isActiveItem) {
    template.height = "20%";
	var lbl = new SMF.UI.Label({
		width: "90%",
		height: "100%",
		top: 0,
		left: "5%",
		fillColor: isActiveItem ? "AliceBlue" : "white",
		touchEnabled: false,
		backgroundTransparent: false
	});
    template.add(lbl);
    lbl.dataKey = "creator.name";
    lbl.setData = function(name) { //argumet is fetch by the value of the dataKey
        this.text = fullNameMaker(name);
        //this object is the lbl itself
    };
}