tested shared Vuex store, created d8 userblock, enabled JSONAPI module

This commit is contained in:
Bachir Soussi Chiadmi 2019-04-11 00:12:23 +02:00
parent 33764c382f
commit ef76fc2596
17 changed files with 442 additions and 60 deletions

View File

@ -33,6 +33,7 @@
"drupal/console": "^1.0.2", "drupal/console": "^1.0.2",
"drupal/core": "^8.6.0", "drupal/core": "^8.6.0",
"drupal/entity_clone": "^1.0", "drupal/entity_clone": "^1.0",
"drupal/jsonapi": "^2.4",
"drupal/login_history": "1.x-dev", "drupal/login_history": "1.x-dev",
"drupal/mailgun": "1.x-dev", "drupal/mailgun": "1.x-dev",
"drupal/mailsystem": "^4.1", "drupal/mailsystem": "^4.1",

70
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "493ce32d7cd55035c10e59679a42f6da", "content-hash": "4d94cbba5e34b10c72cf4a4fe45ca88f",
"packages": [ "packages": [
{ {
"name": "alchemy/zippy", "name": "alchemy/zippy",
@ -6435,6 +6435,70 @@
"source": "http://cgit.drupalcode.org/interval" "source": "http://cgit.drupalcode.org/interval"
} }
}, },
{
"name": "drupal/jsonapi",
"version": "2.4.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/jsonapi.git",
"reference": "8.x-2.4"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/jsonapi-8.x-2.4.zip",
"reference": "8.x-2.4",
"shasum": "5f710c1c602378748fa3b21ceec0977de62359ed"
},
"require": {
"drupal/core": "^8.5.11"
},
"require-dev": {
"drupal/schemata": "1.x-dev#8325d172e1d6880aa24073f8f751ef089282cf9a",
"drupal/schemata_json_schema": "*",
"justinrainbow/json-schema": "^5.2"
},
"type": "drupal-module",
"extra": {
"branch-alias": {
"dev-2.x": "2.x-dev"
},
"drupal": {
"version": "8.x-2.4",
"datestamp": "1553554702",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0+"
],
"authors": [
{
"name": "Wim Leers",
"homepage": "https://www.drupal.org/user/99777"
},
{
"name": "dawehner",
"homepage": "https://www.drupal.org/user/99340"
},
{
"name": "e0ipso",
"homepage": "https://www.drupal.org/user/550110"
},
{
"name": "gabesullice",
"homepage": "https://www.drupal.org/user/2287430"
}
],
"description": "Provides a JSON API standards-compliant API for accessing and manipulating Drupal content and configuration entities.",
"homepage": "https://www.drupal.org/project/jsonapi",
"support": {
"source": "https://git.drupalcode.org/project/jsonapi"
}
},
{ {
"name": "drupal/kint", "name": "drupal/kint",
"version": "2.0.0", "version": "2.0.0",
@ -14061,12 +14125,12 @@
"version": "v1.6.5", "version": "v1.6.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/mikey179/vfsStream.git", "url": "https://github.com/bovigo/vfsStream.git",
"reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145" "reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/mikey179/vfsStream/zipball/d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/d5fec95f541d4d71c4823bb5e30cf9b9e5b96145",
"reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", "reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145",
"shasum": "" "shasum": ""
}, },

View File

@ -0,0 +1,20 @@
uuid: f6ac7bc7-be23-4375-a237-1d9a36edb17e
langcode: en
status: true
dependencies:
module:
- user_block
theme:
- materiotheme
id: userblock
theme: materiotheme
region: header_right
weight: 0
provider: null
plugin: user_block
settings:
id: user_block
label: 'User block'
provider: user_block
label_display: visible
visibility: { }

View File

@ -3,12 +3,12 @@ langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- field.field.user.user.commerce_remote_id
- field.field.user.user.field_company - field.field.user.user.field_company
- field.field.user.user.field_member_type - field.field.user.user.field_member_type
- field.field.user.user.field_memo - field.field.user.user.field_memo
- field.field.user.user.field_showroom - field.field.user.user.field_showroom
module: module:
- path
- user - user
id: user.user.default id: user.user.default
targetEntityType: user targetEntityType: user
@ -21,7 +21,7 @@ content:
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
contact: contact:
weight: 6 weight: 8
region: content region: content
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
@ -35,7 +35,7 @@ content:
type: entity_reference_autocomplete type: entity_reference_autocomplete
region: content region: content
field_member_type: field_member_type:
weight: 8 weight: 4
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
type: options_select type: options_select
@ -58,12 +58,12 @@ content:
type: entity_reference_autocomplete type: entity_reference_autocomplete
region: content region: content
language: language:
weight: 4 weight: 5
region: content region: content
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
matomo: matomo:
weight: 5 weight: 6
region: content region: content
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
@ -73,5 +73,11 @@ content:
region: content region: content
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
simplenews:
weight: 7
region: content
settings: { }
third_party_settings: { }
hidden: hidden:
commerce_remote_id: true
langcode: true langcode: true

