52 lines
1.5 KiB
Vue
52 lines
1.5 KiB
Vue
<template>
|
|||
|
|
<BaseModal id="newClientModal" title="Create New Client" ref="modal">
|
||
|
|
<template #body>
|
||
|
|
<div class="mb-3">
|
||
|
|
<label for="clientName" class="form-label small text-muted text-uppercase fw-bold">Client Name</label>
|
||
|
|
<div class="input-group">
|
||
|
|
<span class="input-group-text"><i class="fas fa-user"></i></span>
|
||
|
|
<input type="text" class="form-control" id="clientName" v-model="clientName" placeholder="e.g. laptop-user" @keyup.enter="confirm" ref="inputRef">
|
||
|
|
</div>
|
||
|
|
<div class="form-text mt-2 text-muted small">
|
||
|
|
<i class="fas fa-info-circle me-1"></i> Use only alphanumeric characters, dashes, or underscores.
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
<template #footer>
|
||
|
|
<button type="button" class="btn-action btn-action-secondary" @click="close">Cancel</button>
|
||
|
|
<button type="button" class="btn-action btn-action-save" @click="confirm" :disabled="!clientName">
|
||
|
|
Create Client
|
||
|
|
</button>
|
||
|
|
</template>
|
||
|
|
</BaseModal>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script setup>
|
||
|
|
import { ref } from 'vue';
|
||
|
|
import BaseModal from './BaseModal.vue';
|
||
|
|
|
||
|
|
const emit = defineEmits(['create']);
|
||
|
|
const modal = ref(null);
|
||
|
|
const clientName = ref('');
|
||
|
|
const inputRef = ref(null);
|
||
|
|
|
||
|
|
const open = () => {
|
||
|
|
clientName.value = '';
|
||
|
|
modal.value.show();
|
||
|
|
setTimeout(() => inputRef.value?.focus(), 500);
|
||
|
|
};
|
||
|
|
|
||
|
|
const close = () => {
|
||
|
|
modal.value.hide();
|
||
|
|
};
|
||
|
|
|
||
|
|
const confirm = () => {
|
||
|
|
if (clientName.value) {
|
||
|
|
emit('create', clientName.value);
|
||
|
|
close();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
defineExpose({ open, close });
|
||
|
|
</script>
|
||
|
|
|