rework config updates to fix drag and drop

This commit is contained in:
Joel Wetzell
2026-06-01 19:28:43 -05:00
parent 947fd14364
commit 31f42e696d
3 changed files with 14 additions and 20 deletions
@@ -7,9 +7,9 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { cloneDeep } from 'lodash-es';
import { ModuleConfig } from '../../models/config';
import { ListsService } from '../../services/lists';
import { SchemaService } from '../../services/schema';
import { ModuleComponent } from '../module/module';
import { ListsService } from '../../services/lists';
@Component({
selector: 'app-module-list',
@@ -75,7 +75,6 @@ export class ModuleListComponent {
}
drop(event: CdkDragDrop<ModuleConfig[] | undefined>) {
console.log('Drop event:', event);
if (event.previousContainer === event.container) {
const currentModules = this.modules();
if (currentModules === undefined) {
+1 -2
View File
@@ -14,9 +14,9 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { cloneDeep } from 'lodash-es';
import { RouteConfig } from '../../models/config';
import { ListsService } from '../../services/lists';
import { SchemaService } from '../../services/schema';
import { RouteComponent } from '../route/route';
import { ListsService } from '../../services/lists';
@Component({
selector: 'app-route-list',
@@ -123,7 +123,6 @@ export class RouteListComponent {
}
drop(event: CdkDragDrop<RouteConfig[] | undefined>) {
console.log('Drop event:', event);
if (event.previousContainer === event.container) {
const currentRoutes = this.routes();
if (currentRoutes === undefined) {
+12 -16
View File
@@ -17,17 +17,18 @@ import { SettingsService } from './settings';
})
export class ConfigService {
pendingConfigIsValid = computed(() => {
const config = this.currentlyShownConfig();
const config = this._currentlyShownConfig();
if (config === undefined) {
return false;
}
return this.schemaService.validate(this.schemaService.configSchemaId, config);
});
currentlyShownConfig = signal<Config | undefined>(undefined);
runningConfig = signal<Config | undefined>(undefined);
private runningConfig = signal<Config | undefined>(undefined);
private _currentlyShownConfig = signal<Config | undefined>(undefined);
readonly currentlyShownConfig = this._currentlyShownConfig.asReadonly();
configIsDirty = computed(() => {
const currentlyShown = this.currentlyShownConfig();
const currentlyShown = this._currentlyShownConfig();
const running = this.runningConfig();
if (currentlyShown === undefined || running === undefined) {
return false;
@@ -44,7 +45,7 @@ export class ConfigService {
constructor(private schemaService: SchemaService) {
effect(() => {
console.log('config state changed', this.currentlyShownConfig());
console.log('config state changed', this._currentlyShownConfig());
});
effect(() => {
@@ -124,27 +125,22 @@ export class ConfigService {
}
updateCurrentlyShownConfig(config: Config) {
if (isEqual(config, this.currentlyShownConfig())) {
// NOTE(jwetzell): no update
return;
}
this.currentlyShownConfig.set(cloneDeep(config));
this._currentlyShownConfig.set(cloneDeep(config));
}
updateModules(modules: ModuleConfig[]) {
const currentConfig = this.currentlyShownConfig();
if (!currentConfig) {
var newConfig = cloneDeep(this._currentlyShownConfig());
if (!newConfig) {
console.error('No currently shown config to update modules on');
return;
}
newConfig.modules = cloneDeep(modules);
currentConfig.modules = cloneDeep(modules);
this.updateCurrentlyShownConfig(currentConfig);
this.updateCurrentlyShownConfig(newConfig);
}
updateRoutes(routes: RouteConfig[]) {
const currentConfig = this.currentlyShownConfig();
const currentConfig = this._currentlyShownConfig();
if (!currentConfig) {
console.error('No currently shown config to update routes on');
return;