View File

@ -3,6 +3,7 @@ langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- field.field.user.user.commerce_remote_id
- field.field.user.user.field_company - field.field.user.user.field_company
- field.field.user.user.field_member_type - field.field.user.user.field_member_type
- field.field.user.user.field_memo - field.field.user.user.field_memo
@ -16,7 +17,7 @@ bundle: user
mode: default mode: default
content: content:
field_company: field_company:
weight: 6 weight: 3
label: above label: above
settings: settings:
link: true link: true
@ -24,21 +25,21 @@ content:
type: entity_reference_label type: entity_reference_label
region: content region: content
field_member_type: field_member_type:
weight: 9 weight: 1
label: above label: above
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
type: list_default type: list_default
region: content region: content
field_memo: field_memo:
weight: 8 weight: 4
label: above label: above
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
type: basic_string type: basic_string
region: content region: content
field_showroom: field_showroom:
weight: 7 weight: 2
label: above label: above
settings: settings:
link: true link: true
@ -46,11 +47,14 @@ content:
type: entity_reference_label type: entity_reference_label
region: content region: content
member_for: member_for:
weight: 5 weight: 0
region: content
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
region: content
hidden: hidden:
commerce_remote_id: true
langcode: true langcode: true
profile_contact_company: true profile_contact_company: true
profile_customer: true
profile_member: true profile_member: true
simplenews: true

View File

@ -72,6 +72,7 @@ module:
image: 0 image: 0
inline_entity_form: 0 inline_entity_form: 0
interval: 0 interval: 0
jsonapi: 0
kint: 0 kint: 0
language: 0 language: 0
link: 0 link: 0
@ -134,6 +135,7 @@ module:
update: 0 update: 0
url_to_video_filter: 0 url_to_video_filter: 0
user: 0 user: 0
user_block: 0
video_embed_field: 0 video_embed_field: 0
video_embed_wysiwyg: 0 video_embed_wysiwyg: 0
views_bulk_edit: 0 views_bulk_edit: 0

View File

@ -0,0 +1,4 @@
langcode: en
read_only: true
_core:
default_config_hash: p_qzzTwtOMiIPE7CyG0wD6M-UCpBp6Y5E4LhNCnCRpY

View File

@ -0,0 +1,83 @@
<?php
namespace Drupal\user_block\Plugin\Block;
use Drupal\Core\Session\AccountProxy;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Url;
/**
* Provides a 'UserBlock' block.
*
* @Block(
* id = "user_block",
* admin_label = @Translation("User block"),
* )
*/
class UserBlock extends BlockBase implements ContainerFactoryPluginInterface{
protected $user;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
// Instantiates this form class.
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('current_user')
);
}
/**
* @param array $configuration
* @param string $plugin_id
* @param mixed $plugin_definition
* @param \Drupal\Core\Session\AccountProxyInterface $account
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, AccountProxyInterface $account) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->user = $account;
}
/**
* {@inheritdoc}
*/
public function build() {
$build = [];
// dpm($this->user);
if($this->user->id()){
$user_url = Url::fromRoute('entity.user.canonical', ['user' => $this->user->id()]);
$build['user-link'] = array(
'#title' => $this->user->getEmail(),
'#type' => 'link',
'#url' => $user_url,
'#options'=>array(
'attributes' => array(
'data-drupal-link-system-path' => $user_url->getInternalPath(),
'alt' => t('User account'),
)
)
);
$logout_url = Url::fromRoute('user.logout');
$build['user-logout'] = array(
'#title' => t('Logout'),
'#type' => 'link',
'#url' => $logout_url,
'#options'=>array(
'attributes' => array(
'data-drupal-link-system-path' => $logout_url->getInternalPath(),
'alt' => t('Logout'),
)
)
);
}
return $build;
}
}

View File

@ -0,0 +1,5 @@
name: 'user_block'
type: module
description: 'Provide a block with user name/email and logout link'
core: 8.x
package: 'Custom'

View File

