Skip to content
Snippets Groups Projects
application.js 1.46 KiB
Newer Older
import BaseAdapter from './_baseAdapter';
import UrlTemplates from "ember-data-url-templates";
Mathis Neumann's avatar
Mathis Neumann committed
 * Basic Adapter for all models, except System.
 * Automatically uses the id of the current system in the URL path
 *
 * @class ApplicationAdapter
 * @param  {UrlTemplate}
 * @param  {Object} configuration for templates
 * @return {Adapter} adapter that is used for all metamodel models
 */
export default BaseAdapter.extend(UrlTemplates, {
Mathis Neumann's avatar
Mathis Neumann committed
    /**
     * template for building the url for requests.
     * See https://github.com/amiel/ember-data-url-templates
     *
     * @property urlTemplate
     * @type {String}
     */
    urlTemplate: '{+host}/{+namespace}/{pathForType}{/id}',
Mathis Neumann's avatar
Mathis Neumann committed

    /**
     * Automatically uses the id of the current system
     * Template for building the findAll url for requests.
     * See https://github.com/amiel/ember-data-url-templates.
     *
     * @property urlTemplate
     * @type {String}
     */
    findAllUrlTemplate: '{+host}/{+namespace}/systems{/systemId}/{pathForType}/{?query*}',

Mathis Neumann's avatar
Mathis Neumann committed
    /**
     * segment which can be used by referencing the name in the template syntax.
     * See https://github.com/amiel/ember-data-url-templates
     * @type {Object}
     */
    urlSegments: {
Mathis Neumann's avatar
Mathis Neumann committed
        /**
         * gets the current id of the system from the session service
         * @return {String} the id of the system
         * @method urlSegments.systemId
         */
          return this.get('session.system.id');
Mathis Neumann's avatar
Mathis Neumann committed
});