estimate-library
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -21,2 +21,3 @@ "use strict"; | ||
Table.prototype.setConfig = config_1.setConfig; | ||
Table.prototype.toggleTaskInSection = core_1.toggleTaskInSection; | ||
exports.default = Table; |
@@ -58,2 +58,3 @@ import ITable from "../types/ITable"; | ||
export declare function updateTaskDepValue(this: ITable, sectionId: string, taskId: string, depId: number, value: number): void; | ||
export declare function toggleTaskInSection(this: ITable, sectionId: string, taskId: string): void; | ||
export declare function calculateTable(this: ITable): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.calculateTable = exports.updateTaskDepValue = exports.updateRowName = exports.updateSectionName = exports.duplicateRow = exports.duplicateSection = exports.deleteRow = exports.addRow = exports.deleteSection = exports.addSection = exports.createTable = void 0; | ||
exports.calculateTable = exports.toggleTaskInSection = exports.updateTaskDepValue = exports.updateRowName = exports.updateSectionName = exports.duplicateRow = exports.duplicateSection = exports.deleteRow = exports.addRow = exports.deleteSection = exports.addSection = exports.createTable = void 0; | ||
var sections_1 = require("./sections"); | ||
@@ -134,2 +134,12 @@ var row_1 = require("./row"); | ||
exports.updateTaskDepValue = updateTaskDepValue; | ||
function toggleTaskInSection(sectionId, taskId) { | ||
var _this = this; | ||
this.sections = this.sections.map(function (section) { | ||
if (section.id === sectionId) | ||
return sections_1.toggleRowInSection.call(_this, section, taskId); | ||
return section; | ||
}); | ||
calculateTable.call(this); | ||
} | ||
exports.toggleTaskInSection = toggleTaskInSection; | ||
function calculateSubtotal() { | ||
@@ -136,0 +146,0 @@ var subtotal = (0, row_1.resetRowDepartments)(this.subtotal); |
@@ -10,2 +10,3 @@ import IRow from "../types/IRow"; | ||
export declare function deleteDepartmentFromRow(this: ITable, row: IRow, depId: number): IRow; | ||
export declare function toggleRow(this: ITable, row: IRow): IRow; | ||
export declare const resetRowDepartments: (row: IRow) => IRow; |
@@ -23,3 +23,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resetRowDepartments = exports.deleteDepartmentFromRow = exports.updateDepartmentInRow = exports.addDepartmentToRow = exports.updateRowName = exports.duplicateRow = exports.createRow = void 0; | ||
exports.resetRowDepartments = exports.toggleRow = exports.deleteDepartmentFromRow = exports.updateDepartmentInRow = exports.addDepartmentToRow = exports.updateRowName = exports.duplicateRow = exports.createRow = void 0; | ||
var uuid_1 = require("uuid"); | ||
@@ -31,2 +31,3 @@ var calculations_1 = require("./calculations"); | ||
id: (0, uuid_1.v4)(), | ||
isDisabled: false, | ||
name: name, | ||
@@ -61,2 +62,7 @@ departments: departments, | ||
exports.deleteDepartmentFromRow = deleteDepartmentFromRow; | ||
function toggleRow(row) { | ||
return calculations_1.calculateRow.call(this, __assign(__assign({}, row), { isDisabled: !row.isDisabled })); | ||
} | ||
exports.toggleRow = toggleRow; | ||
; | ||
var resetRowDepartments = function (row) { | ||
@@ -63,0 +69,0 @@ return __assign(__assign({}, row), { departments: row.departments.map(function (dep) { return (__assign(__assign({}, dep), { value: 0 })); }) }); |
@@ -14,2 +14,3 @@ import IDepartment from "../types/IDepartment"; | ||
export declare function updateDepartmentValueInSection(this: ITable, section: ISection, rowId: string, depId: number, value: number): ISection; | ||
export declare function toggleRowInSection(this: ITable, section: ISection, rowId: string): ISection; | ||
export declare function calculateSection(this: ITable, section: ISection): ISection; |
@@ -23,3 +23,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.calculateSection = exports.updateDepartmentValueInSection = exports.deleteDepartmentFromSection = exports.addDepartmentToSection = exports.updateTask = exports.updateNameSection = exports.deleteRowFromSection = exports.duplicateRowInSection = exports.createDuplicateSection = exports.createRowInSection = exports.createSection = void 0; | ||
exports.calculateSection = exports.toggleRowInSection = exports.updateDepartmentValueInSection = exports.deleteDepartmentFromSection = exports.addDepartmentToSection = exports.updateTask = exports.updateNameSection = exports.deleteRowFromSection = exports.duplicateRowInSection = exports.createDuplicateSection = exports.createRowInSection = exports.createSection = void 0; | ||
var uuid_1 = require("uuid"); | ||
@@ -87,6 +87,17 @@ var row_1 = require("./row"); | ||
exports.updateDepartmentValueInSection = updateDepartmentValueInSection; | ||
function toggleRowInSection(section, rowId) { | ||
var _this = this; | ||
return calculateSection.call(this, __assign(__assign({}, section), { tasks: section.tasks.map(function (task) { | ||
if (task.id === rowId) | ||
return row_1.toggleRow.call(_this, task); | ||
return task; | ||
}) })); | ||
} | ||
exports.toggleRowInSection = toggleRowInSection; | ||
; | ||
function calculateSection(section) { | ||
var total = (0, row_1.resetRowDepartments)(section.total); | ||
section.tasks.forEach(function (task) { | ||
task.departments.forEach(function (dep, d) { return total.departments[d].value += dep.value; }); | ||
if (!task.isDisabled) | ||
task.departments.forEach(function (dep, d) { return total.departments[d].value += dep.value; }); | ||
}); | ||
@@ -93,0 +104,0 @@ return __assign(__assign({}, section), { total: calculations_1.calculateRow.call(this, total) }); |
import IDepartment from "./IDepartment"; | ||
export default interface IRow { | ||
id: string; | ||
isDisabled: boolean; | ||
name: string; | ||
@@ -5,0 +6,0 @@ departments: Array<IDepartment>; |
{ | ||
"name": "estimate-library", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
26237
623