CallBackery

 view release on metacpan or  search on metacpan

lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/Card.js  view on Meta::CPAN

                    if (fieldCfg.set) {
                        ['placeholder','tooltip'].forEach(key => {
                            if (key in fieldCfg.set){
                                fieldCfg.set[key] = this.xtr(fieldCfg.set[key]).toString();
                            }
                        });
                        field.set(fieldCfg.set);
                    }
                    var event;
                    if (field.setLiveUpdate && ! field.getReadOnly()) { // TextField
                        field.setLiveUpdate(true);
                        event = 'changeValue';
                    }
                    if (field.setModelSelection) { // SelectBox
                        if (fieldCfg.items) {
                            for (let item of fieldCfg.items) {
                                field.add(new qx.ui.form.ListItem(this.xtr(item[1]).toString(), null, item[0]));
                            }
                        }
                        event = 'changeSelection';
                    }
                    if (event) {
                        if (event == 'changeSelection') {
                            field.addListener(event, (e) => {
                                let value = e.getData()[0].getModel();
                                this.__parentForm.setSelection({ data : this.__dataCache, key : fieldCfg.key, value : value });
                                if (this.__buttonMap[this._updateAction]) {
                                    this.__buttonMap[this._updateAction].execute();
                                }
                                else {
                                    console.warn('No method for updateCard:', this._updateAction);
                                }
                            });
                        }
                        else {
                            // For input fields we collect multiple fast inputs and only store
                            // if no new input events occur for a certain time
                            let delay = 500; // msec
                            let updateTimer, lastValue;

                            // store input callback for updateTimer
                            let storeInput = () => {
                                updateTimer.stop();
                                let value = field.getValue();
                                if (value === lastValue) {
                                    return;
                                }
                                lastValue = value;
                                this.__parentForm.setSelection({ data : this.__dataCache, selectedField : fieldCfg.key, newValue : value });
                                if (this.__buttonMap[this._updateAction]) {
                                    this.__buttonMap[this._updateAction].execute();
                                }
                                else {
                                    console.warn('No method for updateCard:', this._updateAction);
                                }
                            };

                            // called on inputs into the field
                            field.addListener(event, (e) => {
                                if (updateTimer) {
                                    // delay storing on repeated inputs while timer is running
                                    updateTimer.restart();
                                }
                                else {
                                    // create and start timer on first input
                                    updateTimer = new qx.event.Timer(delay);
                                    updateTimer.addListener("interval", storeInput, this);
                                }
                            });
                        }
                    }
                    this._add(field, fieldCfg.addSet);
                    fld[fieldCfg.key] = field;
                }
            }, this);

            // add action buttons
            this.__actions.forEach(action => {
                var btn = this.__createButton(this.xtr(action.label).toString(), action.buttonSet.icon);
                btn.addListener('execute', function() {
                    this.__parentForm.setSelection(this.__dataCache);
                    this.__buttonMap[action.key].execute();
                }, this);
                this._add(btn, action.cardAddSet);
            }, this);
        }
    }
});



( run in 1.831 second using v1.01-cache-2.11-cpan-e1769b4cff6 )