mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 20:41:17 +01:00
Merge remote-tracking branch 'origin/master'
Conflicts: src/upgrade.js
This commit is contained in:
@@ -11,50 +11,48 @@ define('admin/extend/rewards', function() {
|
||||
conditionals;
|
||||
|
||||
rewards.init = function() {
|
||||
$(window).on('action:ajaxify.end', function() {
|
||||
available = JSON.parse(ajaxify.variables.get('rewards'));
|
||||
active = JSON.parse(ajaxify.variables.get('active'));
|
||||
conditions = JSON.parse(ajaxify.variables.get('conditions'));
|
||||
conditionals = JSON.parse(ajaxify.variables.get('conditionals'));
|
||||
available = JSON.parse(ajaxify.variables.get('rewards'));
|
||||
active = JSON.parse(ajaxify.variables.get('active'));
|
||||
conditions = JSON.parse(ajaxify.variables.get('conditions'));
|
||||
conditionals = JSON.parse(ajaxify.variables.get('conditionals'));
|
||||
|
||||
$('[data-selected]').each(function() {
|
||||
select($(this));
|
||||
});
|
||||
$('[data-selected]').each(function() {
|
||||
select($(this));
|
||||
});
|
||||
|
||||
$('#active')
|
||||
.on('change', '[data-selected]', function() {
|
||||
update($(this));
|
||||
})
|
||||
.on('click', '.delete', function() {
|
||||
var parent = $(this).parents('[data-id]'),
|
||||
id = parent.attr('data-id');
|
||||
$('#active')
|
||||
.on('change', '[data-selected]', function() {
|
||||
update($(this));
|
||||
})
|
||||
.on('click', '.delete', function() {
|
||||
var parent = $(this).parents('[data-id]'),
|
||||
id = parent.attr('data-id');
|
||||
|
||||
socket.emit('admin.rewards.delete', {id: id}, function(err) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
} else {
|
||||
app.alertSuccess('Successfully deleted reward');
|
||||
}
|
||||
});
|
||||
|
||||
parent.remove();
|
||||
return false;
|
||||
})
|
||||
.on('click', '.toggle', function() {
|
||||
var btn = $(this),
|
||||
disabled = btn.html() === 'Enable',
|
||||
id = $(this).parents('[data-id]').attr('data-id');
|
||||
|
||||
btn.toggleClass('btn-warning').toggleClass('btn-success').html(disabled ? 'Enable' : 'Disable');
|
||||
// send disable api call
|
||||
return false;
|
||||
socket.emit('admin.rewards.delete', {id: id}, function(err) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
} else {
|
||||
app.alertSuccess('Successfully deleted reward');
|
||||
}
|
||||
});
|
||||
|
||||
$('#new').on('click', newReward);
|
||||
$('#save').on('click', saveRewards);
|
||||
parent.remove();
|
||||
return false;
|
||||
})
|
||||
.on('click', '.toggle', function() {
|
||||
var btn = $(this),
|
||||
disabled = btn.html() === 'Enable',
|
||||
id = $(this).parents('[data-id]').attr('data-id');
|
||||
|
||||
populateInputs();
|
||||
});
|
||||
btn.toggleClass('btn-warning').toggleClass('btn-success').html(disabled ? 'Enable' : 'Disable');
|
||||
// send disable api call
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#new').on('click', newReward);
|
||||
$('#save').on('click', saveRewards);
|
||||
|
||||
populateInputs();
|
||||
};
|
||||
|
||||
function select(el) {
|
||||
|
||||
@@ -21,7 +21,7 @@ var db = require('./database'),
|
||||
schemaDate, thisSchemaDate,
|
||||
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
|
||||
latestSchema = Date.UTC(2015, 1, 23);
|
||||
latestSchema = Date.UTC(2015, 1, 24);
|
||||
|
||||
Upgrade.check = function(callback) {
|
||||
db.get('schemaDate', function(err, value) {
|
||||
@@ -862,16 +862,34 @@ Upgrade.upgrade = function(callback) {
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = Date.UTC(2015, 1, 23);
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
db.setAdd('plugins:active', 'nodebb-rewards-essentials', function(err) {
|
||||
winston.info('[2015/2/23] Activating NodeBB Essential Rewards');
|
||||
Plugins.reload(function() {
|
||||
if (err) {
|
||||
next(err);
|
||||
} else {
|
||||
Upgrade.update(thisSchemaDate, next);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
winston.info('[2015/2/23] Activating NodeBB Essential Rewards - skipped');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = Date.UTC(2015, 1, 24);
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
winston.info('[2015/02/23] Upgrading plugins:active to sorted set');
|
||||
winston.info('[2015/02/24] Upgrading plugins:active to sorted set');
|
||||
|
||||
db.getSetMembers('plugins:active', function(err, activePlugins) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (!Array.isArray(activePlugins) || !activePlugins.length) {
|
||||
winston.info('[2015/02/23] Upgrading plugins:active to sorted set done');
|
||||
winston.info('[2015/02/24] Upgrading plugins:active to sorted set done');
|
||||
Upgrade.update(thisSchemaDate, next);
|
||||
}
|
||||
|
||||
@@ -887,19 +905,19 @@ Upgrade.upgrade = function(callback) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
winston.info('[2015/02/23] Upgrading plugins:active to sorted set done');
|
||||
winston.info('[2015/02/24] Upgrading plugins:active to sorted set done');
|
||||
Upgrade.update(thisSchemaDate, next);
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
winston.info('[2015/02/23] Upgrading plugins:active to sorted set skipped');
|
||||
winston.info('[2015/02/24] Upgrading plugins:active to sorted set skipped');
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
// Add new schema updates here
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 22!!!
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 24!!!
|
||||
], function(err) {
|
||||
if (!err) {
|
||||
if(updatesMade) {
|
||||
|
||||
Reference in New Issue
Block a user