diff --git a/web/themes/custom/materiotheme/assets/dist/main.js b/web/themes/custom/materiotheme/assets/dist/main.js index 291fcfc4..8ad5bab3 100644 --- a/web/themes/custom/materiotheme/assets/dist/main.js +++ b/web/themes/custom/materiotheme/assets/dist/main.js @@ -417,7 +417,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n /***/ (function(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 _jsonAxios = __webpack_require__(/*! vuejs/api/json-axios */ \"./web/themes/custom/materiotheme/vuejs/api/json-axios.js\");\n\nvar _querystring = _interopRequireDefault(__webpack_require__(/*! querystring */ \"./node_modules/querystring-es3/index.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar _default = {\n name: \"Article\",\n router: _route.default,\n props: ['item'],\n data: function data() {\n return {\n uuid: null,\n content: null\n };\n },\n created: function created() {\n this.getArticle();\n },\n methods: {\n getArticle: function getArticle() {\n console.log(this.$route); // get the article uuid\n\n if (this.$route.query.uuid) {\n // we come from internal link with vuejs\n // directly record uuid\n this.uuid = this.$route.query.uuid;\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.uuid = drupalDecoupled.entity_uuid;\n }\n\n if (this.uuid) {\n this.loadArticle();\n } else {\n // if for any reason we dont have the uuid\n // redirect to home\n this.$route.replace('home');\n }\n },\n loadArticle: function loadArticle() {\n var _this = this;\n\n console.log('loadArticle', this.uuid);\n var params = {\n include: 'field_linked_materials,field_showroom,field_tags,field_thesaurus,field_visuel,uid'\n };\n\n var q = _querystring.default.stringify(params);\n\n _jsonAxios.JSONAPI.get(\"node/article/\".concat(this.uuid, \"?\").concat(q)).then(function (_ref) {\n var data = _ref.data;\n console.log('loadArticle data', data);\n\n _this.parseData(data);\n }).catch(function (error) {\n console.warn('Issue with loadArticle', error);\n Promise.reject(error);\n });\n },\n parseData: function parseData(data) {\n var _this2 = this;\n\n var attrs = data.data.attributes;\n var relations = data.data.relationships;\n console.log('relations', relations);\n var inc = data.included;\n console.log('included', inc);\n this.content = {\n title: attrs.title,\n body: attrs.body.value // parse all relationships\n\n };\n\n var _loop = function _loop(key) {\n // skip loop if the property is from prototype\n if (!relations.hasOwnProperty(key)) return \"continue\";\n var obj = relations[key];\n console.log('typeof obj.data', _typeof(obj.data)); // skip obj if data is not array\n\n if (!Array.isArray(obj.data)) return \"continue\";\n _this2.content[key] = []; // parse relationship values using included\n\n var field = {};\n obj.data.forEach(function (e) {\n // get the included values\n var included = inc.find(function (i) {\n return i.id == e.id;\n }); // fill the values\n\n switch (key) {\n case 'field_visuel':\n field = e.meta;\n field.id = e.id;\n field.src = included.links.card_medium.href;\n break;\n\n case 'field_linked_materials':\n case 'field_thesaurus':\n case 'field_tags':\n field = included.attributes;\n field.id = included.id;\n break;\n // case 'field_showroom':\n // field = included.attributes\n // break\n\n default:\n }\n\n _this2.content[key].push(field);\n });\n };\n\n for (var key in relations) {\n var _ret = _loop(key);\n\n if (_ret === \"continue\") continue;\n }\n\n console.log('article.content', this.content);\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??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 _jsonAxios = __webpack_require__(/*! vuejs/api/json-axios */ \"./web/themes/custom/materiotheme/vuejs/api/json-axios.js\");\n\nvar _querystring = _interopRequireDefault(__webpack_require__(/*! querystring */ \"./node_modules/querystring-es3/index.js\"));\n\nvar _vuex = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.esm.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar _default = {\n name: \"Article\",\n router: _route.default,\n props: ['item'],\n data: function data() {\n return {\n index: -1,\n prevnext: {},\n uuid: null,\n content: null\n };\n },\n created: function created() {\n this.getArticle();\n },\n methods: _objectSpread({}, (0, _vuex.mapActions)({\n getItemIndex: 'Blabla/getItemIndex',\n getPrevNextItems: 'Blabla/getPrevNextItems'\n }), {\n getIndex: function getIndex() {\n var _this = this;\n\n console.log(\"Article getIndex\");\n this.getItemIndex(this.uuid).then(function (index) {\n _this.index = index; // console.log('article index', index, this);\n\n _this.getPrevNextItems(index).then(function (pn) {\n _this.prevnext = pn;\n });\n });\n },\n getArticle: function getArticle() {\n console.log(this.$route); // get the article uuid\n\n if (this.$route.query.uuid) {\n // we come from internal link with vuejs\n // directly record uuid\n this.uuid = this.$route.query.uuid;\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.uuid = drupalDecoupled.entity_uuid;\n }\n\n if (this.uuid) {\n this.getIndex();\n this.loadArticle();\n } else {\n // if for any reason we dont have the uuid\n // redirect to home\n this.$route.replace('home');\n }\n },\n loadArticle: function loadArticle() {\n var _this2 = this;\n\n console.log('loadArticle', this.uuid);\n var params = {\n include: 'field_linked_materials,field_showroom,field_tags,field_thesaurus,field_visuel,uid'\n };\n\n var q = _querystring.default.stringify(params);\n\n _jsonAxios.JSONAPI.get(\"node/article/\".concat(this.uuid, \"?\").concat(q)).then(function (_ref) {\n var data = _ref.data;\n console.log('loadArticle data', data);\n\n _this2.parseData(data);\n }).catch(function (error) {\n console.warn('Issue with loadArticle', error);\n Promise.reject(error);\n });\n },\n parseData: function parseData(data) {\n var _this3 = this;\n\n var attrs = data.data.attributes;\n var relations = data.data.relationships;\n console.log('relations', relations);\n var inc = data.included;\n console.log('included', inc);\n this.content = {\n title: attrs.title,\n body: attrs.body.value // parse all relationships\n\n };\n\n var _loop = function _loop(key) {\n // skip loop if the property is from prototype\n if (!relations.hasOwnProperty(key)) return \"continue\";\n var obj = relations[key];\n console.log('typeof obj.data', _typeof(obj.data)); // skip obj if data is not array\n\n if (!Array.isArray(obj.data)) return \"continue\";\n _this3.content[key] = []; // parse relationship values using included\n\n var field = {};\n obj.data.forEach(function (e) {\n // get the included values\n var included = inc.find(function (i) {\n return i.id == e.id;\n }); // fill the values\n\n switch (key) {\n case 'field_visuel':\n field = e.meta;\n field.id = e.id;\n field.src = included.links.card_medium.href;\n break;\n\n case 'field_linked_materials':\n case 'field_thesaurus':\n case 'field_tags':\n field = included.attributes;\n field.id = included.id;\n break;\n // case 'field_showroom':\n // field = included.attributes\n // break\n\n default:\n }\n\n _this3.content[key].push(field);\n });\n };\n\n for (var key in relations) {\n var _ret = _loop(key);\n\n if (_ret === \"continue\") continue;\n }\n\n console.log('article.content', this.content);\n },\n onNext: function onNext() {\n console.log('clicked on next', this.prevnext.next);\n var alias = this.prevnext.next.view_node.replace(/^.?\\/blabla\\//g, '');\n this.$router.push({\n name: \"article\",\n params: {\n alias: alias\n },\n query: {\n uuid: this.prevnext.next.uuid\n }\n });\n },\n onPrev: function onPrev() {\n console.log('clicked on prev', this.prevnext.next);\n var alias = this.prevnext.prev.view_node.replace(/^.?\\/blabla\\//g, '');\n this.$router.push({\n name: \"article\",\n params: {\n alias: alias\n },\n query: {\n uuid: this.prevnext.prev.uuid\n }\n });\n }\n }),\n watch: {\n '$route': function $route(to, from) {\n console.log('route change');\n this.getArticle();\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options"); /***/ }), @@ -662,7 +662,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"render\", function() { return render; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"staticRenderFns\", function() { return staticRenderFns; });\nvar render = function() {\n var _vm = this\n var _h = _vm.$createElement\n var _c = _vm._self._c || _h\n return !_vm.content\n ? _c(\"div\", { staticClass: \"loading\" }, [\n _c(\"span\", [_vm._v(\"Loading ...\")])\n ])\n : _c(\"article\", { staticClass: \"article\" }, [\n _c(\"header\", [\n _c(\"h1\", [_vm._v(_vm._s(_vm.content.title))]),\n _vm._v(\" \"),\n _c(\"div\", { staticClass: \"taxonomy\" }, [\n _c(\"div\", { staticClass: \"thesaurus\" }, [\n _c(\n \"ul\",\n _vm._l(_vm.content.field_thesaurus, function(term) {\n return _c(\"li\", { key: term.id }, [_vm._v(_vm._s(term.name))])\n }),\n 0\n )\n ]),\n _vm._v(\" \"),\n _c(\"div\", { staticClass: \"tags\" }, [\n _c(\n \"ul\",\n _vm._l(_vm.content.field_tags, function(term) {\n return _c(\"li\", { key: term.id }, [_vm._v(_vm._s(term.name))])\n }),\n 0\n )\n ])\n ]),\n _vm._v(\" \"),\n _c(\"div\", {\n staticClass: \"body\",\n domProps: { innerHTML: _vm._s(_vm.content.body) }\n }),\n _vm._v(\" \"),\n _c(\"div\", { staticClass: \"linked-materials\" }, [\n _c(\n \"ul\",\n _vm._l(_vm.content.field_linked_materials, function(node) {\n return _c(\"li\", { key: node.id }, [\n _c(\"section\", { attrs: { uuid: node.id } }, [\n _c(\"h1\", [_vm._v(_vm._s(node.title))]),\n _vm._v(\" \"),\n _c(\"h3\", [_vm._v(_vm._s(node.field_reference))]),\n _vm._v(\" \"),\n _c(\"h2\", [_vm._v(_vm._s(node.field_short_description))])\n ])\n ])\n }),\n 0\n )\n ]),\n _vm._v(\" \"),\n _c(\n \"div\",\n { staticClass: \"visuels\" },\n _vm._l(_vm.content.field_visuel, function(visuel) {\n return _c(\"figure\", { key: visuel.id }, [\n _c(\"img\", {\n attrs: {\n src: visuel.src,\n alt: visuel.alt,\n title: visuel.title\n }\n }),\n _vm._v(\" \"),\n _c(\"caption\")\n ])\n }),\n 0\n )\n ])\n ])\n}\nvar staticRenderFns = []\nrender._withStripped = true\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"render\", function() { return render; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"staticRenderFns\", function() { return staticRenderFns; });\nvar render = function() {\n var _vm = this\n var _h = _vm.$createElement\n var _c = _vm._self._c || _h\n return !_vm.content\n ? _c(\"div\", { staticClass: \"loading\" }, [\n _c(\"span\", [_vm._v(\"Loading ...\")])\n ])\n : _c(\"article\", { staticClass: \"article\" }, [\n _c(\"header\", [\n _c(\"h1\", [_vm._v(_vm._s(_vm.content.title))]),\n _vm._v(\" \"),\n _vm.index != -1\n ? _c(\"nav\", [\n _c(\n \"a\",\n {\n attrs: { href: \"#\" },\n on: {\n click: function($event) {\n $event.preventDefault()\n return _vm.onPrev($event)\n }\n }\n },\n [_vm._v(\"prev : \" + _vm._s(_vm.prevnext.prev.title))]\n ),\n _vm._v(\" \"),\n _c(\n \"a\",\n {\n attrs: { href: \"#\" },\n on: {\n click: function($event) {\n $event.preventDefault()\n return _vm.onNext($event)\n }\n }\n },\n [_vm._v(\"next : \" + _vm._s(_vm.prevnext.next.title))]\n )\n ])\n : _vm._e()\n ]),\n _vm._v(\" \"),\n _c(\"div\", { staticClass: \"taxonomy\" }, [\n _c(\"div\", { staticClass: \"thesaurus\" }, [\n _c(\n \"ul\",\n _vm._l(_vm.content.field_thesaurus, function(term) {\n return _c(\"li\", { key: term.id }, [_vm._v(_vm._s(term.name))])\n }),\n 0\n )\n ]),\n _vm._v(\" \"),\n _c(\"div\", { staticClass: \"tags\" }, [\n _c(\n \"ul\",\n _vm._l(_vm.content.field_tags, function(term) {\n return _c(\"li\", { key: term.id }, [_vm._v(_vm._s(term.name))])\n }),\n 0\n )\n ])\n ]),\n _vm._v(\" \"),\n _c(\"div\", {\n staticClass: \"body\",\n domProps: { innerHTML: _vm._s(_vm.content.body) }\n }),\n _vm._v(\" \"),\n _c(\"div\", { staticClass: \"linked-materials\" }, [\n _c(\n \"ul\",\n _vm._l(_vm.content.field_linked_materials, function(node) {\n return _c(\"li\", { key: node.id }, [\n _c(\"section\", { attrs: { uuid: node.id } }, [\n _c(\"h1\", [_vm._v(_vm._s(node.title))]),\n _vm._v(\" \"),\n _c(\"h3\", [_vm._v(_vm._s(node.field_reference))]),\n _vm._v(\" \"),\n _c(\"h2\", [_vm._v(_vm._s(node.field_short_description))])\n ])\n ])\n }),\n 0\n )\n ]),\n _vm._v(\" \"),\n _c(\n \"div\",\n { staticClass: \"visuels\" },\n _vm._l(_vm.content.field_visuel, function(visuel) {\n return _c(\"figure\", { key: visuel.id }, [\n _c(\"img\", {\n attrs: { src: visuel.src, alt: visuel.alt, title: visuel.title }\n }),\n _vm._v(\" \"),\n _c(\"caption\")\n ])\n }),\n 0\n )\n ])\n}\nvar staticRenderFns = []\nrender._withStripped = true\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options"); /***/ }), @@ -1307,7 +1307,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _jsonAxios = __webpack_require__(/*! vuejs/api/json-axios */ \"./web/themes/custom/materiotheme/vuejs/api/json-axios.js\");\n\nvar _restAxios = __webpack_require__(/*! vuejs/api/rest-axios */ \"./web/themes/custom/materiotheme/vuejs/api/rest-axios.js\");\n\nvar _maAxios = __webpack_require__(/*! vuejs/api/ma-axios */ \"./web/themes/custom/materiotheme/vuejs/api/ma-axios.js\");\n\nvar _querystring = _interopRequireDefault(__webpack_require__(/*! querystring */ \"./node_modules/querystring-es3/index.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar _default = {\n namespaced: true,\n // initial state\n state: {\n items: [],\n page: 0,\n // infinteState will come from vue-infinite-loading plugin\n // implemented in vuejs/components/Content/Base.vue\n infiniteLoadingState: null\n },\n // getters\n getters: {},\n // mutations\n mutations: {\n setItems: function setItems(state, items) {\n state.items = state.items.concat(items);\n },\n incrementPage: function incrementPage(state) {\n state.page += 1;\n },\n setInfiniteState: function setInfiniteState(state, infiniteLoadingstate) {\n state.infiniteLoadingState = infiniteLoadingstate;\n }\n },\n // actions\n actions: {\n getItems: function getItems(_ref) {\n var dispatch = _ref.dispatch,\n commit = _ref.commit,\n state = _ref.state;\n\n _restAxios.REST.get(\"/blabla_rest?_format=json&page=\".concat(state.page), {}).then(function (_ref2) {\n var data = _ref2.data;\n console.log('blabla REST: data', data);\n\n if (data.length) {\n commit('setItems', data); // console.log('items.length', this.items.length);\n\n if (state.infiniteLoadingState) state.infiniteLoadingState.loaded();\n } else {\n if (state.infiniteLoadingState) state.infiniteLoadingState.complete();\n }\n }).catch(function (error) {\n console.warn('Issue with blabla', error);\n Promise.reject(error);\n });\n },\n nextPage: function nextPage(_ref3, $infiniteLoadingstate) {\n var dispatch = _ref3.dispatch,\n commit = _ref3.commit,\n state = _ref3.state;\n console.log(\"Search nextPage\", $infiniteLoadingstate);\n commit('incrementPage');\n commit('setInfiniteState', $infiniteLoadingstate);\n dispatch('getItems');\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/store/modules/blabla.js?"); +eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _jsonAxios = __webpack_require__(/*! vuejs/api/json-axios */ \"./web/themes/custom/materiotheme/vuejs/api/json-axios.js\");\n\nvar _restAxios = __webpack_require__(/*! vuejs/api/rest-axios */ \"./web/themes/custom/materiotheme/vuejs/api/rest-axios.js\");\n\nvar _maAxios = __webpack_require__(/*! vuejs/api/ma-axios */ \"./web/themes/custom/materiotheme/vuejs/api/ma-axios.js\");\n\nvar _querystring = _interopRequireDefault(__webpack_require__(/*! querystring */ \"./node_modules/querystring-es3/index.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar _default = {\n namespaced: true,\n // initial state\n state: {\n items: [],\n page: 0,\n // infinteState will come from vue-infinite-loading plugin\n // implemented in vuejs/components/Content/Base.vue\n infiniteLoadingState: null\n },\n // getters\n getters: {},\n // mutations\n mutations: {\n setItems: function setItems(state, items) {\n state.items = state.items.concat(items);\n },\n incrementPage: function incrementPage(state) {\n state.page += 1;\n },\n setInfiniteState: function setInfiniteState(state, infiniteLoadingstate) {\n state.infiniteLoadingState = infiniteLoadingstate;\n }\n },\n // actions\n actions: {\n getItems: function getItems(_ref) {\n var dispatch = _ref.dispatch,\n commit = _ref.commit,\n state = _ref.state;\n\n _restAxios.REST.get(\"/blabla_rest?_format=json&page=\".concat(state.page), {}).then(function (_ref2) {\n var data = _ref2.data;\n console.log('blabla REST: data', data);\n\n if (data.length) {\n commit('setItems', data); // console.log('items.length', this.items.length);\n\n if (state.infiniteLoadingState) state.infiniteLoadingState.loaded();\n } else {\n if (state.infiniteLoadingState) state.infiniteLoadingState.complete();\n }\n }).catch(function (error) {\n console.warn('Issue with blabla', error);\n Promise.reject(error);\n });\n },\n nextPage: function nextPage(_ref3, $infiniteLoadingstate) {\n var dispatch = _ref3.dispatch,\n commit = _ref3.commit,\n state = _ref3.state;\n console.log(\"blabla nextPage\", $infiniteLoadingstate);\n commit('incrementPage');\n commit('setInfiniteState', $infiniteLoadingstate);\n dispatch('getItems');\n },\n getItemIndex: function getItemIndex(_ref4, uuid) {\n var dispatch = _ref4.dispatch,\n commit = _ref4.commit,\n state = _ref4.state;\n return state.items.findIndex(function (e) {\n return e.uuid == uuid;\n });\n },\n getPrevNextItems: function getPrevNextItems(_ref5, index) {\n var dispatch = _ref5.dispatch,\n commit = _ref5.commit,\n state = _ref5.state;\n return {\n prev: state.items[index - 1],\n next: state.items[index + 1]\n };\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/store/modules/blabla.js?"); /***/ }), diff --git a/web/themes/custom/materiotheme/vuejs/components/Content/Article.vue b/web/themes/custom/materiotheme/vuejs/components/Content/Article.vue index 17879cd3..e3702b7a 100644 --- a/web/themes/custom/materiotheme/vuejs/components/Content/Article.vue +++ b/web/themes/custom/materiotheme/vuejs/components/Content/Article.vue @@ -5,47 +5,51 @@

