Skip to content

Commit 07cbb0f

Browse files
authored
Merge pull request #186 from scholarsportal/nana-dev
fix weighting issues, alphabetized group list
2 parents bbf2ba1 + 6bcad7c commit 07cbb0f

5 files changed

Lines changed: 20 additions & 9 deletions

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ <h2 class="sr-only">{{ 'TABLE_MENU.VAR_TABLE_OPTS' | translate }}</h2>
9696
name="assign-weight"
9797
[disabled]="variablesSelected()"
9898
>
99-
<option disabled hidden selected value="">
99+
<option disabled hidden selected [value]="''">
100100
{{ 'TABLE_MENU.ASSIGN_WEIGHT' | translate }}
101101
</option>
102+
<option [value]="''">
103+
{{ 'TABLE_MENU.NO_CHANGE' | translate }}
104+
</option>
102105
<option [value]="'remove'">
103106
{{ 'TABLE_MENU.REMOVE_WEIGHT' | translate }}
104107
</option>

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ export class EditComponent {
5151
}>();
5252
allGroups = input.required<{ [groupID: string]: VariableGroup }>();
5353
allGroupsArray = computed(() => {
54-
return Object.keys(this.allGroups());
54+
const groups = Object.keys(this.allGroups());
55+
const alphabetizedGroups = groups.sort((a, b) => {
56+
const labelA = this.allGroups()[a].labl;
57+
const labelB = this.allGroups()[b].labl;
58+
return labelA.localeCompare(labelB);
59+
});
60+
return alphabetizedGroups;
5561
});
5662
decodedVariableGroups = computed(() => {
57-
// console.log(this.variableGroups());
5863
const varGroups: string[] = [];
5964
Object.values(this.allGroups()).map((group) => {
6065
varGroups.push(group.labl);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,37 +125,37 @@ export function changeWeightForSelectedVariables(
125125
Object.keys(frequencyTableForSelectedVariables).forEach((variableID) => {
126126
if (duplicateVariables[variableID]) {
127127
const currentCategories = duplicateVariables[variableID].catgry;
128+
console.log('Weight ID: ', !!weightID);
128129
if (currentCategories && Array.isArray(currentCategories)) {
129130
currentCategories.map((category) => {
130131
if (Array.isArray(category.catStat)) {
131132
category.catStat = [
132133
category.catStat[0],
133134
{
134135
'#text':
135-
weightID.length && weightID !== 'remove'
136+
weightID !== 'remove'
136137
? frequencyTableForSelectedVariables[variableID][
137138
category.catValu
138139
] || 0
139140
: 0,
140141
'@_type': 'freq',
141142
'@_wgtd': 'wgtd',
142-
'@_wgt-var': weightID,
143+
'@_wgt-var': weightID !== 'remove' ? weightID : '',
143144
},
144145
];
145146
} else {
146147
category.catStat = [
147148
category.catStat,
148149
{
149150
'#text':
150-
weightID.length && weightID !== 'remove'
151+
weightID !== 'remove'
151152
? frequencyTableForSelectedVariables[variableID][
152153
category.catValu
153154
] || 0
154155
: 0,
155156
'@_type': 'freq',
156157
'@_wgtd': 'wgtd',
157-
'@_wgt-var':
158-
weightID.length && weightID !== 'remove' ? weightID : '',
158+
'@_wgt-var': weightID !== 'remove' ? weightID : '',
159159
},
160160
];
161161
}
@@ -221,7 +221,7 @@ export function changeAssignedWeightForMultipleVariables(
221221
updatedVariableList.push(tempVar);
222222
});
223223

224-
return updatedVariableList;
224+
return assignedWeight.length ? updatedVariableList : allVariablesArray;
225225
}
226226

227227
export function changeSingleVariable(

src/assets/i18n/en-CA.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"DATASET_CITATION": "Dataset Citation",
7676
"FETCHING_WEIGHT": "Fetching weight data from Dataverse",
7777
"FETCHING_WEIGHT_FAILED": "Failed to fetch weight data from Dataverse",
78+
"DATASET_SAVING": "Dataset saving",
7879
"DATASET_SAVED": "Dataset saved",
7980
"DATASET_UPLOADING": "Dataset uploading to Dataverse",
8081
"DATASET_UPLOADED": "Dataset uploaded to Dataverse",

src/assets/i18n/fr-CA.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"DATASET_CITATION": "Citer l'ensemble de données",
7676
"FETCHING_WEIGHT": "Récupération des données de poids depuis Dataverse",
7777
"FETCHING_WEIGHT_FAILED": "Échec de la récupération des données de poids depuis Dataverse",
78+
"DATASET_SAVING": "Sauvegarde de l'ensemble de données",
7879
"DATASET_SAVED": "Ensemble de données sauvegardé",
7980
"DATASET_UPLOADING": "Téléversement de l'ensemble de données",
8081
"DATASET_UPLOADED": "Ensemble de données téléversé",
@@ -158,6 +159,7 @@
158159
},
159160
"TABLE_MENU": {
160161
"ASSIGN_WEIGHT": "Assigner un poids",
162+
"NO_CHANGE": "Laisser le poids tel quel",
161163
"NO_GROUP": "Aucune option de groupe ou poids sélectionné",
162164
"VAR_TABLE_OPTS": "Options du tableau de variables",
163165
"ADD_SELECTED": "Ajouter les variables sélectionnées au groupe",

0 commit comments

Comments
 (0)