2020-12-01 23:02:35 +01:00
|
|
|
<template>
|
2020-12-23 19:11:46 +01:00
|
|
|
<div class="loading" v-if="!material || loading">
|
|
|
|
<span>Loading ...</span>
|
|
|
|
</div>
|
2021-03-30 15:42:40 +02:00
|
|
|
<article
|
|
|
|
v-else
|
|
|
|
class="card modal-card"
|
|
|
|
v-touch="onTapCard"
|
|
|
|
v-touch:swipe="onSwipeCard"
|
|
|
|
>
|
2020-12-01 23:02:35 +01:00
|
|
|
<section class="col col-right">
|
|
|
|
<header>
|
2020-12-23 19:11:46 +01:00
|
|
|
<h1>{{ material.title }}</h1>
|
|
|
|
<h4>{{ material.short_description }}</h4>
|
|
|
|
<span class="ref">{{ material.reference }}</span>
|
2020-12-01 23:02:35 +01:00
|
|
|
</header>
|
2021-03-30 15:42:40 +02:00
|
|
|
<nav ref="tools" class="tools">
|
2020-12-07 23:11:31 +01:00
|
|
|
<section class="tool close">
|
|
|
|
<span
|
|
|
|
class="btn mdi mdi-close"
|
|
|
|
@click.prevent="onCloseModalCard"
|
|
|
|
/>
|
|
|
|
</section>
|
2020-12-01 23:02:35 +01:00
|
|
|
<section class="tool flags">
|
2021-03-30 15:42:40 +02:00
|
|
|
<span
|
|
|
|
class="btn mdi mdi-folder-outline"
|
|
|
|
v-touch.prevent.stop="onTapTool"
|
|
|
|
/>
|
2020-12-01 23:02:35 +01:00
|
|
|
<div class="tool-content">
|
2021-01-22 12:12:31 +01:00
|
|
|
<span class="label">{{ $t("materio.My folders") }}</span>
|
2020-12-01 23:02:35 +01:00
|
|
|
<ul>
|
|
|
|
<li v-if="flagcolls" v-for="coll in flagcolls" :key="coll.id">
|
|
|
|
<span
|
|
|
|
class="flag mdi"
|
|
|
|
:class="[
|
|
|
|
flagIsLoading(coll.id) ? 'mdi-loading mdi-spin' : flagIsActive(coll.id) ? 'mdi-close-circle isActive' : 'mdi-plus'
|
|
|
|
]"
|
|
|
|
:collid="coll.id"
|
|
|
|
@click.prevent="onFlagActionCard"
|
|
|
|
>
|
|
|
|
{{ coll.name }}
|
|
|
|
</span>
|
|
|
|
</li>
|
2021-03-09 14:53:22 +01:00
|
|
|
<li v-if="collsLength<15" class="create-flag">
|
|
|
|
<input
|
|
|
|
placeholder="new folder"
|
|
|
|
v-model="new_folder_name"
|
|
|
|
@keyup.enter.prevent.stop="onCreateFlagColl"
|
|
|
|
/>
|
|
|
|
<span
|
|
|
|
class="add-btn mdi"
|
|
|
|
:class="addFlagBtnClassObj"
|
|
|
|
@click.prevent.stop="onCreateFlagColl"
|
|
|
|
/>
|
|
|
|
</li>
|
2020-12-01 23:02:35 +01:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-03-09 14:53:22 +01:00
|
|
|
<section class="tool samples" v-if="item.samples && item.samples.length">
|
2021-03-30 15:42:40 +02:00
|
|
|
<span
|
2021-09-16 13:04:37 +02:00
|
|
|
class="btn mdi mdi-map-marker-star-outline"
|
2021-03-30 15:42:40 +02:00
|
|
|
v-touch.prevent.stop="onTapTool"
|
|
|
|
/>
|
2021-01-22 12:12:31 +01:00
|
|
|
<div class="tool-content">
|
|
|
|
<span class="label">{{ $t("materio.Samples") }}</span>
|
|
|
|
<ul>
|
|
|
|
<li
|
2021-03-09 14:53:22 +01:00
|
|
|
v-for="sample in item.samples"
|
2021-01-22 12:12:31 +01:00
|
|
|
:key="sample.showroom.id"
|
|
|
|
>
|
|
|
|
<span class="showroom">{{ sample.showroom.name }}</span>: {{ sample.location }}
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2021-03-09 14:53:22 +01:00
|
|
|
</section>
|
2021-01-26 16:36:27 +01:00
|
|
|
<section class="tool note">
|
2021-03-30 15:42:40 +02:00
|
|
|
<span
|
2021-06-01 12:21:10 +02:00
|
|
|
v-if="note_id"
|
2021-03-30 15:42:40 +02:00
|
|
|
class="btn mdi mdi-note"
|
|
|
|
v-touch.prevent.stop="onTapTool"
|
|
|
|
/>
|
|
|
|
<span
|
|
|
|
v-else
|
|
|
|
class="btn mdi mdi-note-outline"
|
|
|
|
v-touch.prevent.stop="onTapTool"
|
|
|
|
/>
|
2021-01-26 16:36:27 +01:00
|
|
|
<div class="tool-content">
|
2021-06-01 12:21:10 +02:00
|
|
|
<textarea spellcheck="false" v-model="note" name="note" @input="onNoteInput"/>
|
2021-01-26 16:36:27 +01:00
|
|
|
</div>
|
|
|
|
</section>
|
2021-01-25 22:19:21 +01:00
|
|
|
<section class="tool print">
|
2021-08-24 22:36:42 +02:00
|
|
|
<a :href="item.path+'/printable/print'" target="_blank">
|
2021-01-25 22:19:21 +01:00
|
|
|
<span class="btn mdi mdi-printer"/>
|
|
|
|
</a>
|
|
|
|
</section>
|
2021-01-25 17:13:38 +01:00
|
|
|
<!-- <section class="tool industriels" v-if="material.manufacturer || material.distributor">
|
2021-01-22 12:12:31 +01:00
|
|
|
<span class="btn mdi mdi-factory"/>
|
|
|
|
<div class="tool-content">
|
|
|
|
<section v-if="material.distributor">
|
|
|
|
<span class="label">{{ $t("materio.Distributor") }}</span>
|
|
|
|
<ul>
|
|
|
|
<li v-for="distrib in material.distributor" v-bind:key="distrib.id">
|
|
|
|
<h2>{{ distrib.name }}</h2>
|
|
|
|
<p v-if="distrib.website">
|
|
|
|
<a target="_blank" :href="distrib.website.url">distrib.website.url</a>
|
|
|
|
</p>
|
|
|
|
<p v-if="distrib.email"><a :href="'mailto:'+distrib.email">{{ distrib.email }}</a></p>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
<section v-if="material.manufacturer">
|
|
|
|
<span class="label">{{ $t("materio.Manufacturer") }}</span>
|
|
|
|
<ul>
|
|
|
|
<li v-for="manu in material.manufacturer" v-bind:key="manu.id">
|
|
|
|
<h2>{{ manu.name }}</h2>
|
|
|
|
<p v-if="manu.website">
|
|
|
|
<a target="_blank" :href="manu.website.url">manu.website.url</a>
|
|
|
|
</p>
|
|
|
|
<p v-if="manu.email"><a :href="'mailto:'+manu.email">{{ manu.email }}</a></p>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
</div>
|
2021-01-25 17:13:38 +01:00
|
|
|
</section> -->
|
2020-12-01 23:02:35 +01:00
|
|
|
</nav>
|
2021-01-25 17:13:38 +01:00
|
|
|
<vsa-list>
|
2021-01-26 11:29:23 +01:00
|
|
|
<vsa-item :initActive="true">
|
|
|
|
<vsa-heading>
|
|
|
|
<span class="label">Description</span>
|
|
|
|
</vsa-heading>
|
|
|
|
<vsa-content>
|
|
|
|
<section class="body" v-html="material.body"/>
|
2021-03-09 14:53:22 +01:00
|
|
|
<section class="attachments">
|
|
|
|
<!-- <h4 class="label">{{ $t("materio.Attachments") }}</h4> -->
|
|
|
|
<ul>
|
|
|
|
<li
|
|
|
|
v-for="attachmt in material.attachments" :key="attachmt.file.fid"
|
|
|
|
>
|
|
|
|
<a target="_blank" :href="attachmt.file.url">{{ attachmt.file.filename}} <span>({{ prettyFileSize(attachmt.file.filesize) }})</span></a>
|
|
|
|
<p v-if="attachmt.description" class="description" v-html="attachmt.description" />
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
<section class="industriels">
|
|
|
|
<!-- <h4 class="label">{{ $t("default.Contact") }}</h4> -->
|
|
|
|
<section v-if="material.manufacturer">
|
|
|
|
<span class="label">{{ $t("materio.Manufacturer") }}</span>
|
|
|
|
<ul>
|
|
|
|
<li v-for="manu in material.manufacturer" v-bind:key="manu.id">
|
|
|
|
<h2>{{ manu.name }}</h2>
|
|
|
|
<p v-if="manu.website">
|
|
|
|
<a target="_blank" :href="manu.website.url">{{shortUrl(manu.website.url)}}</a>
|
|
|
|
</p>
|
|
|
|
<p v-if="manu.email"><a :href="'mailto:'+manu.email">{{ manu.email }}</a></p>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
<section v-if="material.distributor">
|
|
|
|
<span class="label">{{ $t("materio.Distributor") }}</span>
|
|
|
|
<ul>
|
|
|
|
<li v-for="distrib in material.distributor" v-bind:key="distrib.id">
|
|
|
|
<h2>{{ distrib.name }}</h2>
|
|
|
|
<p v-if="distrib.website">
|
|
|
|
<a target="_blank" :href="distrib.website.url">{{shortUrl(distrib.website.url)}}</a>
|
|
|
|
</p>
|
|
|
|
<p v-if="distrib.email"><a :href="'mailto:'+distrib.email">{{ distrib.email }}</a></p>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
</section>
|
2021-01-26 11:29:23 +01:00
|
|
|
</vsa-content>
|
|
|
|
</vsa-item>
|
|
|
|
|
2021-03-09 14:53:22 +01:00
|
|
|
<!-- <vsa-item v-if="item.samples && item.samples.length">
|
2021-01-26 16:44:21 +01:00
|
|
|
<vsa-heading>
|
|
|
|
<span class="label">{{ $t("materio.Samples") }}</span>
|
|
|
|
</vsa-heading>
|
|
|
|
<vsa-content>
|
|
|
|
<section class="samples">
|
|
|
|
<ul>
|
|
|
|
<li
|
|
|
|
v-for="sample in material.samples"
|
|
|
|
:key="sample.showroom.id"
|
|
|
|
>
|
|
|
|
<span class="showroom">{{ sample.showroom.name }}</span>: {{ sample.location }}
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
</vsa-content>
|
2021-03-09 14:53:22 +01:00
|
|
|
</vsa-item> -->
|
2021-01-26 16:44:21 +01:00
|
|
|
|
2021-03-11 19:00:09 +01:00
|
|
|
<vsa-item v-if="material.linked_materials.length">
|
2021-01-25 17:13:38 +01:00
|
|
|
<vsa-heading>
|
|
|
|
<span class="label">{{ $t("materio.Linked materials") }}</span>
|
|
|
|
</vsa-heading>
|
|
|
|
<vsa-content>
|
|
|
|
<section class="linked-materials">
|
|
|
|
<ul>
|
|
|
|
<li v-for="m in material.linked_materials" v-bind:key="m.id">
|
|
|
|
<LinkedMaterialCard :item="m"/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
</vsa-content>
|
|
|
|
</vsa-item>
|
|
|
|
|
2021-03-09 14:53:22 +01:00
|
|
|
<!-- <vsa-item v-if="material.manufacturer || material.distributor">
|
2021-01-25 17:13:38 +01:00
|
|
|
<vsa-heading>
|
|
|
|
<span class="label">{{ $t("default.Contact") }}</span>
|
|
|
|
</vsa-heading>
|
|
|
|
<vsa-content>
|
|
|
|
<section class="industriels">
|
|
|
|
<section v-if="material.manufacturer">
|
|
|
|
<span class="label">{{ $t("materio.Manufacturer") }}</span>
|
|
|
|
<ul>
|
|
|
|
<li v-for="manu in material.manufacturer" v-bind:key="manu.id">
|
|
|
|
<h2>{{ manu.name }}</h2>
|
|
|
|
<p v-if="manu.website">
|
2021-01-26 11:43:42 +01:00
|
|
|
<a target="_blank" :href="manu.website.url">{{shortUrl(manu.website.url)}}</a>
|
2021-01-25 17:13:38 +01:00
|
|
|
</p>
|
|
|
|
<p v-if="manu.email"><a :href="'mailto:'+manu.email">{{ manu.email }}</a></p>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
2021-01-26 11:43:42 +01:00
|
|
|
<section v-if="material.distributor">
|
|
|
|
<span class="label">{{ $t("materio.Distributor") }}</span>
|
|
|
|
<ul>
|
|
|
|
<li v-for="distrib in material.distributor" v-bind:key="distrib.id">
|
|
|
|
<h2>{{ distrib.name }}</h2>
|
|
|
|
<p v-if="distrib.website">
|
|
|
|
<a target="_blank" :href="distrib.website.url">{{shortUrl(distrib.website.url)}}</a>
|
|
|
|
</p>
|
|
|
|
<p v-if="distrib.email"><a :href="'mailto:'+distrib.email">{{ distrib.email }}</a></p>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
2021-01-25 17:13:38 +01:00
|
|
|
</section>
|
|
|
|
</vsa-content>
|
2021-03-09 14:53:22 +01:00
|
|
|
</vsa-item> -->
|
2021-01-25 17:13:38 +01:00
|
|
|
|
2021-03-09 14:53:22 +01:00
|
|
|
<!-- <vsa-item v-if="material.attachments && material.attachments.length">
|
2021-01-25 17:13:38 +01:00
|
|
|
<vsa-heading>
|
|
|
|
<span class="label">{{ $t("materio.Attachments") }}</span>
|
|
|
|
</vsa-heading>
|
|
|
|
<vsa-content>
|
|
|
|
<section class="attachments">
|
|
|
|
<ul>
|
|
|
|
<li
|
|
|
|
v-for="attachmt in material.attachments" :key="attachmt.file.fid"
|
|
|
|
>
|
|
|
|
<a target="_blank" :href="attachmt.file.url">{{ attachmt.file.filename}} <span>({{ prettyFileSize(attachmt.file.filesize) }})</span></a>
|
|
|
|
<p v-if="attachmt.description" class="description" v-html="attachmt.description" />
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
</vsa-content>
|
2021-03-09 14:53:22 +01:00
|
|
|
</vsa-item> -->
|
2021-01-25 17:13:38 +01:00
|
|
|
</vsa-list>
|
2020-12-01 23:02:35 +01:00
|
|
|
</section>
|
|
|
|
<section class="col col-left images" v-switcher>
|
|
|
|
<figure
|
2020-12-23 19:11:46 +01:00
|
|
|
v-for="(img, index) in material.images"
|
2020-12-01 23:02:35 +01:00
|
|
|
:key="img.url"
|
2021-07-12 12:50:40 +02:00
|
|
|
class="lazy"
|
|
|
|
v-lazy="index"
|
2020-12-01 23:02:35 +01:00
|
|
|
>
|
|
|
|
<img
|
2020-12-23 19:11:46 +01:00
|
|
|
:data-src="img.style_cardfull.url"
|
2020-12-01 23:02:35 +01:00
|
|
|
:title="img.title"
|
|
|
|
/>
|
|
|
|
<img
|
|
|
|
class="blank"
|
|
|
|
:src="blanksrc"
|
|
|
|
@click="lightbox_index = index"
|
|
|
|
>
|
|
|
|
</figure>
|
|
|
|
</section>
|
|
|
|
<CoolLightBox
|
2020-12-23 19:11:46 +01:00
|
|
|
:items="material.images"
|
2020-12-01 23:02:35 +01:00
|
|
|
:index="lightbox_index"
|
2020-12-23 19:11:46 +01:00
|
|
|
srcName="url"
|
2020-12-07 23:11:31 +01:00
|
|
|
:loop="true"
|
2020-12-01 23:02:35 +01:00
|
|
|
@close="lightbox_index = null">
|
|
|
|
</CoolLightBox>
|
|
|
|
</article>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapState, mapActions } from 'vuex'
|
2021-01-20 12:09:22 +01:00
|
|
|
|
2021-04-06 10:42:49 +02:00
|
|
|
import {
|
|
|
|
VsaList,
|
|
|
|
VsaItem,
|
|
|
|
VsaHeading,
|
|
|
|
VsaContent,
|
|
|
|
VsaIcon
|
|
|
|
} from 'vue-simple-accordion'
|
|
|
|
import 'vue-simple-accordion/dist/vue-simple-accordion.css'
|
|
|
|
|
2021-01-20 12:09:22 +01:00
|
|
|
import LinkedMaterialCard from 'vuejs/components/Content/LinkedMaterialCard'
|
|
|
|
|
2020-12-01 23:02:35 +01:00
|
|
|
import cardMixins from 'vuejs/components/cardMixins'
|
|
|
|
|
2021-09-16 21:40:18 +02:00
|
|
|
import REST from 'vuejs/api/rest-axios'
|
|
|
|
import MGQ from 'vuejs/api/graphql-axios'
|
2020-12-23 19:11:46 +01:00
|
|
|
import { print } from 'graphql/language/printer'
|
|
|
|
import gql from 'graphql-tag'
|
|
|
|
import materiauFields from 'vuejs/api/gql/materiaumodal.fragment.gql'
|
|
|
|
|
2021-01-25 16:15:03 +01:00
|
|
|
const prettyBytes = require('pretty-bytes')
|
|
|
|
|
2021-01-26 16:36:27 +01:00
|
|
|
const _debounce = require('lodash/debounce')
|
|
|
|
|
2020-12-01 23:02:35 +01:00
|
|
|
export default {
|
|
|
|
name: "ModalCard",
|
2021-03-10 14:54:58 +01:00
|
|
|
props: ['item', 'addNoteId'],
|
2020-12-01 23:02:35 +01:00
|
|
|
mixins: [cardMixins],
|
2021-01-20 12:09:22 +01:00
|
|
|
components: {
|
2021-04-06 10:42:49 +02:00
|
|
|
LinkedMaterialCard,
|
|
|
|
VsaList,
|
|
|
|
VsaItem,
|
|
|
|
VsaHeading,
|
|
|
|
VsaContent,
|
|
|
|
VsaIcon
|
|
|
|
// VsaList: () => import(
|
|
|
|
// /* webpackPrefetch: true */
|
|
|
|
// /* webpackChunkName: "vsa" */
|
|
|
|
// /* webpackExports: ["VsaList"] */
|
|
|
|
// '/app/node_modules/vue-simple-accordion/'),
|
|
|
|
// VsaItem: () => import(
|
|
|
|
// /* webpackPrefetch: true */
|
|
|
|
// /* webpackChunkName: "vsa" */
|
|
|
|
// /* webpackExports: ["VsaItem"] */
|
|
|
|
// '/app/node_modules/vue-simple-accordion/'),
|
|
|
|
// VsaHeading: () => import(
|
|
|
|
// /* webpackPrefetch: true */
|
|
|
|
// /* webpackChunkName: "vsa" */
|
|
|
|
// /* webpackExports: ["VsaHeading"] */
|
|
|
|
// '/app/node_modules/vue-simple-accordion/'),
|
|
|
|
// VsaContent: () => import(
|
|
|
|
// /* webpackPrefetch: true */
|
|
|
|
// /* webpackChunkName: "vsa" */
|
|
|
|
// /* webpackExports: ["VsaContent"] */
|
|
|
|
// '/app/node_modules/vue-simple-accordion/'),
|
|
|
|
// VsaIcon: () => import(
|
|
|
|
// /* webpackPrefetch: true */
|
|
|
|
// /* webpackChunkName: "vsa" */
|
|
|
|
// /* webpackExports: ["VsaIcon"] */
|
|
|
|
// '/app/node_modules/vue-simple-accordion/')
|
2021-01-20 12:09:22 +01:00
|
|
|
},
|
2020-12-01 23:02:35 +01:00
|
|
|
data() {
|
|
|
|
return {
|
2020-12-23 19:11:46 +01:00
|
|
|
material: null,
|
|
|
|
loading: false,
|
2020-12-01 23:02:35 +01:00
|
|
|
blanksrc:`${drupalSettings.path.themePath}/assets/img/blank.gif`,
|
2021-03-09 14:53:22 +01:00
|
|
|
new_folder_name: "",
|
|
|
|
is_creating_folder: false,
|
2020-12-01 23:02:35 +01:00
|
|
|
loadingFlag: false,
|
2021-01-26 16:36:27 +01:00
|
|
|
lightbox_index: null,
|
|
|
|
note: "",
|
2021-06-01 12:21:10 +02:00
|
|
|
note_id: null
|
2020-12-01 23:02:35 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
2021-01-26 16:36:27 +01:00
|
|
|
csrf_token: state => state.User.csrf_token,
|
2020-12-07 23:11:31 +01:00
|
|
|
flagcolls: state => state.User.flagcolls,
|
|
|
|
showrooms: state => state.Showrooms.showrooms_by_tid
|
2021-03-09 14:53:22 +01:00
|
|
|
}),
|
|
|
|
collsLength() {
|
|
|
|
return Object.keys(this.flagcolls).length
|
|
|
|
},
|
|
|
|
addFlagBtnClassObj() {
|
|
|
|
return {
|
|
|
|
'mdi-plus-circle-outline': !this.is_creating_folder,
|
|
|
|
'mdi-loading': this.is_creating_folder,
|
|
|
|
active: this.new_folder_name.length > 4 && !this.is_creating_folder,
|
|
|
|
loading: this.is_creating_folder
|
|
|
|
}
|
|
|
|
}
|
2020-12-01 23:02:35 +01:00
|
|
|
},
|
2020-12-07 23:11:31 +01:00
|
|
|
created () {
|
|
|
|
console.log('modale item', this.item)
|
2020-12-23 19:11:46 +01:00
|
|
|
this.loadMaterial()
|
2021-06-01 12:21:10 +02:00
|
|
|
this.note_id = this.item.note_id
|
2021-01-26 16:36:27 +01:00
|
|
|
this.debouncedSaveNote = _debounce(this.saveNote, 500)
|
|
|
|
},
|
2021-06-01 12:21:10 +02:00
|
|
|
// watch: {
|
|
|
|
// // whenever question changes, this function will run
|
|
|
|
// // TODO: on mobile, this is called only on white caractere key
|
|
|
|
// note: function (n, o) {
|
|
|
|
// console.log("note watcher: note", n)
|
|
|
|
// this.debouncedSaveNote()
|
|
|
|
// }
|
|
|
|
// },
|
2020-12-01 23:02:35 +01:00
|
|
|
methods: {
|
|
|
|
...mapActions({
|
2021-03-10 14:54:58 +01:00
|
|
|
// refreshItem: 'Search/refreshItem',
|
2021-03-09 14:53:22 +01:00
|
|
|
createFlagColl: 'User/createFlagColl',
|
2020-12-01 23:02:35 +01:00
|
|
|
flagUnflag: 'User/flagUnflag'
|
|
|
|
}),
|
2020-12-23 19:11:46 +01:00
|
|
|
loadMaterial(){
|
|
|
|
console.log('loadMaterial', this.item.id)
|
|
|
|
this.loading = true
|
2021-03-31 18:42:05 +02:00
|
|
|
const ast = gql`{
|
2021-01-19 11:42:14 +01:00
|
|
|
materiau(id: ${this.item.id}, lang: "${drupalDecoupled.lang_code}") {
|
2020-12-23 19:11:46 +01:00
|
|
|
...MateriauFields
|
|
|
|
}
|
|
|
|
}
|
2021-03-31 18:42:05 +02:00
|
|
|
${materiauFields}
|
2020-12-23 19:11:46 +01:00
|
|
|
`
|
|
|
|
MGQ.post('', { query: print(ast)
|
|
|
|
})
|
|
|
|
.then(({ data:{data:{materiau}}}) => {
|
2021-03-31 18:42:05 +02:00
|
|
|
console.log('loadMaterial material loaded', materiau)
|
2020-12-23 19:11:46 +01:00
|
|
|
this.material = materiau
|
|
|
|
this.loading = false
|
2021-03-31 18:42:05 +02:00
|
|
|
if (materiau.note && materiau.note.id) {
|
2021-01-26 16:36:27 +01:00
|
|
|
this.note_id = materiau.note.id
|
|
|
|
this.note = materiau.note.contenu
|
|
|
|
}
|
2020-12-23 19:11:46 +01:00
|
|
|
// delay the lazyload to let the card the time to update dom
|
|
|
|
// maybe not the best method
|
2021-08-04 13:50:00 +02:00
|
|
|
// setTimeout(function () {
|
|
|
|
// this.activateLazyLoad()
|
|
|
|
// }.bind(this), 5)
|
2020-12-23 19:11:46 +01:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.warn('Issue with loadMaterial', error)
|
|
|
|
Promise.reject(error)
|
|
|
|
})
|
|
|
|
},
|
2021-03-09 14:53:22 +01:00
|
|
|
onCreateFlagColl () {
|
|
|
|
console.log("Card onCreateFlagColl", this.new_folder_name)
|
|
|
|
this.is_creating_folder = true;
|
|
|
|
this.createFlagColl(this.new_folder_name)
|
|
|
|
.then(data => {
|
2021-03-31 18:42:05 +02:00
|
|
|
console.log("Card onCreateFlagColl then", data)
|
2021-03-09 14:53:22 +01:00
|
|
|
this.new_folder_name = "";
|
|
|
|
this.is_creating_folder = false;
|
|
|
|
let collid = data.id
|
|
|
|
this.loadingFlag = collid;
|
|
|
|
this.flagUnflag({ action: 'flag', id: this.item.id, collid: collid})
|
|
|
|
.then(data => {
|
2021-03-31 18:42:05 +02:00
|
|
|
console.log("onFlagActionCard then", data)
|
2021-03-09 14:53:22 +01:00
|
|
|
this.loadingFlag = false;
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
2020-12-01 23:02:35 +01:00
|
|
|
flagIsActive(collid) {
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log(this.item.uuid)
|
|
|
|
// console.log(this.flagcolls[collid].items_uuids)
|
2020-12-23 18:05:25 +01:00
|
|
|
// return this.flagcolls[collid].items_uuids.indexOf(this.item.uuid) !== -1;
|
|
|
|
return this.flagcolls[collid].items.indexOf(this.item.id) !== -1;
|
2020-12-01 23:02:35 +01:00
|
|
|
},
|
|
|
|
flagIsLoading(collid) {
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log(this.item.uuid)
|
|
|
|
// console.log(this.flagcolls[collid].items_uuids)
|
2020-12-01 23:02:35 +01:00
|
|
|
return collid === this.loadingFlag;
|
|
|
|
},
|
|
|
|
onFlagActionCard (e) {
|
2021-03-31 18:42:05 +02:00
|
|
|
console.log("Card onFlagActionCard", e)
|
2020-12-01 23:02:35 +01:00
|
|
|
if (!this.loadingFlag) {
|
|
|
|
let collid = e.target.getAttribute('collid');
|
|
|
|
let isActive = this.flagIsActive(collid);
|
|
|
|
let action = isActive ? 'unflag' : 'flag';
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log('collid', collid)
|
|
|
|
// console.log("this.item", this.item)
|
2020-12-01 23:02:35 +01:00
|
|
|
this.loadingFlag = collid;
|
2020-12-23 18:05:25 +01:00
|
|
|
this.flagUnflag({ action: action, id: this.item.id, collid: collid})
|
2020-12-01 23:02:35 +01:00
|
|
|
.then(data => {
|
2021-03-31 18:42:05 +02:00
|
|
|
console.log("onFlagActionCard then", data)
|
2020-12-01 23:02:35 +01:00
|
|
|
this.loadingFlag = false;
|
|
|
|
})
|
|
|
|
}
|
2020-12-07 23:11:31 +01:00
|
|
|
},
|
|
|
|
onCloseModalCard (e) {
|
2021-01-20 12:42:21 +01:00
|
|
|
// this.$modal.hideAll()
|
|
|
|
this.$modal.hide(`modal-${this.item.id}`)
|
2021-01-25 16:15:03 +01:00
|
|
|
},
|
2021-03-30 15:42:40 +02:00
|
|
|
onSwipeCard (e) {
|
|
|
|
console.log('onSwipeCard', e)
|
2021-06-01 12:21:10 +02:00
|
|
|
switch(e){
|
|
|
|
case 'top':
|
|
|
|
break
|
|
|
|
case 'bottom':
|
|
|
|
break
|
|
|
|
case 'left':
|
|
|
|
case 'right':
|
|
|
|
this.$modal.hide(`modal-${this.item.id}`)
|
|
|
|
break
|
|
|
|
}
|
2021-03-30 15:42:40 +02:00
|
|
|
},
|
2021-01-25 16:15:03 +01:00
|
|
|
prettyFileSize(bytes){
|
|
|
|
return prettyBytes(parseInt(bytes))
|
2021-01-26 11:43:42 +01:00
|
|
|
},
|
|
|
|
shortUrl(url){
|
|
|
|
return url.replace(/^http:\/\//, '').replace(/^www\./, '')
|
2021-01-26 16:36:27 +01:00
|
|
|
},
|
2021-06-01 12:21:10 +02:00
|
|
|
onNoteInput(e){
|
|
|
|
console.log('onNoteInput', e, this.note)
|
|
|
|
this.note = e.target.value
|
|
|
|
this.debouncedSaveNote()
|
|
|
|
},
|
2021-01-26 16:36:27 +01:00
|
|
|
saveNote(){
|
2021-06-01 12:21:10 +02:00
|
|
|
console.log("saveNote", this.note_id, this.note)
|
|
|
|
if (this.note_id) {
|
2021-01-26 16:36:27 +01:00
|
|
|
this.updateNote()
|
2021-03-31 18:42:05 +02:00
|
|
|
} else {
|
2021-01-26 16:36:27 +01:00
|
|
|
this.createNote()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
updateNote(){
|
|
|
|
let params = {
|
|
|
|
type: [{target_id:'note'}],
|
|
|
|
field_contenu: this.note
|
|
|
|
}
|
|
|
|
let config = {
|
|
|
|
headers:{
|
|
|
|
"X-CSRF-Token": this.csrf_token
|
|
|
|
}
|
|
|
|
}
|
2021-06-01 12:21:10 +02:00
|
|
|
REST.patch(`/node/${this.note_id}?_format=json`, params, config)
|
2021-01-26 16:36:27 +01:00
|
|
|
.then(({ data }) => {
|
|
|
|
console.log('updateNote REST data', data)
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.warn('Issue with updateNote', error)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
createNote(){
|
|
|
|
let params = {
|
|
|
|
type: [{target_id:'note'}],
|
|
|
|
title: [{value:`note`}],
|
|
|
|
field_contenu: this.note,
|
|
|
|
field_target: this.item.id
|
|
|
|
}
|
|
|
|
let config = {
|
|
|
|
headers:{
|
|
|
|
"X-CSRF-Token": this.csrf_token
|
|
|
|
}
|
|
|
|
}
|
|
|
|
REST.post('/node?_format=json', params, config)
|
|
|
|
.then(({ data }) => {
|
|
|
|
console.log('createNote REST data', data)
|
2021-06-01 12:21:10 +02:00
|
|
|
this.note_id = data.nid[0].value
|
2021-03-10 11:54:08 +01:00
|
|
|
// call search results refresh of the item to display that note is now existing for this item
|
2021-03-10 14:54:58 +01:00
|
|
|
// this.refreshItem({id: this.item.id})
|
|
|
|
// no needs to refresh the entire item via searchresults
|
|
|
|
// plus if we are in article, there is not searchresults
|
2021-06-01 12:21:10 +02:00
|
|
|
// instead call the callbackfunction from the parent to add directly the note id
|
|
|
|
this.addNoteId(this.note_id)
|
2021-01-26 16:36:27 +01:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.warn('Issue with createNote', error)
|
|
|
|
})
|
2021-03-30 15:42:40 +02:00
|
|
|
},
|
|
|
|
onTapTool (e) {
|
|
|
|
console.log('ontapTool', e)
|
|
|
|
let tools = e.target.parentNode.parentNode.querySelectorAll('section.tool')
|
|
|
|
tools.forEach((item, i) => {
|
|
|
|
item.classList.remove('tapped')
|
|
|
|
})
|
|
|
|
e.target.parentNode.classList.add('tapped')
|
|
|
|
},
|
|
|
|
onTapCard (e) {
|
2021-06-01 12:21:10 +02:00
|
|
|
console.log('ontapCard', e.target.tagName)
|
|
|
|
// in case we tap on note's textarea
|
|
|
|
if(e.target.tagName == "TEXTAREA"){
|
|
|
|
return;
|
|
|
|
}
|
2021-03-30 15:42:40 +02:00
|
|
|
let tools = this.$refs['tools'].querySelectorAll('section.tool')
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log()
|
2021-03-30 15:42:40 +02:00
|
|
|
tools.forEach((item, i) => {
|
|
|
|
console.log('item', item)
|
|
|
|
item.classList.remove('tapped')
|
|
|
|
})
|
2020-12-01 23:02:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
|
|
</style>
|