Project

General

Profile

« Previous | Next » 

Revision 51036

Add subjects

View differences:

community.service.ts
112 112
              community['description'] = resData[0].description;
113 113

  
114 114
              if(resData[0].managers != null) {
115

  
116 115
                  if(community['managers'] == undefined) {
117 116
                    community['managers'] = new Array<string>();
118 117
                  }
......
126 125
                  }
127 126
              }
128 127

  
128
              if(resData[0].subjects != null) {
129
                  if(community['subjects'] == undefined) {
130
                    community['subjects'] = new Array<string>();
131
                  }
132

  
133
                  let subjects = resData[0].subjects;
134
                  let length = Array.isArray(subjects) ? subjects.length : 1;
135

  
136
                  for(let i=0; i<length; i++) {
137
                    let subject = Array.isArray(subjects) ? subjects[i] : subjects;
138
                    community.subjects[i] = subject;
139
                  }
140
              }
141

  
129 142
          } else if(!Array.isArray(resData)) {
130 143

  
131 144
              community['title'] = resData.name;
......
148 161
                    community.managers[i] = manager;
149 162
                  }
150 163
              }
164

  
165
              if(resData.subjects != null) {
166
                  if(community['subjects'] == undefined) {
167
                    community['subjects'] = new Array<string>();
168
                  }
169

  
170
                  let subjects = resData.subjects;
171
                  let length = Array.isArray(subjects) ? subjects.length : 1;
172

  
173
                  for(let i=0; i<length; i++) {
174
                    let subject = Array.isArray(subjects) ? subjects[i] : subjects;
175
                    community.subjects[i] = subject;
176
                  }
177
              }
151 178
          }
152 179
      }
153 180
      return community;

Also available in: Unified diff