cms/app-client/app/adapters/application.js
author ymh <ymh.work@gmail.com>
Tue, 04 Oct 2016 11:58:39 +0200
changeset 319 78990a8a069b
parent 318 5564f5065f81
child 393 5ef3bfef0bff
permissions -rw-r--r--
Work on front and back integration, correct the expected data format
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
126
e87a340711a4 improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents: 123
diff changeset
     1
import RESTAdapter from 'ember-data/adapters/rest';
e87a340711a4 improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents: 123
diff changeset
     2
import ENV from 'app-client/config/environment';
91
acfeddc7821d rename "sound" to "document"
nowmad@nowmads-macbook-pro.local
parents: 90
diff changeset
     3
305
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 261
diff changeset
     4
const TYPE_PATH_MAP = {
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 261
diff changeset
     5
    transcript: 'transcript',
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 261
diff changeset
     6
    geostat: 'stats/geostats',
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 261
diff changeset
     7
    theme: 'stats/themes'
306
3fccf43160a7 Some more changes linked to the change of api organization + some jshint error cleaning
ymh <ymh.work@gmail.com>
parents: 305
diff changeset
     8
};
305
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 261
diff changeset
     9
126
e87a340711a4 improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents: 123
diff changeset
    10
export default RESTAdapter.extend({
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    11
319
78990a8a069b Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents: 318
diff changeset
    12
    namespace: (ENV.APP.backRootURL || ENV.rootURL).replace(/\/$/,"")+'/api/v1',
126
e87a340711a4 improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents: 123
diff changeset
    13
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    14
    buildURL: function(modelName, id) {
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    15
        if(modelName === 'transcript') {
319
78990a8a069b Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents: 318
diff changeset
    16
            return this.urlPrefix() + '/documents/' + encodeURIComponent(encodeURIComponent(id)) + '/' + modelName;
78990a8a069b Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents: 318
diff changeset
    17
        } else if (modelName === 'document' && id) {
78990a8a069b Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents: 318
diff changeset
    18
            return this.urlPrefix() + '/documents/' + encodeURIComponent(encodeURIComponent(id)) ;
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    19
        }
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    20
        return this._super(...arguments);
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    21
    },
42
7d091abf82fd add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    22
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    23
    pathForType: function(modelName) {
305
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 261
diff changeset
    24
        return TYPE_PATH_MAP[modelName] || this._super(...arguments);
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    25
    }
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    26
261
02e2396bcbbc Migrate to ember 2.7 + correct jquery null context error + declare shim for popcorn (instead of silencing the JSHint error)
ymh <ymh.work@gmail.com>
parents: 245
diff changeset
    27
});