aboutsummaryrefslogtreecommitdiffstats
path: root/static/js/rules.js
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2017-04-24 10:36:10 +0300
committerFilipp Lepalaan <filipp@mac.com>2017-04-24 10:36:10 +0300
commitc1e043b7ba78cee73d13ded9ef03b256202540f1 (patch)
tree2b913aaf4c3c45972cff707afd76d9ad901d40ba /static/js/rules.js
parentef376c2cf80cb89c3c5a5dc79c39c5045406b5e7 (diff)
downloadServo-c1e043b7ba78cee73d13ded9ef03b256202540f1.tar.gz
Servo-c1e043b7ba78cee73d13ded9ef03b256202540f1.tar.bz2
Servo-c1e043b7ba78cee73d13ded9ef03b256202540f1.zip
Move STATIC_ROOT inside app directory
Diffstat (limited to 'static/js/rules.js')
-rw-r--r--static/js/rules.js118
1 files changed, 0 insertions, 118 deletions
diff --git a/static/js/rules.js b/static/js/rules.js
deleted file mode 100644
index 909743d..0000000
--- a/static/js/rules.js
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * rules.js
- */
-
-// start data model
-// a condition consist of a key, an operator (=) and a value
-var Condition = function(init){
- var self = this;
-
- self.init = init;
-
- self.id = null;
- self.key = ko.observable('QUEUE');
- self.value = ko.observable('');
- self.operator = ko.observable('=');
-
- self.keyChoices = [
- {key: 'QUEUE', title: 'Queue'},
- {key: 'STATUS', title: 'Status'},
- {key: 'CUSTOMER', title: 'Customer'},
- {key: 'DEVICE', title: 'Device'},
- ]
-
- self.valueChoices = ko.computed(function(){
- return self.init[self.key()];
- });
-
- self.selectable = new Array('QUEUE', 'STATUS');
-
- self.canSelect = function(){
- return self.selectable.indexOf(self.key()) != -1;
- }
-
-}
-
-var Action = function(init){
- var self = this;
-
- self.init = init;
-
- self.id = null;
- self.title = ko.observable('Send Email');
- self.key = ko.observable('SEND_EMAIL');
- self.value = ko.observable('');
-
- self.selectable = new Array(
- 'SET_QUEUE', 'SET_STATUS', 'SET_USER', 'ADD_TAG'
- );
-
- self.keyChoices = [
- {title: 'Send Email', key: 'SEND_EMAIL'},
- {title: 'Send SMS', key: 'SEND_SMS'},
- {title: 'Add Tag', key: 'ADD_TAG'},
- {title: 'Set Queue', key: 'SET_QUEUE'},
- {title: 'Assign to', key: 'SET_USER'}
- ];
-
- self.canSelect = function() {
- return self.selectable.indexOf(self.key()) != -1;
- }
-
- self.valueChoices = ko.computed(function(){
- return self.init[self.key()];
- });
-}
-
-var Rule = function(condInit, actionInit){
- var self = this;
-
- self.id = null;
- self.match = ko.observable('ANY');
- self.description = ko.observable('New Rule');
-
- self.matchChoices = [
- {title: 'Any', value: 'ANY'},
- {title: 'All', value: 'ALL'}
- ];
-
- // rules consist of conditions and actions
- self.conditions = ko.observableArray([new Condition(condInit)]);
- self.actions = ko.observableArray([new Action(actionInit)]);
-
-}
-// end data model
-
-var ViewModel = function(cData, aData){
- var self = this;
- self.rule = new Rule(cData, aData);
-
- self.addCondition = function(){
- self.rule.conditions.push(new Condition(cData));
- };
-
- self.removeCondition = function(){
- if (self.rule.conditions().length < 2) return;
- self.rule.conditions.remove(this);
- };
-
- self.addAction = function(){
- self.rule.actions.push(new Action(aData));
- };
-
- self.removeAction = function(){
- if (self.rule.actions().length < 2) return;
- self.rule.actions.remove(this);
- };
-
- self.validateAndSave = function(form){
- $.post($(form).attr('action'), $(form).serialize(), function(r){
- console.log(r);
- });
- };
-
- self.init = function(data){
- console.log(data);
- self.rule = new Rule(cData, aData);
- }
-}