os-js / osjs-dialogs

OS.js Dialogs Module
https://manual.os-js.org/v3/
Other
4 stars 7 forks source link

Latest value chosen in choice dialog! #9

Closed miladhashemi closed 4 years ago

miladhashemi commented 4 years ago

Hi, Continued widget development(https://github.com/os-js/osjs-widgets/issues/9), i faced new problem. I kept a paramter as widget custom options. measurment: 'netdata.apps.cpu.X' Due to changing this custom option value I used choice dialog, but I don't know how should I use my parameter value as choice dialog default value.

createMeasurmentDialog() {
    this.core.make('osjs/dialog', 'choice', {
      title: 'Measurment',
      message: 'Select Measurment',
      //TODO: make this list via grafana service
      choices: {
        'netdata.apps.cpu.X': 'netdata.apps.cpu.X',
        'netdata.statsd_timer_swift.object_server.put.timing.events': 'netdata.statsd_timer_swift.object_server.put.timing.events'
      },
    }, (btn, value) => {
      if (btn === 'ok') {
        this.options.measurment = value;
        this.render();
        this.saveSettings();
      }
    });
  }
andersevenrud commented 4 years ago

So, you want to be able to define the default value in the dropdown based on that option from your widget ?

miladhashemi commented 4 years ago

Exactly

andersevenrud commented 4 years ago

If you update your @osjs/dialogs (version 3.0.20) you should now have a value: something option for the dialog to override the default value.