2018-04-02 19:01:53 +00:00
|
|
|
export default function IdClaimHandler(moddle) {
|
2016-04-18 14:15:00 +00:00
|
|
|
this._moddle = moddle;
|
|
|
|
}
|
|
|
|
|
|
|
|
IdClaimHandler.$inject = [ 'moddle' ];
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|