Skip to content

Commit 76472e0

Browse files
authored
Merge pull request #170 from scholarsportal/nana-dev
Fixes for updating weights, cross-tabulation
2 parents dc25a05 + 64d014a commit 76472e0

26 files changed

Lines changed: 381 additions & 318 deletions

angular.json

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,12 @@
1414
"builder": "@angular-devkit/build-angular:browser",
1515
"options": {
1616
"outputPath": "dist",
17-
"allowedCommonJsDependencies": [
18-
"fast-xml-parser"
19-
],
17+
"allowedCommonJsDependencies": ["fast-xml-parser"],
2018
"index": "src/index.html",
2119
"main": "src/main.ts",
22-
"polyfills": [
23-
"zone.js"
24-
],
20+
"polyfills": ["zone.js"],
2521
"tsConfig": "tsconfig.app.json",
26-
"assets": [
27-
"src/favicon.ico",
28-
"src/assets"
29-
],
22+
"assets": ["src/favicon.ico", "src/assets"],
3023
"styles": [
3124
"src/styles.css",
3225
"node_modules/primeng/resources/primeng.min.css"
@@ -92,38 +85,25 @@
9285
"builder": "@angular-devkit/build-angular:karma",
9386
"options": {
9487
"codeCoverage": true,
95-
"polyfills": [
96-
"zone.js",
97-
"zone.js/testing"
98-
],
88+
"polyfills": ["zone.js", "zone.js/testing"],
9989
"tsConfig": "tsconfig.spec.json",
100-
"assets": [
101-
"src/favicon.ico",
102-
"src/assets"
103-
],
104-
"styles": [
105-
"src/styles.css"
106-
],
90+
"assets": ["src/favicon.ico", "src/assets"],
91+
"styles": ["src/styles.css"],
10792
"scripts": [],
10893
"karmaConfig": "karma.conf.js"
10994
}
11095
},
11196
"lint": {
11297
"builder": "@angular-eslint/builder:lint",
11398
"options": {
114-
"lintFilePatterns": [
115-
"src/**/*.ts",
116-
"src/**/*.html"
117-
]
99+
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
118100
}
119101
}
120102
}
121103
}
122104
},
123105
"cli": {
124106
"analytics": false,
125-
"schematicCollections": [
126-
"@angular-eslint/schematics"
127-
]
107+
"schematicCollections": ["@angular-eslint/schematics"]
128108
}
129109
}

src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export class AppComponent implements OnInit, OnDestroy {
107107
this.route.queryParams
108108
.pipe(takeUntil(this.destroy$))
109109
.subscribe((params) => {
110+
this.setTheme();
110111
const callback = (params['callback'] as string) || null;
111112
const siteURL = params['siteUrl'] as string;
112113
const fileID =
@@ -145,7 +146,6 @@ export class AppComponent implements OnInit, OnDestroy {
145146
}),
146147
);
147148
}
148-
this.setTheme();
149149
});
150150
}
151151

