cms/app-client/app/adapters/application.js
author ymh <ymh.work@gmail.com>
Sun, 04 Dec 2016 00:23:52 +0100
changeset 465 9df336529b2f
parent 424 feb0d3e0fef9
child 467 762fc0eb4946
permissions -rw-r--r--
make filter and theme visualisatiion change on filter modification

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

const TYPE_PATH_MAP = {
    transcript: 'transcript',
    geostat: 'stats/geostats',
    datestat: 'stats/datestats',
    dateminmax: 'stats/dateminmax',
    theme: 'stats/themes',
    discourse: 'stats/discourses'
};

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);
    }

});