This commit is contained in:
James Cole
2016-02-10 15:04:06 +01:00
parent 94b6c7975a
commit 076ff7c7ba
4 changed files with 94 additions and 5 deletions

View File

@@ -11,8 +11,7 @@ var actionCount = 0;
$(function () {
"use strict";
console.log("create-edit");
console.log('edit-create');
});
@@ -21,11 +20,18 @@ function addNewTrigger() {
triggerCount++;
$.getJSON('json/trigger', {count: triggerCount}).done(function (data) {
//console.log(data.html);
$('tbody.rule-trigger-tbody').append(data.html);
$('.remove-trigger').unbind('click').click(function (e) {
removeTrigger(e);
return false;
});
}).fail(function () {
alert('Cannot get a new trigger.');
});
}
function addNewAction() {
@@ -35,7 +41,45 @@ function addNewAction() {
$.getJSON('json/action', {count: actionCount}).done(function (data) {
//console.log(data.html);
$('tbody.rule-action-tbody').append(data.html);
// add action things.
$('.remove-action').unbind('click').click(function (e) {
removeAction(e);
return false;
});
}).fail(function () {
alert('Cannot get a new action.');
});
}
function removeTrigger(e) {
"use strict";
var target = $(e.target);
if(target.prop("tagName") == "I") {
target = target.parent();
}
// remove grand parent:
target.parent().parent().remove();
// if now at zero, immediatly add one again:
if($('.rule-trigger-tbody tr').length == 0) {
addNewTrigger();
}
}
function removeAction(e) {
"use strict";
var target = $(e.target);
if(target.prop("tagName") == "I") {
target = target.parent();
}
// remove grand parent:
target.parent().parent().remove();
// if now at zero, immediatly add one again:
if($('.rule-action-tbody tr').length == 0) {
addNewAction();
}
}