2016-04-18 14:15:00 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
function IdClaimHandler(moddle) {
|
|
|
|
this._moddle = moddle;
|
|
|
|
}
|
|
|
|
|
|
|
|
IdClaimHandler.$inject = [ 'moddle' ];
|
|
|
|
|
|
|
|
module.exports = IdClaimHandler;
|
|
|
|
|
|
|
|
|
|
|
|
IdClaimHandler.prototype.execute = function(context) {
|
|
|
|
var ids = this._moddle.ids,
|
|
|
|
id = context.id,
|
|
|
|
element = context.element,
|
|
|
|
claiming = context.claiming;
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
if (claiming) {
|
2016-04-18 14:15:00 +00:00
|
|
|
ids.claim(id, element);
|
|
|
|
} else {
|
|
|
|
ids.unclaim(id);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command revert implementation.
|
|
|
|
*/
|
|
|
|
IdClaimHandler.prototype.revert = function(context) {
|
|
|
|
var ids = this._moddle.ids,
|
|
|
|
id = context.id,
|
|
|
|
element = context.element,
|
|
|
|
claiming = context.claiming;
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
if (claiming) {
|
2016-04-18 14:15:00 +00:00
|
|
|
ids.unclaim(id);
|
|
|
|
} else {
|
|
|
|
ids.claim(id, element);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|