Skip to content
Snippets Groups Projects
ListLayer.vue 4.05 KiB
Newer Older
<template>
Adam Procter's avatar
Adam Procter committed
  <div>
    <div v-for="(nodes, index) in $options.myArray" v-bind:key="index">
Adam Procter's avatar
Adam Procter committed
      <form class="nodes">
        <template v-if="nodes.read_mode == false">
          <textarea
            @focus="editTrue(true)"
            @blur="editTrue(false)"
            autofocus
            v-model="nodes.node_text"
            @input="editNode"
            :id="nodes.node_id"
            placeholder="Type your thoughts and ideas here! (auto saved every keystroke)"
          ></textarea>
          <p class="info">*markdown supported &amp; autosaves</p>
        </template>
        <template v-else>
          <p
            :id="nodes.node_id"
            :inner-html.prop="nodes.node_text | marked"
          ></p>
        </template>
Adam Procter's avatar
Adam Procter committed

        <div class="btn-row">
          <SvgButton
            buttonClass="nodes"
            @click.prevent="deleteFlag(nodes.node_id)"
          />
          <SvgButton2
            buttonClass="nodes"
            @click.prevent="readFlag(nodes.node_id, nodes.read_mode)"
Adam Procter's avatar
Adam Procter committed
          />
        </div>

        <div class="allemoji">
          <div
            class="eachemoji"
            v-for="(emojis, index) in configEmoji"
Adam Procter's avatar
Adam Procter committed
            :key="index"
          >
            <template v-if="emojis.node_id == nodes.node_id">{{
              emojis.emoji_text
            }}</template>
Adam Procter's avatar
Adam Procter committed
          </div>
        </div>
      </form>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
Adam Procter's avatar
Adam Procter committed
import marked from 'marked'
Adam Procter's avatar
Adam Procter committed
import SvgButton from '@/components/SvgButton'
import SvgButton2 from '@/components/SvgButton2'
Adam Procter's avatar
Adam Procter committed

Adam Procter's avatar
Adam Procter committed
var readmode
export default {
  name: 'ListLayer',
Adam Procter's avatar
Adam Procter committed

  data: function () {
Adam Procter's avatar
Adam Procter committed
      localreadmode: false,
      myArray: null,
Adam Procter's avatar
Adam Procter committed
    marked: marked,
Adam Procter's avatar
Adam Procter committed
  computed: {
    ...mapState({
      myNodes: (state) => state.myNodes,
      configPositions: (state) => state.configPositions,
      configEmoji: (state) => state.configEmoji,
      // toolmode: (state) => state.ui.mode,
Adam Procter's avatar
Adam Procter committed
    }),
Adam Procter's avatar
Adam Procter committed
    nodes_filtered: function () {
      return this.myNodes.filter((nodes) => {
        return nodes.deleted == false
      })
    },
Adam Procter's avatar
Adam Procter committed
  },
Adam Procter's avatar
Adam Procter committed

    setTimeout(this.loadData, 500)
Adam Procter's avatar
Adam Procter committed
    this.$options.myArray = this.nodes_filtered
  },

  updated() {
    setTimeout(this.loadData, 300)
  },

Adam Procter's avatar
Adam Procter committed
  methods: {
    loadData() {
      this.$options.myArray = this.nodes_filtered
      this.$forceUpdate()
    },
Adam Procter's avatar
Adam Procter committed
    editNode(e) {
      var nodeid = e.target.id
      var nodetext = e.target.value
      this.$store.dispatch('editNode', { nodeid, nodetext })
    },
Adam Procter's avatar
Adam Procter committed
    editTrue(e) {
      this.$emit('edit-true', e)
    },
Adam Procter's avatar
Adam Procter committed
    deleteFlag(e) {
      if (confirm('Confirm discard?')) {
        this.$store.dispatch('deleteFlag', { e })
      } else {
        // nothing happens
      }
Adam Procter's avatar
Adam Procter committed
    readFlag(e, f) {
      readmode = f
      readmode = !readmode
      this.$store.dispatch('readFlag', { e, readmode })

      if (readmode == true) {
        this.mode = 'Read'
      } else {
        this.mode = 'Edit'
      }
Adam Procter's avatar
Adam Procter committed
    },
Adam Procter's avatar
Adam Procter committed
  },
Adam Procter's avatar
Adam Procter committed
  components: {
    SvgButton,
    SvgButton2,
  },
}
</script>

<style lang="css" scoped>
Adam Procter's avatar
Adam Procter committed
  width: 95%;
  border: 2px dashed black;
  background-color: rgb(155, 194, 216);
  margin-top: 1em;
Adam Procter's avatar
Adam Procter committed
  margin-left: 0.5em;
Adam Procter's avatar
Adam Procter committed
.readmode {
  margin-top: 1em;
  margin-left: 1em;
}

Adam Procter's avatar
Adam Procter committed
  width: 100%;
  height: 175px;
  resize: none;
  box-sizing: border-box;
Adam Procter's avatar
Adam Procter committed
  font-size: 18px;
  font-family: 'Inter var', Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  border: none;
  outline: none;
  background-color: rgb(187, 227, 255);
  scrollbar-color: yellow rgb(187, 227, 255);
.btn-row {
  position: relative;
  margin-bottom: 5px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 15px;
  border-radius: 4px;
}

.allemoji {
  font-size: 2em;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(0, auto));

  /* float: left; */
}

.eachemoji p {
  margin: 0em;
}
Adam Procter's avatar
Adam Procter committed

@media only screen and (max-width: 600px) {
  .readmode >>> a {
    font-size: 2em;
    word-break: break-all;
    padding-right: 0.5em;
Adam Procter's avatar
Adam Procter committed
  }
}