Work on refactoring measurements out of Lesion Tracker package
- Removed AssociatedStudies Collection - Measurement API is generated from configuration files - Data exchange methods are defined in configuration
This commit is contained in:
1 parent
c511edd419
commit
ab4d4c9008
537 files changed
+5122
-3545
No files matched your search
@@ -0,0 +1,40 @@
|
||||
Template.roundedButtonGroup.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
const reactiveValue = instance.data.value;
|
||||
|
||||
// Get the value for ReactiveVar or ReactiveDict objects
|
||||
instance.getValue = () => {
|
||||
return reactiveValue.get(instance.data.key);
|
||||
};
|
||||
|
||||
// Set the value for ReactiveVar or ReactiveDict objects
|
||||
instance.setValue = value => {
|
||||
const args = [value];
|
||||
if (reactiveValue instanceof ReactiveDict) {
|
||||
args.unshift(instance.data.key);
|
||||
}
|
||||
|
||||
reactiveValue.set(...args);
|
||||
};
|
||||
|
||||
// Initialize the value with the first option if there's no value set and options are not toggleable
|
||||
if (!instance.getValue() && !instance.data.toggleable) {
|
||||
instance.setValue(instance.data.options[0].value);
|
||||
}
|
||||
});
|
||||
|
||||
Template.roundedButtonGroup.events({
|
||||
'click [data-value]'(event, instance) {
|
||||
event.preventDefault();
|
||||
const $target = $(event.currentTarget);
|
||||
const nullValue = $target.hasClass('active') && instance.data.toggleable;
|
||||
const value = nullValue ? null : $target.attr('data-value');
|
||||
instance.setValue(value);
|
||||
}
|
||||
});
|
||||
|
||||
Template.roundedButtonGroup.helpers({
|
||||
getValue() {
|
||||
return Template.instance().getValue();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user