jeudi 11 mai 2017

how to add returned data to the existing template

I am using ember. I intercept one component's button click in controller. The click is to trigger a new report request. When a new report request is made, I want the newly made request to appear on the list of requests that I currently show. How do I make ember refresh the page without obvious flicker?

Here is my sendAction code:

actions: {
    sendData: function () {
  this.set('showLoading', true);

  let data = {
    startTime: date.normalizeTimestamp(this.get('startTimestamp')),
    endTime: date.normalizeTimestamp(this.get('endTimestamp')),
    type: constants.ENTERPRISE.REPORTING_PAYMENT_TYPE
  };

  api.ajaxPost(`${api.buildV3EnterpriseUrl('reports')}`, data).then(response => {
    this.set('showLoading', false);
    return response.report;
  }).catch(error => {
    this.set('showLoading', false);
    if (error.status === constants.HTTP_STATUS.GATEWAY_TIMEOUT) {
      this.notify.error(this.translate('reports.report_timedout'), 
this.translate('reports.report_timedout_desc'));
    } else {
      this.send('error', error);
    }
  });
}




Aucun commentaire:

Enregistrer un commentaire