druxt-router
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -16,3 +16,3 @@ import { mapState } from 'vuex'; | ||
], | ||
meta: this.metatags || {} | ||
meta: this.metatags || false | ||
} | ||
@@ -19,0 +19,0 @@ }, |
@@ -1,1 +0,1 @@ | ||
var DruxtRouter=function(t,e,r){"use strict";r=r&&r.hasOwnProperty("default")?r.default:r;var i={name:"druxt-router",head:function(){return{title:this.title,link:[{rel:"canonical",href:this.canonical||this.route.entity.canonical}],meta:this.metatags||{}}},computed:Object.assign({},{title:function(){return this.route.label}},e.mapState({entity:function(t){return t.druxtRouter.entities[t.druxtRouter.route.entity.uuid]},route:function(t){return t.druxtRouter.route}})),render:function(t){return t("div",{key:this.route.entity.uuid,props:{type:this.route.entity.type+"--"+this.route.entity.bundle,uuid:this.route.entity.uuid}},JSON.stringify(this.route))},fetch:function(t){var e=t.store,r=t.route;return e.dispatch("druxtRouter/getEntityByRouter",r.fullPath)}},n=function(t,e){if(void 0===e&&(e={}),!t)throw new Error("The 'baseURL' parameter is required.");this.axios=r.create({baseURL:t}),this.setOptions(e)};n.prototype.setOptions=function(t){void 0===t&&(t={}),"function"==typeof t.preprocessEntity&&(this.preprocessEntity=t.preprocessEntity)},n.prototype.get=async function(t){var e=await this.getRoute(t);return{entity:await this.getResourceByRoute(e),route:e}},n.prototype.getResource=async function(t){var e=t.id,r=t.type,i=this.convertResourceToEntityBundle(r),n="/api/"+i.entityType+"/"+i.bundle+"/"+e,o=await this.axios.get(n),u={id:e,type:r,data:o.data};return this.preprocessEntity&&(u._raw=u.data,u.data=await this.preprocessEntity(o)),u},n.prototype.getResourceByRoute=function(t){return this.getResource({id:t.entity.uuid,type:t.jsonapi.resourceName})},n.prototype.getRoute=async function(t){var e="/router/translate-path?path="+t;return(await this.axios.get(e)).data},n.prototype.convertResourceToEntityBundle=function(t){var e=t.split("--");return{entityType:e[0],bundle:e[1]}};var o=require("vuex"),u={props:{uuid:{type:String,required:!0},type:{type:String,required:!0}},created:function(){var t=this;void 0===this.entities[this.uuid]&&(this.loading=!0,this.getEntity({id:this.uuid,type:this.type}).then((function(e){t.loading="function"==typeof t.onDruxtRouterLoad&&!!t.onDruxtRouterLoad(e)})))},data:function(){return{loading:!1}},computed:Object.assign({},{entity:function(){return this.entities[this.uuid]},ready:function(){return!this.loading&&!!this.entity}},o.mapState({entities:function(t){return t.druxtRouter.entities}})),methods:Object.assign({},o.mapActions({getEntity:"druxtRouter/getEntity"}))};return t.DruxtRouter=n,t.DruxtRouterComponent=i,t.DruxtRouterEntityMixin=u,t.DruxtRouterStore=function(t){var e=t.store;if(void 0===e)throw new TypeError("Vuex store not found.");e.registerModule("druxtRouter",{namespaced:!0,state:function(){return{entities:{},route:{},routes:{}}},mutations:{addEntity:function(t,e){void 0!==e.id&&(t.entities[e.id]=e)},addRoute:function(t,e){var r=e.path,i=e.route;"string"==typeof r&&void 0!==i&&(t.routes[r]=i)},setRoute:function(t,e){"string"==typeof e&&void 0!==t.routes[e]&&(t.route=t.routes[e])}},actions:{getEntityByRouter:async function(t,e){var r=t.commit;t.dispatch,t.state;try{var i=await this.$druxtRouter().get(e),n=i.entity;return r("addRoute",{path:e,route:i.route}),r("setRoute",e),r("addEntity",n),n}catch(t){if(void 0===t.response)throw t;return this.app.context.error({statusCode:t.response.status,message:t.response.statusText})}},getEntity:async function(t,e){var r=t.commit,i=t.state;if(void 0!==i.entities[e.id])return i.entities[e.id];var n=await this.$druxtRouter().getResource(e);return r("addEntity",n),n}}},{preserveState:Boolean(e.state.druxtRouter)})},t}({},vuex,axios); | ||
var DruxtRouter=function(t,e,r){"use strict";r=r&&r.hasOwnProperty("default")?r.default:r;var i={name:"druxt-router",head:function(){return{title:this.title,link:[{rel:"canonical",href:this.canonical||this.route.entity.canonical}],meta:this.metatags||!1}},computed:Object.assign({},{title:function(){return this.route.label}},e.mapState({entity:function(t){return t.druxtRouter.entities[t.druxtRouter.route.entity.uuid]},route:function(t){return t.druxtRouter.route}})),render:function(t){return t("div",{key:this.route.entity.uuid,props:{type:this.route.entity.type+"--"+this.route.entity.bundle,uuid:this.route.entity.uuid}},JSON.stringify(this.route))},fetch:function(t){var e=t.store,r=t.route;return e.dispatch("druxtRouter/getEntityByRouter",r.fullPath)}},n=function(t,e){if(void 0===e&&(e={}),!t)throw new Error("The 'baseURL' parameter is required.");this.axios=r.create({baseURL:t}),this.setOptions(e)};n.prototype.setOptions=function(t){void 0===t&&(t={}),"function"==typeof t.preprocessEntity&&(this.preprocessEntity=t.preprocessEntity)},n.prototype.get=async function(t){var e=await this.getRoute(t);return{entity:await this.getResourceByRoute(e),route:e}},n.prototype.getResource=async function(t){var e=t.id,r=t.type,i=this.convertResourceToEntityBundle(r),n="/api/"+i.entityType+"/"+i.bundle+"/"+e,o=await this.axios.get(n),u={id:e,type:r,data:o.data};return this.preprocessEntity&&(u._raw=u.data,u.data=await this.preprocessEntity(o)),u},n.prototype.getResourceByRoute=function(t){return this.getResource({id:t.entity.uuid,type:t.jsonapi.resourceName})},n.prototype.getRoute=async function(t){var e="/router/translate-path?path="+t;return(await this.axios.get(e)).data},n.prototype.convertResourceToEntityBundle=function(t){var e=t.split("--");return{entityType:e[0],bundle:e[1]}};var o=require("vuex"),u={props:{uuid:{type:String,required:!0},type:{type:String,required:!0}},created:function(){var t=this;void 0===this.entities[this.uuid]&&(this.loading=!0,this.getEntity({id:this.uuid,type:this.type}).then((function(e){t.loading="function"==typeof t.onDruxtRouterLoad&&!!t.onDruxtRouterLoad(e)})))},data:function(){return{loading:!1}},computed:Object.assign({},{entity:function(){return this.entities[this.uuid]},ready:function(){return!this.loading&&!!this.entity}},o.mapState({entities:function(t){return t.druxtRouter.entities}})),methods:Object.assign({},o.mapActions({getEntity:"druxtRouter/getEntity"}))};return t.DruxtRouter=n,t.DruxtRouterComponent=i,t.DruxtRouterEntityMixin=u,t.DruxtRouterStore=function(t){var e=t.store;if(void 0===e)throw new TypeError("Vuex store not found.");e.registerModule("druxtRouter",{namespaced:!0,state:function(){return{entities:{},route:{},routes:{}}},mutations:{addEntity:function(t,e){void 0!==e.id&&(t.entities[e.id]=e)},addRoute:function(t,e){var r=e.path,i=e.route;"string"==typeof r&&void 0!==i&&(t.routes[r]=i)},setRoute:function(t,e){"string"==typeof e&&void 0!==t.routes[e]&&(t.route=t.routes[e])}},actions:{getEntityByRouter:async function(t,e){var r=t.commit;t.dispatch,t.state;try{var i=await this.$druxtRouter().get(e),n=i.entity;return r("addRoute",{path:e,route:i.route}),r("setRoute",e),r("addEntity",n),n}catch(t){if(void 0===t.response)throw t;return this.app.context.error({statusCode:t.response.status,message:t.response.statusText})}},getEntity:async function(t,e){var r=t.commit,i=t.state;if(void 0!==i.entities[e.id])return i.entities[e.id];var n=await this.$druxtRouter().getResource(e);return r("addEntity",n),n}}},{preserveState:Boolean(e.state.druxtRouter)})},t}({},vuex,axios); |
@@ -13,3 +13,3 @@ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});function _interopDefault(e){return(e&&(typeof e==='object')&&'default'in e)?e['default']:e}var vuex$1=require('vuex'),axios=_interopDefault(require('axios'));var DruxtRouterComponent = { | ||
], | ||
meta: this.metatags || {} | ||
meta: this.metatags || false | ||
} | ||
@@ -16,0 +16,0 @@ }, |
@@ -16,3 +16,3 @@ import { resolve } from 'path' | ||
this.addTemplate({ | ||
src: resolve(__dirname, '../src/component.js'), | ||
src: resolve(__dirname, 'templates/component.js'), | ||
fileName: 'components/druxt-router.js', | ||
@@ -19,0 +19,0 @@ options |
{ | ||
"name": "druxt-router", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Provides a Nuxt <-> Drupal router.", | ||
@@ -5,0 +5,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
24434
9
570
0