Files
growup-crm/storage/framework/views/529827ffcc1e168e7fa532a34b41deb1.php
2026-02-02 15:31:15 -03:00

532 lines
22 KiB
PHP
Executable File

<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag; ?>
<?php foreach($attributes->onlyProps([
'allowEdit' => true,
'attribute' => [],
]) as $__key => $__value) {
$$__key = $$__key ?? $__value;
} ?>
<?php $attributes = $attributes->exceptProps([
'allowEdit' => true,
'attribute' => [],
]); ?>
<?php foreach (array_filter(([
'allowEdit' => true,
'attribute' => [],
]), 'is_string', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
$$__key = $$__key ?? $__value;
} ?>
<?php $__defined_vars = get_defined_vars(); ?>
<?php foreach ($attributes as $__key => $__value) {
if (array_key_exists($__key, $__defined_vars)) unset($$__key);
} ?>
<?php unset($__defined_vars); ?>
<v-inline-look-edit
<?php echo e($attributes); ?>
:attribute="<?php echo e(json_encode($attribute)); ?>"
:allow-edit="<?php echo e($allowEdit ? 'true' : 'false'); ?>"
>
<div class="group w-full max-w-full hover:rounded-sm">
<div class="rounded-xs flex h-[34px] items-center pl-2.5 text-left">
<div class="shimmer h-5 w-48 rounded border border-transparent"></div>
</div>
</div>
</v-inline-look-edit>
<?php if (! $__env->hasRenderedOnce('fb49bde3-54ec-456a-9a40-e4770795d281')): $__env->markAsRenderedOnce('fb49bde3-54ec-456a-9a40-e4770795d281');
$__env->startPush('scripts'); ?>
<script
type="text/x-template"
id="v-inline-look-edit-template"
>
<div class="group w-full max-w-full hover:rounded-sm">
<!-- Non-editing view -->
<div
v-if="! isEditing"
class="flex h-[34px] items-center rounded border border-transparent transition-all"
:class="allowEdit ? 'hover:bg-gray-100 dark:hover:bg-gray-800' : ''"
>
<?php if (isset($component)) { $__componentOriginal53af403f6b2179a3039d488b8ab2a267 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal53af403f6b2179a3039d488b8ab2a267 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'admin::components.form.control-group.control','data' => ['type' => 'hidden',':id' => 'name',':name' => 'name','vModel' => 'inputValue']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('admin::form.control-group.control'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'hidden',':id' => 'name',':name' => 'name','v-model' => 'inputValue']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal53af403f6b2179a3039d488b8ab2a267)): ?>
<?php $attributes = $__attributesOriginal53af403f6b2179a3039d488b8ab2a267; ?>
<?php unset($__attributesOriginal53af403f6b2179a3039d488b8ab2a267); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal53af403f6b2179a3039d488b8ab2a267)): ?>
<?php $component = $__componentOriginal53af403f6b2179a3039d488b8ab2a267; ?>
<?php unset($__componentOriginal53af403f6b2179a3039d488b8ab2a267); ?>
<?php endif; ?>
<div
class="group relative h-[18px] !w-full pl-2.5"
:style="{ 'text-align': position }"
>
<span class="cursor-pointer truncate rounded">
<template v-if="isDirty">
{{ inputValue.length > 20 ? inputValue.substring(0, 20) + '...' : inputValue }}
</template>
<template v-else>
{{ valueLabel ? valueLabel : inputValue.length > 20 ? inputValue.substring(0, 20) + '...' : inputValue }}
</template>
</span>
<!-- Tooltip -->
<div
class="absolute bottom-0 mb-5 hidden flex-col group-hover:flex"
v-if="inputValue.length > 20"
>
<span class="whitespace-no-wrap relative z-10 rounded-md bg-black px-4 py-2 text-xs leading-none text-white shadow-lg dark:bg-white dark:text-gray-900">
{{ inputValue }}
</span>
<div class="-mt-2 ml-4 h-3 w-3 rotate-45 bg-black dark:bg-white"></div>
</div>
</div>
<template v-if="allowEdit">
<i
@click="toggle"
class="icon-edit cursor-pointer rounded p-0.5 text-2xl opacity-0 hover:bg-gray-200 group-hover:opacity-100 dark:hover:bg-gray-950 ltr:mr-1 rtl:ml-1"
></i>
</template>
</div>
<!-- Editing view -->
<div
class="relative flex w-full flex-col"
ref="dropdownContainer"
v-else
>
<?php if (isset($component)) { $__componentOriginal53af403f6b2179a3039d488b8ab2a267 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal53af403f6b2179a3039d488b8ab2a267 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'admin::components.form.control-group.control','data' => ['type' => 'text',':name' => 'name','class' => '!h-[34px] w-full cursor-pointer !py-0 text-gray-800 dark:text-white ltr:pr-20 rtl:pl-20',':placeholder' => 'placeholder','vModel' => 'selectedItem.name','@click' => 'toggleEditor','readonly' => true]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('admin::form.control-group.control'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'text',':name' => 'name','class' => '!h-[34px] w-full cursor-pointer !py-0 text-gray-800 dark:text-white ltr:pr-20 rtl:pl-20',':placeholder' => 'placeholder','v-model' => 'selectedItem.name','@click' => 'toggleEditor','readonly' => true]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal53af403f6b2179a3039d488b8ab2a267)): ?>
<?php $attributes = $__attributesOriginal53af403f6b2179a3039d488b8ab2a267; ?>
<?php unset($__attributesOriginal53af403f6b2179a3039d488b8ab2a267); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal53af403f6b2179a3039d488b8ab2a267)): ?>
<?php $component = $__componentOriginal53af403f6b2179a3039d488b8ab2a267; ?>
<?php unset($__componentOriginal53af403f6b2179a3039d488b8ab2a267); ?>
<?php endif; ?>
<span class="pointer-events-none absolute inset-y-0 flex items-center ltr:right-0 ltr:pr-14 rtl:left-0 rtl:pl-14">
<div class="flex items-center justify-center space-x-1">
<div
class="relative"
v-if="isSearching"
>
<?php if (isset($component)) { $__componentOriginal991e5e3816aa635af8067aa2abbd328b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal991e5e3816aa635af8067aa2abbd328b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'admin::components.spinner.index','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('admin::spinner'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal991e5e3816aa635af8067aa2abbd328b)): ?>
<?php $attributes = $__attributesOriginal991e5e3816aa635af8067aa2abbd328b; ?>
<?php unset($__attributesOriginal991e5e3816aa635af8067aa2abbd328b); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal991e5e3816aa635af8067aa2abbd328b)): ?>
<?php $component = $__componentOriginal991e5e3816aa635af8067aa2abbd328b; ?>
<?php unset($__componentOriginal991e5e3816aa635af8067aa2abbd328b); ?>
<?php endif; ?>
</div>
<i
class="text-2xl"
:class="showPopup ? 'icon-up-arrow': 'icon-down-arrow'"
></i>
</div>
</span>
<!-- Popup Box -->
<div
v-if="showPopup"
class="absolute z-10 mt-1 w-full origin-top transform rounded-lg border border-gray-200 bg-white p-2 shadow-lg transition-transform dark:border-gray-800 dark:bg-gray-800"
:class="dropdownPosition === 'bottom' ? 'top-full mt-1' : 'bottom-full mb-1'"
>
<!-- Search Bar -->
<input
type="text"
v-model.lazy="searchTerm"
v-debounce="200"
class="!mb-2 w-full rounded border border-gray-200 px-2.5 py-2 text-sm font-normal text-gray-800 transition-all hover:border-gray-400 focus:border-gray-400 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-300 dark:hover:border-gray-400 dark:focus:border-gray-400"
placeholder="<?php echo app('translator')->get('admin::app.components.lookup.search'); ?>"
ref="searchInput"
/>
<!-- Results List -->
<ul class="max-h-40 divide-y divide-gray-100 overflow-y-auto">
<li
v-for="item in filteredResults"
:key="item.id"
class="cursor-pointer px-4 py-2 text-gray-800 transition-colors hover:bg-blue-100 dark:text-white dark:hover:bg-gray-950"
@click="selectItem(item)"
>
{{ item.name }}
</li>
<li v-if="filteredResults.length === 0" class="px-4 py-2 text-center text-gray-500 dark:text-gray-300">
<?php echo app('translator')->get('admin::app.components.lookup.no-results'); ?>
</li>
</ul>
</div>
<!-- Action Buttons -->
<div class="absolute top-1/2 flex -translate-y-1/2 transform gap-0.5 bg-white dark:bg-gray-900 ltr:right-2 rtl:left-2">
<button
type="button"
class="flex items-center justify-center bg-green-100 p-1 hover:bg-green-200 ltr:rounded-l-md rtl:rounded-r-md"
@click="save"
>
<i class="icon-tick text-md cursor-pointer font-bold text-green-600 dark:!text-green-600" />
</button>
<button
type="button"
class="item-center flex justify-center bg-red-100 p-1 hover:bg-red-200 ltr:rounded-r-md rtl:rounded-l-md"
@click="cancel"
>
<i class="icon-cross-large text-md cursor-pointer font-bold text-red-600 dark:!text-red-600" />
</button>
</div>
<?php if (isset($component)) { $__componentOriginal8da25fb6534e2ef288914e35c32417f8 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8da25fb6534e2ef288914e35c32417f8 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'admin::components.form.control-group.error','data' => [':name' => 'name']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('admin::form.control-group.error'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([':name' => 'name']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8da25fb6534e2ef288914e35c32417f8)): ?>
<?php $attributes = $__attributesOriginal8da25fb6534e2ef288914e35c32417f8; ?>
<?php unset($__attributesOriginal8da25fb6534e2ef288914e35c32417f8); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8da25fb6534e2ef288914e35c32417f8)): ?>
<?php $component = $__componentOriginal8da25fb6534e2ef288914e35c32417f8; ?>
<?php unset($__componentOriginal8da25fb6534e2ef288914e35c32417f8); ?>
<?php endif; ?>
</div>
</div>
</script>
<script type="module">
app.component('v-inline-look-edit', {
template: '#v-inline-look-edit-template',
emits: ['on-change', 'on-cancelled'],
props: {
name: {
type: String,
required: true,
},
value: {
required: true,
},
position: {
type: String,
default: 'right',
},
errors: {
type: Object,
default: {},
},
attribute: {
type: Object,
default: () => ({}),
},
allowEdit: {
type: Boolean,
default: true,
},
placeholder: {
type: String,
default: 'Search...',
},
url: {
type: String,
default: '',
},
valueLabel: {
type: String,
default: '',
},
},
data() {
return {
inputValue: this.value ?? '',
isEditing: false,
isDirty: false,
showPopup: false,
searchTerm: '',
selectedItem: {},
searchedResults: [],
isSearching: false,
cancelToken: null,
isDropdownOpen: false,
dropdownPosition: "bottom",
isRTL: document.documentElement.dir === 'rtl',
};
},
watch: {
/**
* Watch the value prop.
*
* @param {String} newValue
*/
value(newValue) {
this.inputValue = newValue;
},
searchTerm(newVal, oldVal) {
this.search();
},
},
mounted() {
window.addEventListener("resize", this.setDropdownPosition);
this.$emitter.on('show-pop', this.handleShowPop);
},
computed: {
src() {
return `<?php echo e(route('admin.settings.attributes.lookup')); ?>/${this.attribute.lookup_type}`;
},
/**
* Filter the searchedResults based on the search query.
*
* @return {Array}
*/
filteredResults() {
return this.searchedResults.filter(item =>
item.name.toLowerCase().includes(this.searchTerm.toLowerCase())
);
},
},
methods: {
/**
* Toggle the input.
*
* @return {void}
*/
toggle() {
this.isEditing = true;
this.searchTerm = '';
this.selectedItem.name = this.inputValue;
this.isDropdownOpen = ! this.isDropdownOpen;
if (this.isDropdownOpen) {
this.setDropdownPosition();
}
},
toggleEditor() {
this.$emitter.emit('show-pop', this.$.uid);
},
handleShowPop(uid) {
this.showPopup = (uid === this.$.uid);
if (this.showPopup) {
this.$nextTick(() => this.$refs.searchInput?.focus());
} else {
this.isEditing = false;
}
},
/**
* Save the input value.
*
* @return {void}
*/
save() {
if (this.errors[this.name]) {
return;
}
this.isEditing = false;
if (this.selectedItem.id === undefined) {
return;
}
this.isDirty = true;
this.inputValue = this.selectedItem.name;
if (this.url) {
this.$axios.put(this.url, {
[this.name]: this.selectedItem.id,
})
.then((response) => {
this.$emitter.emit('add-flash', { type: 'success', message: response.data.message });
})
.catch((error) => {
this.isDirty = false;
this.inputValue = this.value;
this.$emitter.emit('add-flash', { type: 'error', message: error.response.data.message });
});
}
this.$emit('on-change', {
name: this.name,
value: this.selectedItem.id,
});
},
/**
* Select an item from the list.
*
* @param {Object} item
*
* @return {void}
*/
selectItem(item) {
this.showPopup = false;
this.searchTerm = '';
this.selectedItem = item;
},
/**
* Cancel the input value.
*
* @return {void}
*/
cancel() {
if (this.selectItem) {
this.inputValue = this.selectedItem.name;
}
this.isEditing = false;
this.$emit('on-cancelled', this.inputValue);
},
/**
* Initialize the items.
*
* @return {void}
*/
search() {
if (this.searchTerm.length <= 2) {
this.searchedResults = [];
this.isSearching = false;
return;
}
this.isSearching = true;
if (this.cancelToken) {
this.cancelToken.cancel();
}
this.cancelToken = this.$axios.CancelToken.source();
this.$axios.get(this.src, {
params: {
...this.params,
query: this.searchTerm
},
cancelToken: this.cancelToken.token,
})
.then(response => {
this.searchedResults = response.data;
})
.catch(error => {
if (! this.$axios.isCancel(error)) {
console.error("Search request failed:", error);
}
this.isSearching = false;
})
.finally(() => this.isSearching = false);
},
setDropdownPosition() {
this.$nextTick(() => {
const dropdownContainer = this.$refs.dropdownContainer;
if (! dropdownContainer) {
return;
}
const dropdownRect = dropdownContainer.getBoundingClientRect();
const viewportHeight = window.innerHeight;
if (dropdownRect.bottom + 250 > viewportHeight) {
this.dropdownPosition = "top";
} else {
this.dropdownPosition = "bottom";
}
});
},
},
});
</script>
<?php $__env->stopPush(); endif; ?>
<?php /**PATH /var/www/html/packages/Webkul/Admin/src/Resources/views/components/form/control-group/controls/inline/lookup.blade.php ENDPATH**/ ?>