created home node and some computed field

This commit is contained in:
Bachir Soussi Chiadmi 2019-05-23 17:52:46 +02:00
parent 74a821104f
commit 5d2a8bc73b
31 changed files with 651 additions and 31 deletions

View File

@ -1,9 +1,10 @@
uuid: 6844a7d0-31bc-4cea-a72b-c0bb4c29b530
langcode: en
status: false
status: true
dependencies:
module:
- system
- user
theme:
- matminimal
_core:
@ -19,4 +20,11 @@ settings:
label: Breadcrumbs
provider: system
label_display: '0'
visibility: { }
visibility:
user_role:
id: user_role
roles:
root: root
negate: false
context_mapping:
user: '@user.current_user_context:current_user'

View File

@ -7,7 +7,7 @@ dependencies:
id: tabs
theme: materiotheme
region: content
weight: 0
weight: -2
provider: null
plugin: local_tasks_block
settings:

View File

@ -0,0 +1,22 @@
uuid: c89b423f-df8e-4075-9745-a47ccc7ecfd1
langcode: en
status: true
dependencies:
config:
- node.type.frontpage
id: node.frontpage.promote
field_name: promote
entity_type: node
bundle: frontpage
label: 'Promoted to front page'
description: ''
required: false
translatable: true
default_value:
-
value: 0
default_value_callback: ''
settings:
on_label: 'On'
off_label: 'Off'
field_type: boolean

View File

@ -0,0 +1,77 @@
uuid: ce93c12b-c1ef-4cf6-a79a-22207000c151
langcode: en
status: true
dependencies:
config:
- field.field.node.frontpage.field_a_database
- field.field.node.frontpage.field_blabla
- field.field.node.frontpage.field_showrooms
- field.field.node.frontpage.field_what_is_materio
- node.type.frontpage
module:
- text
id: node.frontpage.default
targetEntityType: node
bundle: frontpage
mode: default
content:
field_a_database:
weight: 2
settings:
rows: 5
placeholder: ''
third_party_settings: { }
type: text_textarea
region: content
field_blabla:
weight: 4
settings:
rows: 5
placeholder: ''
third_party_settings: { }
type: text_textarea
region: content
field_showrooms:
weight: 3
settings:
rows: 5
placeholder: ''
third_party_settings: { }
type: text_textarea
region: content
field_what_is_materio:
weight: 1
settings:
rows: 5
placeholder: ''
third_party_settings: { }
type: text_textarea
region: content
langcode:
type: language_select
weight: 5
region: content
settings:
include_locked: true
third_party_settings: { }
title:
type: string_textfield
weight: 0
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
translation:
weight: 6
region: content
settings: { }
third_party_settings: { }
hidden:
created: true
path: true
promote: true
status: true
sticky: true
uid: true
url_redirects: true

View File

@ -0,0 +1,65 @@
uuid: 747f810e-f89f-44b0-8532-782c05b8df18
langcode: en
status: true
dependencies:
config:
- field.field.node.frontpage.field_a_database
- field.field.node.frontpage.field_blabla
- field.field.node.frontpage.field_showrooms
- field.field.node.frontpage.field_what_is_materio
- node.type.frontpage
module:
- text
- user
id: node.frontpage.default
targetEntityType: node
bundle: frontpage
mode: default
content:
computed_materials_reference:
weight: 2
region: content
settings:
link: false
third_party_settings: { }
type: entity_reference_label
label: hidden
computed_showrooms_reference:
label: hidden
weight: 4
region: content
settings:
link: true
third_party_settings: { }
type: entity_reference_label
field_a_database:
weight: 1
label: above
settings: { }
third_party_settings: { }
type: text_default
region: content
field_blabla:
weight: 5
label: above
settings: { }
third_party_settings: { }
type: text_default
region: content
field_showrooms:
weight: 3
label: above
settings: { }
third_party_settings: { }
type: text_default
region: content
field_what_is_materio:
weight: 0
label: hidden
settings: { }
third_party_settings: { }
type: text_default
region: content
hidden:
langcode: true
links: true

