vue-modal icon indicating copy to clipboard operation
vue-modal copied to clipboard

promptModal

Open Jenesius opened this issue 3 years ago • 3 comments

Main goal: to add the ability to connect to linear modal windows. A linear modal window is a window whose main task is to return a value. Referencing promt in JavaScript. Tasks:

  • implementation of the promtModal method (Or another name, while being discussed)
  • value return implementation

Principle of operation:

const result = promptModal(VueModal);
// VueModal.vue
<template>
  <div>
    <button @click = "change(1)">up</button>
    <button @click = "change(-1)">down</button>
  </div>
</template>
<script setup>
  function change(v) {
    emit('close', v);
  }
</script>

This example demonstrates a modal window that will return either 1 or -1 (undefined if it was closed with Esc or background)

Jenesius avatar Sep 08 '22 08:09 Jenesius

The only thing that worries is that we are removing the close event from use. It is possible to add the returnValue(value) method to solve this problem. The change function will look like this:

import {returnValue} from "jenesius-vue-modal"
function change(v) {
  returnValue(v);
}

Jenesius avatar Sep 08 '22 08:09 Jenesius

Also need add prop returnValue to EventClose, or just value

Jenesius avatar Sep 08 '22 08:09 Jenesius

The main problem is how returnValue caught where it was called from...

Jenesius avatar Sep 10 '22 10:09 Jenesius

Jenesius is back I test the solution in my work project. On this week will be news: New method: promptModal Form.EVENT_PROMPT

Jenesius avatar Oct 26 '22 13:10 Jenesius