mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 19:01:58 +00:00
Fixes #173
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user