@ -0,0 +1,24 @@
<?php
/**
* @file
* Contains user_block.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
// function user_block_help($route_name, RouteMatchInterface $route_match) {
// switch ($route_name) {
// // Main module help for the user_block module.
// case 'help.page.user_block':
// $output = '';
// $output .= '<h3>' . t('About') . '</h3>';
// $output .= '<p>' . t('Provide a block with user name/email and logout link') . '</p>';
// return $output;
//
// default:
// }
// }

View File

@ -385,6 +385,18 @@ eval("\n\nvar bind = __webpack_require__(/*! ./helpers/bind */ \"./node_modules/
/***/ }), /***/ }),
/***/ "./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js?!./web/themes/custom/materiotheme/vuejs/components/Content/Test.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/Test.vue?vue&type=script&lang=js& ***!
\*************************************************************************************************************************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vuex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.esm.js\");\n//\n//\n//\n//\n//\n//\n//\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n computed: { ...Object(vuex__WEBPACK_IMPORTED_MODULE_0__[\"mapState\"])({\n token: state => state.User.token,\n isloggedin: state => state.User.isloggedin\n })\n }\n});\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Test.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/User/Login.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/User/Login.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/User/Login.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/User/Login.vue?vue&type=script&lang=js& ***!
@ -405,7 +417,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vuex
/***/ (function(module, __webpack_exports__, __webpack_require__) { /***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict"; "use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vuex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.esm.js\");\n/* harmony import */ var vuejs_components_User_Login__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vuejs/components/User/Login */ \"./web/themes/custom/materiotheme/vuejs/components/User/Login.vue\");\n/* harmony import */ var vuejs_components_User_UserTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! vuejs/components/User/UserTools */ \"./web/themes/custom/materiotheme/vuejs/components/User/UserTools.vue\");\n//\n//\n//\n//\n//\n\n\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n // data () {\n // return {}\n // },\n computed: { ...Object(vuex__WEBPACK_IMPORTED_MODULE_0__[\"mapState\"])({\n token: state => state.User.token\n })\n },\n components: {\n Login: vuejs_components_User_Login__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n UserTools: vuejs_components_User_UserTools__WEBPACK_IMPORTED_MODULE_2__[\"default\"]\n }\n});\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/User/UserBlock.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options"); eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vuex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.esm.js\");\n/* harmony import */ var vuejs_components_User_Login__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vuejs/components/User/Login */ \"./web/themes/custom/materiotheme/vuejs/components/User/Login.vue\");\n/* harmony import */ var vuejs_components_User_UserTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! vuejs/components/User/UserTools */ \"./web/themes/custom/materiotheme/vuejs/components/User/UserTools.vue\");\n//\n//\n//\n//\n//\n\n\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n // data () {\n // return {}\n // },\n computed: { ...Object(vuex__WEBPACK_IMPORTED_MODULE_0__[\"mapState\"])({\n isloggedin: state => state.User.isloggedin\n })\n },\n components: {\n Login: vuejs_components_User_Login__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n UserTools: vuejs_components_User_UserTools__WEBPACK_IMPORTED_MODULE_2__[\"default\"]\n }\n});\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/User/UserBlock.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options");
/***/ }), /***/ }),
@ -524,6 +536,18 @@ eval("/* WEBPACK VAR INJECTION */(function(global) {var scope = typeof global !=
/***/ }), /***/ }),
/***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue?vue&type=template&id=8187962c&scoped=true&lang=html&":
/*!*************************************************************************************************************************************************************************************************************************************************************!*\
!*** ./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/Test.vue?vue&type=template&id=8187962c&scoped=true&lang=html& ***!
\*************************************************************************************************************************************************************************************************************************************************************/
/*! 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(\"div\", { attrs: { id: \"block-pagetitle\" } }, [\n _c(\"h1\", [\n _vm._v(\"Test Shared Store ( logged in: \" + _vm._s(_vm.isloggedin) + \" )\")\n ]),\n _vm._v(\" \"),\n _vm.isloggedin ? _c(\"h2\", [_vm._v(\"Shared store is working\")]) : _vm._e()\n ])\n}\nvar staticRenderFns = []\nrender._withStripped = true\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Test.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/User/Login.vue?vue&type=template&id=0419cc67&scoped=true&lang=html&": /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./web/themes/custom/materiotheme/vuejs/components/User/Login.vue?vue&type=template&id=0419cc67&scoped=true&lang=html&":
/*!***********************************************************************************************************************************************************************************************************************************************************!*\ /*!***********************************************************************************************************************************************************************************************************************************************************!*\
!*** ./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/User/Login.vue?vue&type=template&id=0419cc67&scoped=true&lang=html& ***! !*** ./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/User/Login.vue?vue&type=template&id=0419cc67&scoped=true&lang=html& ***!
@ -544,7 +568,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
/***/ (function(module, __webpack_exports__, __webpack_require__) { /***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict"; "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.token ? _c(\"UserTools\") : _c(\"Login\")\n}\nvar staticRenderFns = []\nrender._withStripped = true\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/User/UserBlock.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.isloggedin ? _c(\"UserTools\") : _c(\"Login\")\n}\nvar staticRenderFns = []\nrender._withStripped = true\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/User/UserBlock.vue?./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options");
/***/ }), /***/ }),
@ -639,7 +663,7 @@ eval("var g; // This works in non-strict mode\n\ng = function () {\n return thi
/***/ (function(module, __webpack_exports__, __webpack_require__) { /***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict"; "use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.runtime.esm.js\");\n/* harmony import */ var vuejs_store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vuejs/store */ \"./web/themes/custom/materiotheme/vuejs/store/index.js\");\n/* harmony import */ var vuejs_components_User_UserBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! vuejs/components/User/UserBlock */ \"./web/themes/custom/materiotheme/vuejs/components/User/UserBlock.vue\");\n/* harmony import */ var theme_assets_styles_main_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! theme/assets/styles/main.scss */ \"./web/themes/custom/materiotheme/assets/styles/main.scss\");\n/* harmony import */ var theme_assets_styles_main_scss__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(theme_assets_styles_main_scss__WEBPACK_IMPORTED_MODULE_3__);\n\n\n // require('theme/assets/styles/main.scss');\n\n\n\n(function (Drupal, drupalSettings) {\n var v_user_block = new vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n store: vuejs_store__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n render: h => h(vuejs_components_User_UserBlock__WEBPACK_IMPORTED_MODULE_2__[\"default\"])\n }).$mount('#block-userlogin');\n\n var MaterioTheme = function () {\n // var _is_front = drupalSettings.path.isFront;\n // ___ _ _\n // |_ _|_ _ (_) |_\n // | || ' \\| | _|\n // |___|_||_|_|\\__|\n function init() {\n console.log(\"MaterioTheme init()\");\n }\n\n ;\n init();\n }; // end MaterioTheme()\n // $(document).ready(function($) {\n // if(drupalSettings.path.isFront){\n\n\n var materiotheme = new MaterioTheme(); // }else{\n // $('body').attr('booted', 'booted');\n // }\n // });\n})(Drupal, drupalSettings);\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/assets/scripts/main.js?"); eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.runtime.esm.js\");\n/* harmony import */ var vuejs_store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vuejs/store */ \"./web/themes/custom/materiotheme/vuejs/store/index.js\");\n/* harmony import */ var vuejs_components_User_UserBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! vuejs/components/User/UserBlock */ \"./web/themes/custom/materiotheme/vuejs/components/User/UserBlock.vue\");\n/* harmony import */ var vuejs_components_Content_Test__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! vuejs/components/Content/Test */ \"./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue\");\n/* harmony import */ var vuex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.esm.js\");\n/* harmony import */ var theme_assets_styles_main_scss__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! theme/assets/styles/main.scss */ \"./web/themes/custom/materiotheme/assets/styles/main.scss\");\n/* harmony import */ var theme_assets_styles_main_scss__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(theme_assets_styles_main_scss__WEBPACK_IMPORTED_MODULE_5__);\n\n\n\n\n // require('theme/assets/styles/main.scss');\n\n\n\n(function (Drupal, drupalSettings) {\n var MaterioTheme = function () {\n var v_user_block, v_test_content; // var _is_front = drupalSettings.path.isFront;\n\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 initUserVBlock();\n initTestVContent();\n }\n\n function initUserVBlock() {\n let mount_point = drupalSettings.user.uid !== 0 ? '#block-userblock' : '#block-userlogin';\n v_user_block = new vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n store: vuejs_store__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n computed: { ...Object(vuex__WEBPACK_IMPORTED_MODULE_4__[\"mapState\"])({\n isloggedin: state => state.User.isloggedin\n })\n },\n\n created() {\n if (drupalSettings.user.uid !== 0) {\n this.$store.commit('User/setUid', drupalSettings.user.uid);\n this.$store.dispatch('User/getUser');\n }\n },\n\n render: h => h(vuejs_components_User_UserBlock__WEBPACK_IMPORTED_MODULE_2__[\"default\"])\n }).$mount(mount_point);\n }\n\n function initTestVContent() {\n v_test_content = new vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n store: vuejs_store__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n render: h => h(vuejs_components_Content_Test__WEBPACK_IMPORTED_MODULE_3__[\"default\"])\n }).$mount('#block-pagetitle');\n console.log('initTestVContent', v_test_content);\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?");
/***/ }), /***/ }),
@ -654,6 +678,66 @@ eval("// style-loader: Adds some css to the DOM by adding a <style> tag\n\n// lo
/***/ }), /***/ }),
/***/ "./web/themes/custom/materiotheme/vuejs/api/json-axios.js":
/*!****************************************************************!*\
!*** ./web/themes/custom/materiotheme/vuejs/api/json-axios.js ***!
\****************************************************************/
/*! exports provided: JSONAPI */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"JSONAPI\", function() { return JSONAPI; });\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);\n // https://github.com/alvar0hurtad0/drupal-vuejs-todo/blob/master/frontend/src/api/axiosInterceptor.js\n// console.log('drupalSettings', drupalSettings);\n\nconst JSONAPI = axios__WEBPACK_IMPORTED_MODULE_0___default.a.create({\n baseURL: `http://dev.materio.com/jsonapi`,\n headers: {\n Accept: 'application/vnd.api+json' // Authorization: 'Bearer {token}',\n // \"Content-Type\": \"application/json\"\n\n }\n});\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/api/json-axios.js?");
/***/ }),
/***/ "./web/themes/custom/materiotheme/vuejs/api/rest-axios.js":
/*!****************************************************************!*\
!*** ./web/themes/custom/materiotheme/vuejs/api/rest-axios.js ***!
\****************************************************************/
/*! exports provided: REST */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"REST\", function() { return REST; });\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);\n // https://github.com/alvar0hurtad0/drupal-vuejs-todo/blob/master/frontend/src/api/axiosInterceptor.js\n// console.log('drupalSettings', drupalSettings);\n\nconst REST = axios__WEBPACK_IMPORTED_MODULE_0___default.a.create({\n baseURL: `http://dev.materio.com`,\n headers: {\n Authorization: 'Bearer {token}',\n \"Content-Type\": \"application/json\"\n }\n});\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/api/rest-axios.js?");
/***/ }),
/***/ "./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue":
/*!**************************************************************************!*\
!*** ./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue ***!
\**************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Test_vue_vue_type_template_id_8187962c_scoped_true_lang_html___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Test.vue?vue&type=template&id=8187962c&scoped=true&lang=html& */ \"./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue?vue&type=template&id=8187962c&scoped=true&lang=html&\");\n/* harmony import */ var _Test_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Test.vue?vue&type=script&lang=js& */ \"./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue?vue&type=script&lang=js&\");\n/* empty/unused harmony star reexport *//* 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 _Test_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n _Test_vue_vue_type_template_id_8187962c_scoped_true_lang_html___WEBPACK_IMPORTED_MODULE_0__[\"render\"],\n _Test_vue_vue_type_template_id_8187962c_scoped_true_lang_html___WEBPACK_IMPORTED_MODULE_0__[\"staticRenderFns\"],\n false,\n null,\n \"8187962c\",\n null\n \n)\n\n/* hot reload */\nif (false) { var api; }\ncomponent.options.__file = \"web/themes/custom/materiotheme/vuejs/components/Content/Test.vue\"\n/* harmony default export */ __webpack_exports__[\"default\"] = (component.exports);\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue?");
/***/ }),
/***/ "./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue?vue&type=script&lang=js&":
/*!***************************************************************************************************!*\
!*** ./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue?vue&type=script&lang=js& ***!
\***************************************************************************************************/
/*! exports provided: default */
/***/ (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_Test_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!./Test.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/Test.vue?vue&type=script&lang=js&\");\n/* empty/unused harmony star reexport */ /* harmony default export */ __webpack_exports__[\"default\"] = (_node_modules_babel_loader_lib_index_js_node_modules_vue_loader_lib_index_js_vue_loader_options_Test_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__[\"default\"]); \n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue?");
/***/ }),
/***/ "./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue?vue&type=template&id=8187962c&scoped=true&lang=html&":
/*!*******************************************************************************************************************************!*\
!*** ./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue?vue&type=template&id=8187962c&scoped=true&lang=html& ***!
\*******************************************************************************************************************************/
/*! 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_Test_vue_vue_type_template_id_8187962c_scoped_true_lang_html___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!./Test.vue?vue&type=template&id=8187962c&scoped=true&lang=html& */ \"./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue?vue&type=template&id=8187962c&scoped=true&lang=html&\");\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_Test_vue_vue_type_template_id_8187962c_scoped_true_lang_html___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_Test_vue_vue_type_template_id_8187962c_scoped_true_lang_html___WEBPACK_IMPORTED_MODULE_0__[\"staticRenderFns\"]; });\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Test.vue?");
/***/ }),
/***/ "./web/themes/custom/materiotheme/vuejs/components/User/Login.vue": /***/ "./web/themes/custom/materiotheme/vuejs/components/User/Login.vue":
/*!************************************************************************!*\ /*!************************************************************************!*\
!*** ./web/themes/custom/materiotheme/vuejs/components/User/Login.vue ***! !*** ./web/themes/custom/materiotheme/vuejs/components/User/Login.vue ***!
@ -762,18 +846,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _nod
/***/ }), /***/ }),
/***/ "./web/themes/custom/materiotheme/vuejs/rest/http-axios.js":
/*!*****************************************************************!*\
!*** ./web/themes/custom/materiotheme/vuejs/rest/http-axios.js ***!
\*****************************************************************/
/*! exports provided: HTTP */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"HTTP\", function() { return HTTP; });\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);\n // https://github.com/alvar0hurtad0/drupal-vuejs-todo/blob/master/frontend/src/api/axiosInterceptor.js\n// console.log('drupalSettings', drupalSettings);\n\nconst HTTP = axios__WEBPACK_IMPORTED_MODULE_0___default.a.create({\n baseURL: `http://dev.materio.com`,\n headers: {\n Authorization: 'Bearer {token}',\n \"Content-Type\": \"application/json\"\n }\n});\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/rest/http-axios.js?");
/***/ }),
/***/ "./web/themes/custom/materiotheme/vuejs/store/index.js": /***/ "./web/themes/custom/materiotheme/vuejs/store/index.js":
/*!*************************************************************!*\ /*!*************************************************************!*\
!*** ./web/themes/custom/materiotheme/vuejs/store/index.js ***! !*** ./web/themes/custom/materiotheme/vuejs/store/index.js ***!
@ -794,7 +866,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue_
/***/ (function(module, __webpack_exports__, __webpack_require__) { /***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict"; "use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vuejs_rest_http_axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vuejs/rest/http-axios */ \"./web/themes/custom/materiotheme/vuejs/rest/http-axios.js\");\n/* harmony import */ var querystring__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! querystring */ \"./node_modules/querystring-es3/index.js\");\n/* harmony import */ var querystring__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(querystring__WEBPACK_IMPORTED_MODULE_1__);\n\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n namespaced: true,\n // initial state\n state: {\n uid: null,\n // username: '',\n mail: '',\n token: null,\n logout_token: null // isloggedin: false\n\n },\n // getters\n getters: {},\n // mutations\n mutations: {\n setUser(state, data) {\n state.uid = data.current_user.uid; // state.username = data.username\n\n state.mail = data.current_user.mail;\n state.token = data.csrf_token;\n state.logout_token = data.logout_token;\n },\n\n setLoggedOut(state) {\n state.uid = null;\n state.mail = '';\n state.token = null;\n state.logout_token = null;\n }\n\n },\n // actions\n actions: {\n getToken({\n commit,\n state\n }, credentials) {\n vuejs_rest_http_axios__WEBPACK_IMPORTED_MODULE_0__[\"HTTP\"].post('/user/login?_format=json', credentials).then(({\n data\n }) => {\n console.log('data', data);\n commit('setUser', data);\n }).catch(error => {\n console.log('Issue with login', error);\n Promise.reject(error);\n });\n },\n\n userLogout({\n commit,\n state\n }) {\n let credentials = querystring__WEBPACK_IMPORTED_MODULE_1___default.a.stringify({\n token: state.token\n });\n vuejs_rest_http_axios__WEBPACK_IMPORTED_MODULE_0__[\"HTTP\"].post('/user/logout', credentials).then(resp => {\n console.log('resp', resp);\n commit('setLoggedOut');\n }).catch(error => {\n console.log('Issue with logout', error);\n Promise.reject(error);\n });\n }\n\n }\n});\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/store/modules/user.js?"); eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vuejs_api_rest_axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vuejs/api/rest-axios */ \"./web/themes/custom/materiotheme/vuejs/api/rest-axios.js\");\n/* harmony import */ var vuejs_api_json_axios__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vuejs/api/json-axios */ \"./web/themes/custom/materiotheme/vuejs/api/json-axios.js\");\n/* harmony import */ var querystring__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! querystring */ \"./node_modules/querystring-es3/index.js\");\n/* harmony import */ var querystring__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(querystring__WEBPACK_IMPORTED_MODULE_2__);\n\n\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n namespaced: true,\n // initial state\n state: {\n uid: null,\n // username: '',\n mail: '',\n token: null,\n logout_token: null,\n isloggedin: false\n },\n // getters\n getters: {},\n // mutations\n mutations: {\n setToken(state, data) {\n state.uid = data.current_user.uid; // state.username = data.username\n\n state.mail = data.current_user.mail;\n state.token = data.csrf_token;\n state.isloggedin = true;\n state.logout_token = data.logout_token;\n },\n\n setUid(state, uid) {\n state.uid = uid;\n state.isloggedin = true;\n },\n\n setUser(state, data) {\n state.mail = data.mail[0].value;\n state.uuid = data.uuid[0].value;\n },\n\n setLoggedOut(state) {\n state.uid = null;\n state.mail = '';\n state.token = null;\n state.isloggedin = false;\n state.logout_token = null;\n }\n\n },\n // actions\n actions: {\n getToken({\n dispatch,\n commit,\n state\n }, credentials) {\n vuejs_api_rest_axios__WEBPACK_IMPORTED_MODULE_0__[\"REST\"].post('/user/login?_format=json', credentials).then(({\n data\n }) => {\n console.log('user getToken data', data);\n commit('setToken', data);\n dispatch('getUser');\n }).catch(error => {\n console.warn('Issue with login', error);\n Promise.reject(error);\n });\n },\n\n getUser({\n commit,\n state\n }) {\n let params = {\n token: state.token\n };\n vuejs_api_rest_axios__WEBPACK_IMPORTED_MODULE_0__[\"REST\"].get(`/user/${state.uid}?_format=json`, params).then(({\n data\n }) => {\n console.log('user REST getUser data', data);\n commit('setUser', data);\n vuejs_api_json_axios__WEBPACK_IMPORTED_MODULE_1__[\"JSONAPI\"].get(`/user/user/${state.uuid}`).then(({\n data\n }) => {\n console.log('user JSONAPI getUser data', data);\n }).catch(error => {\n console.warn('Issue with getUser', error);\n Promise.reject(error);\n });\n }).catch(error => {\n console.warn('Issue with getUser', error);\n Promise.reject(error);\n });\n },\n\n userLogout({\n commit,\n state\n }) {\n let credentials = querystring__WEBPACK_IMPORTED_MODULE_2___default.a.stringify({\n token: state.token\n });\n vuejs_api_rest_axios__WEBPACK_IMPORTED_MODULE_0__[\"REST\"].post('/user/logout', credentials).then(resp => {\n console.log('resp', resp);\n commit('setLoggedOut');\n }).catch(error => {\n console.warn('Issue with logout', error);\n Promise.reject(error);\n });\n }\n\n }\n});\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/store/modules/user.js?");
/***/ }) /***/ })

