Skip to content

Commit

Permalink
undo/reset and reset All geneontology/noctua-annotation-review#30
Browse files Browse the repository at this point in the history
  • Loading branch information
tmushayahama committed Jan 5, 2021
1 parent 2235ffc commit 7ae9c19
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 33 deletions.
14 changes: 7 additions & 7 deletions src/@noctua.form/models/annoton/cam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,20 +199,20 @@ export class Cam {
});
}

findNodeById(id, annotons: Annoton[]): AnnotonNode {
findNodeById(uuid, annotons: Annoton[]): AnnotonNode {
const self = this;

let found
each(annotons, (annoton) => {
const found = find(annoton.nodes, (node: AnnotonNode) => {
return node.id === id;
found = find(annoton.nodes, (node: AnnotonNode) => {
return node.uuid === uuid;
});

if (found) {
return found
return false;
}
})

return null;
return found;
}

findAnnotonById(id) {
Expand Down Expand Up @@ -241,7 +241,7 @@ export class Cam {
each(self._annotons, (annoton: Annoton) => {
each(annoton.nodes, (node: AnnotonNode) => {
// node.term.highlight = false;
const found: AnnotonNode = self.findNodeById(node.id, self.storedAnnotons)
const found: AnnotonNode = self.findNodeById(node.uuid, self.storedAnnotons)
if (found && node.term.id !== found.term.id) {
node.term.termHistory.unshift(new Entity(found.term.id, found.term.label));
node.term.modified = true;
Expand Down
31 changes: 17 additions & 14 deletions src/@noctua.form/services/cams.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export class CamsService {
cam.storedGraph = new noctua_graph();
cam.storedGraph.load_data_basic(res.storedModel);
cam.storedAnnotons = self._noctuaGraphService.graphToAnnotons(cam.storedGraph)
console.log(cam.storedGraph)
cam.checkStored()
}

Expand Down Expand Up @@ -176,10 +177,6 @@ export class CamsService {
});
}

applyStored() {

}

replace(entities: Entity[], replaceWithTerm: Entity) {
const self = this;
const groupedEntities = groupBy(entities, 'modelId') as { string: Entity[] };
Expand Down Expand Up @@ -215,16 +212,7 @@ export class CamsService {
return forkJoin(promises);
}

resetModels() {
const self = this;
const promises = [];

each(this.cams, (cam: Cam) => {
promises.push(self._noctuaGraphService.resetModel(cam));
});

return forkJoin(promises);
}

reviewChanges() {
const self = this;
Expand Down Expand Up @@ -252,11 +240,26 @@ export class CamsService {
this.onCamsCheckoutChanged.next(result);
}

reset() {
clearCams() {
this.cams = [];
this.onCamsChanged.next(this.cams);
}

resetCam(cam: Cam) {
return this._noctuaGraphService.resetModel(cam);
}

resetCams() {
const self = this;
const promises = [];

each(this.cams, (cam: Cam) => {
promises.push(self._noctuaGraphService.resetModel(cam));
});

return forkJoin(promises);
}

resetMatch() {
const self = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<ng-container *ngIf="noctuaSearchMenuService.selectedMiddlePanel === MiddlePanel.camsReview">
<button (click)="clear()" type="button" mat-raised-button>Clear List</button>
<span fxFlex=""></span>
<button (click)='resetAll()' type="button" mat-raised-button color="" class="mr-8">Undo Changes</button>
<button (click)='resetCams()' type="button" mat-raised-button color="" class="mr-8">Undo Changes</button>
<button (click)="reviewChanges()" type="submit" class="" mat-raised-button color="primary">
Review Changes
</button>
Expand Down
25 changes: 17 additions & 8 deletions src/@noctua.search/components/art-basket/art-basket.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ export class ArtBasketComponent implements OnInit, OnDestroy {
this.noctuaSearchMenuService.scrollTo(q);
}

resetCam(cam: Cam) {
this.camService.loadCam(cam);
this.camsService.reviewChanges();
}


remove(cam: Cam) {
this.camsService.removeCamFromReview(cam);
Expand All @@ -90,7 +87,7 @@ export class ArtBasketComponent implements OnInit, OnDestroy {
if (cancel) {

this.noctuaReviewSearchService.clear();
this.camsService.reset();
this.camsService.clearCams();
this.noctuaReviewSearchService.clearBasket();
}
};
Expand Down Expand Up @@ -134,10 +131,22 @@ export class ArtBasketComponent implements OnInit, OnDestroy {
success, options);
}

resetAll() {
resetCam(cam: Cam) {
const self = this;

self.camsService.resetCam(cam).subscribe((cams) => {
if (cams) {
self.camsService.loadCams();
self.noctuaReviewSearchService.onReplaceChanged.next(true);
}
});
self.camsService.reviewChanges();
}

resetCams() {
const self = this;

self.camsService.resetModels().subscribe((cams) => {
self.camsService.resetCams().subscribe((cams) => {
if (cams) {
self.camsService.loadCams();
self.noctuaReviewSearchService.onReplaceChanged.next(true);
Expand Down Expand Up @@ -172,7 +181,7 @@ export class ArtBasketComponent implements OnInit, OnDestroy {
self.noctuaSearchMenuService.selectMiddlePanel(MiddlePanel.cams);
self.noctuaSearchMenuService.selectLeftPanel(LeftPanel.filter);
self.noctuaReviewSearchService.clear();
self.camsService.reset();
self.camsService.clearCams();
self.noctuaReviewSearchService.clearBasket();
self.noctuaReviewSearchService.onResetReview.next(true);
self.zone.run(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ export class CamsTableComponent implements OnInit, OnDestroy {

this.noctuaReviewSearchService.onResetReview
.pipe(takeUntil(this._unsubscribeAll))
.subscribe((reset: boolean) => {
if (reset) {
this.camsService.reset();
.subscribe((remove: boolean) => {
if (remove) {
this.camsService.clearCams();
this.selection.clear();
}
});
Expand Down Expand Up @@ -200,6 +200,10 @@ export class CamsTableComponent implements OnInit, OnDestroy {
}
});

this.camsService.bulkStoredModel().subscribe((cams) => {
console.log('stored', cams)
});

}

/** The label for the checkbox on the passed row */
Expand Down

0 comments on commit 7ae9c19

Please sign in to comment.