From 5383719450c09db57526690dda4acbb2564e5bd9 Mon Sep 17 00:00:00 2001 From: bach Date: Thu, 4 Mar 2021 10:52:46 +0100 Subject: [PATCH] added lang param to graphql thematique load --- web/themes/custom/materiotheme/assets/dist/main.js | 2 +- .../custom/materiotheme/vuejs/components/Pages/Thematique.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/themes/custom/materiotheme/assets/dist/main.js b/web/themes/custom/materiotheme/assets/dist/main.js index 8b8424b1..0f1944c2 100644 --- a/web/themes/custom/materiotheme/assets/dist/main.js +++ b/web/themes/custom/materiotheme/assets/dist/main.js @@ -1423,7 +1423,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n})); /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; -eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.default = void 0;\n\nvar _route = _interopRequireDefault(__webpack_require__(/*! vuejs/route */ \"./web/themes/custom/materiotheme/vuejs/route/index.js\"));\n\nvar _store = _interopRequireDefault(__webpack_require__(/*! vuejs/store */ \"./web/themes/custom/materiotheme/vuejs/store/index.js\"));\n\nvar _restAxios = __webpack_require__(/*! vuejs/api/rest-axios */ \"./web/themes/custom/materiotheme/vuejs/api/rest-axios.js\");\n\nvar _graphqlAxios = __webpack_require__(/*! vuejs/api/graphql-axios */ \"./web/themes/custom/materiotheme/vuejs/api/graphql-axios.js\");\n\nvar _printer = __webpack_require__(/*! graphql/language/printer */ \"./node_modules/graphql/language/printer.js\");\n\nvar _graphqlTag = _interopRequireDefault(__webpack_require__(/*! graphql-tag */ \"./node_modules/graphql-tag/src/index.js\"));\n\nvar _thematiqueFragment = _interopRequireDefault(__webpack_require__(/*! vuejs/api/gql/thematique.fragment.gql */ \"./web/themes/custom/materiotheme/vuejs/api/gql/thematique.fragment.gql\"));\n\nvar _Card = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/Card */ \"./web/themes/custom/materiotheme/vuejs/components/Content/Card.vue\"));\n\nvar _vuex = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.common.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _templateObject() {\n var data = _taggedTemplateLiteral([\"{\\n route(path: \\\"\", \"\\\") {\\n ...ThematiqueFields\\n }\\n }\\n \", \"\\n \"]);\n\n _templateObject = function _templateObject() {\n return data;\n };\n\n return data;\n}\n\nfunction _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }\n\nvar _default = {\n name: \"Thematique\",\n router: _route.default,\n store: _store.default,\n data: function data() {\n return {\n nid: null,\n path: null,\n thematique: {},\n image_accroche: null,\n loading: true\n };\n },\n metaInfo: function metaInfo() {\n return {\n title: this.thematique.title\n };\n },\n // computed: {\n // ...mapState({\n // items: state => state.Blabla.items\n // })\n // },\n created: function created() {\n this.getThematique();\n },\n methods: {\n // ...mapActions({\n // getItems: 'Blabla/getItems',\n // getItemIndex: 'Blabla/getItemIndex',\n // getPrevNextItems: 'Blabla/getPrevNextItems'\n // }),\n getThematique: function getThematique() {\n console.log('getThematique', this.$route); // get the article uuid\n // if(this.$route.query.nid){\n // // we come from internal link with vuejs\n // // directly record uuid\n // this.nid = this.$route.query.nid\n //\n // }else if(drupalDecoupled.entity_type == 'node' && drupalDecoupled.entity_bundle == 'article'){\n // // we landed in an internal page\n // // get the uuid from drupalDeclouped, provided by materio_decoupled.module\n // this.nid = drupalDecoupled.entity_id\n // }\n\n if (this.$route.path) {\n // we come from internal link with vuejs\n this.path = this.$route.path;\n } else {\n // we landed in an internal page\n this.path = window.location.pathname;\n }\n\n if (this.path) {\n this.loadThematique();\n } else {\n // if for any reason we dont have the uuid\n // redirect to home\n this.$route.replace('home');\n }\n },\n loadThematique: function loadThematique() {\n var _this = this;\n\n console.log('loadThematique');\n this.loading = true;\n var ast = (0, _graphqlTag.default)(_templateObject(), this.path, _thematiqueFragment.default);\n\n _graphqlAxios.MGQ.post('', {\n query: (0, _printer.print)(ast)\n }).then(function (_ref) {\n var route = _ref.data.data.route;\n console.log('loaded Thematique', route);\n\n _this.parseDataGQL(route);\n }).catch(function (error) {\n console.warn('Issue with loadThematique', error);\n Promise.reject(error);\n });\n },\n parseDataGQL: function parseDataGQL(thematique) {\n console.log('parseDataGQL thematique', thematique);\n this.thematique = thematique;\n this.image_accroche = thematique.images[0]; // update main page title\n\n this.$store.commit('Common/setPagetitle', thematique.title);\n this.loading = false;\n }\n },\n components: {\n Card: _Card.default\n },\n watch: {\n '$route': function $route(to, from) {\n console.log('route change');\n this.getThematique();\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack://materio.com/./web/themes/custom/materiotheme/vuejs/components/Pages/Thematique.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options"); +eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.default = void 0;\n\nvar _route = _interopRequireDefault(__webpack_require__(/*! vuejs/route */ \"./web/themes/custom/materiotheme/vuejs/route/index.js\"));\n\nvar _store = _interopRequireDefault(__webpack_require__(/*! vuejs/store */ \"./web/themes/custom/materiotheme/vuejs/store/index.js\"));\n\nvar _restAxios = __webpack_require__(/*! vuejs/api/rest-axios */ \"./web/themes/custom/materiotheme/vuejs/api/rest-axios.js\");\n\nvar _graphqlAxios = __webpack_require__(/*! vuejs/api/graphql-axios */ \"./web/themes/custom/materiotheme/vuejs/api/graphql-axios.js\");\n\nvar _printer = __webpack_require__(/*! graphql/language/printer */ \"./node_modules/graphql/language/printer.js\");\n\nvar _graphqlTag = _interopRequireDefault(__webpack_require__(/*! graphql-tag */ \"./node_modules/graphql-tag/src/index.js\"));\n\nvar _thematiqueFragment = _interopRequireDefault(__webpack_require__(/*! vuejs/api/gql/thematique.fragment.gql */ \"./web/themes/custom/materiotheme/vuejs/api/gql/thematique.fragment.gql\"));\n\nvar _Card = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/Card */ \"./web/themes/custom/materiotheme/vuejs/components/Content/Card.vue\"));\n\nvar _vuex = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.common.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _templateObject() {\n var data = _taggedTemplateLiteral([\"{\\n route(path: \\\"\", \"\\\", lang: \\\"\", \"\\\") {\\n ...ThematiqueFields\\n }\\n }\\n \", \"\\n \"]);\n\n _templateObject = function _templateObject() {\n return data;\n };\n\n return data;\n}\n\nfunction _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }\n\nvar _default = {\n name: \"Thematique\",\n router: _route.default,\n store: _store.default,\n data: function data() {\n return {\n nid: null,\n path: null,\n thematique: {},\n image_accroche: null,\n loading: true\n };\n },\n metaInfo: function metaInfo() {\n return {\n title: this.thematique.title\n };\n },\n // computed: {\n // ...mapState({\n // items: state => state.Blabla.items\n // })\n // },\n created: function created() {\n this.getThematique();\n },\n methods: {\n // ...mapActions({\n // getItems: 'Blabla/getItems',\n // getItemIndex: 'Blabla/getItemIndex',\n // getPrevNextItems: 'Blabla/getPrevNextItems'\n // }),\n getThematique: function getThematique() {\n console.log('getThematique', this.$route); // get the article uuid\n // if(this.$route.query.nid){\n // // we come from internal link with vuejs\n // // directly record uuid\n // this.nid = this.$route.query.nid\n //\n // }else if(drupalDecoupled.entity_type == 'node' && drupalDecoupled.entity_bundle == 'article'){\n // // we landed in an internal page\n // // get the uuid from drupalDeclouped, provided by materio_decoupled.module\n // this.nid = drupalDecoupled.entity_id\n // }\n\n if (this.$route.path) {\n // we come from internal link with vuejs\n this.path = this.$route.path;\n } else {\n // we landed in an internal page\n this.path = window.location.pathname;\n }\n\n if (this.path) {\n this.loadThematique();\n } else {\n // if for any reason we dont have the uuid\n // redirect to home\n this.$route.replace('home');\n }\n },\n loadThematique: function loadThematique() {\n var _this = this;\n\n console.log('loadThematique');\n this.loading = true;\n var ast = (0, _graphqlTag.default)(_templateObject(), this.path, drupalDecoupled.lang_code, _thematiqueFragment.default);\n\n _graphqlAxios.MGQ.post('', {\n query: (0, _printer.print)(ast)\n }).then(function (_ref) {\n var route = _ref.data.data.route;\n console.log('loaded Thematique', route);\n\n _this.parseDataGQL(route);\n }).catch(function (error) {\n console.warn('Issue with loadThematique', error);\n Promise.reject(error);\n });\n },\n parseDataGQL: function parseDataGQL(thematique) {\n console.log('parseDataGQL thematique', thematique);\n this.thematique = thematique;\n this.image_accroche = thematique.images[0]; // update main page title\n\n this.$store.commit('Common/setPagetitle', thematique.title);\n this.loading = false;\n }\n },\n components: {\n Card: _Card.default\n },\n watch: {\n '$route': function $route(to, from) {\n console.log('route change');\n this.getThematique();\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack://materio.com/./web/themes/custom/materiotheme/vuejs/components/Pages/Thematique.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options"); /***/ }), diff --git a/web/themes/custom/materiotheme/vuejs/components/Pages/Thematique.vue b/web/themes/custom/materiotheme/vuejs/components/Pages/Thematique.vue index 0d843b86..12020aef 100644 --- a/web/themes/custom/materiotheme/vuejs/components/Pages/Thematique.vue +++ b/web/themes/custom/materiotheme/vuejs/components/Pages/Thematique.vue @@ -106,7 +106,7 @@ export default { this.loading = true let ast = gql`{ - route(path: "${this.path}") { + route(path: "${this.path}", lang: "${drupalDecoupled.lang_code}") { ...ThematiqueFields } }