Skip to content

Commit b62bc42

Browse files
committed
fix(ember): use id to filter identities
1 parent e3508e7 commit b62bc42

File tree

7 files changed

+31
-34
lines changed

7 files changed

+31
-34
lines changed

api/mysagw/identity/filters.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515

1616
class IdentityFilterSet(FilterSet):
17+
ids = CharMultiValueFilter(field_name="pk")
1718
idp_ids = CharMultiValueFilter(field_name="idp_id")
1819
has_idp_id = BooleanFilter(field_name="idp_id", lookup_expr="isnull", exclude=True)
1920
member_of_organisations = CharMultiValueFilter(

ember/app/ui/cases/index/controller.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ export default class CasesIndexController extends TableController {
106106
return filters;
107107
});
108108

109-
async fetchAccesses(idpIds) {
110-
if (!idpIds) {
109+
async fetchAccesses(ids) {
110+
if (!ids) {
111111
return [];
112112
}
113113

114114
try {
115115
const accesses = (
116116
await this.store.query("case-access", {
117-
filter: { idpIds: idpIds.join(",") },
117+
filter: { identityIds: ids.join(",") },
118118
})
119119
).map((access) => access.get("caseId"));
120120

ember/app/ui/components/case-transfer/component.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,7 @@ export default class CaseTransfer extends Component {
1515

1616
@action
1717
selectNewAssignees(value) {
18-
this.newAssignees = value.map((assignee) => assignee.idpId);
19-
}
20-
21-
idpIdsToIds(idpIds) {
22-
const idpIdSet = new Set(idpIds);
23-
return this.store.peekAll("identity").reduce((ids, identity) => {
24-
if (idpIdSet.has(identity.idpId)) {
25-
return ids.push(identity.id), ids;
26-
}
27-
return ids;
28-
}, []);
18+
this.newAssignees = value.map((assignee) => assignee.id);
2919
}
3020

3121
@action
@@ -35,12 +25,12 @@ export default class CaseTransfer extends Component {
3525

3626
const body = {
3727
case_ids: this.args.cases,
38-
new_assignees: this.idpIdsToIds(this.newAssignees),
28+
new_assignees: this.newAssignees,
3929
to_remove_assignees: [],
4030
};
4131

4232
if (this.removeAccess) {
43-
body.to_remove_assignees = this.idpIdsToIds(this.args.toRemove);
33+
body.to_remove_assignees = this.args.toRemove;
4434
}
4535

4636
const headers = adapter.headers;

ember/app/ui/components/filters/identity/component.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class FiltersIdentityComponent extends Component {
1717
: this.args.selected;
1818

1919
return this.identityOptions.value?.filter((option) =>
20-
selected.includes(option.idpId),
20+
selected.includes(option.id),
2121
);
2222
}
2323

@@ -26,9 +26,9 @@ export default class FiltersIdentityComponent extends Component {
2626
return [];
2727
}
2828

29-
let idpIds = this.args.selected;
29+
let ids = this.args.selected;
3030
if (typeof this.args.selected !== "string") {
31-
idpIds = this.args.selected.join(",");
31+
ids = this.args.selected.join(",");
3232
}
3333

3434
try {
@@ -37,7 +37,7 @@ export default class FiltersIdentityComponent extends Component {
3737
"identity",
3838
{
3939
filter: {
40-
idpIds,
40+
ids,
4141
},
4242
},
4343
{ adapterOptions: { customEndpoint: "public-identities" } },
@@ -66,7 +66,6 @@ export default class FiltersIdentityComponent extends Component {
6666
filter: {
6767
search,
6868
isOrganisation: false,
69-
has_idp_id: true,
7069
},
7170
},
7271
{ adapterOptions: { customEndpoint: "public-identities" } },

ember/app/ui/components/identity-form/component.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,15 @@ export default class IdentityFormComponent extends Component {
133133
try {
134134
let message = this.intl.t("components.identity-form.delete.prompt");
135135

136-
if (this.args.identity.idpId) {
137-
const accesses = yield this.store.query("case-access", {
138-
filter: { idpIds: this.args.identity.idpId },
139-
});
140-
message += `\n${this.intl.t(
141-
"components.identity-form.delete.promptInfo",
142-
{
143-
caseAmount: accesses.length,
144-
},
145-
)}`;
146-
}
136+
const accesses = yield this.store.query("case-access", {
137+
filter: { identityIds: this.args.identity.id },
138+
});
139+
message += `\n${this.intl.t(
140+
"components.identity-form.delete.promptInfo",
141+
{
142+
caseAmount: accesses.length,
143+
},
144+
)}`;
147145

148146
const modal = UIkit.modal.confirm(message);
149147
// We need to add css white-space rule for the new line

ember/app/ui/work-items/controller.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,17 @@ export default class WorkItemsIndexController extends TableController {
6565
}
6666

6767
if (this.filters.identities) {
68+
const idSet = new Set(arrayFromString(this.filters.identities));
69+
const assignedUsers = this.store
70+
.peekAll("identity")
71+
.reduce((ids, identity) => {
72+
if (idSet.has(identity.id)) {
73+
return ids.push(identity.idpId), ids;
74+
}
75+
return ids;
76+
}, []);
6877
filter.push({
69-
assignedUsers: arrayFromString(this.filters.identities),
78+
assignedUsers,
7079
invert: Boolean(this.invertedFilters.identities),
7180
});
7281
}

ember/app/utils/table-controller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default class TableController extends Controller {
6161
if (Array.isArray(eventOrValue)) {
6262
this.filters[type] = stringFromArray(
6363
eventOrValue,
64-
type === "identities" ? "idpId" : "value",
64+
type === "identities" ? "id" : "value",
6565
);
6666
} else {
6767
this.filters[type] = eventOrValue.target?.value ?? eventOrValue;

0 commit comments

Comments
 (0)