From ab6fbe1ff9ef2ace870045eb039e9fc58755d448 Mon Sep 17 00:00:00 2001 From: Aaron Francis Date: Thu, 12 Oct 2017 13:49:53 -0500 Subject: [PATCH] Set event prefix in the http key --- src/Defaults.js | 18 ++++++++---------- src/Model.js | 2 +- src/VueModel.js | 6 +++--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Defaults.js b/src/Defaults.js index d4f492a..aabb021 100644 --- a/src/Defaults.js +++ b/src/Defaults.js @@ -1,12 +1,16 @@ var _ = require('lodash'); module.exports = { - // Names of any attributes that you want to be reactive + // The default model attributes. We'll initialize them all to + // null if there are no values for them. This is the starting + // point for the data that is sent to the server attributes: [], http: { baseRoute: null, + eventPrefix: null, + // The _minimum_ amount of time that a successful ajax // request should take. If the request fails it will // return immediately, but if it's successful it won't @@ -68,9 +72,7 @@ module.exports = { index: { method: 'GET', route: '', - data: { - only: [] - } + data: false }, store: { method: 'POST', @@ -80,9 +82,7 @@ module.exports = { method: 'GET', route: '{id}', apply: true, - data: { - only: [] - } + data: false }, update: { method: 'PUT', @@ -92,9 +92,7 @@ module.exports = { destroy: { method: 'DELETE', route: '{id}', - data: { - only: [] - } + data: false } }, }, diff --git a/src/Model.js b/src/Model.js index 3f5ceb1..03cea14 100644 --- a/src/Model.js +++ b/src/Model.js @@ -225,7 +225,7 @@ module.exports = class Model { } emit(action, data) { - action = [this.settings.eventPrefix] + action = [this.settings.http.eventPrefix] .concat(_.castArray(action)) .filter(_.identity) .join('.'); diff --git a/src/VueModel.js b/src/VueModel.js index 16366ae..09cbe85 100644 --- a/src/VueModel.js +++ b/src/VueModel.js @@ -13,9 +13,9 @@ class VueModel { // Set the name of the model as the Event Prefix, // but only if there isn't a prefix set yet - definition = _.defaults(definition, { - eventPrefix: name - }); + if (! _.get(definition, 'http.eventPrefix', false)) { + _.set(definition, 'http.eventPrefix', name); + } this.registry[name] = definition; }