Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 5x 5x 5x 5x 5x 5x 4x 2x 2x 1x 1x 5x 54x 54x 30x 24x | import { Component, OnInit } from "@angular/core"
import { UntypedFormControl, Validators, AbstractControl, ValidatorFn, FormsModule, ReactiveFormsModule } from "@angular/forms"
import { CustomConfigHelper } from "../../../../util/customConfigHelper"
import { buildCustomConfigFromState } from "../../../../util/customConfigBuilder"
import { ThreeCameraService } from "../../../codeMap/threeViewer/threeCamera.service"
import { ThreeMapControlsService } from "../../../codeMap/threeViewer/threeMapControls.service"
import { VisibleFilesBySelectionMode, visibleFilesBySelectionModeSelector } from "../../visibleFilesBySelectionMode.selector"
import { CcState } from "../../../../codeCharta.model"
import { State } from "@ngrx/store"
import { MatToolbar } from "@angular/material/toolbar"
import { CdkScrollable } from "@angular/cdk/scrolling"
import { MatDialogContent, MatDialogActions, MatDialogClose } from "@angular/material/dialog"
import { MatFormField, MatLabel, MatHint, MatError } from "@angular/material/form-field"
import { MatInput } from "@angular/material/input"
import { CdkTextareaAutosize } from "@angular/cdk/text-field"
import { DownloadAndPurgeConfigsComponent } from "./downloadAndPurgeConfigs/downloadAndPurgeConfigs.component"
import { MatButton } from "@angular/material/button"
@Component({
selector: "cc-add-custom-config-dialog",
templateUrl: "./addCustomConfigDialog.component.html",
standalone: true,
imports: [
MatToolbar,
CdkScrollable,
MatDialogContent,
MatFormField,
MatLabel,
MatInput,
FormsModule,
ReactiveFormsModule,
MatHint,
MatError,
CdkTextareaAutosize,
MatDialogActions,
DownloadAndPurgeConfigsComponent,
MatButton,
MatDialogClose
]
})
export class AddCustomConfigDialogComponent implements OnInit {
customConfigName: UntypedFormControl
customConfigNote: string
constructor(
private state: State<CcState>,
private threeCameraService: ThreeCameraService,
private threeOrbitControlsService: ThreeMapControlsService
) {}
ngOnInit(): void {
const visibleFilesBySelectionMode = visibleFilesBySelectionModeSelector(this.state.getValue())
this.customConfigName = new UntypedFormControl("", [
Validators.required,
createCustomConfigNameValidator(visibleFilesBySelectionMode)
])
this.customConfigName.setValue(CustomConfigHelper.getConfigNameSuggestionByFileState(visibleFilesBySelectionMode))
}
getErrorMessage() {
if (this.customConfigName.hasError("required")) {
return "Please enter a view name."
}
return this.customConfigName.hasError("Error") ? this.customConfigName.getError("Error") : ""
}
addCustomConfig() {
const newCustomConfig = buildCustomConfigFromState(
this.customConfigName.value,
this.state.getValue(),
{
camera: this.threeCameraService.camera.position,
cameraTarget: this.threeOrbitControlsService.controls.target
},
this.customConfigNote
)
CustomConfigHelper.addCustomConfig(newCustomConfig)
}
}
function createCustomConfigNameValidator(visibleFilesBySelectionMode: VisibleFilesBySelectionMode): ValidatorFn {
return (control: AbstractControl): { Error: string } => {
const desiredConfigName = control.value
if (
!CustomConfigHelper.hasCustomConfigByName(
visibleFilesBySelectionMode.mapSelectionMode,
visibleFilesBySelectionMode.assignedMaps,
desiredConfigName
)
) {
return null
}
return { Error: "A Custom View with this name already exists." }
}
}
|