View File

@ -0,0 +1,29 @@
uuid: c04cd92d-7d88-4dbe-b830-6fe45f5a7534
langcode: en
status: true
dependencies:
config:
- core.entity_view_mode.node.teaser
- node.type.frontpage
module:
- user
id: node.frontpage.teaser
targetEntityType: node
bundle: frontpage
mode: teaser
content:
computed_materials_reference:
label: hidden
weight: -5
region: content
settings:
link: true
third_party_settings: { }
type: entity_reference_label
links:
weight: 100
settings: { }
third_party_settings: { }
region: content
hidden:
langcode: true

View File

@ -0,0 +1,21 @@
uuid: e075ad3e-30ea-496d-be3b-2654ec84933c
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_a_database
- node.type.frontpage
module:
- text
id: node.frontpage.field_a_database
field_name: field_a_database
entity_type: node
bundle: frontpage
label: 'An Intuitive Database'
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings: { }
field_type: text_long

View File

@ -0,0 +1,21 @@
uuid: 60c20264-de47-406f-a869-e87453595477
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_blabla
- node.type.frontpage
module:
- text
id: node.frontpage.field_blabla
field_name: field_blabla
entity_type: node
bundle: frontpage
label: Blabla
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings: { }
field_type: text_long

View File

@ -0,0 +1,21 @@
uuid: bbe2e525-bbd2-4052-86d2-e516a10113fd
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_showrooms
- node.type.frontpage
module:
- text
id: node.frontpage.field_showrooms
field_name: field_showrooms
entity_type: node
bundle: frontpage
label: 'Abundant showrooms'
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings: { }
field_type: text_long

View File

@ -0,0 +1,21 @@
uuid: 38a5726c-514f-4374-ae25-eae156ce99e4
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_what_is_materio
- node.type.frontpage
module:
- text
id: node.frontpage.field_what_is_materio
field_name: field_what_is_materio
entity_type: node
bundle: frontpage
label: 'What is materiO'' ?'
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings: { }
field_type: text_long

View File

@ -0,0 +1,19 @@
uuid: 3189c56a-425f-4f36-ba01-9d69b9fcd6e1
langcode: en
status: true
dependencies:
module:
- node
- text
id: node.field_a_database
field_name: field_a_database
entity_type: node
type: text_long
settings: { }
module: text
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

View File

@ -0,0 +1,19 @@
uuid: 7c95801e-4891-49aa-baca-161b9feb5f88
langcode: en
status: true
dependencies:
module:
- node
- text
id: node.field_blabla
field_name: field_blabla
entity_type: node
type: text_long
settings: { }
module: text
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

View File

@ -0,0 +1,19 @@
uuid: 32483c59-1fa9-4acb-9870-2782db264da7
langcode: en
status: true
dependencies:
module:
- node
- text
id: node.field_showrooms
field_name: field_showrooms
entity_type: node
type: text_long
settings: { }
module: text
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

View File

@ -0,0 +1,19 @@
uuid: d2150010-8560-4399-ba8f-1a0993e9fc52
langcode: en
status: true
dependencies:
module:
- node
- text
id: node.field_what_is_materio
field_name: field_what_is_materio
entity_type: node
type: text_long
settings: { }
module: text
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

View File

@ -0,0 +1,16 @@
uuid: 5655d673-0681-47af-8823-17794fb81645
langcode: en
status: true
dependencies:
config:
- node.type.frontpage
module:
- content_translation
third_party_settings:
content_translation:
enabled: true
id: node.frontpage
target_entity_type_id: node
target_bundle: frontpage
default_langcode: site_default
language_alterable: false

View File

@ -0,0 +1 @@
description: 'Des Showrooms foisonnants'

View File

@ -0,0 +1 @@
description: 'materiO'' c''est quoi?'

View File

