Skip to content

Commit c255fbb

Browse files
committed
fix(groups): fix adding variables to groups
1 parent e47e768 commit c255fbb

3 files changed

Lines changed: 26 additions & 17 deletions

File tree

src/app/components/body/variables/sidebar/group-button/group-button.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class GroupButtonComponent {
2222
if (this.newGroupName) {
2323
this.emitConfirm.emit(this.newGroupName);
2424
this.adding.set(false);
25+
this.newGroupName = '';
2526
}
2627
}
2728

src/app/components/body/variables/sidebar/sidebar-button/sidebar-button.component.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { RenamingSidebarButtonComponent } from './renaming-button/renaming-sideb
1313
import { DeletingSidebarButtonComponent } from './deleting-button/deleting-sidebar-button.component';
1414
import { TranslateModule } from '@ngx-translate/core';
1515
import { VariableTabUIAction } from 'src/app/new.state/ui/ui.actions';
16+
import { XmlManipulationActions } from 'src/app/new.state/xml/xml.actions';
1617

1718
@Component({
1819
selector: 'dct-sidebar-button',
@@ -35,10 +36,6 @@ export class SidebarButtonComponent {
3536
selected = input.required<boolean>();
3637
disabledOptions = input<boolean>(false);
3738

38-
changeSelectedGroupID = output<string>();
39-
emitDeleteGroup = output<string>();
40-
emitRenameGroup = output<{ groupID: string; newLabel: string }>();
41-
4239
renaming = signal(false);
4340
renamingActive = computed(() => {
4441
return this.selected() && this.renaming();
@@ -54,34 +51,41 @@ export class SidebarButtonComponent {
5451
this.store.dispatch(
5552
VariableTabUIAction.changeSelectedGroupID({ groupID: this.groupID() }),
5653
);
57-
// const elem = document.activeElement;
58-
//if (elem instanceof HTMLElement) {
59-
//elem?.blur();
60-
//}
61-
// setTimeout(()=>{
62-
// const heading = document.querySelector('#tableHeading');
63-
// if (heading) {
64-
// (heading as HTMLElement)?.focus();
65-
// }
66-
// },1000)
54+
const elem = document.activeElement;
55+
if (elem instanceof HTMLElement) {
56+
elem?.blur();
57+
}
58+
setTimeout(() => {
59+
const heading = document.querySelector('#tableHeading');
60+
if (heading) {
61+
(heading as HTMLElement)?.focus();
62+
}
63+
}, 1000);
6764
}
6865

6966
delete() {
7067
this.deleting.set(true);
7168
}
7269

7370
confirmDelete() {
71+
this.store.dispatch(
72+
XmlManipulationActions.deleteGroup({ groupID: this.groupID() }),
73+
);
7474
this.resetUI();
75-
this.emitDeleteGroup.emit(this.groupID());
7675
}
7776

7877
rename() {
7978
this.renaming.set(true);
8079
}
8180

8281
confirmRename(newLabel: string) {
82+
this.store.dispatch(
83+
XmlManipulationActions.renameGroup({
84+
groupID: this.groupID(),
85+
newLabel,
86+
}),
87+
);
8388
this.resetUI();
84-
this.emitRenameGroup.emit({ groupID: this.groupID(), newLabel });
8589
}
8690

8791
resetUI() {

src/app/new.state/xml/xml.util.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,11 @@ export function changeGroupsForSingleVariable(
265265
// Then insert variable ID in selected groups
266266
dereferencedArray.forEach((variableGroup) => {
267267
if (groups.includes(variableGroup['@_ID'])) {
268-
variableGroup['@_var'] = variableGroup['@_var'] + ' ' + variableID;
268+
if (variableGroup['@_var']?.split(' ').length) {
269+
variableGroup['@_var'] = variableGroup['@_var'] + ' ' + variableID;
270+
} else {
271+
variableGroup['@_var'] = '' + variableID + '';
272+
}
269273
}
270274
updatedGroupArray.push(variableGroup);
271275
});

0 commit comments

Comments
 (0)