{{ content.title }}

-
-
-
    -
  • {{ term.name }}
  • -
-
-
-
    -
  • {{ term.name }}
  • -
-
-
-
-
+
+
    -
  • -
    -

    {{ node.title }}

    -

    {{ node.field_reference }}

    -

    {{ node.field_short_description }}

    -
    -
  • +
  • {{ term.name }}
-
-
- - -
+
+
    +
  • {{ term.name }}
  • +
- +
+
+
+
    +
  • +
    +

    {{ node.title }}

    +

    {{ node.field_reference }}

    +

    {{ node.field_short_description }}

    +
    +
  • +
+
+
+
+ + +
+
@@ -53,6 +57,7 @@ import router from 'vuejs/route' import { JSONAPI } from 'vuejs/api/json-axios' import qs from 'querystring' +import { mapState, mapActions } from 'vuex' export default { name: "Article", @@ -60,6 +65,8 @@ export default { props: ['item'], data(){ return { + index:-1, + prevnext:{}, uuid:null, content:null } @@ -68,6 +75,20 @@ export default { this.getArticle() }, methods: { + ...mapActions({ + getItemIndex: 'Blabla/getItemIndex', + getPrevNextItems: 'Blabla/getPrevNextItems' + }), + getIndex(){ + console.log("Article getIndex"); + this.getItemIndex(this.uuid).then((index) => { + this.index = index + // console.log('article index', index, this); + this.getPrevNextItems(index).then((pn) => { + this.prevnext = pn + }) + }) + }, getArticle(){ console.log(this.$route); // get the article uuid @@ -82,6 +103,7 @@ export default { } if(this.uuid){ + this.getIndex() this.loadArticle() }else{ // if for any reason we dont have the uuid @@ -157,6 +179,30 @@ export default { console.log('article.content',this.content); + }, + onNext(){ + console.log('clicked on next', this.prevnext.next); + let alias = this.prevnext.next.view_node.replace(/^.?\/blabla\//g, '') + this.$router.push({ + name:`article`, + params: { alias:alias }, + query: { uuid: this.prevnext.next.uuid } + }) + }, + onPrev(){ + console.log('clicked on prev', this.prevnext.next); + let alias = this.prevnext.prev.view_node.replace(/^.?\/blabla\//g, '') + this.$router.push({ + name:`article`, + params: { alias:alias }, + query: { uuid: this.prevnext.prev.uuid } + }) + } + }, + watch: { + '$route' (to, from) { + console.log('route change') + this.getArticle() } } } diff --git a/web/themes/custom/materiotheme/vuejs/store/modules/blabla.js b/web/themes/custom/materiotheme/vuejs/store/modules/blabla.js index 7ea29fb0..33d6ad9c 100644 --- a/web/themes/custom/materiotheme/vuejs/store/modules/blabla.js +++ b/web/themes/custom/materiotheme/vuejs/store/modules/blabla.js @@ -53,10 +53,21 @@ export default { }) }, nextPage ({ dispatch, commit, state }, $infiniteLoadingstate) { - console.log("Search nextPage", $infiniteLoadingstate); + console.log("blabla nextPage", $infiniteLoadingstate); commit('incrementPage') commit('setInfiniteState', $infiniteLoadingstate) dispatch('getItems') + }, + getItemIndex({ dispatch, commit, state}, uuid) { + return state.items.findIndex((e) =>{ + return e.uuid == uuid + }) + }, + getPrevNextItems({ dispatch, commit, state }, index) { + return { + prev:state.items[index-1], + next:state.items[index+1] + } } } }