From c1e043b7ba78cee73d13ded9ef03b256202540f1 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Mon, 24 Apr 2017 10:36:10 +0300 Subject: Move STATIC_ROOT inside app directory --- static/js/rules.js | 118 ----------------------------------------------------- 1 file changed, 118 deletions(-) delete mode 100644 static/js/rules.js (limited to 'static/js/rules.js') 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); - } -} -- cgit v1.2.3