|
|
|
@ -22,7 +22,7 @@ import { EditNotesComponentDialog } from './notes/notes.component';
|
|
|
|
|
import { open } from '@tauri-apps/api/dialog';
|
|
|
|
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
|
|
|
import { MatInputModule } from '@angular/material/input';
|
|
|
|
|
import { MatSelectModule} from '@angular/material/select';
|
|
|
|
|
import { MatSelectModule } from '@angular/material/select';
|
|
|
|
|
import { MatButtonModule } from '@angular/material/button';
|
|
|
|
|
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
|
|
|
|
|
|
|
@ -122,11 +122,17 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dropEndHandler(event: CdkDragDrop<WorldArea[]> | CdkDragDrop<PlanElement[]>) {
|
|
|
|
|
let bounds = this.planElemFilterBounds();
|
|
|
|
|
let end = this.plan.plan.length;
|
|
|
|
|
if (bounds) {
|
|
|
|
|
end = bounds[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isWorldAreaEvent(event) && this.areas) {
|
|
|
|
|
this.plan.plan.splice(this.plan.plan.length, 0, this.planItemFromArea(event.previousContainer.data[event.previousIndex]));
|
|
|
|
|
this.plan.plan.splice(end, 0, this.planItemFromArea(event.previousContainer.data[event.previousIndex]));
|
|
|
|
|
this.scrollToEnd();
|
|
|
|
|
} else {
|
|
|
|
|
moveItemInArray(this.plan.plan, event.previousIndex, this.plan.plan.length);
|
|
|
|
|
moveItemInArray(this.plan.plan, event.previousIndex, end);
|
|
|
|
|
this.scrollToEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -175,15 +181,51 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
this.scrollToEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
planElemFilterBounds() {
|
|
|
|
|
if(this.planFilterAct.value !== 0) {
|
|
|
|
|
let bounds = this.plan.plan.filter(item => item.anchor_act === this.planFilterAct.value || this.planFilterAct.value + 1 === item.anchor_act).map((value) => this.planIndexOf(value));
|
|
|
|
|
console.log("bounds, ", bounds);
|
|
|
|
|
if (bounds.length == 2) {
|
|
|
|
|
return bounds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bounds.length == 1 && this.planFilterAct.value == 10) {
|
|
|
|
|
console.log("Setting bound to last index");
|
|
|
|
|
bounds[1] = this.plan.plan.length;
|
|
|
|
|
return bounds;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
filterPlanElements() {
|
|
|
|
|
const value = (): any[] => {
|
|
|
|
|
if (this.planSearchString !== "" || this.planFilterAct.value != 0) {
|
|
|
|
|
if (this.planSearchString !== "") {
|
|
|
|
|
this.disabledPlanDD = true;
|
|
|
|
|
return this.planFuzzer.search(this.planSearchString).map(({ item }) => item).filter(item => {
|
|
|
|
|
return this.areasMap?.get(item.area_key)?.act === this.planFilterAct.value || this.planFilterAct.value === 0;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.disabledPlanDD = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.planSearchString !== "" || this.planFilterAct.value != 0) {
|
|
|
|
|
let bounds = this.planElemFilterBounds();
|
|
|
|
|
|
|
|
|
|
const searched = this.planFuzzer.search(this.planSearchString).map(({ item }) => item);
|
|
|
|
|
|
|
|
|
|
if (bounds) {
|
|
|
|
|
const definedBounds: number[] = bounds;
|
|
|
|
|
return searched.filter(item => {
|
|
|
|
|
const index = this.planIndexOf(item);
|
|
|
|
|
return index >= definedBounds[0] && index < definedBounds[1];
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
return searched.filter(item => {
|
|
|
|
|
return this.areasMap?.get(item.area_key)?.act === this.planFilterAct.value || this.planFilterAct.value === 0;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return this.plan.plan;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -254,7 +296,7 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
dialogRef.afterClosed().subscribe(note => {
|
|
|
|
|
if(note) {
|
|
|
|
|
if (note) {
|
|
|
|
|
if (item.notes !== note) {
|
|
|
|
|
item.edited = true;
|
|
|
|
|
}
|
|
|
|
|