ditching rewardID in favour of verbose id's

v1.18.x
psychobunny 10 years ago
parent 46e0fad2d8
commit 91c02d4e29

@ -63,16 +63,16 @@ define('admin/extend/rewards', function() {
} }
function selectReward(el) { function selectReward(el) {
var parent = el.parents('[data-rewardID]'), var parent = el.parents('[data-id]'),
div = parent.find('.inputs'), div = parent.find('.inputs'),
inputs, inputs,
html = ''; html = '';
for (var reward in available) { for (var reward in available) {
if (available.hasOwnProperty(reward)) { if (available.hasOwnProperty(reward)) {
if (parseInt(available[reward].rewardID, 10) === parseInt(el.attr('data-selected'), 10)) { if (available[reward].id === el.attr('data-selected')) {
inputs = available[reward].inputs; inputs = available[reward].inputs;
parent.attr('data-rewardID', available[reward].rewardID); parent.attr('data-id', available[reward].id);
break; break;
} }
} }
@ -104,7 +104,7 @@ define('admin/extend/rewards', function() {
} }
function populateInputs() { function populateInputs() {
$('[data-rewardID]').each(function(i) { $('[data-id]').each(function(i) {
var div = $(this).find('.inputs'), var div = $(this).find('.inputs'),
rewards = active[i].rewards; rewards = active[i].rewards;
@ -121,7 +121,7 @@ define('admin/extend/rewards', function() {
li = $('#active li').last().clone(true); li = $('#active li').last().clone(true);
li.attr('data-index', parseInt(li.attr('data-index') + 1, 10)) li.attr('data-index', parseInt(li.attr('data-index') + 1, 10))
.attr('data-rewardID', ''); .attr('data-id', '');
li.find('.inputs').html(''); li.find('.inputs').html('');
li.find('[name="reward"]').val(''); li.find('[name="reward"]').val('');

@ -55,7 +55,7 @@ rewards.get = function(callback) {
rewards: function(next) { rewards: function(next) {
plugins.fireHook('filter:rewards.rewards', [ plugins.fireHook('filter:rewards.rewards', [
{ {
"rewardID": 0, "id": "core:add-to-group",
"name": "Add to Group", "name": "Add to Group",
"inputs": [ "inputs": [
{ {
@ -80,7 +80,7 @@ rewards.get = function(callback) {
] ]
}, },
{ {
"rewardID": 1, "id": "core:alert-user",
"name": "Send alert message", "name": "Send alert message",
"inputs": [ "inputs": [
{ {
@ -107,7 +107,7 @@ function getConditions() {
function getActiveRewards(callback) { function getActiveRewards(callback) {
callback(false, [ callback(false, [
{ {
"rewardID": 1, "id": "core:alert-user",
"condition": "postcount", "condition": "postcount",
"conditional": "greaterthan", "conditional": "greaterthan",
"rewards": { "rewards": {
@ -118,7 +118,7 @@ function getActiveRewards(callback) {
"disabled": false "disabled": false
}, },
{ {
"rewardID": 0, "id": "core:add-to-group",
"condition": "lastLoggedIn", "condition": "lastLoggedIn",
"conditional": "lesserthan", "conditional": "lesserthan",
"rewards": { "rewards": {

@ -6,7 +6,7 @@
<form> <form>
<ul id="active"> <ul id="active">
<!-- BEGIN active --> <!-- BEGIN active -->
<li data-rewardID="{active.rewardID}" data-index="@index"> <li data-id="{active.id}" data-index="@index">
<div class="well inline-block"> <div class="well inline-block">
<label for="condition">If User's</label><br /> <label for="condition">If User's</label><br />
<select name="condition" data-selected="{active.condition}"> <select name="condition" data-selected="{active.condition}">
@ -26,9 +26,9 @@
</div> </div>
<div class="well inline-block"> <div class="well inline-block">
<label for="condition">Then:</label><br /> <label for="condition">Then:</label><br />
<select name="reward" data-selected="{active.rewardID}"> <select name="reward" data-selected="{active.id}">
<!-- BEGIN rewards --> <!-- BEGIN rewards -->
<option value="{rewards.rewardID}">{rewards.name}</option> <option value="{rewards.id}">{rewards.name}</option>
<!-- END rewards --> <!-- END rewards -->
</select> </select>
</div> </div>

Loading…
Cancel
Save