Sha256: 8078682505e195ba570b6c923395887ec249321d686e71d3b38520b8a7b594e1

Contents?: true

Size: 775 Bytes

Versions: 11

Compression:

Stored size: 775 Bytes

Contents

class ApiFetcher { // eslint-disable-line no-unused-vars

  constructor(query, variables) {
    this.query = query;
    this.variables = variables;
  }

  fetch(callback) {
    $.ajax({
      method: "POST",
      url: "/api",
      contentType: "application/json",
      data: JSON.stringify({
        query: this.query,
        variables: this.variables
      })
    }).done(function(data) {
      callback(data.data);
    });
  }

  fetchAll (callback) {
    this.fetch(callback);
  }

  static findTranslation(translations) {
    let text, lang = document.querySelector('html').getAttribute('lang');
    
    translations.forEach((t) => {
      if(t.text) {
        if(!text || t.locale == lang) {
          text = t.text
        }
      }
    });
    return text;
  }
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.7.2 app/assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6
decidim-decidim_awesome-0.7.0 app/assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6
decidim-decidim_awesome-0.6.7 app/assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6
decidim-decidim_awesome-0.6.6 app/assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6
decidim-decidim_awesome-0.6.5 app/assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6
decidim-decidim_awesome-0.6.4 app/assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6
decidim-decidim_awesome-0.6.3 app/assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6
decidim-decidim_awesome-0.6.2 app/assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6
decidim-decidim_awesome-0.6.1 app/assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6
decidim-decidim_awesome-0.6.0 app/assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6
decidim-decidim_awesome-0.5.1 app/assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6