teambition-sdk-socket
Version:
Front-End SDK for Teambition
56 lines • 2.34 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Observable_1 = require("rxjs/Observable");
var BaseModel_1 = require("./BaseModel");
var Stage_1 = require("../schemas/Stage");
var index_1 = require("../utils/index");
var StageModel = (function (_super) {
__extends(StageModel, _super);
function StageModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._schemaName = 'Stage';
return _this;
}
StageModel.prototype.addStages = function (_tasklistId, stages) {
var result = index_1.datasToSchemas(stages, Stage_1.default);
return this._saveCollection("tasklist:stages/" + _tasklistId, result, this._schemaName, function (data) {
return data._tasklistId === _tasklistId && !data.isArchived;
});
};
StageModel.prototype.getStages = function (_tasklistId) {
return this._get("tasklist:stages/" + _tasklistId);
};
StageModel.prototype.addOne = function (stage) {
var result = index_1.dataToSchema(stage, Stage_1.default);
return this._save(result);
};
StageModel.prototype.getOne = function (_id) {
return this._get(_id);
};
StageModel.prototype.updateOrders = function (_tasklistId, ids) {
var stages = [];
index_1.forEach(ids, function (id, pos) {
stages.push({
_id: id,
order: pos
});
});
return Observable_1.Observable.combineLatest(this._updateCollection("tasklist:stages/" + _tasklistId, stages), this.update(_tasklistId, {
stageIds: ids
})).map(function (r) { return r[1]; });
};
return StageModel;
}(BaseModel_1.default));
exports.StageModel = StageModel;
exports.default = new StageModel;
//# sourceMappingURL=StageModel.js.map