Browse Source

Deleted segments

master
rozetko 6 years ago
parent
commit
483039aef0
  1. 7
      src/panel/graph_panel/controllers/analytic_controller.ts
  2. 3
      src/panel/graph_panel/models/analytic_unit.ts
  3. 12
      src/panel/graph_panel/services/analytic_service.ts

7
src/panel/graph_panel/controllers/analytic_controller.ts

@ -162,7 +162,7 @@ export class AnalyticController {
this.labelingUnit.segments.remove(s.id); this.labelingUnit.segments.remove(s.id);
}); });
this._labelingDataDeletedSegments.getSegments().forEach(s => { this._labelingDataDeletedSegments.getSegments().forEach(s => {
s.deleted = false; this.labelingUnit.segments.addSegment(s);
}); });
this.dropLabeling(); this.dropLabeling();
} }
@ -298,7 +298,7 @@ export class AnalyticController {
} }
} }
var expanded = s.expandDist(rangeDist, 0.01); const expanded = s.expandDist(rangeDist, 0.01);
options.grid.markings.push({ options.grid.markings.push({
xaxis: { from: expanded.from, to: expanded.to }, xaxis: { from: expanded.from, to: expanded.to },
color: segmentFillColor color: segmentFillColor
@ -317,11 +317,10 @@ export class AnalyticController {
} }
deleteLabelingAnalyticUnitSegmentsInRange(from: number, to: number) { deleteLabelingAnalyticUnitSegmentsInRange(from: number, to: number) {
let allRemovedSegs = this.labelingUnit.removeSegmentsInRange(from, to); const allRemovedSegs = this.labelingUnit.removeSegmentsInRange(from, to);
allRemovedSegs.forEach(s => { allRemovedSegs.forEach(s => {
if(!this._labelingDataAddedSegments.has(s.id)) { if(!this._labelingDataAddedSegments.has(s.id)) {
this._labelingDataDeletedSegments.addSegment(s); this._labelingDataDeletedSegments.addSegment(s);
this.labelingUnit.addLabeledSegment(s, true);
} }
}); });
this._labelingDataAddedSegments.removeInRange(from, to); this._labelingDataAddedSegments.removeInRange(from, to);

3
src/panel/graph_panel/models/analytic_unit.ts

@ -88,9 +88,6 @@ export class AnalyticUnit {
removeSegmentsInRange(from: number, to: number): AnalyticSegment[] { removeSegmentsInRange(from: number, to: number): AnalyticSegment[] {
let deletedSegments = this._segmentSet.removeInRange(from, to); let deletedSegments = this._segmentSet.removeInRange(from, to);
deletedSegments.forEach(s => {
s.deleted = true;
});
return deletedSegments; return deletedSegments;
} }

12
src/panel/graph_panel/services/analytic_service.ts

@ -66,20 +66,22 @@ export class AnalyticService {
} }
async updateSegments( async updateSegments(
id: AnalyticUnitId, addedSegments: SegmentsSet<Segment>, removedSegments: SegmentsSet<Segment> id: AnalyticUnitId, addedSegments: SegmentsSet<AnalyticSegment>, removedSegments: SegmentsSet<AnalyticSegment>
): Promise<SegmentId[]> { ): Promise<SegmentId[]> {
const getJSONs = (segs: SegmentsSet<Segment>) => segs.getSegments().map(segment => ({ const getJSONs = (segs: SegmentsSet<AnalyticSegment>) => segs.getSegments().map(segment => ({
from: segment.from, from: segment.from,
to: segment.to to: segment.to,
labeled: segment.labeled,
deleted: segment.deleted
})); }));
var payload = { const payload = {
id, id,
addedSegments: getJSONs(addedSegments), addedSegments: getJSONs(addedSegments),
removedSegments: removedSegments.getSegments().map(s => s.id) removedSegments: removedSegments.getSegments().map(s => s.id)
}; };
var data = await this.patch('/segments', payload); const data = await this.patch('/segments', payload);
if(data.addedIds === undefined) { if(data.addedIds === undefined) {
throw new Error('Server didn`t send addedIds'); throw new Error('Server didn`t send addedIds');
} }

Loading…
Cancel
Save