Project

General

Profile

« Previous | Next » 

Revision 54755

[trunk]: Merging branch 'changeDeposit' into trunk for revisions 54355:54751

View differences:

fetchDataproviders.class.ts
14 14
                     };
15 15
  public CSVDownloaded = false;
16 16
  public csvParams: string;
17
  public loadPaging: boolean = true;
18
  public oldTotalResults: number = 0;
17 19

  
18

  
19 20
  constructor ( private _searchDataprovidersService: SearchDataprovidersService ) {
20 21
    this.errorCodes = new ErrorCodes();
21 22
    this.searchUtils.status = this.errorCodes.LOADING;
......
174 175
public getResultsForDeposit(id:string, type:string, page: number,  size: number, properties:EnvProperties){
175 176
    //var errorCodes:ErrorCodes = new ErrorCodes();
176 177
    this.searchUtils.status = this.errorCodes.LOADING;
178
    this.results = [];
179
    this.searchUtils.totalResults = 0;
180
    this.loadPaging = false;
177 181

  
178 182
  if(id != "") {
179 183

  
......
188 192
              if(this.searchUtils.totalResults == 0 ){
189 193
                this.searchUtils.status = this.errorCodes.NONE;
190 194
              }
195

  
196
              if(this.searchUtils.status == this.errorCodes.DONE) {
197
                // Page out of limit!!!
198
                let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
199
                if(!(Number.isInteger(totalPages))) {
200
                    totalPages = (parseInt(totalPages, 10) + 1);
201
                }
202
                if(totalPages < page) {
203
                  this.searchUtils.totalResults = 0;
204
                  this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
205
                }
206
              }
207
              this.loadPaging = true;
208
              this.oldTotalResults = this.searchUtils.totalResults;
191 209
          },
192 210
          err => {
193 211
              console.log(err);
......
204 222
              } else {
205 223
                this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
206 224
              }
225
              this.loadPaging = true;
226
              this.oldTotalResults = 0;
207 227
          }
208 228
      );
209 229
  }
210 230
}
211 231
public getResultsBySubjectsForDeposit(subject:string, type:string, page: number,  size: number, properties:EnvProperties){
212 232
    //var errorCodes:ErrorCodes = new ErrorCodes();
233

  
213 234
    this.searchUtils.status = this.errorCodes.LOADING;
235
    this.results = [];
236
    this.searchUtils.totalResults = 0;
237
    this.loadPaging = false;
238

  
214 239
      this._searchDataprovidersService.searchDataProvidersBySubjects(subject,type, page, size, properties).subscribe(
215 240
          data => {
216 241
              this.searchUtils.totalResults = data[0];
......
222 247
              if(this.searchUtils.totalResults == 0 ){
223 248
                this.searchUtils.status = this.errorCodes.NONE;
224 249
              }
250
              if(this.searchUtils.status == this.errorCodes.DONE) {
251
                // Page out of limit!!!
252
                let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
253
                if(!(Number.isInteger(totalPages))) {
254
                    totalPages = (parseInt(totalPages, 10) + 1);
255
                }
256
                if(totalPages < page) {
257
                  this.searchUtils.totalResults = 0;
258
                  this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
259
                }
260
              }
261
              this.loadPaging = true;
262
              this.oldTotalResults = this.searchUtils.totalResults;
225 263
          },
226 264
          err => {
227 265
              console.log(err);
......
238 276
              } else {
239 277
                this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
240 278
              }
279
              this.loadPaging = true;
280
              this.oldTotalResults = 0;
241 281
          }
242 282
      );
243 283

  

Also available in: Unified diff