View File

@ -1,40 +1,67 @@
import Vue from 'vue' import Vue from 'vue'
import store from 'vuejs/store' import store from 'vuejs/store'
import VUserBlock from 'vuejs/components/User/UserBlock' import VUserBlock from 'vuejs/components/User/UserBlock'
import VTestContent from 'vuejs/components/Content/Test'
import { mapState } from 'vuex'
// require('theme/assets/styles/main.scss'); // require('theme/assets/styles/main.scss');
import 'theme/assets/styles/main.scss' import 'theme/assets/styles/main.scss'
(function(Drupal, drupalSettings) { (function(Drupal, drupalSettings) {
var v_user_block = new Vue({
store,
render: h => h(VUserBlock)
}).$mount('#block-userlogin')
var MaterioTheme = function(){ var MaterioTheme = function(){
var v_user_block, v_test_content;
// var _is_front = drupalSettings.path.isFront; // var _is_front = drupalSettings.path.isFront;
console.log('drupalSettings', drupalSettings);
// ___ _ _ // ___ _ _
// |_ _|_ _ (_) |_ // |_ _|_ _ (_) |_
// | || ' \| | _| // | || ' \| | _|
// |___|_||_|_|\__| // |___|_||_|_|\__|
function init(){ function init(){
console.log("MaterioTheme init()"); console.log("MaterioTheme init()")
initVues()
}
}; function initVues(){
initUserVBlock()
initTestVContent()
}
function initUserVBlock(){
let mount_point = drupalSettings.user.uid !== 0 ? '#block-userblock' : '#block-userlogin';
v_user_block = new Vue({
store,
computed: {
...mapState({
isloggedin: state => state.User.isloggedin
})
},
created () {
if(drupalSettings.user.uid !== 0){
this.$store.commit('User/setUid', drupalSettings.user.uid)
this.$store.dispatch('User/getUser')
}
},
render: h => h(VUserBlock)
}).$mount(mount_point)
}
init(); function initTestVContent(){
v_test_content = new Vue({
store,
render: h => h(VTestContent)
}).$mount('#block-pagetitle')
console.log('initTestVContent', v_test_content);
}
init()
} // end MaterioTheme() } // end MaterioTheme()
// $(document).ready(function($) {
// if(drupalSettings.path.isFront){
var materiotheme = new MaterioTheme(); var materiotheme = new MaterioTheme();
// }else{
// $('body').attr('booted', 'booted');
// }
// });
})(Drupal, drupalSettings); })(Drupal, drupalSettings);

View File

@ -0,0 +1,14 @@
import axios from 'axios'
// https://github.com/alvar0hurtad0/drupal-vuejs-todo/blob/master/frontend/src/api/axiosInterceptor.js
// console.log('drupalSettings', drupalSettings);
export const JSONAPI = axios.create({
baseURL: `http://dev.materio.com/jsonapi`,
headers: {
Accept: 'application/vnd.api+json'
// Authorization: 'Bearer {token}',
// "Content-Type": "application/json"
}
})

View File

@ -4,7 +4,7 @@ import axios from 'axios'
// console.log('drupalSettings', drupalSettings); // console.log('drupalSettings', drupalSettings);
export const HTTP = axios.create({ export const REST = axios.create({
baseURL: `http://dev.materio.com`, baseURL: `http://dev.materio.com`,
headers: { headers: {
Authorization: 'Bearer {token}', Authorization: 'Bearer {token}',

View File

@ -0,0 +1,22 @@
<template lang="html">
<div id="block-pagetitle" class="">
<h1>Test Shared Store ( logged in: {{ isloggedin }} )</h1>
<h2 v-if="isloggedin">Shared store is working</h2>
</div>
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
computed: {
...mapState({
token: state => state.User.token,
isloggedin: state => state.User.isloggedin
})
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@ -1,5 +1,5 @@
<template lang="html"> <template lang="html">
<UserTools v-if="token" /> <UserTools v-if="isloggedin" />
<Login v-else /> <Login v-else />
</template> </template>
@ -15,7 +15,7 @@ export default {
// }, // },
computed: { computed: {
...mapState({ ...mapState({
token: state => state.User.token isloggedin: state => state.User.isloggedin
}) })
}, },
components: { components: {

View File

@ -1,4 +1,5 @@
import { HTTP } from 'vuejs/rest/http-axios' import { REST } from 'vuejs/api/rest-axios'
import { JSONAPI } from 'vuejs/api/json-axios'
import qs from 'querystring' import qs from 'querystring'
export default { export default {
@ -10,8 +11,8 @@ export default {
// username: '', // username: '',
mail:'', mail:'',
token: null, token: null,
logout_token: null logout_token: null,
// isloggedin: false isloggedin: false
}, },
// getters // getters
@ -19,31 +20,64 @@ export default {
// mutations // mutations
mutations : { mutations : {
setUser (state, data) { setToken (state, data) {
state.uid = data.current_user.uid state.uid = data.current_user.uid
// state.username = data.username // state.username = data.username
state.mail = data.current_user.mail state.mail = data.current_user.mail
state.token = data.csrf_token state.token = data.csrf_token
state.isloggedin = true
state.logout_token = data.logout_token state.logout_token = data.logout_token
}, },
setUid (state, uid) {
state.uid = uid
state.isloggedin = true
},
setUser (state, data) {
state.mail = data.mail[0].value
state.uuid = data.uuid[0].value
},
setLoggedOut (state) { setLoggedOut (state) {
state.uid= null state.uid= null
state.mail = '' state.mail = ''
state.token = null state.token = null
state.isloggedin = false
state.logout_token = null state.logout_token = null
} }
}, },
// actions // actions
actions : { actions : {
getToken ({ commit, state }, credentials) { getToken ({ dispatch, commit, state }, credentials) {
HTTP.post('/user/login?_format=json', credentials) REST.post('/user/login?_format=json', credentials)
.then(({ data }) => { .then(({ data }) => {
console.log('data', data) console.log('user getToken data', data)
commit('setUser', data) commit('setToken', data)
dispatch('getUser')
}) })
.catch(( error ) => { .catch(( error ) => {
console.log('Issue with login', error) console.warn('Issue with login', error)
Promise.reject(error)
})
},
getUser ({ commit, state }) {
let params = {
token: state.token
}
REST.get(`/user/${state.uid}?_format=json`, params)
.then(({ data }) => {
console.log('user REST getUser data', data)
commit('setUser', data)
JSONAPI.get(`/user/user/${state.uuid}`)
.then(({ data }) => {
console.log('user JSONAPI getUser data', data)
})
.catch(( error ) => {
console.warn('Issue with getUser', error)
Promise.reject(error)
})
})
.catch(( error ) => {
console.warn('Issue with getUser', error)
Promise.reject(error) Promise.reject(error)
}) })
}, },
@ -51,13 +85,13 @@ export default {
let credentials = qs.stringify({ let credentials = qs.stringify({
token: state.token token: state.token
}) })
HTTP.post('/user/logout', credentials) REST.post('/user/logout', credentials)
.then((resp) => { .then((resp) => {
console.log('resp', resp) console.log('resp', resp)
commit('setLoggedOut') commit('setLoggedOut')
}) })
.catch(( error ) => { .catch(( error ) => {
console.log('Issue with logout', error) console.warn('Issue with logout', error)
Promise.reject(error) Promise.reject(error)
}) })
} }