rewards: adding new rows

v1.18.x
psychobunny
parent 029ae11ed5
commit 4acf8cafee

@ -39,6 +39,8 @@ define('admin/extend/rewards', function() {
// send disable api call // send disable api call
return false; return false;
}); });
$('#new').on('click', newReward);
}); });
}; };
@ -77,7 +79,7 @@ define('admin/extend/rewards', function() {
} }
if (!inputs) { if (!inputs) {
app.alertError('Illegal reward - no inputs found! ' + el.attr('data-selected')); return app.alertError('Illegal reward - no inputs found! ' + el.attr('data-selected'));
} }
inputs.forEach(function(input) { inputs.forEach(function(input) {
@ -114,5 +116,19 @@ define('admin/extend/rewards', function() {
}); });
} }
function newReward() {
var ul = $('#active'),
li = $('#active li').last().clone(true);
li.attr('data-index', parseInt(li.attr('data-index') + 1, 10))
.attr('data-rewardID', '');
li.find('.inputs').html('');
li.find('[name="reward"]').val('');
ul.append(li);
}
return rewards; return rewards;
}); });

@ -4,7 +4,7 @@
<div class="panel-heading">Rewards</div> <div class="panel-heading">Rewards</div>
<div class="panel-body"> <div class="panel-body">
<form> <form>
<ul> <ul id="active">
<!-- BEGIN active --> <!-- BEGIN active -->
<li data-rewardID="{active.rewardID}" data-index="@index"> <li data-rewardID="{active.rewardID}" data-index="@index">
<div class="well inline-block"> <div class="well inline-block">
@ -54,8 +54,9 @@
<div class="col-lg-3 acp-sidebar"> <div class="col-lg-3 acp-sidebar">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">Save Settings</div> <div class="panel-heading">Rewards Control</div>
<div class="panel-body"> <div class="panel-body">
<button class="btn btn-success btn-md" id="new">New Reward</button><br />
<button class="btn btn-primary btn-md" id="save">Save Changes</button> <button class="btn btn-primary btn-md" id="save">Save Changes</button>
</div> </div>
</div> </div>

Loading…
Cancel
Save