@ -1,5 +1,5 @@
uuid: 75218419-b6ef-4f16-9ea9-bc7a04727826
langcode: fr
langcode: en
status: true
dependencies:
enforced:

View File

@ -0,0 +1,17 @@
uuid: 6e1252ad-defb-409c-8b11-faa2979c74c8
langcode: en
status: true
dependencies:
module:
- menu_ui
third_party_settings:
menu_ui:
available_menus: { }
parent: ''
name: frontpage
type: frontpage
description: 'a content type to edit the front page content (only one node from this CT)'
help: ''
new_revision: true
preview_mode: 1
display_submitted: false

View File

@ -4,7 +4,7 @@ slogan: 'the material library your projects deserve'
page:
403: ''
404: ''
front: /home
front: /node/19990
admin_compact_mode: false
weight_select_max: 100
langcode: en

View File

@ -68,6 +68,7 @@ permissions:
- 'edit any autre_son content'
- 'edit any enregistrement content'
- 'edit any evenement content'
- 'edit any frontpage content'
- 'edit any materiau content'
- 'edit any page content'
- 'edit any simplenews_issue content'
@ -105,6 +106,7 @@ permissions:
- 'revert autre_son revisions'
- 'revert enregistrement revisions'
- 'revert evenement revisions'
- 'revert frontpage revisions'
- 'revert materiau revisions'
- 'revert page revisions'
- 'revert simplenews_issue revisions'
@ -140,6 +142,7 @@ permissions:
- 'view contact_company profile'
- 'view enregistrement revisions'
- 'view evenement revisions'
- 'view frontpage revisions'
- 'view materiau revisions'
- 'view materio_order_type commerce_order'
- 'view member profile'

View File

@ -3,5 +3,11 @@
use Drupal\Core\Url;
function template_preprocess_materio_home(&$vars){
$node_view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
$vm = "default";
$fpnode = $vars['frontpage_node'];
$nvb_fpnode = $node_view_builder->view($fpnode, $vm);
$vars['frontpage_node'] = $nvb_fpnode;
}

View File

@ -1,16 +1,113 @@
<?php
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\mymodule\Plugin\Field\FieldType\MyFieldComputed;
/**
* Implements hook_theme().
*/
function materio_home_theme($existing, $type, $theme, $path) {
// @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
// function materio_home_theme($existing, $type, $theme, $path) {
// // @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
//
// return array(
// 'materio_home' => array(
// // 'render element' => '',
// 'file' => 'includes/materio_home.inc',
// 'variables' => array(
// 'frontpage_node' => NULL,
// ),
// ),
// );
// }
return array(
'materio_home' => array(
// 'render element' => '',
'file' => 'includes/materio_home.inc',
'variables' => array(),
),
);
/**
* Implement hook_entity_bundle_field_info().
*
* @param EntityTypeInterface $entity_type
* @param $bundle
* @param array $base_field_definitions
* @return array
*/
// function materio_home_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
function materio_home_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
// $fields = array();
// if ($entity_type->id() == 'node' && $bundle === 'frontpage') {
if ($entity_type->id() == 'node') {
$fields['computed_materials_reference'] = BaseFieldDefinition::create('entity_reference')
->setName('computed_materials_reference')
->setLabel(t('Computed Materials References'))
->setDescription(t('Computed Materials References.'))
// // The Entity Type this field belongs to.
->setSetting('target_type', 'node')
// // The Entity Type bundle this field belongs to.
->setTargetBundle('frontpage')
->setTargetEntityTypeId('node')
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
->setComputed(TRUE)
->setRevisionable(FALSE)
->setTranslatable(FALSE)
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'weight' => -5,
])
->setClass(\Drupal\materio_home\Plugin\Field\FieldType\ComputedMaterialsReferences::class);
$fields['computed_showrooms_reference'] = BaseFieldDefinition::create('entity_reference')
->setName('computed_showrooms_reference')
->setLabel(t('Computed Showrooms References'))
->setDescription(t('Computed Showrooms References.'))
->setSetting('target_type', 'taxonomy_term')
// // The Entity Type this field belongs to.
->setTargetEntityTypeId('node')
// // The Entity Type bundle this field belongs to.
->setTargetBundle('frontpage')
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
->setComputed(TRUE)
->setRevisionable(FALSE)
->setTranslatable(FALSE)
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'weight' => -5,
])
->setClass(\Drupal\materio_home\Plugin\Field\FieldType\ComputedShowroomsReferences::class);
}
return $fields;
}
// /**
// * implements hook_entity_extra_field_info
// *
// */
// function materio_home_entity_extra_field_info() {
// $extra = [];
// // $extra['node']['frontpage']['form']['computed_materials_reference'] = [
// // 'label' => t('Computed Materials References'),
// // 'description' => t('Computed Materials References'),
// // 'weight' => 10,
// // ];
// // $extra['node']['frontpage']['display']['computed_materials_reference'] = [
// // 'label' => t('Computed Materials References'),
// // 'description' => t('Computed Materials References'),
// // 'weight' => 10,
// // ];
// return $extra;
// }
/**
* Implements hook_install().
*/
function materio_home_install() {
$entity_type = \Drupal::service('entity_type.manager')->getDefinition('node');
\Drupal::service('entity.definition_update_manager')->updateEntityType($entity_type);
}
/**
* Implements hook_uninstall().
*/
function materio_home_uninstall() {
$entity_type = \Drupal::service('entity_type.manager')->getDefinition('node');
\Drupal::service('entity.definition_update_manager')->updateEntityType($entity_type);
}

