FIX: Resetting user directory columns (#21162)
Having any `plugin` type columns was breaking "Reset to default" functionality.
This commit is contained in:
parent
4b9a52cd7c
commit
9858171f3c
|
@ -49,12 +49,16 @@ export default Controller.extend(ModalFunctionality, {
|
||||||
resetToDefault() {
|
resetToDefault() {
|
||||||
let resetColumns = this.columns;
|
let resetColumns = this.columns;
|
||||||
resetColumns
|
resetColumns
|
||||||
.sort((a, b) =>
|
.sort((a, b) => {
|
||||||
(a.automatic_position || a.user_field.position + 1000) >
|
const a1 = a.automatic_position || (a.user_field?.position || 0) + 1000;
|
||||||
(b.automatic_position || b.user_field.position + 1000)
|
const b1 = b.automatic_position || (b.user_field?.position || 0) + 1000;
|
||||||
? 1
|
|
||||||
: -1
|
if (a1 === b1) {
|
||||||
)
|
return a.name.localeCompare(b.name);
|
||||||
|
} else {
|
||||||
|
return a1 > b1 ? 1 : -1;
|
||||||
|
}
|
||||||
|
})
|
||||||
.forEach((column, index) => {
|
.forEach((column, index) => {
|
||||||
column.setProperties({
|
column.setProperties({
|
||||||
position: column.automatic_position || index + 1,
|
position: column.automatic_position || index + 1,
|
||||||
|
|
|
@ -84,7 +84,7 @@ acceptance("User directory - Editing columns", function (needs) {
|
||||||
const columns = queryAll(
|
const columns = queryAll(
|
||||||
".edit-directory-columns-container .edit-directory-column"
|
".edit-directory-columns-container .edit-directory-column"
|
||||||
);
|
);
|
||||||
assert.strictEqual(columns.length, 8);
|
assert.strictEqual(columns.length, 9);
|
||||||
|
|
||||||
const checked = queryAll(
|
const checked = queryAll(
|
||||||
".edit-directory-columns-container .edit-directory-column input[type='checkbox']:checked"
|
".edit-directory-columns-container .edit-directory-column input[type='checkbox']:checked"
|
||||||
|
@ -94,7 +94,7 @@ acceptance("User directory - Editing columns", function (needs) {
|
||||||
const unchecked = queryAll(
|
const unchecked = queryAll(
|
||||||
".edit-directory-columns-container .edit-directory-column input[type='checkbox']:not(:checked)"
|
".edit-directory-columns-container .edit-directory-column input[type='checkbox']:not(:checked)"
|
||||||
);
|
);
|
||||||
assert.strictEqual(unchecked.length, 1);
|
assert.strictEqual(unchecked.length, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchColumns = function () {
|
const fetchColumns = function () {
|
||||||
|
@ -134,6 +134,7 @@ acceptance("User directory - Editing columns", function (needs) {
|
||||||
await click(moveUserFieldColumnUpBtn);
|
await click(moveUserFieldColumnUpBtn);
|
||||||
await click(moveUserFieldColumnUpBtn);
|
await click(moveUserFieldColumnUpBtn);
|
||||||
await click(moveUserFieldColumnUpBtn);
|
await click(moveUserFieldColumnUpBtn);
|
||||||
|
await click(moveUserFieldColumnUpBtn);
|
||||||
|
|
||||||
columns = fetchColumns();
|
columns = fetchColumns();
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
|
@ -160,6 +161,7 @@ acceptance("User directory - Editing columns", function (needs) {
|
||||||
"Topics Viewed",
|
"Topics Viewed",
|
||||||
"Posts Read",
|
"Posts Read",
|
||||||
"Days Visited",
|
"Days Visited",
|
||||||
|
"[en.an_extra_field]",
|
||||||
"Favorite Color",
|
"Favorite Color",
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1043,11 +1043,21 @@ export function applyDefaultHandlers(pretender) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 9,
|
id: 9,
|
||||||
|
name: "an_extra_field",
|
||||||
|
type: "plugin",
|
||||||
|
enabled: false,
|
||||||
|
automatic_position: null,
|
||||||
|
position: 8,
|
||||||
|
icon: null,
|
||||||
|
user_field: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
name: null,
|
name: null,
|
||||||
type: "user_field",
|
type: "user_field",
|
||||||
enabled: false,
|
enabled: false,
|
||||||
automatic_position: null,
|
automatic_position: null,
|
||||||
position: 8,
|
position: 9,
|
||||||
icon: null,
|
icon: null,
|
||||||
user_field: {
|
user_field: {
|
||||||
id: 3,
|
id: 3,
|
||||||
|
|
Loading…
Reference in New Issue