From a38653f7ce8b83df51165532ba91a191e9daaad7 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Tue, 24 Nov 2020 14:07:10 +0100 Subject: [PATCH] flagging unflagging cards --- config/sync/flag.flag.dossier.yml | 18 ++- .../sync/flag_lists.flag_for_list.dossier.yml | 2 +- .../materio_flag/materio_flag.routing.yml | 24 ++++ .../MaterioFlagActionsController.php | 118 +++++++++++++++++ .../src/Controller/MaterioFlagController.php | 80 ++++++++++-- .../materio_sapi/src/Controller/Base.php | 3 + .../custom/materiotheme/assets/dist/main.css | 31 +++++ .../custom/materiotheme/assets/dist/main.js | 14 +-- .../materiotheme/assets/styles/main.scss | 39 ++++++ .../custom/materiotheme/vuejs/api/ma-axios.js | 1 + .../vuejs/components/Content/Card.vue | 69 +++++++++- .../vuejs/components/User/UserFlags.vue | 36 +++--- .../vuejs/store/modules/search.js | 3 +- .../materiotheme/vuejs/store/modules/user.js | 119 ++++++++++++------ 14 files changed, 476 insertions(+), 81 deletions(-) create mode 100644 web/modules/custom/materio_flag/src/Controller/MaterioFlagActionsController.php diff --git a/config/sync/flag.flag.dossier.yml b/config/sync/flag.flag.dossier.yml index 009e2b6c..f3aec93e 100644 --- a/config/sync/flag.flag.dossier.yml +++ b/config/sync/flag.flag.dossier.yml @@ -3,9 +3,10 @@ langcode: en status: true dependencies: module: + - flag_lists - node id: dossier -label: Dossier +label: Folder bundles: - article - materiau @@ -21,11 +22,20 @@ unflag_long: '' unflag_message: '' unflag_denied_text: '' flag_type: 'entity:node' -link_type: reload +link_type: ajax_link flagTypeConfig: - show_in_links: { } + show_in_links: + card_big: card_big + card_full: card_full + card_medium: card_medium + card_small: card_small + full: full + search_index: search_index + search_result: search_result + teaser: teaser + token: token show_as_field: true - show_on_form: false + show_on_form: true show_contextual_link: true extra_permissions: owner: owner diff --git a/config/sync/flag_lists.flag_for_list.dossier.yml b/config/sync/flag_lists.flag_for_list.dossier.yml index b403d3e6..21b6b9ea 100644 --- a/config/sync/flag_lists.flag_for_list.dossier.yml +++ b/config/sync/flag_lists.flag_for_list.dossier.yml @@ -3,7 +3,7 @@ langcode: en status: true dependencies: { } id: dossier -label: Dossier +label: Folder base_flag: dossier owner: root weight: null diff --git a/web/modules/custom/materio_flag/materio_flag.routing.yml b/web/modules/custom/materio_flag/materio_flag.routing.yml index e45f3c52..078c4eb7 100644 --- a/web/modules/custom/materio_flag/materio_flag.routing.yml +++ b/web/modules/custom/materio_flag/materio_flag.routing.yml @@ -21,3 +21,27 @@ materio_flag.delete_user_flagging_collection: _title: 'Delete User Flagging Collection' requirements: _permission: 'edit own flag lists' + +materio_flag.flag: + path: 'materio_flag/flag' + defaults: + _controller: '\Drupal\materio_flag\Controller\MaterioFlagActionsController::flaglistentity' + _title: 'Add entity to Flagging Collection' + requirements: + _permission: 'edit own flag lists' + +materio_flag.unFlag: + path: 'materio_flag/unflag' + defaults: + _controller: '\Drupal\materio_flag\Controller\MaterioFlagActionsController::unFlaglistentity' + _title: 'Remove entity from Flagging Collection' + requirements: + _permission: 'edit own flag lists' + +# materio_flag.unflag +# path: 'materio_flag/unflag' +# defaults: +# _controller: '\Drupal\materio_flag\Controller\MaterioFlagController::unFlag' +# _title: 'Remove entity from Flagging Collection' +# requirements: +# _permission: 'edit own flag lists' diff --git a/web/modules/custom/materio_flag/src/Controller/MaterioFlagActionsController.php b/web/modules/custom/materio_flag/src/Controller/MaterioFlagActionsController.php new file mode 100644 index 00000000..00eea836 --- /dev/null +++ b/web/modules/custom/materio_flag/src/Controller/MaterioFlagActionsController.php @@ -0,0 +1,118 @@ +get('flag'), + $container->get('flaglists'), + $container->get('renderer') + ); + } + + /** + * Constructs a new MaterioFlagController object. + */ + public function __construct( + FlagServiceInterface $flag, + FlagListsServiceInterface $flag_lists, + RendererInterface $renderer + ) { + parent::__construct($flag, $flag_lists, $renderer); + } + + public function flaglistentity(Request $request) { + $post_data = json_decode( $request->getContent(),TRUE); + $flagid = $post_data['flagid']; + $uuid = $post_data['uuid']; + $flagcollid = $post_data['flagcollid']; + + // $flagcoll = $this->flagListsService->getFlaggingCollectionById($flagcollid); + // $flag = $flagcoll->getRelatedFlag(); + $flag = $this->flagService->getFlagById($flagid); + + $node = \Drupal::service('entity.repository')->loadEntityByUuid('node', $uuid); + $nid = $node->id(); + + // call the parent flag function + $this->flag($flag, $nid, $flagcollid); + + // // OR rewrite it entirely + // $entity = $this->flagService->getFlaggableById($flag, $nid); + // // flag + // $this->flagService->flag($flag, $entity); + // // Create the flag list item. + // // $actionLinkHelper = new ActionLinkHelper($this->flagListsService); + // // $actionLinkHelper->flagHelper($flag, $nid, $flagcoll); + // $flag_list_item = FlagListItem::create([ + // 'entity_id' => $nid, + // 'type' => $flag->getFlaggableEntityTypeId(), + // 'baseflag' => $flagid, + // 'flag_list' => $flagcollid, + // 'name' => $flagcoll->getName() . ' ' . $nid, + // ]); + // $flag_list_item->save(); + + $data = [ + 'flag' => $flag->toArray(), + 'flagid' => $flagid, + 'entity_id' => $nid, + 'entity_uuid' => $uuid, + 'flagcollid' => $flagcollid, + // 'post_data' => $post_data, + // 'flaggableEntityTypeId' => $flag->getFlaggableEntityTypeId(), + // 'entity_title' => $entity->get('title')->value, + // 'flag_list_item' => $flag_list_item->getName(), + ]; + return new JsonResponse($data); + } + + public function unFlaglistentity(Request $request) { + $post_data = json_decode( $request->getContent(),TRUE); + $flagid = $post_data['flagid']; + $uuid = $post_data['uuid']; + $flagcollid = $post_data['flagcollid']; + // get flag + $flag = $this->flagService->getFlagById($flagid); + // get the nid from uuid + $node = \Drupal::service('entity.repository')->loadEntityByUuid('node', $uuid); + $nid = $node->id(); + // call the parent flag function + $this->unflag($flag, $nid, $flagcollid); + // response + $data = [ + 'flag' => $flag->toArray(), + 'flagid' => $flagid, + 'entity_id' => $nid, + 'entity_uuid' => $uuid, + 'flagcollid' => $flagcollid, + ]; + return new JsonResponse($data); + } +} diff --git a/web/modules/custom/materio_flag/src/Controller/MaterioFlagController.php b/web/modules/custom/materio_flag/src/Controller/MaterioFlagController.php index 2de286ea..90ea2f63 100644 --- a/web/modules/custom/materio_flag/src/Controller/MaterioFlagController.php +++ b/web/modules/custom/materio_flag/src/Controller/MaterioFlagController.php @@ -6,8 +6,10 @@ use Drupal\Core\Controller\ControllerBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Session\AccountProxy; use Drupal\Core\Session\AccountProxyInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\flag_lists\FlagListsService; use Drupal\flag_lists\Entity\FlaggingCollection; +use Drupal\flag_lists\Controller\ActionLinkController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\JsonResponse; /** @@ -16,10 +18,15 @@ use Symfony\Component\HttpFoundation\JsonResponse; class MaterioFlagController extends ControllerBase { + /* + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected $entityTypeManager; + /** * @var \Drupal\flag_lists\FlagListsService */ - protected $flaglists; + protected $flagListsService; /** * @var \Drupal\user\User @@ -31,6 +38,7 @@ class MaterioFlagController extends ControllerBase { */ public static function create(ContainerInterface $container) { return new static( + $container->get('entity_type.manager'), $container->get('flaglists'), $container->get('current_user') ); @@ -39,9 +47,10 @@ class MaterioFlagController extends ControllerBase { /** * Constructs a new MaterioFlagController object. */ - public function __construct(FlagListsService $flag_lists_service, AccountProxyInterface $account) { - $this->flaglists = $flag_lists_service; - $this->user = $account; + public function __construct(EntityTypeManagerInterface $entity_type_manager, FlagListsService $flag_lists_service, AccountProxyInterface $account) { + $this->entityTypeManager = $entity_type_manager; + $this->flagListsService = $flag_lists_service; + $this->user = $account; } /** @@ -52,13 +61,35 @@ class MaterioFlagController extends ControllerBase { */ public function getUsersFlaggingCollections() { - $colls = $this->flaglists->getUsersFlaggingCollections(); + $colls = $this->flagListsService->getUsersFlaggingCollections(); $data = []; foreach ($colls as $id => $collection) { - $data[] = array( - "id" => $id, - "name" => $collection->getName() + $flag_id = $collection->getRelatedFlag()->id(); + + // get the items + $itemsids = $this->flagListsService->getFlagListItemIds($flag_id,$id); + $items = []; + foreach ($this->flagListsService->getFlagListItems($itemsids) as $id => $item) { + // $items[] = array( + // 'id' => $id, + // 'name' => $item->getName(), + // 'connected_entity_id' => $item->getConnectedEntityId(), + // ); + $items[] = $item->getConnectedEntityId(); + } + $items_uuids = []; + foreach ($items as $nid) { + $node = $this->entityTypeManager->getStorage('node')->load($nid); + $items_uuids[] = $node->uuid(); + } + + $data[$collection->id()] = array( + "id" => $collection->id(), + "name" => $collection->getName(), + "flag_id" => $flag_id, + "items" => $items, + "items_uuids" => $items_uuids, ); } @@ -91,9 +122,9 @@ class MaterioFlagController extends ControllerBase { public function deleteUserFlaggingCollection(Request $request) { // dpm($request); $post_data = json_decode( $request->getContent(),TRUE); - $flagid = $post_data['flagid']; + $flagcollid = $post_data['flagcollid']; - $flagcoll = $this->flaglists->getFlaggingCollectionById($flagid); + $flagcoll = $this->flagListsService->getFlaggingCollectionById($flagcollid); // dump($flagcoll); $flagcoll->delete(); // TODO: warning, sometimes relatedFlag deos not exists @@ -101,9 +132,36 @@ class MaterioFlagController extends ControllerBase { $data = [ // 'result' => $flag, - 'id' => $flagid + 'id' => $flagcollid ]; return new JsonResponse($data); } + // public function flag(Request $request) { + // // dpm($request); + // $post_data = json_decode( $request->getContent(),TRUE); + // $flagid = $post_data['flagid']; + // $nid = $post_data['nid']; + // $flagcollid = $post_data['flagcollid']; + // + // $actionLinkController = new ActionLinkController(); + // // FlagInterface $flag, $entity_id, $flag_list + // $status = $actionLinkController->flag($flagid, $nid, $flagcollid); + // + // // $flagcoll = $this->flagListsService->getFlaggingCollectionById($flagid); + // // // dump($flagcoll); + // // $flagcoll->delete(); + // // // TODO: warning, sometimes relatedFlag deos not exists + // // // $flag = $flagcoll->getRelatedFlag(); + // + // $data = [ + // 'status' => $flag, + // 'flagid' => $flagid, + // 'nid' => $nid, + // 'flagcollid' => $flagcollid + // ]; + // return new JsonResponse($data); + // } + + } diff --git a/web/modules/custom/materio_sapi/src/Controller/Base.php b/web/modules/custom/materio_sapi/src/Controller/Base.php index 36f9f6f1..e7421314 100644 --- a/web/modules/custom/materio_sapi/src/Controller/Base.php +++ b/web/modules/custom/materio_sapi/src/Controller/Base.php @@ -101,6 +101,7 @@ class Base extends ControllerBase { // $items = []; $uuids = []; + $nids = []; foreach ($this->results as $result) { // $nid = $result->getField('nid')->getValues()[0]; // $uuid = $result->getField('uuid')->getValues()[0]; @@ -111,9 +112,11 @@ class Base extends ControllerBase { // 'title' => $title, // ]; $uuids[] = $result->getField('uuid')->getValues()[0]; + $nids[] = $result->getField('nid')->getValues()[0]; } // $resp['items'] = $items; $resp['uuids'] = $uuids; + $resp['nids'] = $nids; } return new JsonResponse($resp); diff --git a/web/themes/custom/materiotheme/assets/dist/main.css b/web/themes/custom/materiotheme/assets/dist/main.css index 2e175848..b30c8c8e 100644 --- a/web/themes/custom/materiotheme/assets/dist/main.css +++ b/web/themes/custom/materiotheme/assets/dist/main.css @@ -1631,6 +1631,37 @@ article.card { font-size: 0.693em; font-weight: 300; line-height: 1; } + article.card nav.tools { + position: absolute; + top: 0; + right: 0; + z-index: 21; + width: 1em; + background-color: #fff; + box-sizing: content-box; + padding: 0.3em 0.1em; } + article.card nav.tools > * { + overflow: visible; + position: relative; } + article.card nav.tools > * span.btn { + overflow: hidden; + font-size: 0.882em; } + article.card nav.tools > * .tool-content { + position: absolute; + top: 0px; + right: 100%; + width: 5em; + box-sizing: content-box; + padding: 0.3em; + background-color: #fff; + box-shadow: -2px 3px 4px rgba(0, 0, 0, 0.2); } + article.card nav.tools .tool.flags span.flag { + cursor: pointer; + font-size: 0.756em; + color: #bbb; + transition: color 0.3s ease-in-out; } + article.card nav.tools .tool.flags span.flag:hover, article.card nav.tools .tool.flags span.flag.isActive { + color: #1a1a1a; } article.card section.images { position: relative; } article.card section.images, article.card section.images * { diff --git a/web/themes/custom/materiotheme/assets/dist/main.js b/web/themes/custom/materiotheme/assets/dist/main.js index 8888e15c..1f2d31c0 100644 --- a/web/themes/custom/materiotheme/assets/dist/main.js +++ b/web/themes/custom/materiotheme/assets/dist/main.js @@ -429,7 +429,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//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nvar _default = {\n name: \"Card\",\n props: ['item'],\n data: function data() {\n return {\n blanksrc: \"\".concat(drupalSettings.path.themePath, \"/assets/img/blank.gif\")\n };\n },\n directives: {\n lazy: {\n bind: function bind(img, binding) {\n // console.log('lazy bind', img, binding);\n if (binding.value === 0) {\n img.setAttribute('src', img.getAttribute('data-src'));\n img.removeAttribute('data-src');\n img.classList.remove('lazy');\n }\n }\n },\n switcher: {\n inserted: function inserted(el, binding) {\n // switch images on mousemove\n el.addEventListener('mousemove', function (event) {\n var figs = this.querySelectorAll('figure'); // console.log('mousemove', this, event, figs.length);\n // let len = figs.length\n // let w = this.clientWidth;\n // let g = w / len;\n // let delta = Math.floor(event.layerX / g)\n\n var delta = Math.floor(event.layerX / (this.clientWidth / figs.length)); // console.log('delta', delta);\n\n figs.forEach(function (fig, index) {\n // console.log(index);\n if (index == delta) {\n fig.style.display = \"block\";\n } else {\n fig.style.display = \"none\";\n }\n });\n });\n }\n }\n },\n mounted: function mounted() {\n // lazy load images on mouseover\n this.$el.addEventListener('mouseover', function (event) {\n var imgs = this.querySelectorAll('.images figure img.lazy'); // console.log('mouseover', this, imgs);\n\n imgs.forEach(function (img) {\n // console.log('forEach img',img);\n img.setAttribute('src', img.getAttribute('data-src'));\n img.removeAttribute('data-src');\n img.classList.remove('lazy');\n });\n }, {\n once: true\n });\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Card.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 _vuex = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.esm.js\");\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar _default = {\n name: \"Card\",\n props: ['item'],\n data: function data() {\n return {\n blanksrc: \"\".concat(drupalSettings.path.themePath, \"/assets/img/blank.gif\"),\n loadingFlag: false\n };\n },\n computed: _objectSpread({}, (0, _vuex.mapState)({\n flagcolls: function flagcolls(state) {\n return state.User.flagcolls;\n }\n })),\n directives: {\n lazy: {\n bind: function bind(img, binding) {\n // console.log('lazy bind', img, binding);\n if (binding.value === 0) {\n img.setAttribute('src', img.getAttribute('data-src'));\n img.removeAttribute('data-src');\n img.classList.remove('lazy');\n }\n }\n },\n switcher: {\n inserted: function inserted(el, binding) {\n // switch images on mousemove\n el.addEventListener('mousemove', function (event) {\n var figs = this.querySelectorAll('figure'); // console.log('mousemove', this, event, figs.length);\n // let len = figs.length\n // let w = this.clientWidth;\n // let g = w / len;\n // let delta = Math.floor(event.layerX / g)\n\n var delta = Math.floor(event.layerX / (this.clientWidth / figs.length)); // console.log('delta', delta);\n\n figs.forEach(function (fig, index) {\n // console.log(index);\n if (index == delta) {\n fig.style.display = \"block\";\n } else {\n fig.style.display = \"none\";\n }\n });\n });\n }\n }\n },\n mounted: function mounted() {\n // lazy load images on mouseover\n this.$el.addEventListener('mouseover', function (event) {\n var imgs = this.querySelectorAll('.images figure img.lazy'); // console.log('mouseover', this, imgs);\n\n imgs.forEach(function (img) {\n // console.log('forEach img',img);\n img.setAttribute('src', img.getAttribute('data-src'));\n img.removeAttribute('data-src');\n img.classList.remove('lazy');\n });\n }, {\n once: true\n });\n },\n methods: _objectSpread({}, (0, _vuex.mapActions)({\n flag: 'User/flag',\n unFlag: 'User/unFlag'\n }), {\n flagIsActive: function flagIsActive(collid) {\n // console.log(this.item.uuid);\n // console.log(this.flagcolls[collid].items_uuids);\n return this.flagcolls[collid].items_uuids.indexOf(this.item.uuid) !== -1;\n },\n flagIsLoading: function flagIsLoading(collid) {\n // console.log(this.item.uuid);\n // console.log(this.flagcolls[collid].items_uuids);\n return collid === this.loadingFlag;\n },\n onFlagActionCard: function onFlagActionCard(e) {\n var _this = this;\n\n console.log(\"Card onFlagActionCard\", isActive, e);\n\n if (!this.loadingFlag) {\n var collid = e.target.getAttribute('collid');\n\n var _isActive = this.flagIsActive(collid); // console.log('collid', collid);\n // console.log(\"this.item\", this.item);\n\n\n this.loadingFlag = collid;\n\n if (_isActive) {\n this.unFlag({\n uuid: this.item.uuid,\n collid: collid\n }).then(function (data) {\n console.log(\"onFlagActionCard then\", data);\n _this.loadingFlag = false;\n });\n } else {\n this.flag({\n uuid: this.item.uuid,\n collid: collid\n }).then(function (data) {\n console.log(\"onFlagActionCard then\", data);\n _this.loadingFlag = false;\n });\n }\n }\n }\n })\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Card.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options"); /***/ }), @@ -609,7 +609,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _vuex = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.esm.js\");\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar _default = {\n name: \"userFlags\",\n data: function data() {\n return {\n new_folder_name: \"\",\n is_creating_folder: false,\n is_deleting_folder: false\n };\n },\n computed: _objectSpread({}, (0, _vuex.mapState)({\n flags: function flags(state) {\n return state.User.flags;\n }\n }), {\n addFlagBtnClassObj: function addFlagBtnClassObj() {\n return {\n 'mdi-plus-circle-outline': !this.is_creating_folder,\n 'mdi-loading': this.is_creating_folder,\n active: this.new_folder_name.length > 4 && !this.is_creating_folder,\n loading: this.is_creating_folder\n };\n },\n flagDeletingClassObj: function flagDeletingClassObj() {\n return {\n 'mdi-trash-can-outline': !this.is_deleting_folder,\n 'mdi-loading': this.is_deleting_folder,\n 'loading': this.is_deleting_folder\n };\n }\n }),\n methods: _objectSpread({}, (0, _vuex.mapActions)({\n createFlag: 'User/createFlag',\n deleteFlag: 'User/deleteFlag'\n }), {\n onCreateFlag: function onCreateFlag() {\n var _this = this;\n\n console.log(\"UserFlags onCreateFlag\", this.new_folder_name);\n this.is_creating_folder = true;\n this.createFlag(this.new_folder_name).then(function (data) {\n console.log(\"onCreateFlag then\", data);\n _this.new_folder_name = \"\";\n _this.is_creating_folder = false;\n });\n },\n onDeleteFlag: function onDeleteFlag(e) {\n var _this2 = this;\n\n var flagid = e.target.getAttribute('flagid');\n console.log(\"UserFlags onDeleteFlag\", flagid);\n this.is_deleting_folder = flagid;\n this.deleteFlag(flagid).then(function () {\n // console.log(\"onDeleteFlag then\", data);\n _this2.is_deleting_folder = false;\n });\n }\n })\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/User/UserFlags.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 _vuex = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.esm.js\");\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar _default = {\n name: \"userFlags\",\n data: function data() {\n return {\n new_folder_name: \"\",\n is_creating_folder: false,\n is_deleting_folder: false\n };\n },\n computed: _objectSpread({}, (0, _vuex.mapState)({\n flagcolls: function flagcolls(state) {\n return state.User.flagcolls;\n }\n }), {\n addFlagBtnClassObj: function addFlagBtnClassObj() {\n return {\n 'mdi-plus-circle-outline': !this.is_creating_folder,\n 'mdi-loading': this.is_creating_folder,\n active: this.new_folder_name.length > 4 && !this.is_creating_folder,\n loading: this.is_creating_folder\n };\n },\n flagDeletingClassObj: function flagDeletingClassObj() {\n return {\n 'mdi-trash-can-outline': !this.is_deleting_folder,\n 'mdi-loading': this.is_deleting_folder,\n 'loading': this.is_deleting_folder\n };\n }\n }),\n methods: _objectSpread({}, (0, _vuex.mapActions)({\n createFlagColl: 'User/createFlagColl',\n deleteFlagColl: 'User/deleteFlagColl'\n }), {\n onCreateFlagColl: function onCreateFlagColl() {\n var _this = this;\n\n console.log(\"UserFlags onCreateFlagColl\", this.new_folder_name);\n this.is_creating_folder = true;\n this.createFlagColl(this.new_folder_name).then(function (data) {\n console.log(\"onCreateFlagColl then\", data);\n _this.new_folder_name = \"\";\n _this.is_creating_folder = false;\n });\n },\n onDeleteFlagColl: function onDeleteFlagColl(e) {\n var _this2 = this;\n\n var flagcollid = e.target.getAttribute('flagcollid');\n console.log(\"UserFlags onDeleteFlagColl\", flagcollid);\n this.is_deleting_folder = flagcollid;\n this.deleteFlagColl(flagcollid).then(function () {\n // console.log(\"onDeleteFlagColl then\", data);\n _this2.is_deleting_folder = false;\n });\n }\n })\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/User/UserFlags.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options"); /***/ }), @@ -838,7 +838,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 _c(\"article\", { staticClass: \"card\" }, [\n _c(\"header\", [\n _c(\"h1\", [_vm._v(_vm._s(_vm.item.title))]),\n _vm._v(\" \"),\n _c(\"h4\", [_vm._v(_vm._s(_vm.item.field_short_description))]),\n _vm._v(\" \"),\n _c(\"span\", { staticClass: \"ref\" }, [\n _vm._v(_vm._s(_vm.item.field_reference))\n ])\n ]),\n _vm._v(\" \"),\n _c(\n \"section\",\n {\n directives: [{ name: \"switcher\", rawName: \"v-switcher\" }],\n staticClass: \"images\"\n },\n _vm._l(_vm.item.images, function(img, index) {\n return _c(\"figure\", { key: img.url }, [\n _c(\"img\", {\n directives: [\n {\n name: \"lazy\",\n rawName: \"v-lazy\",\n value: index,\n expression: \"index\"\n }\n ],\n staticClass: \"lazy\",\n attrs: { \"data-src\": img.url, title: img.title }\n }),\n _vm._v(\" \"),\n _c(\"img\", { staticClass: \"blank\", attrs: { src: _vm.blanksrc } })\n ])\n }),\n 0\n )\n ])\n}\nvar staticRenderFns = []\nrender._withStripped = true\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Card.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(\"article\", { staticClass: \"card\" }, [\n _c(\"header\", [\n _c(\"h1\", [_vm._v(_vm._s(_vm.item.title))]),\n _vm._v(\" \"),\n _c(\"h4\", [_vm._v(_vm._s(_vm.item.field_short_description))]),\n _vm._v(\" \"),\n _c(\"span\", { staticClass: \"ref\" }, [\n _vm._v(_vm._s(_vm.item.field_reference))\n ])\n ]),\n _vm._v(\" \"),\n _c(\"nav\", { staticClass: \"tools\" }, [\n _c(\"section\", { staticClass: \"tool flags\" }, [\n _c(\"span\", { staticClass: \"btn mdi mdi-folder-outline\" }),\n _vm._v(\" \"),\n _c(\"div\", { staticClass: \"tool-content\" }, [\n _c(\n \"ul\",\n _vm._l(_vm.flagcolls, function(coll) {\n return _vm.flagcolls\n ? _c(\"li\", { key: coll.id }, [\n _c(\n \"span\",\n {\n staticClass: \"flag mdi\",\n class: [\n _vm.flagIsLoading(coll.id)\n ? \"mdi-loading mdi-spin\"\n : _vm.flagIsActive(coll.id)\n ? \"mdi-close isActive\"\n : \"mdi-plus\"\n ],\n attrs: { collid: coll.id },\n on: {\n click: function($event) {\n $event.preventDefault()\n return _vm.onFlagActionCard($event)\n }\n }\n },\n [\n _vm._v(\n \"\\n \" +\n _vm._s(coll.name) +\n \"\\n \"\n )\n ]\n )\n ])\n : _vm._e()\n }),\n 0\n )\n ])\n ])\n ]),\n _vm._v(\" \"),\n _c(\n \"section\",\n {\n directives: [{ name: \"switcher\", rawName: \"v-switcher\" }],\n staticClass: \"images\"\n },\n _vm._l(_vm.item.images, function(img, index) {\n return _c(\"figure\", { key: img.url }, [\n _c(\"img\", {\n directives: [\n {\n name: \"lazy\",\n rawName: \"v-lazy\",\n value: index,\n expression: \"index\"\n }\n ],\n staticClass: \"lazy\",\n attrs: { \"data-src\": img.url, title: img.title }\n }),\n _vm._v(\" \"),\n _c(\"img\", { staticClass: \"blank\", attrs: { src: _vm.blanksrc } })\n ])\n }),\n 0\n )\n ])\n}\nvar staticRenderFns = []\nrender._withStripped = true\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/Content/Card.vue?./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options"); /***/ }), @@ -970,7 +970,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 _c(\"div\", { attrs: { id: \"user-flags\" } }, [\n _c(\"h2\", { staticClass: \"mdi mdi-folder-outline\" }, [_vm._v(\"My folders\")]),\n _vm._v(\" \"),\n _c(\n \"ul\",\n [\n _vm._l(_vm.flags, function(flag) {\n return _vm.flags\n ? _c(\"li\", { key: flag.id }, [\n _c(\"h5\", [_vm._v(_vm._s(flag.name))]),\n _vm._v(\" \"),\n _c(\"div\", { staticClass: \"actions\" }, [\n _c(\"span\", {\n staticClass: \"delete-btn mdi\",\n class: _vm.flagDeletingClassObj,\n attrs: { flagid: flag.id },\n on: {\n click: function($event) {\n $event.preventDefault()\n return _vm.onDeleteFlag($event)\n }\n }\n })\n ])\n ])\n : _vm._e()\n }),\n _vm._v(\" \"),\n _c(\"li\", { staticClass: \"create-flag\" }, [\n _c(\"input\", {\n directives: [\n {\n name: \"model\",\n rawName: \"v-model\",\n value: _vm.new_folder_name,\n expression: \"new_folder_name\"\n }\n ],\n attrs: { placeholder: \"new folder\" },\n domProps: { value: _vm.new_folder_name },\n on: {\n input: function($event) {\n if ($event.target.composing) {\n return\n }\n _vm.new_folder_name = $event.target.value\n }\n }\n }),\n _vm._v(\" \"),\n _c(\"span\", {\n staticClass: \"add-btn mdi\",\n class: _vm.addFlagBtnClassObj,\n on: {\n click: function($event) {\n $event.preventDefault()\n return _vm.onCreateFlag($event)\n }\n }\n })\n ])\n ],\n 2\n )\n ])\n}\nvar staticRenderFns = []\nrender._withStripped = true\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/User/UserFlags.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: \"user-flags\" } }, [\n _c(\"h2\", { staticClass: \"mdi mdi-folder-outline\" }, [_vm._v(\"My folders\")]),\n _vm._v(\" \"),\n _c(\n \"ul\",\n [\n _vm._l(_vm.flagcolls, function(coll) {\n return _vm.flagcolls\n ? _c(\"li\", { key: coll.id }, [\n _c(\"h5\", [\n _vm._v(\n _vm._s(coll.name) + \" (\" + _vm._s(coll.items.length) + \")\"\n )\n ]),\n _vm._v(\" \"),\n _c(\"div\", { staticClass: \"actions\" }, [\n _c(\"span\", {\n staticClass: \"delete-btn mdi\",\n class: _vm.flagDeletingClassObj,\n attrs: { flagcollid: coll.id },\n on: {\n click: function($event) {\n $event.preventDefault()\n return _vm.onDeleteFlagColl($event)\n }\n }\n })\n ])\n ])\n : _vm._e()\n }),\n _vm._v(\" \"),\n _c(\"li\", { staticClass: \"create-flag\" }, [\n _c(\"input\", {\n directives: [\n {\n name: \"model\",\n rawName: \"v-model\",\n value: _vm.new_folder_name,\n expression: \"new_folder_name\"\n }\n ],\n attrs: { placeholder: \"new folder\" },\n domProps: { value: _vm.new_folder_name },\n on: {\n input: function($event) {\n if ($event.target.composing) {\n return\n }\n _vm.new_folder_name = $event.target.value\n }\n }\n }),\n _vm._v(\" \"),\n _c(\"span\", {\n staticClass: \"add-btn mdi\",\n class: _vm.addFlagBtnClassObj,\n on: {\n click: function($event) {\n $event.preventDefault()\n return _vm.onCreateFlagColl($event)\n }\n }\n })\n ])\n ],\n 2\n )\n ])\n}\nvar staticRenderFns = []\nrender._withStripped = true\n\n\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/components/User/UserFlags.vue?./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options"); /***/ }), @@ -1087,7 +1087,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.MA = void 0;\n\nvar _axios = _interopRequireDefault(__webpack_require__(/*! axios */ \"./node_modules/axios/index.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n// https://github.com/alvar0hurtad0/drupal-vuejs-todo/blob/master/frontend/src/api/axiosInterceptor.js\n// console.log('drupalSettings', drupalSettings);\nvar MA = _axios.default.create({\n baseURL: window.location.origin + '/' + drupalSettings.path.pathPrefix,\n withCredentials: true,\n headers: {\n \"Content-Type\": \"application/json\"\n }\n});\n\nexports.MA = MA;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/api/ma-axios.js?"); +eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.MA = void 0;\n\nvar _axios = _interopRequireDefault(__webpack_require__(/*! axios */ \"./node_modules/axios/index.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n// https://github.com/alvar0hurtad0/drupal-vuejs-todo/blob/master/frontend/src/api/axiosInterceptor.js\n// console.log('drupalSettings', drupalSettings);\nvar MA = _axios.default.create({\n baseURL: window.location.origin + '/' + drupalSettings.path.pathPrefix,\n withCredentials: true,\n headers: {\n \"Content-Type\": \"application/json\" // \"X-CSRF-Token\": \"csrf_token\"\n\n }\n});\n\nexports.MA = MA;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/api/ma-axios.js?"); /***/ }), @@ -1939,7 +1939,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _restAxios = __webpack_require__(/*! vuejs/api/rest-axios */ \"./web/themes/custom/materiotheme/vuejs/api/rest-axios.js\");\n\nvar _jsonAxios = __webpack_require__(/*! vuejs/api/json-axios */ \"./web/themes/custom/materiotheme/vuejs/api/json-axios.js\");\n\nvar _maAxios = __webpack_require__(/*! vuejs/api/ma-axios */ \"./web/themes/custom/materiotheme/vuejs/api/ma-axios.js\");\n\nvar _querystring = _interopRequireDefault(__webpack_require__(/*! querystring */ \"./node_modules/querystring-es3/index.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar _default = {\n namespaced: true,\n // initial state\n state: {\n keys: \"\",\n term: \"\",\n uuids: [],\n items: [],\n offset: 0,\n limit: 15,\n infos: null,\n count: 0,\n // infinteState will come from vue-infinite-loading plugin\n // implemented in vuejs/components/Content/Base.vue\n infiniteLoadingState: null\n },\n // getters\n getters: {},\n // mutations\n mutations: {\n setUuids: function setUuids(state, uuids) {\n state.uuids = state.uuids.concat(uuids);\n },\n resetUuids: function resetUuids(state) {\n state.uuids = [];\n },\n setItems: function setItems(state, items) {\n state.items = state.items.concat(items);\n },\n resetItems: function resetItems(state) {\n state.items = [];\n },\n setKeys: function setKeys(state, keys) {\n state.keys = keys;\n },\n setTerm: function setTerm(state, term) {\n state.term = term;\n },\n setInfos: function setInfos(state, infos) {\n state.infos = infos;\n },\n setCount: function setCount(state, count) {\n state.count = count;\n },\n resetOffset: function resetOffset(state) {\n state.offset = 0;\n },\n incrementOffset: function incrementOffset(state) {\n state.offset += state.limit;\n },\n setInfiniteState: function setInfiniteState(state, infiniteLoadingstate) {\n state.infiniteLoadingState = infiniteLoadingstate;\n }\n },\n // actions\n actions: {\n newSearch: function newSearch(_ref) {\n var dispatch = _ref.dispatch,\n commit = _ref.commit,\n state = _ref.state;\n console.log('Search newSearch');\n commit('resetUuids');\n commit('resetItems');\n commit('resetOffset');\n this.commit('Common/setPagetitle', state.keys);\n dispatch('getResults');\n },\n nextPage: function nextPage(_ref2, $infiniteLoadingstate) {\n var dispatch = _ref2.dispatch,\n commit = _ref2.commit,\n state = _ref2.state;\n console.log(\"Search nextPage\", $infiniteLoadingstate);\n commit('incrementOffset');\n commit('setInfiniteState', $infiniteLoadingstate);\n dispatch('getResults');\n },\n getResults: function getResults(_ref3) {\n var dispatch = _ref3.dispatch,\n commit = _ref3.commit,\n state = _ref3.state;\n var params = {\n keys: state.keys,\n term: state.term,\n offset: state.offset,\n limit: state.limit\n }; // console.log('Search getResults params', params);\n\n var q = _querystring.default.stringify(params);\n\n return _maAxios.MA.get(\"/materio_sapi/getresults?\" + q).then(function (_ref4) {\n var data = _ref4.data;\n console.log('search MA getresults data', data); // commit('setItems', data.items)\n\n commit('setInfos', data.infos);\n commit('setCount', data.count);\n commit('setUuids', data.uuids);\n dispatch('getItems', data.uuids);\n }).catch(function (error) {\n console.warn('Issue with getResults', error);\n Promise.reject(error);\n });\n },\n getItems: function getItems(_ref5, uuids) {\n var dispatch = _ref5.dispatch,\n commit = _ref5.commit,\n state = _ref5.state;\n var params = {\n // include: 'images', // no needs to include thanks to consumers_image_styles module\n 'filter[uuids-groupe][group][conjunction]': 'OR'\n };\n\n for (var i = 0; i < uuids.length; i++) {\n var uuid = uuids[i];\n params[\"filter[\".concat(uuid, \"][condition][path]\")] = 'id';\n params[\"filter[\".concat(uuid, \"][condition][value]\")] = uuid;\n params[\"filter[\".concat(uuid, \"][condition][operator]\")] = '=';\n params[\"filter[\".concat(uuid, \"][condition][memberOf]\")] = 'uuids-groupe';\n } // console.log('search JSONAPI params', params);\n\n\n var q = _querystring.default.stringify(params);\n\n return _jsonAxios.JSONAPI.get('node/materiau?' + q).then(function (_ref6) {\n var data = _ref6.data;\n console.log('search getItems data', data);\n dispatch('parseItems', {\n data: data.data,\n uuids: uuids\n }); // commit('setItems', data.items)\n }).catch(function (error) {\n console.warn('Issue with getItems', error);\n Promise.reject(error);\n });\n },\n parseItems: function parseItems(_ref7, _ref8) {\n var dispatch = _ref7.dispatch,\n commit = _ref7.commit,\n state = _ref7.state;\n var data = _ref8.data,\n uuids = _ref8.uuids;\n // data comes from jsonapi query\n // uuids comes from solr search query (we loop from uuids to conserve the search results order)\n console.log('search parseItems data, uuids', data, uuids);\n var items = []; // for (var i = 0; i < data.length; i++) {\n\n var _loop = function _loop() {\n var uuid = uuids[i]; // https://stackoverflow.com/questions/11258077/how-to-find-index-of-an-object-by-key-and-value-in-an-javascript-array\n\n var item_index = data.findIndex(function (p) {\n return p.id == uuid;\n }); // console.log('item_index', item_index);\n\n if (item_index == -1) return \"continue\";\n var item_src = data[item_index];\n var attrs = item_src.attributes;\n var relations = item_src.relationships; // get field values\n\n var item = {\n uuid: uuid,\n title: attrs.title,\n field_short_description: attrs.field_short_description,\n body: attrs.body,\n field_reference: attrs.field_reference\n }; // get images included values\n\n var img_src = relations.images.data;\n console.log('img_src', img_src); // this is a temporary deactivation of images\n // img_src = [];\n\n item.images = [];\n\n for (j = 0; j < img_src.length; j++) {\n if (img_src[j].meta.imageDerivatives) {\n item.images.push({\n title: img_src[j].meta.title,\n // meta.imageDerivatives.style.href link is provided by drupal consumers_image_styles module\n // BUG: missing all image derivative but first\n url: img_src[j].meta.imageDerivatives.links.card_medium.href\n });\n } else {\n console.warn('missing image derivative ' + j + '/' + img_src.length + ' for ' + attrs.title);\n }\n }\n\n items.push(item);\n };\n\n for (var i = 0; i < uuids.length; i++) {\n var j;\n\n var _ret = _loop();\n\n if (_ret === \"continue\") continue;\n }\n\n console.log('items', items);\n commit('setItems', items);\n\n if (state.infiniteLoadingState) {\n if (state.offset + state.limit > state.count) {\n console.log('Search infinite completed'); // tell to vue-infinite-loading plugin that there si no new page\n\n state.infiniteLoadingState.complete();\n } else {\n console.log('Search infinite loaded'); // tell to vue-infinite-loading plugin that newpage is loaded\n\n state.infiniteLoadingState.loaded();\n }\n }\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/store/modules/search.js?"); +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 _jsonAxios = __webpack_require__(/*! vuejs/api/json-axios */ \"./web/themes/custom/materiotheme/vuejs/api/json-axios.js\");\n\nvar _maAxios = __webpack_require__(/*! vuejs/api/ma-axios */ \"./web/themes/custom/materiotheme/vuejs/api/ma-axios.js\");\n\nvar _querystring = _interopRequireDefault(__webpack_require__(/*! querystring */ \"./node_modules/querystring-es3/index.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar _default = {\n namespaced: true,\n // initial state\n state: {\n keys: \"\",\n term: \"\",\n uuids: [],\n items: [],\n offset: 0,\n limit: 15,\n infos: null,\n count: 0,\n // infinteState will come from vue-infinite-loading plugin\n // implemented in vuejs/components/Content/Base.vue\n infiniteLoadingState: null\n },\n // getters\n getters: {},\n // mutations\n mutations: {\n setUuids: function setUuids(state, uuids) {\n state.uuids = state.uuids.concat(uuids);\n },\n resetUuids: function resetUuids(state) {\n state.uuids = [];\n },\n setItems: function setItems(state, items) {\n state.items = state.items.concat(items);\n },\n resetItems: function resetItems(state) {\n state.items = [];\n },\n setKeys: function setKeys(state, keys) {\n state.keys = keys;\n },\n setTerm: function setTerm(state, term) {\n state.term = term;\n },\n setInfos: function setInfos(state, infos) {\n state.infos = infos;\n },\n setCount: function setCount(state, count) {\n state.count = count;\n },\n resetOffset: function resetOffset(state) {\n state.offset = 0;\n },\n incrementOffset: function incrementOffset(state) {\n state.offset += state.limit;\n },\n setInfiniteState: function setInfiniteState(state, infiniteLoadingstate) {\n state.infiniteLoadingState = infiniteLoadingstate;\n }\n },\n // actions\n actions: {\n newSearch: function newSearch(_ref) {\n var dispatch = _ref.dispatch,\n commit = _ref.commit,\n state = _ref.state;\n console.log('Search newSearch');\n commit('resetUuids');\n commit('resetItems');\n commit('resetOffset');\n this.commit('Common/setPagetitle', state.keys);\n dispatch('getResults');\n },\n nextPage: function nextPage(_ref2, $infiniteLoadingstate) {\n var dispatch = _ref2.dispatch,\n commit = _ref2.commit,\n state = _ref2.state;\n console.log(\"Search nextPage\", $infiniteLoadingstate);\n commit('incrementOffset');\n commit('setInfiniteState', $infiniteLoadingstate);\n dispatch('getResults');\n },\n getResults: function getResults(_ref3) {\n var dispatch = _ref3.dispatch,\n commit = _ref3.commit,\n state = _ref3.state;\n var params = {\n keys: state.keys,\n term: state.term,\n offset: state.offset,\n limit: state.limit\n }; // console.log('Search getResults params', params);\n\n var q = _querystring.default.stringify(params);\n\n return _maAxios.MA.get(\"/materio_sapi/getresults?\" + q).then(function (_ref4) {\n var data = _ref4.data;\n console.log('search MA getresults data', data); // commit('setItems', data.items)\n\n commit('setInfos', data.infos);\n commit('setCount', data.count);\n commit('setUuids', data.uuids);\n dispatch('getItems', data.uuids);\n }).catch(function (error) {\n console.warn('Issue with getResults', error);\n Promise.reject(error);\n });\n },\n getItems: function getItems(_ref5, uuids) {\n var dispatch = _ref5.dispatch,\n commit = _ref5.commit,\n state = _ref5.state;\n var params = {\n // include: 'images', // no needs to include thanks to consumers_image_styles module\n // include: 'drupal_internal__nid',\n 'filter[uuids-groupe][group][conjunction]': 'OR'\n };\n\n for (var i = 0; i < uuids.length; i++) {\n var uuid = uuids[i];\n params[\"filter[\".concat(uuid, \"][condition][path]\")] = 'id';\n params[\"filter[\".concat(uuid, \"][condition][value]\")] = uuid;\n params[\"filter[\".concat(uuid, \"][condition][operator]\")] = '=';\n params[\"filter[\".concat(uuid, \"][condition][memberOf]\")] = 'uuids-groupe';\n } // console.log('search JSONAPI params', params);\n\n\n var q = _querystring.default.stringify(params);\n\n return _jsonAxios.JSONAPI.get('node/materiau?' + q).then(function (_ref6) {\n var data = _ref6.data;\n console.log('search getItems data', data);\n dispatch('parseItems', {\n data: data.data,\n uuids: uuids\n }); // commit('setItems', data.items)\n }).catch(function (error) {\n console.warn('Issue with getItems', error);\n Promise.reject(error);\n });\n },\n parseItems: function parseItems(_ref7, _ref8) {\n var dispatch = _ref7.dispatch,\n commit = _ref7.commit,\n state = _ref7.state;\n var data = _ref8.data,\n uuids = _ref8.uuids;\n // data comes from jsonapi query\n // uuids comes from solr search query (we loop from uuids to conserve the search results order)\n console.log('search parseItems data, uuids', data, uuids);\n var items = []; // for (var i = 0; i < data.length; i++) {\n\n var _loop = function _loop() {\n var uuid = uuids[i]; // https://stackoverflow.com/questions/11258077/how-to-find-index-of-an-object-by-key-and-value-in-an-javascript-array\n\n var item_index = data.findIndex(function (p) {\n return p.id == uuid;\n }); // console.log('item_index', item_index);\n\n if (item_index == -1) return \"continue\";\n var item_src = data[item_index];\n var attrs = item_src.attributes;\n var relations = item_src.relationships; // get field values\n\n var item = {\n uuid: uuid,\n title: attrs.title,\n field_short_description: attrs.field_short_description,\n body: attrs.body,\n field_reference: attrs.field_reference\n }; // get images included values\n\n var img_src = relations.images.data; // console.log('img_src', img_src);\n // this is a temporary deactivation of images\n // img_src = [];\n\n item.images = [];\n\n for (j = 0; j < img_src.length; j++) {\n if (img_src[j].meta.imageDerivatives) {\n item.images.push({\n title: img_src[j].meta.title,\n // meta.imageDerivatives.style.href link is provided by drupal consumers_image_styles module\n // BUG: missing all image derivative but first\n url: img_src[j].meta.imageDerivatives.links.card_medium.href\n });\n } else {\n console.warn('missing image derivative ' + j + '/' + img_src.length + ' for ' + attrs.title);\n }\n }\n\n items.push(item);\n };\n\n for (var i = 0; i < uuids.length; i++) {\n var j;\n\n var _ret = _loop();\n\n if (_ret === \"continue\") continue;\n }\n\n console.log('items', items);\n commit('setItems', items);\n\n if (state.infiniteLoadingState) {\n if (state.offset + state.limit > state.count) {\n console.log('Search infinite completed'); // tell to vue-infinite-loading plugin that there si no new page\n\n state.infiniteLoadingState.complete();\n } else {\n console.log('Search infinite loaded'); // tell to vue-infinite-loading plugin that newpage is loaded\n\n state.infiniteLoadingState.loaded();\n }\n }\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/store/modules/search.js?"); /***/ }), @@ -1963,7 +1963,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _restAxios = __webpack_require__(/*! vuejs/api/rest-axios */ \"./web/themes/custom/materiotheme/vuejs/api/rest-axios.js\");\n\nvar _maAxios = __webpack_require__(/*! vuejs/api/ma-axios */ \"./web/themes/custom/materiotheme/vuejs/api/ma-axios.js\");\n\nvar _querystring = _interopRequireDefault(__webpack_require__(/*! querystring */ \"./node_modules/querystring-es3/index.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n// import { JSONAPI } from 'vuejs/api/json-axios';\nvar _default = {\n namespaced: true,\n // initial state\n state: {\n uid: null,\n // username: '',\n mail: \"\",\n token: null,\n csrftoken: null,\n logout_token: null,\n isloggedin: false,\n isAdmin: false,\n isAdherent: false,\n canSearch: false,\n roles: [],\n flags: false\n },\n // getters\n getters: {},\n // mutations\n mutations: {\n SetCsrftoken: function SetCsrftoken(state, token) {\n state.csrftoken = token;\n },\n setToken: function 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 setUid: function setUid(state, uid) {\n state.uid = uid;\n state.isloggedin = true;\n },\n setUser: function setUser(state, data) {\n state.mail = data.mail[0].value;\n state.uuid = data.uuid[0].value;\n },\n setRoles: function setRoles(state, roles) {\n console.log(\"User setRoles\", roles);\n state.roles = [];\n\n for (var i = 0; i < roles.length; i++) {\n state.roles.push(roles[i].target_id);\n } // check if admin\n\n\n if (state.roles.indexOf(\"admin\") !== -1 || state.roles.indexOf(\"root\") !== -1) {\n // console.log('is admin');\n state.isAdmin = true;\n } // check if has access to search\n\n\n if (state.roles.indexOf(\"adherent\") !== -1) {\n // console.log('is admin');\n state.canSearch = true;\n state.isAdherent = true;\n }\n },\n setLoggedOut: function setLoggedOut(state) {\n console.log(\"setLoggedOut state\", state);\n state.uid = null;\n state.mail = \"\";\n state.token = null;\n state.isloggedin = false;\n state.logout_token = null;\n\n if (state.isAdmin) {\n // TODO: what if on a page where login is needed (as commerce checkout and cart)\n window.location.reload(true);\n }\n\n state.asAdmin = false;\n state.canSearch = false;\n },\n setFlags: function setFlags(state, flags) {\n console.log(\"User setFlags\", flags);\n state.flags = flags;\n }\n },\n // actions\n actions: {\n userRegister: function userRegister(_ref, credentials) {\n var dispatch = _ref.dispatch,\n commit = _ref.commit,\n state = _ref.state;\n return new Promise(function (resolve, reject) {\n _restAxios.REST.get(\"/session/token\").then(function (_ref2) {\n var token = _ref2.token;\n commit(\"SetCsrftoken\", token);\n\n _restAxios.REST.post(\"/user/register?_format=json\", credentials, {\n \"X-CSRF-Token\": state.csrftoken\n }).then(function (_ref3) {\n var data = _ref3.data;\n console.log(\"user REST registered\", data);\n dispatch(\"userLogin\", credentials).then(function () {\n resolve();\n });\n }).catch(function (error) {\n console.warn(\"Issue with register\", error);\n Promise.reject(error);\n });\n });\n });\n },\n userLogin: function userLogin(_ref4, credentials) {\n var dispatch = _ref4.dispatch,\n commit = _ref4.commit,\n state = _ref4.state;\n return new Promise(function (resolve, reject) {\n dispatch(\"getToken\", credentials).then(function () {\n dispatch(\"getUser\").then(function (userdata) {\n console.log(\"User Loggedin\");\n\n if (state.isAdmin) {\n window.location.reload(true);\n }\n\n resolve();\n });\n });\n });\n },\n getToken: function getToken(_ref5, credentials) {\n var dispatch = _ref5.dispatch,\n commit = _ref5.commit,\n state = _ref5.state;\n return _restAxios.REST.post(\"/user/login?_format=json\", credentials).then(function (_ref6) {\n var data = _ref6.data;\n console.log(\"user REST getToken data\", data);\n commit(\"setToken\", data);\n }).catch(function (error) {\n console.warn(\"Issue with getToken\", error);\n Promise.reject(error);\n });\n },\n getUser: function getUser(_ref7) {\n var dispatch = _ref7.dispatch,\n commit = _ref7.commit,\n state = _ref7.state;\n var params = {\n token: state.token\n };\n return _restAxios.REST.get(\"/user/\".concat(state.uid, \"?_format=json\"), params).then(function (_ref8) {\n var data = _ref8.data;\n console.log(\"user REST getUser data\", data);\n console.log(\"roles\", data.roles);\n commit(\"setUser\", data);\n\n if (data.roles) {\n commit(\"setRoles\", data.roles);\n }\n\n dispatch(\"getUserFlags\");\n }).catch(function (error) {\n console.warn(\"Issue with getUser\", error);\n Promise.reject(error);\n });\n },\n getUserFlags: function getUserFlags(_ref9) {\n var dispatch = _ref9.dispatch,\n commit = _ref9.commit,\n state = _ref9.state;\n // flags\n // REST.get('/flagging_collection/1?_format=json')\n // .then(( data ) => {\n // console.log('TEST FLAG REST data', data)\n // })\n // .catch(error => {\n // console.warn('Issue USER TEST FLAG REST', error)\n // Promise.reject(error)\n // })\n return _maAxios.MA.get(\"materio_flag/user_flagging_collections\").then(function (_ref10) {\n var data = _ref10.data;\n console.log(\"user MA getFlags data\", data);\n commit(\"setFlags\", data);\n }).catch(function (error) {\n console.warn(\"Issue USER MA getFlags\", error);\n Promise.reject(error);\n });\n },\n // https://drupal.stackexchange.com/questions/248539/cant-get-flagging-api-to-accept-post-request\n createFlag: function createFlag(_ref11, new_flag_name) {\n var dispatch = _ref11.dispatch,\n commit = _ref11.commit,\n state = _ref11.state;\n console.log(\"user createFlag\", new_flag_name);\n return new Promise(function (resolve, reject) {\n var params = {\n name: new_flag_name\n };\n\n _maAxios.MA.post(\"materio_flag/create_user_flagging_collection\", params).then(function (_ref12) {\n var data = _ref12.data;\n console.log(\"user MA createFlag data\", data);\n\n if (data.status) {\n dispatch('getUserFlags').then(function () {\n resolve();\n });\n }\n }).catch(function (error) {\n console.warn(\"Issue USER MA createFlag\", error);\n reject(error);\n });\n });\n },\n deleteFlag: function deleteFlag(_ref13, flagid) {\n var dispatch = _ref13.dispatch,\n commit = _ref13.commit,\n state = _ref13.state;\n console.log(\"user deleteFlag\", flagid);\n return new Promise(function (resolve, reject) {\n var params = {\n flagid: flagid\n };\n\n _maAxios.MA.post(\"materio_flag/delete_user_flagging_collection\", params).then(function (_ref14) {\n var data = _ref14.data;\n console.log(\"user MA deleteFlag data\", data);\n dispatch('getUserFlags').then(function () {\n resolve();\n });\n }).catch(function (error) {\n console.warn(\"Issue USER MA createFlag\", error);\n reject(error);\n });\n });\n },\n userLogout: function userLogout(_ref15) {\n var commit = _ref15.commit,\n state = _ref15.state;\n\n var credentials = _querystring.default.stringify({\n token: state.token\n });\n\n _restAxios.REST.post(\"/user/logout\", credentials).then(function (resp) {\n console.log(\"userLogout resp\", resp);\n commit(\"setLoggedOut\");\n }).catch(function (error) {\n console.warn(\"Issue with logout\", error);\n Promise.reject(error);\n });\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/store/modules/user.js?"); +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 _maAxios = __webpack_require__(/*! vuejs/api/ma-axios */ \"./web/themes/custom/materiotheme/vuejs/api/ma-axios.js\");\n\nvar _querystring = _interopRequireDefault(__webpack_require__(/*! querystring */ \"./node_modules/querystring-es3/index.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n// import { JSONAPI } from 'vuejs/api/json-axios';\nvar _default = {\n namespaced: true,\n // initial state\n state: {\n uid: null,\n // username: '',\n mail: \"\",\n csrf_token: null,\n logout_token: null,\n isloggedin: false,\n isAdmin: false,\n isAdherent: false,\n canSearch: false,\n roles: [],\n flagcolls: false\n },\n // getters\n getters: {},\n // mutations\n mutations: {\n SetCsrftoken: function SetCsrftoken(state, token) {\n console.log('SetCsrftoken', token);\n state.csrf_token = token;\n },\n setToken: function setToken(state, data) {\n state.uid = data.current_user.uid; // state.username = data.username;\n\n state.mail = data.current_user.mail;\n state.csrf_token = data.csrf_token;\n state.isloggedin = true;\n state.logout_token = data.logout_token;\n },\n setUid: function setUid(state, uid) {\n state.uid = uid;\n state.isloggedin = true;\n },\n setUser: function setUser(state, data) {\n state.mail = data.mail[0].value;\n state.uuid = data.uuid[0].value;\n },\n setRoles: function setRoles(state, roles) {\n console.log(\"User setRoles\", roles);\n state.roles = [];\n\n for (var i = 0; i < roles.length; i++) {\n state.roles.push(roles[i].target_id);\n } // check if admin\n\n\n if (state.roles.indexOf(\"admin\") !== -1 || state.roles.indexOf(\"root\") !== -1) {\n // console.log('is admin');\n state.isAdmin = true;\n } // check if has access to search\n\n\n if (state.roles.indexOf(\"adherent\") !== -1) {\n // console.log('is admin');\n state.canSearch = true;\n state.isAdherent = true;\n }\n },\n setLoggedOut: function setLoggedOut(state) {\n console.log(\"setLoggedOut state\", state);\n state.uid = null;\n state.mail = \"\";\n state.csrf_token = null;\n state.isloggedin = false;\n state.logout_token = null;\n\n if (state.isAdmin) {\n // TODO: what if on a page where login is needed (as commerce checkout and cart)\n window.location.reload(true);\n }\n\n state.asAdmin = false;\n state.canSearch = false;\n },\n setFlagColls: function setFlagColls(state, flagcolls) {\n console.log(\"User setFlagColls\", flagcolls);\n state.flagcolls = flagcolls;\n }\n },\n // actions\n actions: {\n userRegister: function userRegister(_ref, credentials) {\n var dispatch = _ref.dispatch,\n commit = _ref.commit,\n state = _ref.state;\n return new Promise(function (resolve, reject) {\n _restAxios.REST.get(\"/session/token\").then(function (_ref2) {\n var token = _ref2.token;\n commit(\"SetCsrftoken\", token);\n\n _restAxios.REST.post(\"/user/register?_format=json\", credentials, {\n \"X-CSRF-Token\": state.csrftoken\n }).then(function (_ref3) {\n var data = _ref3.data;\n console.log(\"user REST registered\", data);\n dispatch(\"userLogin\", credentials).then(function () {\n resolve();\n });\n }).catch(function (error) {\n console.warn(\"Issue with register\", error);\n Promise.reject(error);\n });\n });\n });\n },\n userLogin: function userLogin(_ref4, credentials) {\n var dispatch = _ref4.dispatch,\n commit = _ref4.commit,\n state = _ref4.state;\n return new Promise(function (resolve, reject) {\n dispatch(\"getToken\", credentials).then(function () {\n dispatch(\"getUser\").then(function (userdata) {\n console.log(\"User Loggedin\");\n\n if (state.isAdmin) {\n window.location.reload(true);\n }\n\n resolve();\n });\n });\n });\n },\n getToken: function getToken(_ref5, credentials) {\n var dispatch = _ref5.dispatch,\n commit = _ref5.commit,\n state = _ref5.state;\n return _restAxios.REST.post(\"/user/login?_format=json\", credentials).then(function (_ref6) {\n var data = _ref6.data;\n console.log(\"user REST getToken data\", data);\n commit(\"setToken\", data);\n }).catch(function (error) {\n console.warn(\"Issue with getToken\", error);\n Promise.reject(error);\n });\n },\n getUser: function getUser(_ref7) {\n var dispatch = _ref7.dispatch,\n commit = _ref7.commit,\n state = _ref7.state;\n return new Promise(function (resolve, reject) {\n _restAxios.REST.get(\"/session/token\").then(function (_ref8) {\n var data = _ref8.data;\n console.log('csrftoken', data);\n commit(\"SetCsrftoken\", data);\n console.log('state.csrf_token', state.csrf_token);\n var params = {\n token: state.csrf_token\n };\n\n _restAxios.REST.get(\"/user/\".concat(state.uid, \"?_format=json\"), params).then(function (_ref9) {\n var data = _ref9.data;\n console.log(\"user REST getUser data\", data);\n console.log(\"roles\", data.roles);\n commit(\"setUser\", data);\n\n if (data.roles) {\n commit(\"setRoles\", data.roles);\n }\n\n dispatch(\"getUserFlagColls\");\n resolve();\n }).catch(function (error) {\n console.warn(\"Issue with getUser\", error);\n Promise.reject(error);\n });\n });\n });\n },\n getUserFlagColls: function getUserFlagColls(_ref10) {\n var dispatch = _ref10.dispatch,\n commit = _ref10.commit,\n state = _ref10.state;\n // flags\n // REST.get('/flagging_collection/1?_format=json')\n // .then(( data ) => {\n // console.log('TEST FLAG REST data', data)\n // })\n // .catch(error => {\n // console.warn('Issue USER TEST FLAG REST', error)\n // Promise.reject(error)\n // })\n return _maAxios.MA.get(\"materio_flag/user_flagging_collections\").then(function (_ref11) {\n var data = _ref11.data;\n console.log(\"user MA getFlags data\", data);\n commit(\"setFlagColls\", data);\n }).catch(function (error) {\n console.warn(\"Issue USER MA getFlags\", error);\n Promise.reject(error);\n });\n },\n // https://drupal.stackexchange.com/questions/248539/cant-get-flagging-api-to-accept-post-request\n createFlagColl: function createFlagColl(_ref12, new_collection_name) {\n var dispatch = _ref12.dispatch,\n commit = _ref12.commit,\n state = _ref12.state;\n console.log(\"user createFlagColl\", new_collection_name);\n return new Promise(function (resolve, reject) {\n var params = {\n name: new_collection_name\n };\n\n _maAxios.MA.post(\"materio_flag/create_user_flagging_collection\", params).then(function (_ref13) {\n var data = _ref13.data;\n console.log(\"user MA createFlagColl data\", data);\n\n if (data.status) {\n dispatch('getUserFlagColls').then(function () {\n resolve();\n });\n }\n }).catch(function (error) {\n console.warn(\"Issue USER MA createFlag\", error);\n reject(error);\n });\n });\n },\n deleteFlagColl: function deleteFlagColl(_ref14, flagcollid) {\n var dispatch = _ref14.dispatch,\n commit = _ref14.commit,\n state = _ref14.state;\n console.log(\"user deleteFlagColl\", flagcollid);\n return new Promise(function (resolve, reject) {\n var params = {\n flagcollid: flagcollid\n };\n\n _maAxios.MA.post(\"materio_flag/delete_user_flagging_collection\", params).then(function (_ref15) {\n var data = _ref15.data;\n console.log(\"user MA deleteFlagColl data\", data);\n dispatch('getUserFlagColls').then(function () {\n resolve();\n });\n }).catch(function (error) {\n console.warn(\"Issue USER MA createFlag\", error);\n reject(error);\n });\n });\n },\n flag: function flag(_ref16, args) {\n var dispatch = _ref16.dispatch,\n commit = _ref16.commit,\n state = _ref16.state;\n console.log(\"user flag\", args.uuid, args.collid);\n var params = {\n flagid: state.flagcolls[args.collid].flag_id,\n uuid: args.uuid,\n flagcollid: args.collid\n };\n return _maAxios.MA.post(\"materio_flag/flag\", params).then(function (_ref17) {\n var data = _ref17.data;\n console.log(\"user MA flag\", data);\n dispatch('getUserFlagColls');\n }).catch(function (error) {\n console.warn(\"Issue USER MA flag\", error);\n });\n },\n unFlag: function unFlag(_ref18, args) {\n var dispatch = _ref18.dispatch,\n commit = _ref18.commit,\n state = _ref18.state;\n console.log(\"user unFlag\", args.uuid, args.collid);\n var params = {\n flagid: state.flagcolls[args.collid].flag_id,\n uuid: args.uuid,\n flagcollid: args.collid\n };\n return _maAxios.MA.post(\"materio_flag/unflag\", params).then(function (_ref19) {\n var data = _ref19.data;\n console.log(\"user MA unFlag\", data);\n dispatch('getUserFlagColls');\n }).catch(function (error) {\n console.warn(\"Issue USER MA unFlag\", error);\n });\n },\n userLogout: function userLogout(_ref20) {\n var commit = _ref20.commit,\n state = _ref20.state;\n\n var credentials = _querystring.default.stringify({\n token: state.csrf_token\n });\n\n _restAxios.REST.post(\"/user/logout\", credentials).then(function (resp) {\n console.log(\"userLogout resp\", resp);\n commit(\"setLoggedOut\");\n }).catch(function (error) {\n console.warn(\"Issue with logout\", error);\n Promise.reject(error);\n });\n }\n }\n};\nexports.default = _default;\n\n//# sourceURL=webpack:///./web/themes/custom/materiotheme/vuejs/store/modules/user.js?"); /***/ }) diff --git a/web/themes/custom/materiotheme/assets/styles/main.scss b/web/themes/custom/materiotheme/assets/styles/main.scss index bf57377e..f4d5eac4 100644 --- a/web/themes/custom/materiotheme/assets/styles/main.scss +++ b/web/themes/custom/materiotheme/assets/styles/main.scss @@ -694,6 +694,45 @@ article.card{ line-height: 1; } } + nav.tools{ + position: absolute; + top: 0; + right: 0; + z-index: 21; + width: 1em; + background-color: #fff; + box-sizing: content-box; + padding: 0.3em 0.1em; + >*{ + overflow: visible; + position: relative; + span.btn{ + overflow: hidden; + font-size: 0.882em; + } + .tool-content{ + position: absolute; + top: 0px; + right: 100%; + width: 5em; + box-sizing: content-box; + padding: 0.3em; + background-color: #fff; + box-shadow: -2px 3px 4px rgba(0, 0, 0, 0.2); + } + } + .tool.flags{ + span.flag{ + cursor: pointer; + font-size: 0.756em; + color: #bbb; + transition: color 0.3s ease-in-out; + &:hover, &.isActive{ + color:#1a1a1a; + } + } + } + } section.images{ position: relative; &, *{width: 100%; height:100%;} diff --git a/web/themes/custom/materiotheme/vuejs/api/ma-axios.js b/web/themes/custom/materiotheme/vuejs/api/ma-axios.js index 9910e738..d842cb5d 100644 --- a/web/themes/custom/materiotheme/vuejs/api/ma-axios.js +++ b/web/themes/custom/materiotheme/vuejs/api/ma-axios.js @@ -9,5 +9,6 @@ export const MA = axios.create({ withCredentials: true, headers: { "Content-Type": "application/json" + // "X-CSRF-Token": "csrf_token" } }) diff --git a/web/themes/custom/materiotheme/vuejs/components/Content/Card.vue b/web/themes/custom/materiotheme/vuejs/components/Content/Card.vue index 96104912..8fed7245 100644 --- a/web/themes/custom/materiotheme/vuejs/components/Content/Card.vue +++ b/web/themes/custom/materiotheme/vuejs/components/Content/Card.vue @@ -5,6 +5,27 @@

{{ item.field_short_description }}

{{ item.field_reference }} +