diff --git a/public/src/admin/extend/rewards.js b/public/src/admin/extend/rewards.js index 9dae5a731b..54177ea4c9 100644 --- a/public/src/admin/extend/rewards.js +++ b/public/src/admin/extend/rewards.js @@ -41,13 +41,14 @@ define('admin/extend/rewards', function() { }); $('#new').on('click', newReward); + $('#save').on('click', saveRewards); }); }; function select(el) { el.val(el.attr('data-selected')); switch (el.attr('name')) { - case 'reward': + case 'id': selectReward(el); break; } @@ -56,7 +57,7 @@ define('admin/extend/rewards', function() { function update(el) { el.attr('data-selected', el.val()); switch (el.attr('name')) { - case 'reward': + case 'id': selectReward(el); break; } @@ -130,5 +131,26 @@ define('admin/extend/rewards', function() { ul.append(li); } + function saveRewards() { + var activeRewards = []; + + $('#active li').each(function() { + var data = $(this).find('form.main').serializeArray(); + + data.rewards = $(this).find('form.rewards').serializeArray(); + data.disabled = $(this).find('.toggle').html() === 'Enable'; + + activeRewards.push(data); + }); + + socket.emit('admin.rewards.save', activeRewards, function(err) { + if (err) { + app.alertError(err.message); + } else { + app.alertSuccess('Successfully saved rewards'); + } + }); + } + return rewards; }); \ No newline at end of file diff --git a/src/socket.io/admin.js b/src/socket.io/admin.js index a770af5c53..49b3744dbb 100644 --- a/src/socket.io/admin.js +++ b/src/socket.io/admin.js @@ -25,6 +25,7 @@ var async = require('async'), categories: require('./admin/categories'), groups: require('./admin/groups'), tags: require('./admin/tags'), + rewards: require('./admin/rewards'), themes: {}, plugins: {}, widgets: {}, diff --git a/src/socket.io/admin/rewards.js b/src/socket.io/admin/rewards.js new file mode 100644 index 0000000000..70ac1fecf5 --- /dev/null +++ b/src/socket.io/admin/rewards.js @@ -0,0 +1,13 @@ +"use strict"; + +var rewards = require('../../rewards'), + rewards = {}; + +rewards.save = function(socket, data, callback) { + console.log(data); + callback(new Error('derp')); + //callback(err ? err.message : null); +}; + + +module.exports = rewards; \ No newline at end of file diff --git a/src/views/admin/extend/rewards.tpl b/src/views/admin/extend/rewards.tpl index cc628cbf5b..af6dac1865 100644 --- a/src/views/admin/extend/rewards.tpl +++ b/src/views/admin/extend/rewards.tpl @@ -3,10 +3,10 @@
Rewards
-
-
    - -
  • +
      + +
    • +

      - +

      -
      +
    • + +
      -
      - - - - - - -
      -
      - - -
    - + + +
    + + + + + + +
    +
    +
  • + +