src/app/components/body/cross-tabulation/cross-table/cross-table.component.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ export class CrossTableComponent {
3333
cols = input.required<string[]>();
3434
hasData = input.required<boolean>();
3535
selectedViewOption = input<string>('Count');
36+
aggregatorName = input.required<string>();
3637
element: ElementRef = inject(ElementRef);
3738

38-
constructor(private liveAnnouncer: LiveAnnouncer, private translate: TranslateService) {
39+
constructor(
40+
private liveAnnouncer: LiveAnnouncer,
41+
private translate: TranslateService,
42+
) {
3943
effect(() => {
4044
if (this.data() && (this.rows() || this.cols())) {
4145
this.createTable();
@@ -73,10 +77,14 @@ export class CrossTableComponent {
7377
rendererName: 'Table',
7478
showUI: false,
7579
});
76-
let txt: string = "";
77-
this.translate.get("CROSS_TABULATION.TABLE_MESSAGE").subscribe((res: string) => {
78-
txt = res;
79-
});
80-
setTimeout(() => {this.liveAnnouncer.announce(txt);},2000);
80+
let txt: string = '';
81+
this.translate
82+
.get('CROSS_TABULATION.TABLE_MESSAGE')
83+
.subscribe((res: string) => {
84+
txt = res;
85+
});
86+
setTimeout(() => {
87+
this.liveAnnouncer.announce(txt);
88+
}, 2000);
8189
}
8290
}

src/app/components/body/cross-tabulation/cross-tabulation.component.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@
5757
[ngModel]="selectedWeightVariable()"
5858
[options]="variablesWithWeightedOnTop()"
5959
(onChange)="onWeightChange($event)"
60+
[showClear]="!!this.selectedWeightVariable()"
6061
placeholder="{{ 'CROSS_TABULATION.SELECT' | translate }}"
6162
styleClass="select border w-1/5 py-1.5 mr-0 md:mr-5"
6263
panelStyleClass="rounded border rounded-t-none w-full h-full text-base-content bg-base-100"
6364
>
65+
<ng-template pTemplate="selectedItem">
66+
{{ getSelectedWeightVariableToString() }}
67+
</ng-template>
6468
<ng-template let-item pTemplate="item">
6569
<span class="flex flex-row w-full px-2.5 py-0.5 hover:bg-base-300">
6670
{{ item.labl['#text'] }}
@@ -107,6 +111,7 @@
107111
[rows]="rows()"
108112
[cols]="cols()"
109113
[hasData]="hasData()"
114+
[aggregatorName]="selectedOptionComputed()"
110115
class="my-auto graph-area"
111116
></dct-cross-table>
112117
} @else if (defaultDataView() === 'Chart') {

src/app/components/body/cross-tabulation/cross-tabulation.component.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import {
33
ChangeDetectionStrategy,
44
Component,
55
computed,
6-
effect,
76
inject,
87
signal,
9-
OnInit
8+
OnInit,
109
} from '@angular/core';
1110
import { Store } from '@ngrx/store';
1211
import { CrossTableComponent } from './cross-table/cross-table.component';
@@ -44,15 +43,18 @@ import { TranslateModule, TranslateService } from '@ngx-translate/core';
4443
FormsModule,
4544
CrossChartComponent,
4645
SelectButtonModule,
47-
TranslateModule
46+
TranslateModule,
4847
],
4948
templateUrl: './cross-tabulation.component.html',
5049
styleUrl: './cross-tabulation.component.css',
5150
changeDetection: ChangeDetectionStrategy.OnPush,
5251
})
5352
export class CrossTabulationComponent implements OnInit {
5453
loadingStatus: 'init' | 'delayed' | '' = '';
54+
filterValue: string = '';
5555
store = inject(Store);
56+
liveAnnouncer = inject(LiveAnnouncer);
57+
translate = inject(TranslateService);
5658
variables = this.store.selectSignal(selectDatasetProcessedVariables);
5759
crossTabVariables = this.store.selectSignal(
5860
selectDatasetVariableCrossTabValues,
@@ -87,7 +89,7 @@ export class CrossTabulationComponent implements OnInit {
8789
table = computed(() => this.tableData().pivotData);
8890

8991
opt1 = 'test';
90-
92+
9193
options = signal([
9294
'SHOW_VALUE',
9395
// 'Weighted Value',
@@ -97,7 +99,7 @@ export class CrossTabulationComponent implements OnInit {
9799
]);
98100

99101
selectedOption = signal('SHOW_VALUE');
100-
102+
101103
selectedOptionComputed = computed(() => {
102104
switch (this.selectedOption()) {
103105
case 'SHOW_VALUE':
@@ -113,20 +115,17 @@ export class CrossTabulationComponent implements OnInit {
113115
}
114116
});
115117

116-
constructor(private liveAnnouncer: LiveAnnouncer, private translate: TranslateService) {
117-
effect(() => {
118-
if (this.isFetching()) {
119-
this.fetchingCheck();
120-
} else {
121-
this.loadingStatus = '';
122-
}
123-
});
118+
ngOnInit(): void {
119+
this.translate
120+
.get('CROSS_TABULATION.SHOW_VALUE')
121+
.subscribe((res: string) => {
122+
this.opt1 = res;
123+
});
124124
}
125125

126-
ngOnInit(): void {
127-
this.translate.get("CROSS_TABULATION.SHOW_VALUE").subscribe((res: string) => {
128-
this.opt1 = res;
129-
});
126+
getSelectedWeightVariableToString() {
127+
const fullVariable = this.variables()[this.selectedWeightVariable()];
128+
return fullVariable['labl']['#text'];
130129
}
131130

132131
fetchingCheck() {
@@ -143,20 +142,21 @@ export class CrossTabulationComponent implements OnInit {
143142
orientation: '',
144143
}),
145144
);
146-
let txt: string = "";
147-
this.translate.get("CROSS_TABULATION.NEW_ROW").subscribe((res: string) => {
145+
let txt: string = '';
146+
this.translate.get('CROSS_TABULATION.NEW_ROW').subscribe((res: string) => {
148147
txt = res;
149148
});
150149
this.liveAnnouncer.announce(txt);
151150
}
152151

153-
onWeightChange(event: { value: Variable }) {
154-
const variable: Variable = event.value;
155-
const variableID = variable['@_ID'];
152+
onWeightChange(event: { value: Variable | null }) {
153+
const variable: Variable | null = event?.value;
154+
const variableID = variable?.['@_ID'];
156155
const crossTabValues = this.crossTabVariables();
156+
console.log(event, 'variableID');
157157
this.store.dispatch(
158-
CrossTabulationUIActions.startVariableWeightSelection({
159-
variableID,
158+
CrossTabulationUIActions.addWeightVariableToSelection({
159+
variableID: variableID ?? null,
160160
crossTabValues,
161161
}),
162162
);

src/app/components/body/variables/data/data.component.html

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/app/components/body/variables/data/data.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import {
2929
selector: 'dct-data',
3030
standalone: true,
3131
imports: [TableComponent],
32-
templateUrl: './data.component.html',
32+
// templateUrl: './data.component.html',
33+
template: ` <dct-table class="md:flex flex-col w-full table" /> `,
3334
styleUrl: './data.component.css',
3435
//changeDetection: ChangeDetectionStrategy.OnPush,
3536
})

src/app/components/body/variables/data/table-menu/table-menu.component.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { DropdownModule } from 'primeng/dropdown';
1414
import { XmlManipulationActions } from '../../../../../new.state/xml/xml.actions';
1515
import { BulkEditModalComponent } from '../table/bulk-edit-modal/bulk-edit-modal.component';
1616
import { TranslateModule } from '@ngx-translate/core';
17+
import { selectCrossTabSelection } from 'src/app/new.state/ui/ui.selectors';
18+
import { selectDatasetVariableCrossTabValues } from 'src/app/new.state/dataset/dataset.selectors';
1719
// import { Variable, VariableGroup } from 'src/app/state/interface';
1820
// import {
1921
// bulkChangeGroupsAndWeight,
@@ -25,7 +27,6 @@ import { TranslateModule } from '@ngx-translate/core';
2527
standalone: true,
2628
imports: [
2729
CommonModule,
28-
MultiselectDropdownComponent,
2930
MultiSelectModule,
3031
DropdownModule,
3132
ChipModule,
@@ -52,9 +53,10 @@ export class TableMenuComponent {
5253
selectedWeight: string = '';
5354
selectedGroups: string[] = [];
5455
allVariables = input.required<{ [variableID: string]: Variable }>();
55-
variablesWithCrossTabMetadata = input.required<{
56-
[variableID: string]: string[];
57-
}>();
56+
variablesWithCrossTabMetadata = this.store.selectSignal(
57+
selectDatasetVariableCrossTabValues,
58+
);
59+
variablesInCrossTab = this.store.selectSignal(selectCrossTabSelection);
5860
weights = input.required<{ [weightID: string]: string }>();
5961
allGroups = input.required<{ [id: string]: VariableGroup }>();
6062
allGroupsArray = computed(() => {
@@ -93,13 +95,13 @@ export class TableMenuComponent {
9395
onApplyChanges() {
9496
if (this.selectedGroups.length > 0 || this.selectedWeight) {
9597
this.store.dispatch(
96-
XmlManipulationActions.bulkSaveVariableInfo({
98+
XmlManipulationActions.bulkSaveWeightAndGroupChange({
9799
variableIDs: this.selectedVariables(),
98-
assignedWeight: this.selectedWeight,
99-
groups: this.selectedGroups,
100100
allVariables: this.allVariables(),
101-
variablesWithCrossTabMetadata: this.variablesWithCrossTabMetadata(),
102-
typeOfChange: 'partial',
101+
groupsToUpdate: this.selectedGroups,
102+
weightToUpdate: this.selectedWeight,
103+
allGroups: this.allGroups(),
104+
crossTabMetadata: this.variablesWithCrossTabMetadata(),
103105
}),
104106
);
105107
this.saved = true;

src/app/components/body/variables/data/table/bulk-edit-modal/bulk-edit-modal.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@ export class BulkEditModalComponent {
6060
notes: this.variableForm.value.notes || '',
6161
};
6262
this.store.dispatch(
63-
XmlManipulationActions.bulkSaveVariableInfo({
63+
XmlManipulationActions.bulkSaveVariableModal({
6464
variableIDs: this.selectedVariables(),
6565
newVariableValue,
6666
allVariables: this.allVariables(),
6767
variablesWithCrossTabMetadata: this.variablesWithCrossTabMetadata(),
68-
typeOfChange: 'full',
6968
}),
7069
);
7170

src/app/components/body/variables/data/table/modal/chart/chart.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { TranslateModule } from '@ngx-translate/core';
2828
CommonModule,
2929
SummaryStatisticsComponent,
3030
VariableInformationComponent,
31-
TranslateModule
31+
TranslateModule,
3232
],
3333
changeDetection: ChangeDetectionStrategy.OnPush,
3434
templateUrl: './chart.component.html',
@@ -151,12 +151,12 @@ export class ChartComponent implements OnInit {
151151
this.chartJS.data.labels = chart.map((item) => item.y); // Update labels
152152
this.chartJS.data.datasets[0].data = chart.map((item) => item.x); // Update data
153153
this.chartJS.update();
154-
154+
155155
const light = 'black';
156156
const dark = 'white';
157157
const neutral = '#c8c5d0';
158158
const theme = localStorage.getItem('theme');
159-
159+
160160
if (theme === 'light') {
161161
this.chartJS.options.scales.x.grid.color = neutral;
162162
this.chartJS.options.scales.y.grid.color = neutral;

0 commit comments

Comments
 (0)