From 014280e5d436ccd958c1207e6a7492f32bf191f1 Mon Sep 17 00:00:00 2001 From: Zipher04 Date: Tue, 15 Aug 2017 13:15:57 +0800 Subject: [PATCH] Fix error custom_fields not defined In kanbanclasses.js, get Tasks reported error when there is no custom field defined in MantisBT. A check to variable UsingCustomField is added before read the length of custom field. --- js/kanbanclasses.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/js/kanbanclasses.js b/js/kanbanclasses.js index f33a75b..fa71398 100644 --- a/js/kanbanclasses.js +++ b/js/kanbanclasses.js @@ -284,23 +284,27 @@ KanbanStory.prototype = { }, get Tasks() { - for(var iq = 0; iq < this.StorySource.custom_fields.length; iq++) { - var customField = this.StorySource.custom_fields[iq]; - if(customField.field.name == Mantis.TaskListField) { - if(this.StorySource.custom_fields[iq].value == null) { - return []; - } else { - return JSON.parse(this.StorySource.custom_fields[iq].value); + if (Kanban.UsingCustomField) { + for(var iq = 0; iq < this.StorySource.custom_fields.length; iq++) { + var customField = this.StorySource.custom_fields[iq]; + if(customField.field.name == Mantis.TaskListField) { + if(this.StorySource.custom_fields[iq].value == null) { + return []; + } else { + return JSON.parse(this.StorySource.custom_fields[iq].value); + } } } } return []; }, set Tasks(value) { - for(var iq = 0; iq < this.StorySource.custom_fields.length; iq++) { - var customField = this.StorySource.custom_fields[iq]; - if(customField.field.name == Mantis.TaskListField) { - this.StorySource.custom_fields[iq].value = JSON.stringify(value); + if (Kanban.UsingCustomField) { + for(var iq = 0; iq < this.StorySource.custom_fields.length; iq++) { + var customField = this.StorySource.custom_fields[iq]; + if(customField.field.name == Mantis.TaskListField) { + this.StorySource.custom_fields[iq].value = JSON.stringify(value); + } } } },