From a926595856910e04e94699874f107083c83335df Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Sat, 13 Jul 2019 15:40:14 +0200 Subject: [PATCH] balbla page displaying article as cards with infinite loading --- config/sync/views.view.blabla.yml | 436 ++++++++++++++++-- .../custom/materiotheme/assets/dist/main.js | 66 ++- .../materiotheme/assets/scripts/main.js | 8 +- .../vuejs/components/Content/Article.vue | 23 + .../vuejs/components/Content/Blabla.vue | 54 ++- 5 files changed, 546 insertions(+), 41 deletions(-) create mode 100644 web/themes/custom/materiotheme/vuejs/components/Content/Article.vue diff --git a/config/sync/views.view.blabla.yml b/config/sync/views.view.blabla.yml index 366869ae..d6f44059 100644 --- a/config/sync/views.view.blabla.yml +++ b/config/sync/views.view.blabla.yml @@ -4,12 +4,20 @@ status: true dependencies: config: - core.entity_view_mode.node.teaser + - field.storage.node.body + - field.storage.node.field_date + - field.storage.node.field_visuel + - image.style.card_medium - node.type.article - system.menu.header module: + - datetime_range + - image - node - rest - serialization + - smart_trim + - taxonomy - user id: blabla label: Blabla @@ -80,39 +88,54 @@ display: id: title table: node_field_data field: title - entity_type: node - entity_field: title - label: '' - alter: - alter_text: false - make_link: false - absolute: false - trim: false - word_boundary: false - ellipsis: false - strip_tags: false - html: false - hide_empty: false - empty_zero: false - settings: - link_to_entity: true - plugin_id: field relationship: none group_type: group admin_label: '' + label: '' exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: false + ellipsis: false + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false element_type: '' element_class: '' element_label_type: '' element_label_class: '' - element_label_colon: true + element_label_colon: false element_wrapper_type: '' element_wrapper_class: '' element_default_classes: true empty: '' + hide_empty: false + empty_zero: false hide_alter_empty: true click_sort_column: value type: string + settings: + link_to_entity: false group_column: value group_columns: { } group_rows: true @@ -123,6 +146,336 @@ display: multi_type: separator separator: ', ' field_api_classes: false + entity_type: node + entity_field: title + plugin_id: field + body: + id: body + table: node__body + field: body + relationship: none + group_type: group + admin_label: '' + label: '' + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: smart_trim + settings: + trim_length: 100 + trim_type: chars + trim_suffix: ... + wrap_output: false + wrap_class: trimmed + more_link: false + more_text: More + more_class: more-link + summary_handler: full + trim_options: + text: true + trim_zero: false + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + plugin_id: field + uuid: + id: uuid + table: node + field: uuid + relationship: none + group_type: group + admin_label: '' + label: '' + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: string + settings: + link_to_entity: false + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + entity_type: node + entity_field: uuid + plugin_id: field + field_visuel: + id: field_visuel + table: node__field_visuel + field: field_visuel + relationship: none + group_type: group + admin_label: '' + label: '' + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: target_id + type: image + settings: + image_style: card_medium + image_link: '' + group_column: '' + group_columns: { } + group_rows: true + delta_limit: 1 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + plugin_id: field + term_node_tid: + id: term_node_tid + table: node_field_data + field: term_node_tid + relationship: none + group_type: group + admin_label: '' + label: '' + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + type: separator + separator: ', ' + link_to_taxonomy: false + limit: false + vids: + company: '0' + showroom: '0' + tags: '0' + thesaurus: '0' + entity_type: node + plugin_id: taxonomy_index_tid + field_date: + id: field_date + table: node__field_date + field: field_date + relationship: none + group_type: group + admin_label: '' + label: '' + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: daterange_default + settings: + timezone_override: '' + format_type: html_date + separator: '-' + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + plugin_id: field filters: status: value: '1' @@ -215,7 +568,10 @@ display: - url.query_args - 'user.node_grants:view' - user.permissions - tags: { } + tags: + - 'config:field.storage.node.body' + - 'config:field.storage.node.field_date' + - 'config:field.storage.node.field_visuel' page_1: display_plugin: page id: page_1 @@ -242,7 +598,10 @@ display: - url.query_args - 'user.node_grants:view' - user.permissions - tags: { } + tags: + - 'config:field.storage.node.body' + - 'config:field.storage.node.field_date' + - 'config:field.storage.node.field_visuel' rest_export_1: display_plugin: rest_export id: rest_export_1 @@ -254,23 +613,48 @@ display: path: blabla_rest style: type: serializer + options: + uses_fields: false + formats: + json: json defaults: style: false row: false row: - type: data_entity - options: { } - pager: - type: some + type: data_field options: - items_per_page: 10 + field_options: + title: + alias: '' + raw_output: false + pager: + type: mini + options: + items_per_page: 20 offset: 0 + id: 0 + total_pages: null + tags: + previous: ‹‹ + next: ›› + expose: + items_per_page: false + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 25, 50' + items_per_page_options_all: false + items_per_page_options_all_label: '- All -' + offset: false + offset_label: Offset cache_metadata: max-age: -1 contexts: - 'languages:language_content' - 'languages:language_interface' - request_format + - url.query_args - 'user.node_grants:view' - user.permissions - tags: { } + tags: + - 'config:field.storage.node.body' + - 'config:field.storage.node.field_date' + - 'config:field.storage.node.field_visuel' diff --git a/web/themes/custom/materiotheme/assets/dist/main.js b/web/themes/custom/materiotheme/assets/dist/main.js index 5261dabb..6fb853a8 100644 --- a/web/themes/custom/materiotheme/assets/dist/main.js +++ b/web/themes/custom/materiotheme/assets/dist/main.js @@ -409,6 +409,18 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n /***/ }), +/***/ "./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js?!./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?vue&type=script&lang=js&": +/*!****************************************************************************************************************************************************************************************!*\ + !*** ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?vue&type=script&lang=js& ***! + \****************************************************************************************************************************************************************************************/ +/*! no static exports found */ +/***/ (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\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nvar _default = {\n name: \"Article\",\n props: ['item']\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"); + +/***/ }), + /***/ "./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js?!./web/themes/custom/materiotheme/vuejs/components/Content/Base.vue?vue&type=script&lang=js&": /*!*************************************************************************************************************************************************************************************!*\ !*** ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./web/themes/custom/materiotheme/vuejs/components/Content/Base.vue?vue&type=script&lang=js& ***! @@ -429,7 +441,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//\n//\n//\n//\n//\n//\nvar _default = {\n name: \"Blabla\",\n data: function data() {\n return {};\n },\n beforeMount: function beforeMount() {}\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Blabla.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 _restAxios = __webpack_require__(/*! vuejs/api/rest-axios */ \"./web/themes/custom/materiotheme/vuejs/api/rest-axios.js\");\n\nvar _Article = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/Article */ \"./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nvar _default = {\n name: \"Blabla\",\n data: function data() {\n return {\n items: [],\n page: 1\n };\n },\n beforeMount: function beforeMount() {\n this.getArticles();\n },\n methods: {\n getArticles: function getArticles($state) {\n var _this = this;\n\n _restAxios.REST.get(\"/blabla_rest?_format=json&page=\".concat(this.page), {}).then(function (_ref) {\n var data = _ref.data;\n console.log('blabla REST: data', data);\n\n if (data.length) {\n _this.items = _this.items.concat(data); // console.log('items.length', this.items.length);\n\n _this.page += 1;\n if ($state) $state.loaded();\n } else {\n if ($state) $state.complete();\n }\n }).catch(function (error) {\n console.warn('Issue with blabla', error);\n Promise.reject(error);\n });\n }\n },\n components: {\n Article: _Article.default\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Blabla.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options"); /***/ }), @@ -665,6 +677,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ }), +/***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?vue&type=template&id=cd687464&scoped=true&": +/*!******************************************************************************************************************************************************************************************************************************************************!*\ + !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?vue&type=template&id=cd687464&scoped=true& ***! + \******************************************************************************************************************************************************************************************************************************************************/ +/*! exports provided: render, staticRenderFns */ +/***/ (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 _c(\"article\", { staticClass: \"card article\" }, [\n _c(\"header\", [\n _c(\"h1\", { domProps: { innerHTML: _vm._s(_vm.item.title) } }),\n _vm._v(\" \"),\n _c(\"h4\", {\n staticClass: \"body\",\n domProps: { innerHTML: _vm._s(_vm.item.body) }\n })\n ]),\n _vm._v(\" \"),\n _c(\"section\", { staticClass: \"images\" }, [\n _c(\"figure\", { domProps: { innerHTML: _vm._s(_vm.item.field_visuel) } })\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"); + +/***/ }), + /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./web/themes/custom/materiotheme/vuejs/components/Content/Base.vue?vue&type=template&id=c60a80ae&scoped=true&": /*!***************************************************************************************************************************************************************************************************************************************************!*\ !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./web/themes/custom/materiotheme/vuejs/components/Content/Base.vue?vue&type=template&id=c60a80ae&scoped=true& ***! @@ -685,7 +709,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._m(0)\n}\nvar staticRenderFns = [\n function() {\n var _vm = this\n var _h = _vm.$createElement\n var _c = _vm._self._c || _h\n return _c(\"div\", { attrs: { id: \"blabla\" } }, [\n _c(\"h1\", [_vm._v(\"Blabla\")])\n ])\n }\n]\nrender._withStripped = true\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Blabla.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 _c(\"div\", { attrs: { id: \"blabla\" } }, [\n !_vm.items.length\n ? _c(\"div\", { staticClass: \"loading\" }, [\n _c(\"span\", [_vm._v(\"Loading ...\")])\n ])\n : _c(\n \"div\",\n { staticClass: \"cards-list\" },\n [\n _c(\n \"ul\",\n _vm._l(_vm.items, function(item) {\n return _c(\n \"li\",\n { key: item.uuid },\n [_c(\"Article\", { attrs: { item: item } })],\n 1\n )\n }),\n 0\n ),\n _vm._v(\" \"),\n _c(\"infinite-loading\", { on: { infinite: _vm.getArticles } }, [\n _c(\"div\", { attrs: { slot: \"no-more\" }, slot: \"no-more\" }, [\n _vm._v(\"No more results\")\n ])\n ])\n ],\n 1\n )\n ])\n}\nvar staticRenderFns = []\nrender._withStripped = true\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Blabla.vue?./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options"); /***/ }), @@ -848,7 +872,7 @@ eval("module.exports = \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUC /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\n\nvar _vue = _interopRequireDefault(__webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.js\"));\n\nvar _vueInfiniteLoading = _interopRequireDefault(__webpack_require__(/*! vue-infinite-loading */ \"./node_modules/vue-infinite-loading/dist/vue-infinite-loading.js\"));\n\nvar _store = _interopRequireDefault(__webpack_require__(/*! vuejs/store */ \"./web/themes/custom/materiotheme/vuejs/store/index.js\"));\n\nvar _route = _interopRequireDefault(__webpack_require__(/*! vuejs/route */ \"./web/themes/custom/materiotheme/vuejs/route/index.js\"));\n\nvar _UserBlock = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Block/UserBlock */ \"./web/themes/custom/materiotheme/vuejs/components/Block/UserBlock.vue\"));\n\nvar _MainContent = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/MainContent */ \"./web/themes/custom/materiotheme/vuejs/components/Content/MainContent.vue\"));\n\nvar _SearchBlock = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Block/SearchBlock */ \"./web/themes/custom/materiotheme/vuejs/components/Block/SearchBlock.vue\"));\n\nvar _vuex = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.esm.js\");\n\n__webpack_require__(/*! theme/assets/styles/main.scss */ \"./web/themes/custom/materiotheme/assets/styles/main.scss\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: 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\n_vue.default.use(_vueInfiniteLoading.default, {\n props: {\n spinner: 'spiral' // slots.noMore: ''\n\n } // system: {\n // throttleLimit: 50,\n // /* other settings need to configure */\n // }\n\n});\n\n(function (Drupal, drupalSettings) {\n var MaterioTheme = function MaterioTheme() {\n var _v_sitebranding_block, _v_user_block, _v_header_menu, _v_pagetitle_block, _v_search_block, _v_main_content;\n\n var _is_front = drupalSettings.path.isFront;\n console.log('drupalSettings', drupalSettings); // ___ _ _\n // |_ _|_ _ (_) |_\n // | || ' \\| | _|\n // |___|_||_|_|\\__|\n\n function init() {\n console.log(\"MaterioTheme init()\");\n initVues();\n }\n\n function initVues() {\n initVRouter();\n initVSiteBrandingBlock();\n initVPagetitleBlock();\n initVUserBlock();\n initVHeaderMenu();\n initVMainContent();\n initVSearchBlock();\n }\n\n function initVRouter() {\n // we need this to update the title while using history nav\n _route.default.beforeEach(function (to, from, next) {\n // console.log('router beforeEach');\n // console.log(to);\n // console.log(from);\n // console.log(next);\n _store.default.commit('Common/setPagetitle', to.name);\n\n next();\n });\n }\n\n function initVSiteBrandingBlock() {\n _v_sitebranding_block = new _vue.default({\n store: _store.default,\n router: _route.default,\n el: '#block-sitebranding',\n methods: {\n onclick: function onclick(event) {\n // console.log(\"Clicked on logo event\", event);\n var href = event.target.getAttribute('href'); // console.log(\"Clicked on logo href\", href);\n\n this.$router.push(href); // replaced by router.beforeEach\n // this.$store.commit('Common/setPagetitle', null)\n }\n }\n });\n }\n\n function initVPagetitleBlock() {\n var $blk = document.querySelector('#block-pagetitle');\n var $h2 = $blk.querySelector('h2'); // get the loaded pagetitle\n\n var title = $h2.innerText; // if not front recorde the loaded pagetitle in store\n\n if (!_is_front) {\n _store.default.commit('Common/setPagetitle', title);\n } // replace in template the pagetitle by vue binding\n\n\n $h2.innerText = '{{ pagetitle }}'; // create the vue\n\n _v_pagetitle_block = new _vue.default({\n store: _store.default,\n router: _route.default,\n el: $blk,\n computed: _objectSpread({}, (0, _vuex.mapState)({\n pagetitle: function pagetitle(state) {\n return state.Common.pagetitle;\n }\n }))\n });\n }\n\n function initVUserBlock() {\n var mount_point = drupalSettings.user.uid !== 0 ? 'block-userblock' : 'block-userlogin';\n var props = {\n title: \"\",\n loginblock: \"\"\n };\n\n switch (mount_point) {\n case 'block-userlogin':\n var $block = document.getElementById(mount_point);\n console.log('initVUserBlock login form html', $block);\n props.loginblock = $block.outerHTML.trim();\n break;\n\n case 'block-userblock':\n default:\n break;\n }\n\n _v_user_block = new _vue.default({\n store: _store.default,\n // computed: {\n // ...mapState({\n // isloggedin: state => state.User.isloggedin\n // })\n // },\n created: function created() {\n // if already loggedin, call store.user to get the user infos\n if (drupalSettings.user.uid !== 0) {\n this.$store.commit('User/setUid', drupalSettings.user.uid);\n this.$store.dispatch('User/getUser');\n }\n },\n render: function render(h) {\n return h(_UserBlock.default, {\n props: props\n });\n }\n }).$mount('#' + mount_point); // console.log('initVUserBlock', _v_user_block);\n }\n\n function initVHeaderMenu() {\n // console.log('initVHeaderMenu');\n // adding vuejs attributes has it wont work on twig template (see menu--header.html.twig)\n // not working : String contains an invalid character\n // document.querySelectorAll(`#block-header a`).forEach(link => {\n // console.log(link);\n // link.setAttribute('@click.prevent', 'onclick')\n // });\n _v_header_menu = new _vue.default({\n store: _store.default,\n router: _route.default,\n el: \"#block-header\",\n methods: {\n onclick: function onclick(event) {\n // console.log(\"Clicked on header menu link\", event);\n var href = event.target.getAttribute('href');\n var title = event.target.innerText; // console.log(\"Clicked on header menu link : href\", href);\n\n this.$router.push(href); // replaced by router.beforeEach\n // this.$store.commit('Common/setPagetitle', title)\n }\n }\n });\n }\n\n function initVMainContent() {\n var id = \"main-content\";\n var $main_content = document.querySelector('#' + id); // console.log('main-content', $main_content);\n\n var main_html = $main_content.innerHTML;\n _v_main_content = new _vue.default({\n store: _store.default,\n render: function render(h) {\n return h(_MainContent.default, {\n props: {\n id: id,\n html: main_html,\n isfront: drupalSettings.path.isFront\n }\n });\n }\n }).$mount('#' + id);\n }\n\n function initVSearchBlock() {\n // console.log('initVSearchBlock');\n var id = \"block-materiosapisearchblock\";\n var $search_block = document.getElementById(id);\n var formhtml = null;\n\n if ($search_block) {\n // get the search form html to pass it as template to the vue\n // we gain display speed vs async downloaded data\n formhtml = $search_block.innerHTML;\n } else {\n // else create the empty block to fill it later with async data\n $search_block = document.createElement('div');\n $search_block.setAttribute('id', id); // TODO: get region by REST\n\n var $region = document.getElementById('header-bottom');\n $region.appendChild($search_block);\n } // in any case create the vue\n\n\n _v_search_block = new _vue.default({\n store: _store.default,\n render: function render(h) {\n return h(_SearchBlock.default, {\n props: {\n blockid: id,\n formhtml: formhtml\n }\n });\n }\n }).$mount('#' + id);\n }\n\n init();\n }; // end MaterioTheme()\n\n\n var materiotheme = new MaterioTheme();\n})(Drupal, drupalSettings);\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/assets/scripts/main.js?"); +eval("\n\nvar _vue = _interopRequireDefault(__webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.js\"));\n\nvar _vueInfiniteLoading = _interopRequireDefault(__webpack_require__(/*! vue-infinite-loading */ \"./node_modules/vue-infinite-loading/dist/vue-infinite-loading.js\"));\n\nvar _store = _interopRequireDefault(__webpack_require__(/*! vuejs/store */ \"./web/themes/custom/materiotheme/vuejs/store/index.js\"));\n\nvar _route = _interopRequireDefault(__webpack_require__(/*! vuejs/route */ \"./web/themes/custom/materiotheme/vuejs/route/index.js\"));\n\nvar _UserBlock = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Block/UserBlock */ \"./web/themes/custom/materiotheme/vuejs/components/Block/UserBlock.vue\"));\n\nvar _MainContent = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/MainContent */ \"./web/themes/custom/materiotheme/vuejs/components/Content/MainContent.vue\"));\n\nvar _SearchBlock = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Block/SearchBlock */ \"./web/themes/custom/materiotheme/vuejs/components/Block/SearchBlock.vue\"));\n\nvar _vuex = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.esm.js\");\n\n__webpack_require__(/*! theme/assets/styles/main.scss */ \"./web/themes/custom/materiotheme/assets/styles/main.scss\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: 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\n_vue.default.use(_vueInfiniteLoading.default, {\n props: {\n spinner: 'spiral' // slots.noMore: ''\n\n } // system: {\n // throttleLimit: 50,\n // /* other settings need to configure */\n // }\n\n});\n\n(function (Drupal, drupalSettings) {\n var MaterioTheme = function MaterioTheme() {\n var _v_sitebranding_block, _v_user_block, _v_header_menu, _v_pagetitle_block, _v_search_block, _v_main_content;\n\n var _is_front = drupalSettings.path.isFront;\n console.log('drupalSettings', drupalSettings); // ___ _ _\n // |_ _|_ _ (_) |_\n // | || ' \\| | _|\n // |___|_||_|_|\\__|\n\n function init() {\n console.log(\"MaterioTheme init()\");\n initVues();\n }\n\n function initVues() {\n initVRouter();\n initVSiteBrandingBlock();\n initVPagetitleBlock();\n initVUserBlock();\n initVHeaderMenu();\n initVMainContent();\n initVSearchBlock();\n }\n\n function initVRouter() {\n // we need this to update the title while using history nav\n _route.default.beforeEach(function (to, from, next) {\n _store.default.commit('Common/setPagetitle', to.name != 'home' ? to.name : null);\n\n next();\n });\n }\n\n function initVSiteBrandingBlock() {\n _v_sitebranding_block = new _vue.default({\n store: _store.default,\n router: _route.default,\n el: '#block-sitebranding',\n methods: {\n onclick: function onclick(event) {\n // console.log(\"Clicked on logo event\", event);\n var href = event.target.getAttribute('href'); // console.log(\"Clicked on logo href\", href);\n\n this.$router.push(href); // replaced by router.beforeEach\n // this.$store.commit('Common/setPagetitle', null)\n }\n }\n });\n }\n\n function initVPagetitleBlock() {\n var $blk = document.querySelector('#block-pagetitle');\n var $h2 = $blk.querySelector('h2'); // get the loaded pagetitle\n\n var title = $h2.innerText; // if not front recorde the loaded pagetitle in store\n\n if (!_is_front) {\n _store.default.commit('Common/setPagetitle', title);\n } // replace in template the pagetitle by vue binding\n\n\n $h2.innerText = '{{ pagetitle }}'; // create the vue\n\n _v_pagetitle_block = new _vue.default({\n store: _store.default,\n router: _route.default,\n el: $blk,\n computed: _objectSpread({}, (0, _vuex.mapState)({\n pagetitle: function pagetitle(state) {\n return state.Common.pagetitle;\n }\n }))\n });\n }\n\n function initVUserBlock() {\n var mount_point = drupalSettings.user.uid !== 0 ? 'block-userblock' : 'block-userlogin';\n var props = {\n title: \"\",\n loginblock: \"\"\n };\n\n switch (mount_point) {\n case 'block-userlogin':\n var $block = document.getElementById(mount_point);\n console.log('initVUserBlock login form html', $block);\n props.loginblock = $block.outerHTML.trim();\n break;\n\n case 'block-userblock':\n default:\n break;\n }\n\n _v_user_block = new _vue.default({\n store: _store.default,\n // computed: {\n // ...mapState({\n // isloggedin: state => state.User.isloggedin\n // })\n // },\n created: function created() {\n // if already loggedin, call store.user to get the user infos\n if (drupalSettings.user.uid !== 0) {\n this.$store.commit('User/setUid', drupalSettings.user.uid);\n this.$store.dispatch('User/getUser');\n }\n },\n render: function render(h) {\n return h(_UserBlock.default, {\n props: props\n });\n }\n }).$mount('#' + mount_point); // console.log('initVUserBlock', _v_user_block);\n }\n\n function initVHeaderMenu() {\n // console.log('initVHeaderMenu');\n // adding vuejs attributes has it wont work on twig template (see menu--header.html.twig)\n // not working : String contains an invalid character\n // document.querySelectorAll(`#block-header a`).forEach(link => {\n // console.log(link);\n // link.setAttribute('@click.prevent', 'onclick')\n // });\n _v_header_menu = new _vue.default({\n store: _store.default,\n router: _route.default,\n el: \"#block-header\",\n methods: {\n onclick: function onclick(event) {\n // console.log(\"Clicked on header menu link\", event);\n var href = event.target.getAttribute('href');\n var title = event.target.innerText; // console.log(\"Clicked on header menu link : href\", href);\n\n this.$router.push(href); // replaced by router.beforeEach\n // this.$store.commit('Common/setPagetitle', title)\n }\n }\n });\n }\n\n function initVMainContent() {\n var id = \"main-content\";\n var $main_content = document.querySelector('#' + id); // console.log('main-content', $main_content);\n\n var main_html = $main_content.innerHTML;\n _v_main_content = new _vue.default({\n store: _store.default,\n render: function render(h) {\n return h(_MainContent.default, {\n props: {\n id: id,\n html: main_html,\n isfront: drupalSettings.path.isFront\n }\n });\n }\n }).$mount('#' + id);\n }\n\n function initVSearchBlock() {\n // console.log('initVSearchBlock');\n var id = \"block-materiosapisearchblock\";\n var $search_block = document.getElementById(id);\n var formhtml = null;\n\n if ($search_block) {\n // get the search form html to pass it as template to the vue\n // we gain display speed vs async downloaded data\n formhtml = $search_block.innerHTML;\n } else {\n // else create the empty block to fill it later with async data\n $search_block = document.createElement('div');\n $search_block.setAttribute('id', id); // TODO: get region by REST\n\n var $region = document.getElementById('header-bottom');\n $region.appendChild($search_block);\n } // in any case create the vue\n\n\n _v_search_block = new _vue.default({\n store: _store.default,\n render: function render(h) {\n return h(_SearchBlock.default, {\n props: {\n blockid: id,\n formhtml: formhtml\n }\n });\n }\n }).$mount('#' + id);\n }\n\n init();\n }; // end MaterioTheme()\n\n\n var materiotheme = new MaterioTheme();\n})(Drupal, drupalSettings);\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/assets/scripts/main.js?"); /***/ }), @@ -1007,6 +1031,42 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _nod /***/ }), +/***/ "./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue": +/*!*****************************************************************************!*\ + !*** ./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue ***! + \*****************************************************************************/ +/*! no static exports found */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Article_vue_vue_type_template_id_cd687464_scoped_true___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Article.vue?vue&type=template&id=cd687464&scoped=true& */ \"./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?vue&type=template&id=cd687464&scoped=true&\");\n/* harmony import */ var _Article_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Article.vue?vue&type=script&lang=js& */ \"./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?vue&type=script&lang=js&\");\n/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _Article_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__) if(__WEBPACK_IMPORT_KEY__ !== 'default') (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _Article_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__[key]; }) }(__WEBPACK_IMPORT_KEY__));\n/* harmony import */ var _node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js */ \"./node_modules/vue-loader/lib/runtime/componentNormalizer.js\");\n\n\n\n\n\n/* normalize component */\n\nvar component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(\n _Article_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n _Article_vue_vue_type_template_id_cd687464_scoped_true___WEBPACK_IMPORTED_MODULE_0__[\"render\"],\n _Article_vue_vue_type_template_id_cd687464_scoped_true___WEBPACK_IMPORTED_MODULE_0__[\"staticRenderFns\"],\n false,\n null,\n \"cd687464\",\n null\n \n)\n\n/* hot reload */\nif (false) { var api; }\ncomponent.options.__file = \"web/themes/custom/materiotheme/vuejs/components/Content/Article.vue\"\n/* harmony default export */ __webpack_exports__[\"default\"] = (component.exports);\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?"); + +/***/ }), + +/***/ "./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?vue&type=script&lang=js&": +/*!******************************************************************************************************!*\ + !*** ./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?vue&type=script&lang=js& ***! + \******************************************************************************************************/ +/*! no static exports found */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _node_modules_babel_loader_lib_index_js_node_modules_vue_loader_lib_index_js_vue_loader_options_Article_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../../../../../node_modules/babel-loader/lib!../../../../../../../node_modules/vue-loader/lib??vue-loader-options!./Article.vue?vue&type=script&lang=js& */ \"./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js?!./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?vue&type=script&lang=js&\");\n/* harmony import */ var _node_modules_babel_loader_lib_index_js_node_modules_vue_loader_lib_index_js_vue_loader_options_Article_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_babel_loader_lib_index_js_node_modules_vue_loader_lib_index_js_vue_loader_options_Article_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__);\n/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _node_modules_babel_loader_lib_index_js_node_modules_vue_loader_lib_index_js_vue_loader_options_Article_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== 'default') (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _node_modules_babel_loader_lib_index_js_node_modules_vue_loader_lib_index_js_vue_loader_options_Article_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__));\n /* harmony default export */ __webpack_exports__[\"default\"] = (_node_modules_babel_loader_lib_index_js_node_modules_vue_loader_lib_index_js_vue_loader_options_Article_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0___default.a); \n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?"); + +/***/ }), + +/***/ "./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?vue&type=template&id=cd687464&scoped=true&": +/*!************************************************************************************************************************!*\ + !*** ./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?vue&type=template&id=cd687464&scoped=true& ***! + \************************************************************************************************************************/ +/*! exports provided: render, staticRenderFns */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_Article_vue_vue_type_template_id_cd687464_scoped_true___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../../../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../../../../../node_modules/vue-loader/lib??vue-loader-options!./Article.vue?vue&type=template&id=cd687464&scoped=true& */ \"./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?vue&type=template&id=cd687464&scoped=true&\");\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"render\", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_Article_vue_vue_type_template_id_cd687464_scoped_true___WEBPACK_IMPORTED_MODULE_0__[\"render\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"staticRenderFns\", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_Article_vue_vue_type_template_id_cd687464_scoped_true___WEBPACK_IMPORTED_MODULE_0__[\"staticRenderFns\"]; });\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Article.vue?"); + +/***/ }), + /***/ "./web/themes/custom/materiotheme/vuejs/components/Content/Base.vue": /*!**************************************************************************!*\ !*** ./web/themes/custom/materiotheme/vuejs/components/Content/Base.vue ***! diff --git a/web/themes/custom/materiotheme/assets/scripts/main.js b/web/themes/custom/materiotheme/assets/scripts/main.js index 0d12f0af..f6e0a79e 100644 --- a/web/themes/custom/materiotheme/assets/scripts/main.js +++ b/web/themes/custom/materiotheme/assets/scripts/main.js @@ -57,13 +57,7 @@ import 'theme/assets/styles/main.scss' function initVRouter(){ // we need this to update the title while using history nav router.beforeEach((to, from, next) => { - - // console.log('router beforeEach'); - // console.log(to); - // console.log(from); - // console.log(next); - - store.commit('Common/setPagetitle', to.name) + store.commit('Common/setPagetitle', to.name != 'home' ? to.name : null) next(); }) } diff --git a/web/themes/custom/materiotheme/vuejs/components/Content/Article.vue b/web/themes/custom/materiotheme/vuejs/components/Content/Article.vue new file mode 100644 index 00000000..86c86d17 --- /dev/null +++ b/web/themes/custom/materiotheme/vuejs/components/Content/Article.vue @@ -0,0 +1,23 @@ + + + + + diff --git a/web/themes/custom/materiotheme/vuejs/components/Content/Blabla.vue b/web/themes/custom/materiotheme/vuejs/components/Content/Blabla.vue index d46cd718..9e7fd457 100644 --- a/web/themes/custom/materiotheme/vuejs/components/Content/Blabla.vue +++ b/web/themes/custom/materiotheme/vuejs/components/Content/Blabla.vue @@ -1,17 +1,61 @@