Fixed Board does not load, by disabling Custom Fields sorting.

Thanks to marcungeschikts, olivierlambert and xet7 !

Fixes #3540
This commit is contained in:
Lauri Ojansivu 2021-02-08 21:08:36 +02:00
parent c33d39f5d0
commit d57eb6a2fc

View file

@ -702,14 +702,16 @@ Cards.helpers({
const definitions = CustomFields.find({ const definitions = CustomFields.find({
boardIds: { $in: [this.boardId] }, boardIds: { $in: [this.boardId] },
}).fetch(); }).fetch();
if (definitions === undefined) {
return {};
}
// match right definition to each field // match right definition to each field
if (!this.customFields) return []; if (!this.customFields) return [];
const ret = this.customFields.map(customField => { const ret = this.customFields.map(customField => {
const definition = definitions.find(definition => { const definition = definitions.find(definition => {
return definition._id === customField._id; return definition._id === customField._id;
}); });
if (!definition) { if (definition === undefined) {
return {}; return {};
} }
//search for "True Value" which is for DropDowns other then the Value (which is the id) //search for "True Value" which is for DropDowns other then the Value (which is the id)
@ -731,12 +733,28 @@ Cards.helpers({
definition, definition,
}; };
}); });
ret.sort( /*
(a, b) => Sometimes sorting custom fields returns a is undefined or
a.definition.name !== undefined && something else is undefined, so only trying does it work,
b.definition.name !== undefined && and catching errors.
=> Custom Fields sorting disabled, because could not
get with working with any error handling logic,
board did have errors with many variations of below changes.
if (definition === undefined) {
return {};
}
if (definition.name === undefined) {
return {};
}
try {
ret.sort((a, b) =>
a.definition.name.localeCompare(b.definition.name), a.definition.name.localeCompare(b.definition.name),
); );
} catch (error) {
console.error(error);
}
*/
return ret; return ret;
}, },