cms/app-client/app/adapters/application.js
author ymh <ymh.work@gmail.com>
Thu, 03 Nov 2016 11:14:41 +0100
changeset 391 4f6118afabee
parent 319 78990a8a069b
child 393 5ef3bfef0bff
permissions -rw-r--r--
Carto improvement: - add count on hover, - carto filter use geonames id resolution - geonames id in filter

import RESTAdapter from 'ember-data/adapters/rest';
import ENV from 'app-client/config/environment';

const TYPE_PATH_MAP = {
    transcript: 'transcript',
    geostat: 'stats/geostats',
    theme: 'stats/themes'
};

export default RESTAdapter.extend({

    namespace: (ENV.APP.backRootURL || ENV.rootURL).replace(/\/$/,"")+'/api/v1',

    buildURL: function(modelName, id) {
        if(modelName === 'transcript') {
            return this.urlPrefix() + '/documents/' + encodeURIComponent(encodeURIComponent(id)) + '/' + modelName;
        } else if (modelName === 'document' && id) {
            return this.urlPrefix() + '/documents/' + encodeURIComponent(encodeURIComponent(id)) ;
        }
        return this._super(...arguments);
    },

    pathForType: function(modelName) {
        return TYPE_PATH_MAP[modelName] || this._super(...arguments);
    }

});