summaryrefslogtreecommitdiffstats
path: root/ui/imports/ui/components/data-cubic/data-cubic.js
blob: ac0860a8382e594dbd547740c82d83b9adbd29d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) and others /
//                                                                                      /
// All rights reserved. This program and the accompanying materials                     /
// are made available under the terms of the Apache License, Version 2.0                /
// which accompanies this distribution, and is available at                             /
// http://www.apache.org/licenses/LICENSE-2.0                                           /
/////////////////////////////////////////////////////////////////////////////////////////
/*
 * Template Component: DataCubic 
 */
    
//import { Meteor } from 'meteor/meteor'; 
import { Template } from 'meteor/templating';
import { ReactiveDict } from 'meteor/reactive-dict';
import * as R from 'ramda';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { Icon } from '/imports/lib/icon';
        
import './data-cubic.html';     
    
/*  
 * Lifecycles
 */   
  
Template.DataCubic.onCreated(function() {
  var instance = this;

  instance.state = new ReactiveDict();
  instance.state.setDefault({
    theme: null
  });

  this.autorun(() => {
    new SimpleSchema({
      header: { type: String },
      dataInfo: { type: String },
      icon: { type: Icon },
      theme: { type: String, optional: true }
    }).validate(Template.currentData());

    let theme = Template.currentData().theme;
    theme = R.isNil(theme) ? 'light' : theme; 
    instance.state.set('theme', theme);
  });
});  

/*
Template.DataCubic.rendered = function() {
};  
*/

/*
 * Events
 */

Template.DataCubic.events({
});
   
/*  
 * Helpers
 */

Template.DataCubic.helpers({    
  getTheme: function () {
    let instance = Template.instance();
    return instance.state.get('theme');
  }
});