mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 16:46:12 +08:00
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() {
|
||||
let resetColumns = this.columns;
|
||||
resetColumns
|
||||
.sort((a, b) =>
|
||||
(a.automatic_position || a.user_field.position + 1000) >
|
||||
(b.automatic_position || b.user_field.position + 1000)
|
||||
? 1
|
||||
: -1
|
||||
)
|
||||
.sort((a, b) => {
|
||||
const a1 = a.automatic_position || (a.user_field?.position || 0) + 1000;
|
||||
const b1 = b.automatic_position || (b.user_field?.position || 0) + 1000;
|
||||
|
||||
if (a1 === b1) {
|
||||
return a.name.localeCompare(b.name);
|
||||
} else {
|
||||
return a1 > b1 ? 1 : -1;
|
||||
}
|
||||
})
|
||||
.forEach((column, index) => {
|
||||
column.setProperties({
|
||||
position: column.automatic_position || index + 1,
|
||||
|
|
|
@ -84,7 +84,7 @@ acceptance("User directory - Editing columns", function (needs) {
|
|||
const columns = queryAll(
|
||||
".edit-directory-columns-container .edit-directory-column"
|
||||
);
|
||||
assert.strictEqual(columns.length, 8);
|
||||
assert.strictEqual(columns.length, 9);
|
||||
|
||||
const checked = queryAll(
|
||||
".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(
|
||||
".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 () {
|
||||
|
@ -134,6 +134,7 @@ acceptance("User directory - Editing columns", function (needs) {
|
|||
await click(moveUserFieldColumnUpBtn);
|
||||
await click(moveUserFieldColumnUpBtn);
|
||||
await click(moveUserFieldColumnUpBtn);
|
||||
await click(moveUserFieldColumnUpBtn);
|
||||
|
||||
columns = fetchColumns();
|
||||
assert.strictEqual(
|
||||
|
@ -160,6 +161,7 @@ acceptance("User directory - Editing columns", function (needs) {
|
|||
"Topics Viewed",
|
||||
"Posts Read",
|
||||
"Days Visited",
|
||||
"[en.an_extra_field]",
|
||||
"Favorite Color",
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -1043,11 +1043,21 @@ export function applyDefaultHandlers(pretender) {
|
|||
},
|
||||
{
|
||||
id: 9,
|
||||
name: "an_extra_field",
|
||||
type: "plugin",
|
||||
enabled: false,
|
||||
automatic_position: null,
|
||||
position: 8,
|
||||
icon: null,
|
||||
user_field: null,
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
name: null,
|
||||
type: "user_field",
|
||||
enabled: false,
|
||||
automatic_position: null,
|
||||
position: 8,
|
||||
position: 9,
|
||||
icon: null,
|
||||
user_field: {
|
||||
id: 3,
|
||||
|
|
Loading…
Reference in New Issue
Block a user