reorganize packages, start converting overall app to react (very broken at the moment)

This commit is contained in:
Erik Ziegler committed 2018-12-12 18:06:25 +01:00
1 parent 024fe1a448
commit 5f30f7bd35
479 files changed
+5364 -11611

No files matched your search

@@ -0,0 +1,46 @@
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);
// Stop here if the tool is disabled
if ($target.hasClass('disabled')) {
return;
}
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();
}
});