View File

@ -1,10 +1,10 @@
materio_home.home:
path: '/home'
defaults:
_controller: '\Drupal\materio_home\Controller\HomeController::home'
_title: 'Home'
requirements:
_permission: 'access content'
# materio_home.home:
# path: '/home'
# defaults:
# _controller: '\Drupal\materio_home\Controller\HomeController::home'
# _title: 'Home'
# requirements:
# _permission: 'access content'
# materio_home.home_mobile:
# path: '/home_m'

View File

@ -28,6 +28,15 @@ class HomeController extends ControllerBase {
$contents = array("#theme"=>'materio_home');
// presentation
$query = \Drupal::entityQuery('node')
->condition('status', 1)
->condition('nid', 19990);
// TODO: présentation nid should be a setting
$pres_nid = $query->execute();
$contents["#frontpage_node"] = entity_load('node', array_pop($pres_nid));
return $contents;
}

View File

@ -0,0 +1,57 @@
<?php
namespace Drupal\materio_home\Plugin\Field\FieldType;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Field\EntityReferenceFieldItemList;
use Drupal\Core\Field\EntityReferenceFieldItemListInterface;
use Drupal\Core\Field\FieldItemList;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\TypedData\ComputedItemListTrait;
// https://www.drupal.org/node/2112677
// https://www.cornel.co/article/entity-reference-computed-field-example-drupal
// https://www.caxy.com/blog/drupal-custom-form-and-computed-fields
class ComputedMaterialsReferences extends EntityReferenceFieldItemList
{
use ComputedItemListTrait;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* {@inheritdoc}
*/
public function __construct(BaseFieldDefinition $definition, $name, TypedDataInterface $parent) {
parent::__construct($definition, $name, $parent);
$this->entityTypeManager = \Drupal::entityTypeManager();
}
/**
* Compute the values.
*/
protected function computeValue() {
$query = \Drupal::entityQuery('node')
->condition('status', 1)
->condition('type', 'materiau')
->sort('created', 'DESC')
->range(0,200);
$results = $query->execute();
$nids = array_rand($results, 20);
$nodes = entity_load_multiple('node', $nids);
// \Drupal::logger('materio_home')->notice(print_r($nodes, true));
$key = 0;
foreach ($nodes as $nid => $node) {
// \Drupal::logger('materio_home')->notice($nid);
$this->list[$key] = $this->createItem($key, $node->id());
$key++;
}
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace Drupal\materio_home\Plugin\Field\FieldType;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Field\EntityReferenceFieldItemList;
use Drupal\Core\Field\EntityReferenceFieldItemListInterface;
use Drupal\Core\Field\FieldItemList;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\TypedData\ComputedItemListTrait;
// https://www.drupal.org/node/2112677
// https://www.cornel.co/article/entity-reference-computed-field-example-drupal
// https://www.caxy.com/blog/drupal-custom-form-and-computed-fields
class ComputedShowroomsReferences extends EntityReferenceFieldItemList
{
use ComputedItemListTrait;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* {@inheritdoc}
*/
public function __construct(BaseFieldDefinition $definition, $name, TypedDataInterface $parent) {
parent::__construct($definition, $name, $parent);
$this->entityTypeManager = \Drupal::entityTypeManager();
}
/**
* Compute the values.
*/
protected function computeValue() {
$query = \Drupal::entityQuery('taxonomy_term')
->condition('status', 1)
->condition('vid', 'showroom');
$tids = $query->execute();
shuffle($tids);
$terms = entity_load_multiple('taxonomy_term', $tids);
// \Drupal::logger('materio_home')->notice(print_r($nodes, true));
$key = 0;
foreach ($terms as $tid => $term) {
// \Drupal::logger('materio_home')->notice($nid);
$this->list[$key] = $this->createItem($key, $term->id());
$key++;
}
}
}

View File

@ -1 +1 @@
Hello Materio :)
{{ frontpage_node }}

View File

@ -7,7 +7,7 @@ function computed_field_field_index_compute($entity_type_manager, $entity, $fiel
return $entity->field_index->value;
}
// TODO: finish the job
/* FROM D7
// dsm('-- computed --');
@ -70,6 +70,7 @@ function computed_field_field_reference_compute($entity_type_manager, $entity, $
return $entity->field_reference->value;
}
// TODO: finish the job
/* FROM D7
// dsm('-- computed --');

View File

@ -707,7 +707,7 @@ eval("var g; // This works in non-strict mode\n\ng = function () {\n return thi
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nvar _vue = _interopRequireDefault(__webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.runtime.esm.js\"));\n\nvar _store = _interopRequireDefault(__webpack_require__(/*! vuejs/store */ \"./web/themes/custom/materiotheme/vuejs/store/index.js\"));\n\nvar _UserBlock = _interopRequireDefault(__webpack_require__(/*! vuejs/components/User/UserBlock */ \"./web/themes/custom/materiotheme/vuejs/components/User/UserBlock.vue\"));\n\nvar _Test = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/Test */ \"./web/themes/custom/materiotheme/vuejs/components/Content/Test.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(function (Drupal, drupalSettings) {\n var MaterioTheme = function MaterioTheme() {\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 var props = {\n title: \"\"\n };\n var mount_point = drupalSettings.user.uid !== 0 ? '#block-userblock' : '#block-userlogin';\n\n switch (mount_point) {\n case '#block-userlogin':\n var $block = document.querySelector(mount_point);\n props = {\n title: $block.querySelector('h2').textContent,\n form: {\n ph_email: $block.querySelector('input#edit-name').getAttribute('placeholder'),\n ph_pass: $block.querySelector('input#edit-pass').getAttribute('placeholder'),\n btn_value: $block.querySelector('input#edit-submit').getAttribute('value'),\n register: {\n title: $block.querySelector('a.create-account-link').textContent,\n href: $block.querySelector('a.create-account-link').getAttribute('href')\n },\n reset: {\n title: $block.querySelector('a.request-password-link').textContent,\n href: $block.querySelector('a.request-password-link').getAttribute('href')\n }\n }\n };\n break;\n\n case '#block-userblock':\n break;\n\n default:\n }\n\n console.log(props);\n v_user_block = new _vue.default({\n // data: data,\n store: _store.default,\n computed: _objectSpread({}, (0, _vuex.mapState)({\n isloggedin: function isloggedin(state) {\n return state.User.isloggedin;\n }\n })),\n created: function 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 render: function render(h) {\n return h(_UserBlock.default, {\n props: props\n });\n }\n }).$mount(mount_point);\n console.log('initUserVBlock', v_user_block);\n }\n\n function initTestVContent() {\n v_test_content = new _vue.default({\n store: _store.default,\n render: function render(h) {\n return h(_Test.default);\n }\n }).$mount('#block-pagetitle'); // 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?");
eval("\n\nvar _vue = _interopRequireDefault(__webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.runtime.esm.js\"));\n\nvar _store = _interopRequireDefault(__webpack_require__(/*! vuejs/store */ \"./web/themes/custom/materiotheme/vuejs/store/index.js\"));\n\nvar _UserBlock = _interopRequireDefault(__webpack_require__(/*! vuejs/components/User/UserBlock */ \"./web/themes/custom/materiotheme/vuejs/components/User/UserBlock.vue\"));\n\nvar _Test = _interopRequireDefault(__webpack_require__(/*! vuejs/components/Content/Test */ \"./web/themes/custom/materiotheme/vuejs/components/Content/Test.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(function (Drupal, drupalSettings) {\n var MaterioTheme = function MaterioTheme() {\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(); // initTestVContent()\n }\n\n function initUserVBlock() {\n var mount_point = drupalSettings.user.uid !== 0 ? '#block-userblock' : '#block-userlogin';\n var props = {\n title: \"\"\n };\n\n switch (mount_point) {\n case '#block-userlogin':\n var $block = document.querySelector(mount_point);\n props = {\n title: $block.querySelector('h2').textContent,\n form: {\n ph_email: $block.querySelector('input#edit-name').getAttribute('placeholder'),\n ph_pass: $block.querySelector('input#edit-pass').getAttribute('placeholder'),\n btn_value: $block.querySelector('input#edit-submit').getAttribute('value'),\n register: {\n title: $block.querySelector('a.create-account-link').textContent,\n href: $block.querySelector('a.create-account-link').getAttribute('href')\n },\n reset: {\n title: $block.querySelector('a.request-password-link').textContent,\n href: $block.querySelector('a.request-password-link').getAttribute('href')\n }\n }\n };\n break;\n\n case '#block-userblock':\n default:\n break;\n } // console.log(props);\n\n\n v_user_block = new _vue.default({\n store: _store.default,\n computed: _objectSpread({}, (0, _vuex.mapState)({\n isloggedin: function isloggedin(state) {\n return state.User.isloggedin;\n }\n })),\n created: function 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 render: function render(h) {\n return h(_UserBlock.default, {\n props: props\n });\n }\n }).$mount(mount_point);\n console.log('initUserVBlock', v_user_block);\n }\n\n function initTestVContent() {\n v_test_content = new _vue.default({\n store: _store.default,\n render: function render(h) {\n return h(_Test.default);\n }\n }).$mount('#block-pagetitle'); // 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?");
/***/ }),

View File

@ -29,14 +29,14 @@ import 'theme/assets/styles/main.scss'
function initVues(){
initUserVBlock()
initTestVContent()
// initTestVContent()
}
function initUserVBlock(){
let mount_point = drupalSettings.user.uid !== 0 ? '#block-userblock' : '#block-userlogin';
let props = {
title: ""
};
let mount_point = drupalSettings.user.uid !== 0 ? '#block-userblock' : '#block-userlogin';
switch (mount_point) {
case '#block-userlogin':
let $block = document.querySelector(mount_point);
@ -58,14 +58,12 @@ import 'theme/assets/styles/main.scss'
}
break;
case '#block-userblock':
break;
default:
break;
}
console.log(props);
// console.log(props);
v_user_block = new Vue({
// data: data,
store,
computed: {
...mapState({